aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore (renamed from nitrocli/.gitignore)0
-rw-r--r--CHANGELOG.md (renamed from nitrocli/CHANGELOG.md)54
-rw-r--r--Cargo.lock299
-rw-r--r--Cargo.toml (renamed from nitrocli/Cargo.toml)35
-rw-r--r--LICENSE (renamed from nitrocli/LICENSE)0
-rw-r--r--Makefile (renamed from nitrocli/Makefile)0
-rw-r--r--README.md (renamed from nitrocli/README.md)61
-rw-r--r--argparse/.gitignore13
-rw-r--r--argparse/.travis.yml34
-rw-r--r--argparse/Cargo.toml12
-rw-r--r--argparse/LICENSE19
-rw-r--r--argparse/README.rst341
-rw-r--r--argparse/bulk.yaml11
-rw-r--r--argparse/examples/greeting.rs26
-rw-r--r--argparse/examples/structure.rs38
-rw-r--r--argparse/examples/subcommands.rs88
-rw-r--r--argparse/src/action.rs33
-rw-r--r--argparse/src/bool.rs22
-rw-r--r--argparse/src/custom.rs95
-rw-r--r--argparse/src/from_cli.rs100
-rw-r--r--argparse/src/generic.rs133
-rw-r--r--argparse/src/help.rs93
-rw-r--r--argparse/src/lib.rs64
-rw-r--r--argparse/src/num.rs58
-rw-r--r--argparse/src/parser.rs967
-rw-r--r--argparse/src/print.rs13
-rw-r--r--argparse/src/test_bool.rs98
-rw-r--r--argparse/src/test_const.rs28
-rw-r--r--argparse/src/test_enum.rs51
-rw-r--r--argparse/src/test_env.rs43
-rw-r--r--argparse/src/test_float.rs50
-rw-r--r--argparse/src/test_help.rs154
-rw-r--r--argparse/src/test_int.rs107
-rw-r--r--argparse/src/test_many.rs95
-rw-r--r--argparse/src/test_optional.rs54
-rw-r--r--argparse/src/test_parser.rs64
-rw-r--r--argparse/src/test_path.rs30
-rw-r--r--argparse/src/test_pos.rs196
-rw-r--r--argparse/src/test_str.rs28
-rw-r--r--argparse/src/test_usage.rs57
-rw-r--r--argparse/vagga.yaml59
-rw-r--r--base32/.gitignore2
-rw-r--r--base32/.travis.yml1
-rw-r--r--base32/Cargo.toml16
-rw-r--r--base32/LICENSE-APACHE202
-rw-r--r--base32/LICENSE-MIT19
-rw-r--r--base32/README.md35
-rw-r--r--base32/src/lib.rs221
-rw-r--r--cc/.gitignore4
-rw-r--r--cc/Cargo.toml26
-rw-r--r--cc/LICENSE-APACHE201
-rw-r--r--cc/LICENSE-MIT25
-rw-r--r--cc/README.md202
-rw-r--r--cc/azure-pipelines.yml101
-rw-r--r--cc/cc-test/Cargo.toml15
-rw-r--r--cc/cc-test/build.rs90
-rw-r--r--cc/cc-test/src/NMakefile14
-rw-r--r--cc/cc-test/src/aarch64.S10
-rw-r--r--cc/cc-test/src/bar1.c7
-rw-r--r--cc/cc-test/src/bar2.c6
-rw-r--r--cc/cc-test/src/baz.cpp9
-rw-r--r--cc/cc-test/src/expand.c4
-rw-r--r--cc/cc-test/src/foo.c9
-rw-r--r--cc/cc-test/src/i686.S9
-rw-r--r--cc/cc-test/src/i686.asm9
-rw-r--r--cc/cc-test/src/include/foo.h0
-rw-r--r--cc/cc-test/src/lib.rs16
-rw-r--r--cc/cc-test/src/msvc.c7
-rw-r--r--cc/cc-test/src/opt_linkage.c5
-rw-r--r--cc/cc-test/src/windows.c3
-rw-r--r--cc/cc-test/src/x86_64.S9
-rw-r--r--cc/cc-test/src/x86_64.asm8
-rw-r--r--cc/cc-test/tests/all.rs60
-rw-r--r--cc/ci/azure-install-rust.yml24
-rw-r--r--cc/ci/azure-steps.yml21
-rw-r--r--cc/src/bin/gcc-shim.rs23
-rw-r--r--cc/src/com.rs155
-rw-r--r--cc/src/lib.rs2422
-rw-r--r--cc/src/registry.rs204
-rw-r--r--cc/src/setup_config.rs283
-rw-r--r--cc/src/winapi.rs218
-rw-r--r--cc/src/windows_registry.rs759
-rw-r--r--cc/tests/cc_env.rs121
-rw-r--r--cc/tests/support/mod.rs133
-rw-r--r--cc/tests/test.rs371
-rw-r--r--ci/gitlab-ci.yml (renamed from nitrocli/ci/gitlab-ci.yml)14
-rw-r--r--doc/CONTRIBUTING.md (renamed from nitrocli/doc/CONTRIBUTING.md)0
-rw-r--r--doc/nitrocli.1 (renamed from nitrocli/doc/nitrocli.1)45
-rw-r--r--doc/nitrocli.1.pdfbin0 -> 38453 bytes
-rw-r--r--doc/packaging.md (renamed from nitrocli/doc/packaging.md)12
-rw-r--r--libc/.cirrus.yml27
-rw-r--r--libc/.github/issue_template.md24
-rw-r--r--libc/.gitignore4
-rw-r--r--libc/.travis.yml254
-rw-r--r--libc/CONTRIBUTING.md66
-rw-r--r--libc/Cargo.toml35
-rw-r--r--libc/LICENSE-APACHE201
-rw-r--r--libc/LICENSE-MIT25
-rw-r--r--libc/README.md105
-rw-r--r--libc/appveyor.yml28
-rw-r--r--libc/build.rs101
-rw-r--r--libc/ci/README.md243
-rw-r--r--libc/ci/android-install-ndk.sh50
-rw-r--r--libc/ci/android-install-sdk.sh73
-rw-r--r--libc/ci/android-sysimage.sh56
-rw-r--r--libc/ci/build.sh221
-rw-r--r--libc/ci/docker/aarch64-linux-android/Dockerfile45
-rw-r--r--libc/ci/docker/aarch64-unknown-linux-gnu/Dockerfile7
-rw-r--r--libc/ci/docker/aarch64-unknown-linux-musl/Dockerfile15
-rw-r--r--libc/ci/docker/arm-linux-androideabi/Dockerfile45
-rw-r--r--libc/ci/docker/arm-unknown-linux-gnueabihf/Dockerfile7
-rw-r--r--libc/ci/docker/arm-unknown-linux-musleabihf/Dockerfile13
-rw-r--r--libc/ci/docker/asmjs-unknown-emscripten/Dockerfile20
-rw-r--r--libc/ci/docker/i686-linux-android/Dockerfile45
-rw-r--r--libc/ci/docker/i686-unknown-linux-gnu/Dockerfile5
-rw-r--r--libc/ci/docker/i686-unknown-linux-musl/Dockerfile12
-rw-r--r--libc/ci/docker/mips-unknown-linux-gnu/Dockerfile10
-rw-r--r--libc/ci/docker/mips-unknown-linux-musl/Dockerfile17
-rw-r--r--libc/ci/docker/mips64-unknown-linux-gnuabi64/Dockerfile11
-rw-r--r--libc/ci/docker/mips64el-unknown-linux-gnuabi64/Dockerfile11
-rw-r--r--libc/ci/docker/mipsel-unknown-linux-musl/Dockerfile17
-rw-r--r--libc/ci/docker/powerpc-unknown-linux-gnu/Dockerfile11
-rw-r--r--libc/ci/docker/powerpc64-unknown-linux-gnu/Dockerfile11
-rw-r--r--libc/ci/docker/powerpc64le-unknown-linux-gnu/Dockerfile11
-rw-r--r--libc/ci/docker/s390x-unknown-linux-gnu/Dockerfile18
-rw-r--r--libc/ci/docker/sparc64-unknown-linux-gnu/Dockerfile18
-rw-r--r--libc/ci/docker/wasm32-unknown-emscripten/Dockerfile27
-rwxr-xr-xlibc/ci/docker/wasm32-unknown-emscripten/node-wrapper.sh15
-rw-r--r--libc/ci/docker/wasm32-wasi/Dockerfile93
-rwxr-xr-xlibc/ci/docker/wasm32-wasi/clang.sh2
-rw-r--r--libc/ci/docker/x86_64-linux-android/Dockerfile26
-rw-r--r--libc/ci/docker/x86_64-rumprun-netbsd/Dockerfile10
-rw-r--r--libc/ci/docker/x86_64-rumprun-netbsd/runtest.rs55
-rw-r--r--libc/ci/docker/x86_64-unknown-linux-gnu/Dockerfile9
-rw-r--r--libc/ci/docker/x86_64-unknown-linux-gnux32/Dockerfile5
-rw-r--r--libc/ci/docker/x86_64-unknown-linux-musl/Dockerfile10
-rw-r--r--libc/ci/dox.sh70
-rwxr-xr-xlibc/ci/emscripten-entry.sh20
-rw-r--r--libc/ci/emscripten.sh56
-rw-r--r--libc/ci/install-musl.sh69
-rw-r--r--libc/ci/ios/deploy_and_run_on_ios_simulator.rs175
-rw-r--r--libc/ci/linux-s390x.sh20
-rw-r--r--libc/ci/linux-sparc64.sh19
-rwxr-xr-xlibc/ci/run-docker.sh42
-rw-r--r--libc/ci/run-qemu.sh34
-rwxr-xr-xlibc/ci/run.sh98
-rw-r--r--libc/ci/runtest-android.rs47
-rw-r--r--libc/ci/semver.sh70
-rw-r--r--libc/ci/style.rs212
-rw-r--r--libc/ci/switch.json37
-rwxr-xr-xlibc/ci/test-runner-linux25
-rw-r--r--libc/libc-test/Cargo.toml54
-rw-r--r--libc/libc-test/build.rs2393
-rw-r--r--libc/libc-test/src/cmsg.c28
-rw-r--r--libc/libc-test/test/cmsg.rs101
-rw-r--r--libc/libc-test/test/linux_elf.rs12
-rw-r--r--libc/libc-test/test/linux_fcntl.rs12
-rw-r--r--libc/libc-test/test/linux_ipv6.rs12
-rw-r--r--libc/libc-test/test/linux_strerror_r.rs12
-rw-r--r--libc/libc-test/test/linux_termios.rs12
-rw-r--r--libc/libc-test/test/main.rs6
-rw-r--r--libc/rustfmt.toml3
-rw-r--r--libc/src/cloudabi/aarch64.rs4
-rw-r--r--libc/src/cloudabi/arm.rs4
-rw-r--r--libc/src/cloudabi/mod.rs325
-rw-r--r--libc/src/cloudabi/x86.rs4
-rw-r--r--libc/src/cloudabi/x86_64.rs4
-rw-r--r--libc/src/fixed_width_ints.rs44
-rw-r--r--libc/src/fuchsia/aarch64.rs347
-rw-r--r--libc/src/fuchsia/align.rs142
-rw-r--r--libc/src/fuchsia/mod.rs4316
-rw-r--r--libc/src/fuchsia/no_align.rs129
-rw-r--r--libc/src/fuchsia/x86_64.rs502
-rw-r--r--libc/src/hermit/aarch64.rs2
-rw-r--r--libc/src/hermit/mod.rs74
-rw-r--r--libc/src/hermit/x86_64.rs2
-rw-r--r--libc/src/lib.rs143
-rw-r--r--libc/src/macros.rs195
-rw-r--r--libc/src/sgx.rs47
-rw-r--r--libc/src/switch.rs50
-rw-r--r--libc/src/unix/align.rs6
-rw-r--r--libc/src/unix/bsd/apple/b32.rs97
-rw-r--r--libc/src/unix/bsd/apple/b64.rs102
-rw-r--r--libc/src/unix/bsd/apple/mod.rs3349
-rw-r--r--libc/src/unix/bsd/freebsdlike/dragonfly/mod.rs1060
-rw-r--r--libc/src/unix/bsd/freebsdlike/freebsd/aarch64.rs44
-rw-r--r--libc/src/unix/bsd/freebsdlike/freebsd/arm.rs47
-rw-r--r--libc/src/unix/bsd/freebsdlike/freebsd/freebsd11/mod.rs214
-rw-r--r--libc/src/unix/bsd/freebsdlike/freebsd/freebsd11/x86_64.rs30
-rw-r--r--libc/src/unix/bsd/freebsdlike/freebsd/freebsd12/mod.rs207
-rw-r--r--libc/src/unix/bsd/freebsdlike/freebsd/freebsd12/x86_64.rs32
-rw-r--r--libc/src/unix/bsd/freebsdlike/freebsd/mod.rs1357
-rw-r--r--libc/src/unix/bsd/freebsdlike/freebsd/powerpc64.rs44
-rw-r--r--libc/src/unix/bsd/freebsdlike/freebsd/x86.rs43
-rw-r--r--libc/src/unix/bsd/freebsdlike/freebsd/x86_64.rs17
-rw-r--r--libc/src/unix/bsd/freebsdlike/mod.rs1316
-rw-r--r--libc/src/unix/bsd/mod.rs689
-rw-r--r--libc/src/unix/bsd/netbsdlike/mod.rs686
-rw-r--r--libc/src/unix/bsd/netbsdlike/netbsd/aarch64.rs22
-rw-r--r--libc/src/unix/bsd/netbsdlike/netbsd/arm.rs22
-rw-r--r--libc/src/unix/bsd/netbsdlike/netbsd/mod.rs1654
-rw-r--r--libc/src/unix/bsd/netbsdlike/netbsd/powerpc.rs21
-rw-r--r--libc/src/unix/bsd/netbsdlike/netbsd/sparc64.rs8
-rw-r--r--libc/src/unix/bsd/netbsdlike/netbsd/x86.rs15
-rw-r--r--libc/src/unix/bsd/netbsdlike/netbsd/x86_64.rs23
-rw-r--r--libc/src/unix/bsd/netbsdlike/openbsd/aarch64.rs14
-rw-r--r--libc/src/unix/bsd/netbsdlike/openbsd/mod.rs1451
-rw-r--r--libc/src/unix/bsd/netbsdlike/openbsd/x86.rs14
-rw-r--r--libc/src/unix/bsd/netbsdlike/openbsd/x86_64.rs22
-rw-r--r--libc/src/unix/haiku/b32.rs3
-rw-r--r--libc/src/unix/haiku/b64.rs3
-rw-r--r--libc/src/unix/haiku/mod.rs1396
-rw-r--r--libc/src/unix/hermit/aarch64.rs2
-rw-r--r--libc/src/unix/hermit/mod.rs1024
-rw-r--r--libc/src/unix/hermit/x86_64.rs2
-rw-r--r--libc/src/unix/mod.rs1206
-rw-r--r--libc/src/unix/newlib/aarch64/mod.rs5
-rw-r--r--libc/src/unix/newlib/align.rs61
-rw-r--r--libc/src/unix/newlib/arm/mod.rs5
-rw-r--r--libc/src/unix/newlib/mod.rs717
-rw-r--r--libc/src/unix/newlib/no_align.rs51
-rw-r--r--libc/src/unix/no_align.rs6
-rw-r--r--libc/src/unix/notbsd/android/b32/arm.rs357
-rw-r--r--libc/src/unix/notbsd/android/b32/mod.rs223
-rw-r--r--libc/src/unix/notbsd/android/b32/x86.rs415
-rw-r--r--libc/src/unix/notbsd/android/b64/aarch64.rs325
-rw-r--r--libc/src/unix/notbsd/android/b64/mod.rs281
-rw-r--r--libc/src/unix/notbsd/android/b64/x86_64.rs420
-rw-r--r--libc/src/unix/notbsd/android/mod.rs2209
-rw-r--r--libc/src/unix/notbsd/emscripten/align.rs66
-rw-r--r--libc/src/unix/notbsd/emscripten/mod.rs1866
-rw-r--r--libc/src/unix/notbsd/emscripten/no_align.rs63
-rw-r--r--libc/src/unix/notbsd/linux/align.rs98
-rw-r--r--libc/src/unix/notbsd/linux/mips/align.rs13
-rw-r--r--libc/src/unix/notbsd/linux/mips/mips32.rs695
-rw-r--r--libc/src/unix/notbsd/linux/mips/mips64.rs645
-rw-r--r--libc/src/unix/notbsd/linux/mips/mod.rs1008
-rw-r--r--libc/src/unix/notbsd/linux/mips/no_align.rs10
-rw-r--r--libc/src/unix/notbsd/linux/mod.rs2672
-rw-r--r--libc/src/unix/notbsd/linux/musl/b32/arm.rs844
-rw-r--r--libc/src/unix/notbsd/linux/musl/b32/mips.rs853
-rw-r--r--libc/src/unix/notbsd/linux/musl/b32/mod.rs62
-rw-r--r--libc/src/unix/notbsd/linux/musl/b32/powerpc.rs870
-rw-r--r--libc/src/unix/notbsd/linux/musl/b32/x86.rs952
-rw-r--r--libc/src/unix/notbsd/linux/musl/b64/aarch64.rs491
-rw-r--r--libc/src/unix/notbsd/linux/musl/b64/mod.rs328
-rw-r--r--libc/src/unix/notbsd/linux/musl/b64/powerpc64.rs587
-rw-r--r--libc/src/unix/notbsd/linux/musl/b64/x86_64.rs649
-rw-r--r--libc/src/unix/notbsd/linux/musl/mod.rs394
-rw-r--r--libc/src/unix/notbsd/linux/no_align.rs80
-rw-r--r--libc/src/unix/notbsd/linux/other/align.rs13
-rw-r--r--libc/src/unix/notbsd/linux/other/b32/arm.rs612
-rw-r--r--libc/src/unix/notbsd/linux/other/b32/mod.rs392
-rw-r--r--libc/src/unix/notbsd/linux/other/b32/powerpc.rs617
-rw-r--r--libc/src/unix/notbsd/linux/other/b32/x86.rs895
-rw-r--r--libc/src/unix/notbsd/linux/other/b64/aarch64.rs836
-rw-r--r--libc/src/unix/notbsd/linux/other/b64/mod.rs85
-rw-r--r--libc/src/unix/notbsd/linux/other/b64/not_x32.rs422
-rw-r--r--libc/src/unix/notbsd/linux/other/b64/powerpc64.rs937
-rw-r--r--libc/src/unix/notbsd/linux/other/b64/sparc64.rs869
-rw-r--r--libc/src/unix/notbsd/linux/other/b64/x32.rs375
-rw-r--r--libc/src/unix/notbsd/linux/other/b64/x86_64.rs787
-rw-r--r--libc/src/unix/notbsd/linux/other/mod.rs1142
-rw-r--r--libc/src/unix/notbsd/linux/other/no_align.rs10
-rw-r--r--libc/src/unix/notbsd/linux/s390x/align.rs10
-rw-r--r--libc/src/unix/notbsd/linux/s390x/mod.rs1403
-rw-r--r--libc/src/unix/notbsd/linux/s390x/no_align.rs7
-rw-r--r--libc/src/unix/notbsd/mod.rs1404
-rw-r--r--libc/src/unix/redox/mod.rs596
-rw-r--r--libc/src/unix/solarish/compat.rs21
-rw-r--r--libc/src/unix/solarish/mod.rs2046
-rw-r--r--libc/src/unix/uclibc/align.rs66
-rw-r--r--libc/src/unix/uclibc/arm/align.rs13
-rw-r--r--libc/src/unix/uclibc/arm/mod.rs687
-rw-r--r--libc/src/unix/uclibc/arm/no_align.rs10
-rw-r--r--libc/src/unix/uclibc/mips/mips32/align.rs13
-rw-r--r--libc/src/unix/uclibc/mips/mips32/mod.rs627
-rw-r--r--libc/src/unix/uclibc/mips/mips32/no_align.rs10
-rw-r--r--libc/src/unix/uclibc/mips/mips64/align.rs10
-rw-r--r--libc/src/unix/uclibc/mips/mips64/mod.rs213
-rw-r--r--libc/src/unix/uclibc/mips/mips64/no_align.rs8
-rw-r--r--libc/src/unix/uclibc/mips/mod.rs478
-rw-r--r--libc/src/unix/uclibc/mod.rs1997
-rw-r--r--libc/src/unix/uclibc/no_align.rs53
-rw-r--r--libc/src/unix/uclibc/x86_64/align.rs77
-rw-r--r--libc/src/unix/uclibc/x86_64/l4re.rs48
-rw-r--r--libc/src/unix/uclibc/x86_64/mod.rs312
-rw-r--r--libc/src/unix/uclibc/x86_64/no_align.rs59
-rw-r--r--libc/src/unix/uclibc/x86_64/other.rs5
-rw-r--r--libc/src/wasi.rs1328
-rw-r--r--libc/src/windows/gnu.rs13
-rw-r--r--libc/src/windows/mod.rs457
-rw-r--r--libc/src/windows/msvc.rs10
-rw-r--r--nitrocli/Cargo.lock246
-rw-r--r--nitrocli/doc/nitrocli.1.pdfbin18096 -> 0 bytes
-rw-r--r--nitrocli/src/args.rs938
-rw-r--r--nitrocli/src/commands.rs890
-rw-r--r--nitrocli/src/tests/storage.rs117
-rw-r--r--nitrokey-sys/.gitignore4
-rw-r--r--nitrokey-sys/CHANGELOG.md50
-rw-r--r--nitrokey-sys/Cargo.toml16
-rw-r--r--nitrokey-sys/LICENSE166
-rw-r--r--nitrokey-sys/README.md35
-rw-r--r--nitrokey-sys/build.rs94
-rw-r--r--nitrokey-sys/libnitrokey-v3.4.1/DeviceCommunicationExceptions.cpp24
-rw-r--r--nitrokey-sys/libnitrokey-v3.4.1/LICENSE166
-rw-r--r--nitrokey-sys/libnitrokey-v3.4.1/NK_C_API.cc755
-rw-r--r--nitrokey-sys/libnitrokey-v3.4.1/NK_C_API.h792
-rw-r--r--nitrokey-sys/libnitrokey-v3.4.1/NitrokeyManager.cc1149
-rw-r--r--nitrokey-sys/libnitrokey-v3.4.1/README.md210
-rw-r--r--nitrokey-sys/libnitrokey-v3.4.1/command_id.cc184
-rw-r--r--nitrokey-sys/libnitrokey-v3.4.1/device.cc295
-rw-r--r--nitrokey-sys/libnitrokey-v3.4.1/libnitrokey/CommandFailedException.h76
-rw-r--r--nitrokey-sys/libnitrokey-v3.4.1/libnitrokey/DeviceCommunicationExceptions.h73
-rw-r--r--nitrokey-sys/libnitrokey-v3.4.1/libnitrokey/LibraryException.h118
-rw-r--r--nitrokey-sys/libnitrokey-v3.4.1/libnitrokey/LongOperationInProgressException.h45
-rw-r--r--nitrokey-sys/libnitrokey-v3.4.1/libnitrokey/NitrokeyManager.h303
-rw-r--r--nitrokey-sys/libnitrokey-v3.4.1/libnitrokey/command.h112
-rw-r--r--nitrokey-sys/libnitrokey-v3.4.1/libnitrokey/command_id.h154
-rw-r--r--nitrokey-sys/libnitrokey-v3.4.1/libnitrokey/cxx_semantics.h44
-rw-r--r--nitrokey-sys/libnitrokey-v3.4.1/libnitrokey/deprecated.h35
-rw-r--r--nitrokey-sys/libnitrokey-v3.4.1/libnitrokey/device.h169
-rw-r--r--nitrokey-sys/libnitrokey-v3.4.1/libnitrokey/device_proto.h491
-rw-r--r--nitrokey-sys/libnitrokey-v3.4.1/libnitrokey/dissect.h145
-rw-r--r--nitrokey-sys/libnitrokey-v3.4.1/libnitrokey/hidapi/hidapi.h391
-rw-r--r--nitrokey-sys/libnitrokey-v3.4.1/libnitrokey/log.h108
-rw-r--r--nitrokey-sys/libnitrokey-v3.4.1/libnitrokey/misc.h94
-rw-r--r--nitrokey-sys/libnitrokey-v3.4.1/libnitrokey/stick10_commands.h889
-rw-r--r--nitrokey-sys/libnitrokey-v3.4.1/libnitrokey/stick10_commands_0.8.h348
-rw-r--r--nitrokey-sys/libnitrokey-v3.4.1/libnitrokey/stick20_commands.h394
-rw-r--r--nitrokey-sys/libnitrokey-v3.4.1/libnitrokey/version.h33
-rw-r--r--nitrokey-sys/libnitrokey-v3.4.1/log.cc103
-rw-r--r--nitrokey-sys/libnitrokey-v3.4.1/misc.cc123
-rw-r--r--nitrokey-sys/libnitrokey-v3.4.1/version.cc37
-rw-r--r--nitrokey-sys/libnitrokey-v3.4.1/version.cc.in37
-rw-r--r--nitrokey-sys/src/ffi.rs1112
-rw-r--r--nitrokey-sys/src/lib.rs31
-rw-r--r--nitrokey/.builds/archlinux-use-system-lib.yaml22
-rw-r--r--nitrokey/.builds/archlinux.yml21
-rw-r--r--nitrokey/.gitignore6
-rw-r--r--nitrokey/CHANGELOG.md77
-rw-r--r--nitrokey/Cargo.toml26
-rw-r--r--nitrokey/LICENSE21
-rw-r--r--nitrokey/README.md81
-rw-r--r--nitrokey/TODO.md22
-rw-r--r--nitrokey/src/auth.rs417
-rw-r--r--nitrokey/src/config.rs99
-rw-r--r--nitrokey/src/device.rs1367
-rw-r--r--nitrokey/src/lib.rs169
-rw-r--r--nitrokey/src/otp.rs414
-rw-r--r--nitrokey/src/pws.rs383
-rw-r--r--nitrokey/src/util.rs206
-rw-r--r--nitrokey/tests/device.rs496
-rw-r--r--nitrokey/tests/lib.rs7
-rw-r--r--nitrokey/tests/otp.rs302
-rw-r--r--nitrokey/tests/pws.rs161
-rw-r--r--nitrokey/tests/util/mod.rs2
-rw-r--r--rand/.gitignore2
-rw-r--r--rand/.travis.yml230
-rw-r--r--rand/CHANGELOG.md509
-rw-r--r--rand/COPYRIGHT12
-rw-r--r--rand/Cargo.toml84
-rw-r--r--rand/LICENSE-APACHE201
-rw-r--r--rand/LICENSE-MIT26
-rw-r--r--rand/README.md122
-rw-r--r--rand/appveyor.yml55
-rw-r--r--rand/benches/distributions.rs259
-rw-r--r--rand/benches/generators.rs240
-rw-r--r--rand/benches/misc.rs160
-rw-r--r--rand/benches/seq.rs174
-rw-r--r--rand/build.rs10
-rw-r--r--rand/examples/monte-carlo.rs51
-rw-r--r--rand/examples/monty-hall.rs116
-rw-r--r--rand/rand_chacha/CHANGELOG.md12
-rw-r--r--rand/rand_chacha/COPYRIGHT12
-rw-r--r--rand/rand_chacha/Cargo.toml25
-rw-r--r--rand/rand_chacha/LICENSE-APACHE201
-rw-r--r--rand/rand_chacha/LICENSE-MIT26
-rw-r--r--rand/rand_chacha/README.md45
-rw-r--r--rand/rand_chacha/build.rs7
-rw-r--r--rand/rand_chacha/src/chacha.rs449
-rw-r--r--rand/rand_chacha/src/lib.rs25
-rw-r--r--rand/rand_core/CHANGELOG.md33
-rw-r--r--rand/rand_core/COPYRIGHT12
-rw-r--r--rand/rand_core/Cargo.toml28
-rw-r--r--rand/rand_core/LICENSE-APACHE201
-rw-r--r--rand/rand_core/LICENSE-MIT26
-rw-r--r--rand/rand_core/README.md65
-rw-r--r--rand/rand_core/src/block.rs508
-rw-r--r--rand/rand_core/src/error.rs177
-rw-r--r--rand/rand_core/src/impls.rs165
-rw-r--r--rand/rand_core/src/le.rs68
-rw-r--r--rand/rand_core/src/lib.rs486
-rw-r--r--rand/rand_hc/CHANGELOG.md8
-rw-r--r--rand/rand_hc/COPYRIGHT12
-rw-r--r--rand/rand_hc/Cargo.toml21
-rw-r--r--rand/rand_hc/LICENSE-APACHE201
-rw-r--r--rand/rand_hc/LICENSE-MIT25
-rw-r--r--rand/rand_hc/README.md45
-rw-r--r--rand/rand_hc/src/hc128.rs462
-rw-r--r--rand/rand_hc/src/lib.rs25
-rw-r--r--rand/rand_isaac/CHANGELOG.md12
-rw-r--r--rand/rand_isaac/COPYRIGHT12
-rw-r--r--rand/rand_isaac/Cargo.toml31
-rw-r--r--rand/rand_isaac/LICENSE-APACHE201
-rw-r--r--rand/rand_isaac/LICENSE-MIT26
-rw-r--r--rand/rand_isaac/README.md47
-rw-r--r--rand/rand_isaac/src/isaac.rs484
-rw-r--r--rand/rand_isaac/src/isaac64.rs481
-rw-r--r--rand/rand_isaac/src/isaac_array.rs136
-rw-r--r--rand/rand_isaac/src/lib.rs36
-rw-r--r--rand/rand_os/CHANGELOG.md13
-rw-r--r--rand/rand_os/COPYRIGHT12
-rw-r--r--rand/rand_os/Cargo.toml38
-rw-r--r--rand/rand_os/LICENSE-APACHE201
-rw-r--r--rand/rand_os/LICENSE-MIT26
-rw-r--r--rand/rand_os/README.md33
-rw-r--r--rand/rand_os/src/cloudabi.rs39
-rw-r--r--rand/rand_os/src/dragonfly_haiku_emscripten.rs39
-rw-r--r--rand/rand_os/src/dummy_log.rs10
-rw-r--r--rand/rand_os/src/freebsd.rs45
-rw-r--r--rand/rand_os/src/fuchsia.rs43
-rw-r--r--rand/rand_os/src/lib.rs439
-rw-r--r--rand/rand_os/src/linux_android.rs182
-rw-r--r--rand/rand_os/src/macos.rs53
-rw-r--r--rand/rand_os/src/netbsd.rs54
-rw-r--r--rand/rand_os/src/openbsd_bitrig.rs40
-rw-r--r--rand/rand_os/src/random_device.rs70
-rw-r--r--rand/rand_os/src/redox.rs30
-rw-r--r--rand/rand_os/src/sgx.rs38
-rw-r--r--rand/rand_os/src/solaris.rs175
-rw-r--r--rand/rand_os/src/wasm32_bindgen.rs125
-rw-r--r--rand/rand_os/src/wasm32_stdweb.rs107
-rw-r--r--rand/rand_os/src/windows.rs44
-rw-r--r--rand/rand_os/tests/mod.rs80
-rw-r--r--rand/rand_pcg/CHANGELOG.md19
-rw-r--r--rand/rand_pcg/COPYRIGHT12
-rw-r--r--rand/rand_pcg/Cargo.toml37
-rw-r--r--rand/rand_pcg/LICENSE-APACHE201
-rw-r--r--rand/rand_pcg/LICENSE-MIT26
-rw-r--r--rand/rand_pcg/README.md51
-rw-r--r--rand/rand_pcg/build.rs7
-rw-r--r--rand/rand_pcg/src/lib.rs48
-rw-r--r--rand/rand_pcg/src/pcg128.rs122
-rw-r--r--rand/rand_pcg/src/pcg64.rs141
-rw-r--r--rand/rand_pcg/tests/lcg64xsh32.rs58
-rw-r--r--rand/rand_pcg/tests/mcg128xsl64.rs59
-rw-r--r--rand/rand_xorshift/CHANGELOG.md11
-rw-r--r--rand/rand_xorshift/COPYRIGHT12
-rw-r--r--rand/rand_xorshift/Cargo.toml31
-rw-r--r--rand/rand_xorshift/LICENSE-APACHE201
-rw-r--r--rand/rand_xorshift/LICENSE-MIT26
-rw-r--r--rand/rand_xorshift/README.md45
-rw-r--r--rand/rand_xorshift/src/lib.rs123
-rw-r--r--rand/rand_xorshift/tests/mod.rs92
-rw-r--r--rand/rand_xoshiro/CHANGELOG.md8
-rw-r--r--rand/rand_xoshiro/COPYRIGHT12
-rw-r--r--rand/rand_xoshiro/Cargo.toml19
-rw-r--r--rand/rand_xoshiro/LICENSE-APACHE201
-rw-r--r--rand/rand_xoshiro/LICENSE-MIT25
-rw-r--r--rand/rand_xoshiro/README.md28
-rw-r--r--rand/rand_xoshiro/src/common.rs243
-rw-r--r--rand/rand_xoshiro/src/lib.rs106
-rw-r--r--rand/rand_xoshiro/src/splitmix64.rs150
-rw-r--r--rand/rand_xoshiro/src/xoroshiro128plus.rs132
-rw-r--r--rand/rand_xoshiro/src/xoroshiro128starstar.rs129
-rw-r--r--rand/rand_xoshiro/src/xoroshiro64star.rs97
-rw-r--r--rand/rand_xoshiro/src/xoroshiro64starstar.rs96
-rw-r--r--rand/rand_xoshiro/src/xoshiro128plus.rs114
-rw-r--r--rand/rand_xoshiro/src/xoshiro128starstar.rs113
-rw-r--r--rand/rand_xoshiro/src/xoshiro256plus.rs133
-rw-r--r--rand/rand_xoshiro/src/xoshiro256starstar.rs130
-rw-r--r--rand/rand_xoshiro/src/xoshiro512plus.rs124
-rw-r--r--rand/rand_xoshiro/src/xoshiro512starstar.rs124
-rw-r--r--rand/src/deprecated.rs544
-rw-r--r--rand/src/distributions/bernoulli.rs165
-rw-r--r--rand/src/distributions/binomial.rs177
-rw-r--r--rand/src/distributions/cauchy.rs115
-rw-r--r--rand/src/distributions/dirichlet.rs137
-rw-r--r--rand/src/distributions/exponential.rs124
-rw-r--r--rand/src/distributions/float.rs259
-rw-r--r--rand/src/distributions/gamma.rs413
-rw-r--r--rand/src/distributions/integer.rs161
-rw-r--r--rand/src/distributions/mod.rs621
-rw-r--r--rand/src/distributions/normal.rs197
-rw-r--r--rand/src/distributions/other.rs219
-rw-r--r--rand/src/distributions/pareto.rs74
-rw-r--r--rand/src/distributions/poisson.rs157
-rw-r--r--rand/src/distributions/triangular.rs86
-rw-r--r--rand/src/distributions/uniform.rs1298
-rw-r--r--rand/src/distributions/unit_circle.rs101
-rw-r--r--rand/src/distributions/unit_sphere.rs99
-rw-r--r--rand/src/distributions/utils.rs504
-rw-r--r--rand/src/distributions/weibull.rs71
-rw-r--r--rand/src/distributions/weighted.rs232
-rw-r--r--rand/src/distributions/ziggurat_tables.rs279
-rw-r--r--rand/src/lib.rs852
-rw-r--r--rand/src/prelude.rs27
-rw-r--r--rand/src/prng/mod.rs37
-rw-r--r--rand/src/rngs/adapter/mod.rs15
-rw-r--r--rand/src/rngs/adapter/read.rs137
-rw-r--r--rand/src/rngs/adapter/reseeding.rs370
-rw-r--r--rand/src/rngs/entropy.rs249
-rw-r--r--rand/src/rngs/jitter.rs885
-rw-r--r--rand/src/rngs/mock.rs59
-rw-r--r--rand/src/rngs/mod.rs182
-rw-r--r--rand/src/rngs/small.rs105
-rw-r--r--rand/src/rngs/std.rs81
-rw-r--r--rand/src/rngs/thread.rs141
-rw-r--r--rand/src/seq/index.rs378
-rw-r--r--rand/src/seq/mod.rs836
-rw-r--r--rand/tests/uniformity.rs67
-rw-r--r--rand/utils/ci/install.sh49
-rwxr-xr-xrand/utils/ci/install_cargo_web.sh15
-rw-r--r--rand/utils/ci/script.sh24
-rwxr-xr-xrand/utils/ziggurat_tables.py125
-rw-r--r--rustfmt.toml (renamed from nitrocli/rustfmt.toml)0
-rw-r--r--src/arg_util.rs (renamed from nitrocli/src/arg_util.rs)98
-rw-r--r--src/args.rs433
-rw-r--r--src/commands.rs1008
-rw-r--r--src/error.rs (renamed from nitrocli/src/error.rs)55
-rw-r--r--src/main.rs (renamed from nitrocli/src/main.rs)128
-rw-r--r--src/pinentry.rs (renamed from nitrocli/src/pinentry.rs)60
-rw-r--r--src/redefine.rs (renamed from nitrocli/src/redefine.rs)0
-rw-r--r--src/tests/config.rs (renamed from nitrocli/src/tests/config.rs)38
-rw-r--r--src/tests/encrypted.rs95
-rw-r--r--src/tests/hidden.rs (renamed from nitrocli/src/tests/run.rs)59
-rw-r--r--src/tests/list.rs42
-rw-r--r--src/tests/lock.rs (renamed from nitrocli/src/tests/lock.rs)19
-rw-r--r--src/tests/mod.rs (renamed from nitrocli/src/tests/mod.rs)78
-rw-r--r--src/tests/otp.rs (renamed from nitrocli/src/tests/otp.rs)46
-rw-r--r--src/tests/pin.rs (renamed from nitrocli/src/tests/pin.rs)60
-rw-r--r--src/tests/pws.rs (renamed from nitrocli/src/tests/pws.rs)24
-rw-r--r--src/tests/reset.rs (renamed from nitrocli/src/tests/reset.rs)34
-rw-r--r--src/tests/run.rs110
-rw-r--r--src/tests/status.rs (renamed from nitrocli/src/tests/status.rs)36
-rw-r--r--src/tests/unencrypted.rs46
-rwxr-xr-xvar/binary-size.py (renamed from nitrocli/var/binary-size.py)0
-rw-r--r--var/shell-complete.rs164
539 files changed, 2803 insertions, 115217 deletions
diff --git a/nitrocli/.gitignore b/.gitignore
index c6262ea..c6262ea 100644
--- a/nitrocli/.gitignore
+++ b/.gitignore
diff --git a/nitrocli/CHANGELOG.md b/CHANGELOG.md
index e826004..152eff1 100644
--- a/nitrocli/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,55 @@
-Unreleased
-----------
+0.3.3
+-----
+- Added bash completion support via `shell-complete` utility program
+- Updated minimum required Rust version to `1.40.0`
+- Converted `Cargo.lock` to new lock file format
+- Bumped `libc` dependency to `0.2.69`
+- Bumped `structopt` dependency to `0.3.13`
+- Bumped various transitive dependencies to most recent versions
+
+
+0.3.2
+-----
+- Added the `list` command that lists all attached Nitrokey devices
+- Reworked argument handling:
+ - Added `structopt` dependency in version `0.3.7`
+ - Replaced `argparse` with `structopt`
+ - Removed `argparse` dependency
+ - Made the `--verbose` and `--model` options global
+- Removed vendored dependencies and moved source code into repository
+ root
+- Bumped `nitrokey` dependency to `0.6.0`
+- Bumped `quote` dependency to `1.0.3`
+- Bumped `syn` dependency to `1.0.14`
+
+
+0.3.1
+-----
+- Added note about interaction with GnuPG to `README` file
+- Bumped `nitrokey` dependency to `0.4.0`
+ - Bumped `nitrokey-sys` dependency to `3.5.0`
+ - Added `lazy_static` dependency in version `1.4.0`
+ - Added `cfg-if` dependency in version `0.1.10`
+ - Added `getrandom` dependency in version `0.1.13`
+
+
+0.3.0
+-----
+- Added `unencrypted` command with `set` subcommand for changing the
+ unencrypted volume's read-write mode
+- Changed `storage hidden` subcommand to `hidden` top-level command
+- Renamed `storage` command to `encrypted`
+- Removed `storage status` subcommand
+ - Moved its output into `status` command
+- Removed previously deprecated `--ascii` option from `otp set` command
+- Fixed wrong hexadecimal conversion used in `otp set` command
+- Bumped `nitrokey` dependency to `0.3.5`
+- Bumped `libc` dependency to `0.2.66`
+- Bumped `cc` dependency to `1.0.48`
+
+
+0.2.4
+-----
- Added the `reset` command to perform a factory reset
- Added the `-V`/`--version` option to print the program's version
- Check the status of a PWS slot before accessing it in `pws get`
diff --git a/Cargo.lock b/Cargo.lock
new file mode 100644
index 0000000..975dc46
--- /dev/null
+++ b/Cargo.lock
@@ -0,0 +1,299 @@
+# This file is automatically @generated by Cargo.
+# It is not intended for manual editing.
+[[package]]
+name = "aho-corasick"
+version = "0.7.10"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8716408b8bc624ed7f65d223ddb9ac2d044c0547b6fa4b0d554f3a9540496ada"
+dependencies = [
+ "memchr",
+]
+
+[[package]]
+name = "base32"
+version = "0.4.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "23ce669cd6c8588f79e15cf450314f9638f967fc5770ff1c7c1deb0925ea7cfa"
+
+[[package]]
+name = "bitflags"
+version = "1.2.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693"
+
+[[package]]
+name = "cc"
+version = "1.0.50"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "95e28fa049fda1c330bcf9d723be7663a899c4679724b34c81e9f5a326aab8cd"
+
+[[package]]
+name = "cfg-if"
+version = "0.1.10"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822"
+
+[[package]]
+name = "clap"
+version = "2.33.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5067f5bb2d80ef5d68b4c87db81601f0b75bca627bc2ef76b141d7b846a3c6d9"
+dependencies = [
+ "bitflags",
+ "textwrap",
+ "unicode-width",
+]
+
+[[package]]
+name = "getrandom"
+version = "0.1.14"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7abc8dd8451921606d809ba32e95b6111925cd2906060d2dcc29c070220503eb"
+dependencies = [
+ "cfg-if",
+ "libc",
+ "wasi",
+]
+
+[[package]]
+name = "heck"
+version = "0.3.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "20564e78d53d2bb135c343b3f47714a56af2061f1c928fdb541dc7b9fdd94205"
+dependencies = [
+ "unicode-segmentation",
+]
+
+[[package]]
+name = "lazy_static"
+version = "1.4.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
+
+[[package]]
+name = "libc"
+version = "0.2.69"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "99e85c08494b21a9054e7fe1374a732aeadaff3980b6990b94bfd3a70f690005"
+
+[[package]]
+name = "memchr"
+version = "2.3.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "3728d817d99e5ac407411fa471ff9800a778d88a24685968b36824eaf4bee400"
+
+[[package]]
+name = "nitrocli"
+version = "0.3.3"
+dependencies = [
+ "base32",
+ "libc",
+ "nitrokey",
+ "nitrokey-test",
+ "nitrokey-test-state",
+ "regex",
+ "structopt",
+]
+
+[[package]]
+name = "nitrokey"
+version = "0.6.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1587c61144935958f74fb9111c9a369a23a2e5ad39476bde1750b7b8c0c87ac0"
+dependencies = [
+ "lazy_static",
+ "libc",
+ "nitrokey-sys",
+ "rand_core",
+]
+
+[[package]]
+name = "nitrokey-sys"
+version = "3.5.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "71c6052aeb37309317d25c8fec2801f271b96c5a15656f2573d8e78ba4124c49"
+dependencies = [
+ "cc",
+]
+
+[[package]]
+name = "nitrokey-test"
+version = "0.3.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f3da0c2cedaa512f79fbc3ed45143a52c76c5edcca88d0823b967ff11d05fe37"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn",
+]
+
+[[package]]
+name = "nitrokey-test-state"
+version = "0.1.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a59b732ed6d5212424ed31ec9649f05652bcbc38f45f2292b27a6044e7098803"
+
+[[package]]
+name = "proc-macro-error"
+version = "1.0.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "98e9e4b82e0ef281812565ea4751049f1bdcdfccda7d3f459f2e138a40c08678"
+dependencies = [
+ "proc-macro-error-attr",
+ "proc-macro2",
+ "quote",
+ "syn",
+ "version_check",
+]
+
+[[package]]
+name = "proc-macro-error-attr"
+version = "1.0.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "4f5444ead4e9935abd7f27dc51f7e852a0569ac888096d5ec2499470794e2e53"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn",
+ "syn-mid",
+ "version_check",
+]
+
+[[package]]
+name = "proc-macro2"
+version = "1.0.10"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "df246d292ff63439fea9bc8c0a270bed0e390d5ebd4db4ba15aba81111b5abe3"
+dependencies = [
+ "unicode-xid",
+]
+
+[[package]]
+name = "quote"
+version = "1.0.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "2bdc6c187c65bca4260c9011c9e3132efe4909da44726bad24cf7572ae338d7f"
+dependencies = [
+ "proc-macro2",
+]
+
+[[package]]
+name = "rand_core"
+version = "0.5.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19"
+dependencies = [
+ "getrandom",
+]
+
+[[package]]
+name = "regex"
+version = "1.3.7"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a6020f034922e3194c711b82a627453881bc4682166cabb07134a10c26ba7692"
+dependencies = [
+ "aho-corasick",
+ "memchr",
+ "regex-syntax",
+ "thread_local",
+]
+
+[[package]]
+name = "regex-syntax"
+version = "0.6.17"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7fe5bd57d1d7414c6b5ed48563a2c855d995ff777729dcd91c369ec7fea395ae"
+
+[[package]]
+name = "structopt"
+version = "0.3.13"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ff6da2e8d107dfd7b74df5ef4d205c6aebee0706c647f6bc6a2d5789905c00fb"
+dependencies = [
+ "clap",
+ "lazy_static",
+ "structopt-derive",
+]
+
+[[package]]
+name = "structopt-derive"
+version = "0.4.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a489c87c08fbaf12e386665109dd13470dcc9c4583ea3e10dd2b4523e5ebd9ac"
+dependencies = [
+ "heck",
+ "proc-macro-error",
+ "proc-macro2",
+ "quote",
+ "syn",
+]
+
+[[package]]
+name = "syn"
+version = "1.0.17"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0df0eb663f387145cab623dea85b09c2c5b4b0aef44e945d928e682fce71bb03"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "unicode-xid",
+]
+
+[[package]]
+name = "syn-mid"
+version = "0.5.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7be3539f6c128a931cf19dcee741c1af532c7fd387baa739c03dd2e96479338a"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn",
+]
+
+[[package]]
+name = "textwrap"
+version = "0.11.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060"
+dependencies = [
+ "unicode-width",
+]
+
+[[package]]
+name = "thread_local"
+version = "1.0.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d40c6d1b69745a6ec6fb1ca717914848da4b44ae29d9b3080cbee91d72a69b14"
+dependencies = [
+ "lazy_static",
+]
+
+[[package]]
+name = "unicode-segmentation"
+version = "1.6.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e83e153d1053cbb5a118eeff7fd5be06ed99153f00dbcd8ae310c5fb2b22edc0"
+
+[[package]]
+name = "unicode-width"
+version = "0.1.7"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "caaa9d531767d1ff2150b9332433f32a24622147e5ebb1f26409d5da67afd479"
+
+[[package]]
+name = "unicode-xid"
+version = "0.2.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "826e7639553986605ec5979c7dd957c7895e93eabed50ab2ffa7f6128a75097c"
+
+[[package]]
+name = "version_check"
+version = "0.9.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "078775d0255232fb988e6fccf26ddc9d1ac274299aaedcedce21c6f72cc533ce"
+
+[[package]]
+name = "wasi"
+version = "0.9.0+wasi-snapshot-preview1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519"
diff --git a/nitrocli/Cargo.toml b/Cargo.toml
index 69f2d3c..18d8968 100644
--- a/nitrocli/Cargo.toml
+++ b/Cargo.toml
@@ -1,7 +1,7 @@
# Cargo.toml
#/***************************************************************************
-# * Copyright (C) 2017-2019 Daniel Mueller (deso@posteo.net) *
+# * Copyright (C) 2017-2020 Daniel Mueller (deso@posteo.net) *
# * *
# * This program is free software: you can redistribute it and/or modify *
# * it under the terms of the GNU General Public License as published by *
@@ -19,7 +19,7 @@
[package]
name = "nitrocli"
-version = "0.2.3"
+version = "0.3.3"
edition = "2018"
authors = ["Daniel Mueller <deso@posteo.net>"]
license = "GPL-3.0-or-later"
@@ -29,44 +29,41 @@ readme = "README.md"
categories = ["command-line-utilities", "authentication", "cryptography", "hardware-support"]
keywords = ["nitrokey", "nitrokey-storage", "nitrokey-pro", "cli", "usb"]
description = """
-A command line tool for interacting with the Nitrokey Storage device.
+A command line tool for interacting with Nitrokey devices.
"""
exclude = ["ci/*", "rustfmt.toml"]
[badges]
gitlab = { repository = "d-e-s-o/nitrocli", branch = "master" }
+[[bin]]
+name = "shell-complete"
+path = "var/shell-complete.rs"
+
[profile.release]
opt-level = "z"
lto = true
codegen-units = 1
incremental = false
-[dependencies.argparse]
-version = "0.2.2"
-
[dependencies.base32]
version = "0.4.0"
-path = "../base32"
[dependencies.libc]
version = "0.2"
[dependencies.nitrokey]
-version = "0.3.1"
+version = "0.6"
+
+[dependencies.structopt]
+version = "0.3.7"
+default-features = false
[dev-dependencies.nitrokey-test]
-version = "0.1.1"
+version = "0.3.1"
+
+[dev-dependencies.nitrokey-test-state]
+version = "0.1"
[dev-dependencies.regex]
version = "1"
-
-[patch.crates-io]
-argparse = { path = "../argparse" }
-base32 = { path = "../base32" }
-cc = { path = "../cc" }
-libc = { path = "../libc" }
-nitrokey = { path = "../nitrokey" }
-nitrokey-sys = { path = "../nitrokey-sys" }
-rand_core = { path = "../rand/rand_core" }
-rand_os = { path = "../rand/rand_os" }
diff --git a/nitrocli/LICENSE b/LICENSE
index ef7e7ef..ef7e7ef 100644
--- a/nitrocli/LICENSE
+++ b/LICENSE
diff --git a/nitrocli/Makefile b/Makefile
index e7f7da5..e7f7da5 100644
--- a/nitrocli/Makefile
+++ b/Makefile
diff --git a/nitrocli/README.md b/README.md
index 515e06a..f276d93 100644
--- a/nitrocli/README.md
+++ b/README.md
@@ -1,6 +1,6 @@
[![pipeline](https://gitlab.com/d-e-s-o/nitrocli/badges/master/pipeline.svg)](https://gitlab.com/d-e-s-o/nitrocli/commits/master)
[![crates.io](https://img.shields.io/crates/v/nitrocli.svg)](https://crates.io/crates/nitrocli)
-[![rustc](https://img.shields.io/badge/rustc-1.31+-blue.svg)](https://blog.rust-lang.org/2018/12/06/Rust-1.31-and-rust-2018.html)
+[![rustc](https://img.shields.io/badge/rustc-1.40+-blue.svg)](https://blog.rust-lang.org/2019/12/19/Rust-1.40.0.html)
nitrocli
========
@@ -13,19 +13,19 @@ Storage][nitrokey-storage] devices.
The following commands are currently supported:
+- list: List all attached Nitrokey devices.
- status: Report status information about the Nitrokey.
- lock: Lock the Nitrokey.
- config: Access the Nitrokey's configuration
- get: Read the current configuration.
- set: Change the configuration.
-- storage: Work with the Nitrokey's storage.
+- encrypted: Work with the Nitrokey Storage's encrypted volume.
- open: Open the encrypted volume. The user PIN needs to be entered.
- close: Close the encrypted volume.
- - status: Print information about the Nitrokey's storage.
- - hidden:
- - create: Create a hidden volume.
- - open: Open a hidden volume with a password.
- - close: Close a hidden volume.
+- hidden: Work with the Nitrokey Storage's hidden volume.
+ - create: Create a hidden volume.
+ - open: Open a hidden volume with a password.
+ - close: Close a hidden volume.
- otp: Access one-time passwords (OTP).
- get: Generate a one-time password.
- set: Set an OTP slot.
@@ -40,6 +40,8 @@ The following commands are currently supported:
- set: Set the data on a PWS slot.
- status: List all PWS slots.
- clear: Delete a PWS slot.
+- unencrypted: Work with the Nitrokey Storage's unencrypted volume.
+ - set: Change the read-write mode of the unencrypted volume.
Usage
@@ -59,16 +61,14 @@ Status:
firmware version: 0.47
user retry count: 3
admin retry count: 3
-
-$ nitrocli storage status
-Status:
- SD card ID: 0x05dcad1d
- firmware: unlocked
- storage keys: created
- volumes:
- unencrypted: active
- encrypted: active
- hidden: inactive
+ Storage:
+ SD card ID: 0x05dcad1d
+ firmware: unlocked
+ storage keys: created
+ volumes:
+ unencrypted: active
+ encrypted: active
+ hidden: inactive
# Close it again.
$ nitrocli storage close
@@ -103,8 +103,7 @@ $ cargo install nitrocli --root=$PWD/nitrocli
```
#### From Source
-After cloning the repository and changing into the `nitrocli` subfolder,
-the build is as simple as running:
+After cloning the repository the build is as simple as running:
```bash
$ cargo build --release
```
@@ -113,6 +112,20 @@ It is recommended that the resulting executable be installed in a
directory accessible via the `PATH` environment variable.
+#### Bash Completion
+**nitrocli** comes with Bash completion support for options and
+arguments to them. A completion script can be generated via the
+`shell-complete` utility program and then only needs to be sourced to
+make the current shell provide context-sensitive tab completion support.
+```bash
+$ cargo run --bin=shell-complete > nitrocli.bash
+$ source nitrocli.bash
+```
+
+The generated completion script can be installed system-wide as usual
+and sourced through Bash initialization files, such as `~/.bashrc`.
+
+
Known Problems
--------------
@@ -123,6 +136,9 @@ Known Problems
- `nitrocli` cannot connect to a Nitrokey device that is currently being
accessed by `nitrokey-app` ([upstream issue][libnitrokey#32]). To
prevent this problem, quit `nitrokey-app` before using `nitrocli`.
+- Applications using the Nitrokey device (such as `nitrocli` or
+ `nitrokey-app`) cannot easily share access with an instance of GnuPG
+ running shortly afterwards ([upstream issue][libnitrokey#137]).
Contributing
@@ -154,11 +170,12 @@ the full text of the license.
[`libnitrokey`]: https://github.com/nitrokey/libnitrokey
[nitrokey-ug]: https://www.nitrokey.com
[nitrokey-pro]: https://shop.nitrokey.com/shop/product/nitrokey-pro-2-3
-[nitrokey-storage]: https://shop.nitrokey.com/shop/product/nitrokey-storage-2-16gb-23
+[nitrokey-storage]: https://shop.nitrokey.com/shop/product/nitrokey-storage-2-56
[nitrocli-arch]: https://aur.archlinux.org/packages/nitrocli
[nitrocli-cratesio]: https://crates.io/crates/nitrocli
-[nitrocli-debian]: https://packages.debian.org/buster/nitrocli
+[nitrocli-debian]: https://packages.debian.org/stable/nitrocli
[nitrocli-gentoo]: https://packages.gentoo.org/packages/app-crypt/nitrocli
-[nitrocli-ubuntu]: https://packages.ubuntu.com/disco/nitrocli
+[nitrocli-ubuntu]: https://packages.ubuntu.com/search?keywords=nitrocli
[gplv3-tldr]: https://tldrlegal.com/license/gnu-general-public-license-v3-(gpl-3)
[libnitrokey#32]: https://github.com/Nitrokey/libnitrokey/issues/32
+[libnitrokey#137]: https://github.com/Nitrokey/libnitrokey/issues/137
diff --git a/argparse/.gitignore b/argparse/.gitignore
deleted file mode 100644
index 6ae6389..0000000
--- a/argparse/.gitignore
+++ /dev/null
@@ -1,13 +0,0 @@
-/.vagga
-*.o
-*.so
-*.rlib
-/argparse_test
-/target
-# examples
-/greeting
-/structure
-/subcommands
-
-# Cargo files
-Cargo.lock
diff --git a/argparse/.travis.yml b/argparse/.travis.yml
deleted file mode 100644
index 7ccbf43..0000000
--- a/argparse/.travis.yml
+++ /dev/null
@@ -1,34 +0,0 @@
-sudo: false
-dist: trusty
-language: rust
-
-cache:
-- cargo
-
-before_cache:
-- rm -r $TRAVIS_BUILD_DIR/target/debug
-
-jobs:
- include:
- - os: linux
- rust: stable
- - os: linux
- rust: beta
- - os: linux
- rust: nightly
-
- # deploy
- - stage: publish
- os: linux
- rust: stable
- env:
- # CARGO_TOKEN
- - secure: "tk6bJEv46YfZwAKYzxn9+afzEb6nGym9lo/YJgjYIolv2qsNyMLlmC8ptRSRTHwOQPd3c54Y9XYP+61miMmWjppQSjJ4yvkUqnyiYzzdxzVM5dNIbXcqO6GbTgE2rIx9BOH0c/qrmw1KW2iz8TChxgQu/vv8pmDL1kmyawVy3EE="
- install: true
- script: true
-
- deploy:
- - provider: script
- script: 'cargo publish --verbose --token=$CARGO_TOKEN'
- on:
- tags: true
diff --git a/argparse/Cargo.toml b/argparse/Cargo.toml
deleted file mode 100644
index 7552373..0000000
--- a/argparse/Cargo.toml
+++ /dev/null
@@ -1,12 +0,0 @@
-[package]
-
-name = "argparse"
-description = "Powerful command-line argument parsing library"
-license = "MIT"
-readme = "README.rst"
-keywords = ["command-line", "cli", "command", "argument"]
-categories = ["command-line-interface"]
-homepage = "http://github.com/tailhook/rust-argparse"
-version = "0.2.2"
-authors = ["Paul Colomiets <paul@colomiets.name>"]
-
diff --git a/argparse/LICENSE b/argparse/LICENSE
deleted file mode 100644
index 3e00de4..0000000
--- a/argparse/LICENSE
+++ /dev/null
@@ -1,19 +0,0 @@
-Copyright (c) 2014-2015 Paul Colomiets
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-THE SOFTWARE.
diff --git a/argparse/README.rst b/argparse/README.rst
deleted file mode 100644
index 8a3fca0..0000000
--- a/argparse/README.rst
+++ /dev/null
@@ -1,341 +0,0 @@
-========
-Argparse
-========
-
-The ``rust-argparse`` is command-line parsing module for rust. It's inspired
-by python's ``argparse`` module.
-
-Features:
-
-* Supports standard (GNU) option conventions
-* Properly typed values
-* Automatically generated help and usage messages
-
-Importing
-=========
-Edit your Cargo.toml to add ``rust-argparse`` to your project.
-
-.. code-block:: rust
-
- [dependencies]
- argparse = "0.2.2"
-
-
-Example
-=======
-
-The following code is a simple Rust program with command-line arguments:
-
-.. code-block:: rust
-
- extern crate argparse;
-
- use argparse::{ArgumentParser, StoreTrue, Store};
-
- fn main() {
- let mut verbose = false;
- let mut name = "World".to_string();
- { // this block limits scope of borrows by ap.refer() method
- let mut ap = ArgumentParser::new();
- ap.set_description("Greet somebody.");
- ap.refer(&mut verbose)
- .add_option(&["-v", "--verbose"], StoreTrue,
- "Be verbose");
- ap.refer(&mut name)
- .add_option(&["--name"], Store,
- "Name for the greeting");
- ap.parse_args_or_exit();
- }
-
- if verbose {
- println!("name is {}", name);
- }
- println!("Hello {}!", name);
- }
-
-Assuming the Rust code above is saved into a file ``greeting.rs``, let's see
-what we have now::
-
- $ rustc greeting.rs
- $ ./greeting -h
- Usage:
- ./greeting [OPTIONS]
-
- Greet somebody.
-
- Optional arguments:
- -h, --help Show this help message and exit
- -v, --verbose
- Be verbose
- --name NAME Name for the greeting
- $ ./greeting
- Hello World!
- $ ./greeting --name Bob
- Hello Bob!
- $ ./greeting -v --name Alice
- name is Alice
- Hello Alice!
-
-
-Basic Workflow
-==============
-
-
-Create ArgumentParser
----------------------
-
-The argument parser is created empty and is built incrementally. So we create
-a mutable variable::
-
- extern crate argparse;
- use argparse::ArgumentParser;
-
- let mut parser = ArgumentParser::new();
-
-
-Customize
----------
-
-There are optional customization methods. The most important one is::
-
- parser.set_description("My command-line utility")
-
-The descripion is rewrapped to fit 80 column string nicely. Just like option
-descriptions.
-
-Add Options
------------
-
-The ``refer`` method creates a cell variable, which the result will be written
-to::
-
- let mut verbose = false;
- parser.refer(&mut verbose);
-
-Next we add an options which control the variable:
-For example::
-
- parser.refer(&mut verbose)
- .add_option(&["-v", "--verbose"], StoreTrue,
- "Be verbose");
-
-You may add multiple options for the same variable::
-
- parser.refer(&mut verbose)
- .add_option(&["-v", "--verbose"], StoreTrue,
- "Be verbose")
- .add_option(&["-q", "--quiet"], StoreFalse,
- "Be verbose");
-
-Similarly positional arguments are added::
-
- let mut command = String;
- parser.refer(&mut command)
- .add_argument("command", Store,
- "Command to run");
-
-
-
-Organizing Options
-------------------
-
-It's often useful to organize options into some kind of structure. You can
-easily borrow variables from the structure into option parser. For example::
-
- struct Options {
- verbose: bool,
- }
- ...
- let mut options = Options { verbose: false };
- parser.refer(&mut options.verbose)
- .add_option(&["-v"], StoreTrue,
- "Be verbose");
-
-
-Parsing Arguments
------------------
-
-All the complex work is done in ``parser.parse_args()``. But there is
-a simpler option::
-
- parser.parse_args_or_exit()
-
-In case you don't want argparse to exit itself, you might use the
-``parse_args`` function directly::
-
- use std::process::exit;
-
- match parser.parse_args() {
- Ok(()) => {}
- Err(x) => {
- std::process::exit(x);
- }
- }
-
-
-ArgumentParser Methods
-======================
-
-``parser.refer<T>(var: &mut T) -> Ref``
- Attach the variable to argument parser. The options are added to the
- returned ``Ref`` object and modify a variable passed to the method.
-
-``parser.add_option(names: &[&str], action: TypedAction, help: &str)``
- Add a single option which has no parameters. Most options must be added
- by ``refer(..)`` and methods on ``Ref`` object (see below).
-
- Example::
-
- ap.add_option(&["-V", "--version"],
- Print(env!("CARGO_PKG_VERSION").to_string()), "Show version");
-
-``parser.set_description(descr: &str)``
- Set description that is at the top of help message.
-
-``parser.stop_on_first_argument(val: bool)``
- If called with ``true``, parser will stop searching for options when first
- non-option (the one doesn't start with ``-``) argument is encountered. This
- is useful if you want to parse following options with another argparser or
- external program.
-
-``parser.silence_double_dash(val: bool)``
- If called with ``true`` (default), parser will not treat *first* double
- dash ``--`` as positional argument. Use ``false`` if you need to add some
- meaning to the ``--`` marker.
-
-``parser.print_usage(name: &str, writer: &mut Write)``
- Prints usage string to stderr.
-
-``parser.print_help(name: &str, writer: &mut Write)``
- Writes help to ``writer``, used by ``--help`` option internally.
-
-``parser.parse_args()``
- Method that does all the dirty work. And returns ``Result``
-
-``parser.parse_args_or_exit()``
- Method that does all the dirty work. And in case of failure just ``exit()``
-
-
-Variable Reference Methods
-==========================
-
-The ``argparse::Ref`` object is returned from ``parser.refer()``.
-The following methods are used to add and customize arguments:
-
-``option.add_option(names: &[&str], action: TypedAction, help: &str)``
- Add an option. All items in names should be either in format ``-X`` or
- ``--long-option`` (i.e. one dash and one char or two dashes and long name).
- How this option will be interpreted and whether it will have an argument
- dependes on the action. See below list of actions.
-
-``option.add_argument(name: &str, action: TypedAction, help: &str)``
- Add a positional argument
-
-``option.metavar(var: &str)``
- A name of the argument in usage messages (for options having argument).
-
-``option.envvar(var: &str)``
- A name of the environment variable to get option value from. The value
- would be parsed with ``FromStr::from_str``, just like an option having
- ``Store`` action.
-
-``option.required()``
- The option or argument is required (it's optional by default). If multiple
- options or multiple arguments are defined for this reference at least one
- of them is required.
-
-
-Actions
-=======
-
-The following actions are available out of the box. They may be used in either
-``add_option`` or ``add_argument``:
-
-``Store``
- An option has single argument. Stores a value from command-line in a
- variable. Any type that has the ``FromStr`` and ``Clone`` traits implemented
- may be used.
-
-``StoreOption``
- As ``Store``, but wrap value with ``Some`` for use with ``Option``. For
- example:
-
- let mut x: Option<i32> = None;
- ap.refer(&mut x).add_option(&["-x"], StoreOption, "Set var x");
-
-``StoreConst(value)``
- An option has no arguments. Store a hard-coded ``value`` into variable,
- when specified. Any type with the ``Clone`` trait implemented may be used.
-
-``PushConst(value)``
- An option has no arguments. Push a hard-coded ``value`` into variable,
- when specified. Any type which has the ``Clone`` type implemented may be
- used. Option might used for a list of operations to perform, when ``required``
- is set for this variable, at least one operation is required.
-
-``StoreTrue``
- Stores boolean ``true`` value in a variable.
- (shortcut for ``StoreConst(true)``)
-
-``StoreFalse``
- Stores boolean ``false`` value in a variable.
- (shortcut for ``StoreConst(false)``)
-
-
-``IncrBy(num)``
- An option has no arguments. Increments the value stored in a variable by a
- value ``num``. Any type which has the ``Add`` and ``Clone`` traits may be used.
-
-``DecrBy(nym)``
- Decrements the value stored in a variable by a value ``num``. Any type
- which has the ``Add`` and ``Clone`` traits may be used.
-
-``Collect``
- When used for an ``--option``, requires single argument. When used for a
- positional argument consumes all remaining arguments. Parsed options are
- added to the list. I.e. a ``Collect`` action requires a
- ``Vec<int>`` variable. Parses arguments using ``FromStr`` trait.
-
-``List``
- When used for positional argument, works the same as ``List``. When used
- as an option, consumes all remaining arguments.
-
- Note the usage of ``List`` is strongly discouraged, because of complex
- rules below. Use ``Collect`` and positional options if possible. But usage
- of ``List`` action may be useful if you need shell expansion of anything
- other than last positional argument.
-
- Let's learn rules by example. For the next options::
-
- ap.refer(&mut lst1).add_option(&["-X", "--xx"], List, "List1");
- ap.refer(&mut lst2).add_argument("yy", List, "List2");
-
- The following command line::
-
- ./run 1 2 3 -X 4 5 6
-
- Will return ``[1, 2, 3]`` in the ``lst1`` and the ``[4,5,6]`` in the
- ``lst2``.
-
- Note that using when using ``=`` or equivalent short option mode, the
- 'consume all' mode is not enabled. I.e. in the following command-line::
-
- ./run 1 2 -X3 4 --xx=5 6
-
- The ``lst1`` has ``[3, 5]`` and ``lst2`` has ``[1, 2, 4, 6]``.
- The argument consuming also stops on ``--`` or the next option::
-
- ./run: -X 1 2 3 -- 4 5 6
- ./run: -X 1 2 --xx=3 4 5 6
-
- Both of the above parse ``[4, 5, 6]`` as ``lst1`` and
- the ``[1, 2, 3]`` as the ``lst2``.
-
-``Print(value)``
- Print the text and exit (with status ``0``). Useful for ``--version``
- option::
-
- ap.add_option(&["-V", "--version"],
- Print(env!("CARGO_PKG_VERSION").to_string()), "Show version");
-
-
diff --git a/argparse/bulk.yaml b/argparse/bulk.yaml
deleted file mode 100644
index 73a7d02..0000000
--- a/argparse/bulk.yaml
+++ /dev/null
@@ -1,11 +0,0 @@
-minimum-bulk: v0.4.5
-
-versions:
-
-- file: Cargo.toml
- block-start: ^\[package\]
- block-end: ^\[.*\]
- regex: ^version\s*=\s*"(\S+)"
-
-- file: README.rst
- regex: ^\s*argparse\s*=\s*"(\S+)"
diff --git a/argparse/examples/greeting.rs b/argparse/examples/greeting.rs
deleted file mode 100644
index 77e719c..0000000
--- a/argparse/examples/greeting.rs
+++ /dev/null
@@ -1,26 +0,0 @@
-extern crate argparse;
-
-use argparse::{ArgumentParser, StoreTrue, Store, Print};
-
-fn main() {
- let mut verbose = false;
- let mut name = "World".to_string();
- {
- let mut ap = ArgumentParser::new();
- ap.set_description("Greet somebody.");
- ap.add_option(&["-V", "--version"],
- Print(env!("CARGO_PKG_VERSION").to_string()), "Show version");
- ap.refer(&mut verbose)
- .add_option(&["-v", "--verbose"], StoreTrue,
- "Be verbose");
- ap.refer(&mut name)
- .add_option(&["--name"], Store,
- "Name for the greeting");
- ap.parse_args_or_exit();
- }
-
- if verbose {
- println!("name is {}", name);
- }
- println!("Hello {}!", name);
-}
diff --git a/argparse/examples/structure.rs b/argparse/examples/structure.rs
deleted file mode 100644
index 59b9345..0000000
--- a/argparse/examples/structure.rs
+++ /dev/null
@@ -1,38 +0,0 @@
-extern crate argparse;
-
-use std::process::exit;
-
-use argparse::{ArgumentParser, StoreTrue, Store};
-
-struct Options {
- verbose: bool,
- name: String,
-}
-
-fn main() {
- let mut options = Options {
- verbose: false,
- name: "World".to_string(),
- };
- {
- let mut ap = ArgumentParser::new();
- ap.set_description("Greet somebody.");
- ap.refer(&mut options.verbose)
- .add_option(&["-v", "--verbose"], StoreTrue,
- "Be verbose");
- ap.refer(&mut options.name)
- .add_option(&["--name"], Store,
- "Name for the greeting");
- match ap.parse_args() {
- Ok(()) => {}
- Err(x) => {
- exit(x);
- }
- }
- }
-
- if options.verbose {
- println!("name is {}", options.name);
- }
- println!("Hello {}!", options.name);
-}
diff --git a/argparse/examples/subcommands.rs b/argparse/examples/subcommands.rs
deleted file mode 100644
index 8fb061a..0000000
--- a/argparse/examples/subcommands.rs
+++ /dev/null
@@ -1,88 +0,0 @@
-use std::str::FromStr;
-use std::io::{stdout, stderr};
-extern crate argparse;
-
-use argparse::{ArgumentParser, StoreTrue, Store, List};
-
-#[allow(non_camel_case_types)]
-#[derive(Debug)]
-enum Command {
- play,
- record,
-}
-
-impl FromStr for Command {
- type Err = ();
- fn from_str(src: &str) -> Result<Command, ()> {
- return match src {
- "play" => Ok(Command::play),
- "record" => Ok(Command::record),
- _ => Err(()),
- };
- }
-}
-
-
-
-fn play_command(verbose: bool, args: Vec<String>) {
- let mut output = "".to_string();
- {
- let mut ap = ArgumentParser::new();
- ap.set_description("Plays a sound");
- ap.refer(&mut output)
- .add_option(&["--output"], Store,
- r#"Output sink to play to"#);
- match ap.parse(args, &mut stdout(), &mut stderr()) {
- Ok(()) => {}
- Err(x) => {
- std::process::exit(x);
- }
- }
- }
- println!("Verbosity: {}, Output: {}", verbose, output);
-}
-
-fn record_command(verbose: bool, args: Vec<String>) {
- let mut input = "".to_string();
- {
- let mut ap = ArgumentParser::new();
- ap.set_description("Records a sound");
- ap.refer(&mut input)
- .add_option(&["--input"], Store,
- r#"Output source to record from"#);
- match ap.parse(args, &mut stdout(), &mut stderr()) {
- Ok(()) => {}
- Err(x) => {
- std::process::exit(x);
- }
- }
- }
- println!("Verbosity: {}, Input: {}", verbose, input);
-}
-
-fn main() {
- let mut verbose = false;
- let mut subcommand = Command::play;
- let mut args = vec!();
- {
- let mut ap = ArgumentParser::new();
- ap.set_description("Plays or records sound");
- ap.refer(&mut verbose)
- .add_option(&["-v", "--verbose"], StoreTrue,
- "Be verbose");
- ap.refer(&mut subcommand).required()
- .add_argument("command", Store,
- r#"Command to run (either "play" or "record")"#);
- ap.refer(&mut args)
- .add_argument("arguments", List,
- r#"Arguments for command"#);
- ap.stop_on_first_argument(true);
- ap.parse_args_or_exit();
- }
-
- args.insert(0, format!("subcommand {:?}", subcommand));
- match subcommand {
- Command::play => play_command(verbose, args),
- Command::record => record_command(verbose, args),
- }
-}
diff --git a/argparse/src/action.rs b/argparse/src/action.rs
deleted file mode 100644
index c3a0aff..0000000
--- a/argparse/src/action.rs
+++ /dev/null
@@ -1,33 +0,0 @@
-use std::cell::RefCell;
-use std::rc::Rc;
-
-pub enum ParseResult {
- Parsed,
- Help,
- Exit,
- Error(String),
-}
-
-
-pub enum Action<'a> {
- Flag(Box<IFlagAction + 'a>),
- Single(Box<IArgAction + 'a>),
- Push(Box<IArgsAction + 'a>),
- Many(Box<IArgsAction + 'a>),
-}
-
-pub trait TypedAction<T> {
- fn bind<'x>(&self, Rc<RefCell<&'x mut T>>) -> Action<'x>;
-}
-
-pub trait IFlagAction {
- fn parse_flag(&self) -> ParseResult;
-}
-
-pub trait IArgAction {
- fn parse_arg(&self, arg: &str) -> ParseResult;
-}
-
-pub trait IArgsAction {
- fn parse_args(&self, args: &[&str]) -> ParseResult;
-}
diff --git a/argparse/src/bool.rs b/argparse/src/bool.rs
deleted file mode 100644
index 6ada458..0000000
--- a/argparse/src/bool.rs
+++ /dev/null
@@ -1,22 +0,0 @@
-use std::cell::RefCell;
-use std::rc::Rc;
-
-use super::action::Action;
-use super::action::TypedAction;
-use super::action::Action::Flag;
-use super::generic::StoreConstAction;
-use super::{StoreTrue, StoreFalse};
-
-
-impl TypedAction<bool> for StoreTrue {
- fn bind<'x>(&self, cell: Rc<RefCell<&'x mut bool>>) -> Action<'x> {
- return Flag(Box::new(StoreConstAction { cell: cell, value: true }));
- }
-}
-
-impl TypedAction<bool> for StoreFalse {
- fn bind<'x>(&self, cell: Rc<RefCell<&'x mut bool>>) -> Action<'x> {
- return Flag(Box::new(StoreConstAction { cell: cell, value: false }));
- }
-}
-
diff --git a/argparse/src/custom.rs b/argparse/src/custom.rs
deleted file mode 100644
index d002ffe..0000000
--- a/argparse/src/custom.rs
+++ /dev/null
@@ -1,95 +0,0 @@
-use std::cell::RefCell;
-use std::rc::Rc;
-
-use super::{Parse, ParseOption, ParseList, ParseCollect, FromCommandLine};
-use super::action::Action;
-use super::action::{TypedAction, IArgAction, IArgsAction};
-use super::action::ParseResult;
-use super::action::ParseResult::{Parsed, Error};
-use super::action::Action::{Single, Push, Many};
-
-pub struct ParseAction<'a, T: 'a> {
- pub cell: Rc<RefCell<&'a mut T>>,
-}
-
-pub struct ParseOptionAction<'a, T: 'a> {
- cell: Rc<RefCell<&'a mut Option<T>>>,
-}
-
-pub struct ParseListAction<'a, T: 'a> {
- cell: Rc<RefCell<&'a mut Vec<T>>>,
-}
-
-impl<T: 'static + FromCommandLine> TypedAction<T> for Parse {
- fn bind<'x>(&self, cell: Rc<RefCell<&'x mut T>>) -> Action<'x> {
- return Single(Box::new(ParseAction { cell: cell }));
- }
-}
-
-impl<T: 'static + FromCommandLine> TypedAction<Option<T>> for ParseOption {
- fn bind<'x>(&self, cell: Rc<RefCell<&'x mut Option<T>>>) -> Action<'x> {
- return Single(Box::new(ParseOptionAction { cell: cell }));
- }
-}
-
-impl<T: 'static + FromCommandLine + Clone> TypedAction<Vec<T>> for ParseList {
- fn bind<'x>(&self, cell: Rc<RefCell<&'x mut Vec<T>>>) -> Action<'x> {
- return Many(Box::new(ParseListAction { cell: cell }));
- }
-}
-
-impl<T> TypedAction<Vec<T>> for ParseCollect
- where T: 'static + FromCommandLine + Clone
-{
- fn bind<'x>(&self, cell: Rc<RefCell<&'x mut Vec<T>>>) -> Action<'x> {
- return Push(Box::new(ParseListAction { cell: cell }))
- }
-}
-
-impl<'a, T: FromCommandLine> IArgAction for ParseAction<'a, T> {
- fn parse_arg(&self, arg: &str) -> ParseResult {
- match FromCommandLine::from_argument(arg) {
- Ok(x) => {
- **self.cell.borrow_mut() = x;
- return Parsed;
- }
- Err(error) => {
- return Error(format!("Bad value {:?}: {}", arg, error));
- }
- }
- }
-}
-
-impl<'a, T: FromCommandLine> IArgAction for ParseOptionAction<'a, T> {
- fn parse_arg(&self, arg: &str) -> ParseResult {
- match FromCommandLine::from_argument(arg) {
- Ok(x) => {
- **self.cell.borrow_mut() = Some(x);
- return Parsed;
- }
- Err(error) => {
- return Error(format!("Bad value {:?}: {}", arg, error));
- }
- }
- }
-}
-
-impl<'a, T: FromCommandLine + Clone> IArgsAction for ParseListAction<'a, T> {
- fn parse_args(&self, args: &[&str]) -> ParseResult {
- let mut result = vec!();
- for arg in args.iter() {
- match FromCommandLine::from_argument(*arg) {
- Ok(x) => {
- result.push(x);
- }
- Err(error) => {
- return Error(format!("Bad value {:?}: {}", arg, error));
- }
- }
- }
- **self.cell.borrow_mut() = result;
- return Parsed;
- }
-}
-
-
diff --git a/argparse/src/from_cli.rs b/argparse/src/from_cli.rs
deleted file mode 100644
index 7ea6d58..0000000
--- a/argparse/src/from_cli.rs
+++ /dev/null
@@ -1,100 +0,0 @@
-use std::str::FromStr;
-use std::path::PathBuf;
-use std::net::{Ipv4Addr, Ipv6Addr, SocketAddr};
-
-use super::FromCommandLine;
-
-
-impl FromCommandLine for PathBuf {
- fn from_argument(s: &str) -> Result<Self, String> {
- Ok(From::from(s))
- }
-}
-
-impl FromCommandLine for f32 {
- fn from_argument(s: &str) -> Result<Self, String> {
- FromStr::from_str(s).map_err(|e| format!("{:?}", e))
- }
-}
-impl FromCommandLine for f64 {
- fn from_argument(s: &str) -> Result<Self, String> {
- FromStr::from_str(s).map_err(|e| format!("{:?}", e))
- }
-}
-
-// TODO(tailhook) implement various radices for integer values
-impl FromCommandLine for isize {
- fn from_argument(s: &str) -> Result<Self, String> {
- FromStr::from_str(s).map_err(|e| format!("{:?}", e))
- }
-}
-impl FromCommandLine for i8 {
- fn from_argument(s: &str) -> Result<Self, String> {
- FromStr::from_str(s).map_err(|e| format!("{:?}", e))
- }
-}
-impl FromCommandLine for i16 {
- fn from_argument(s: &str) -> Result<Self, String> {
- FromStr::from_str(s).map_err(|e| format!("{:?}", e))
- }
-}
-impl FromCommandLine for i32 {
- fn from_argument(s: &str) -> Result<Self, String> {
- FromStr::from_str(s).map_err(|e| format!("{:?}", e))
- }
-}
-impl FromCommandLine for i64 {
- fn from_argument(s: &str) -> Result<Self, String> {
- FromStr::from_str(s).map_err(|e| format!("{:?}", e))
- }
-}
-impl FromCommandLine for usize {
- fn from_argument(s: &str) -> Result<Self, String> {
- FromStr::from_str(s).map_err(|e| format!("{:?}", e))
- }
-}
-impl FromCommandLine for u8 {
- fn from_argument(s: &str) -> Result<Self, String> {
- FromStr::from_str(s).map_err(|e| format!("{:?}", e))
- }
-}
-impl FromCommandLine for u16 {
- fn from_argument(s: &str) -> Result<Self, String> {
- FromStr::from_str(s).map_err(|e| format!("{:?}", e))
- }
-}
-impl FromCommandLine for u32 {
- fn from_argument(s: &str) -> Result<Self, String> {
- FromStr::from_str(s).map_err(|e| format!("{:?}", e))
- }
-}
-impl FromCommandLine for u64 {
- fn from_argument(s: &str) -> Result<Self, String> {
- FromStr::from_str(s).map_err(|e| format!("{:?}", e))
- }
-}
-impl FromCommandLine for bool {
- fn from_argument(s: &str) -> Result<Self, String> {
- FromStr::from_str(s).map_err(|e| format!("{:?}", e))
- }
-}
-impl FromCommandLine for String {
- fn from_argument(s: &str) -> Result<Self, String> {
- FromStr::from_str(s).map_err(|_| unreachable!())
- }
-}
-impl FromCommandLine for Ipv4Addr {
- fn from_argument(s: &str) -> Result<Self, String> {
- FromStr::from_str(s).map_err(|e| format!("{:?}", e))
- }
-}
-impl FromCommandLine for Ipv6Addr {
- fn from_argument(s: &str) -> Result<Self, String> {
- FromStr::from_str(s).map_err(|e| format!("{:?}", e))
- }
-}
-impl FromCommandLine for SocketAddr {
- fn from_argument(s: &str) -> Result<Self, String> {
- FromStr::from_str(s).map_err(|e| format!("{:?}", e))
- }
-}
diff --git a/argparse/src/generic.rs b/argparse/src/generic.rs
deleted file mode 100644
index 1b1b7dc..0000000
--- a/argparse/src/generic.rs
+++ /dev/null
@@ -1,133 +0,0 @@
-use std::cell::RefCell;
-use std::str::FromStr;
-use std::rc::Rc;
-
-use super::{StoreConst, Store, StoreOption, List, Collect, PushConst};
-use super::action::Action;
-use super::action::{TypedAction, IFlagAction, IArgAction, IArgsAction};
-use super::action::ParseResult;
-use super::action::ParseResult::{Parsed, Error};
-use super::action::Action::{Flag, Single, Push, Many};
-
-pub struct StoreConstAction<'a, T: 'a> {
- pub value: T,
- pub cell: Rc<RefCell<&'a mut T>>,
-}
-
-pub struct PushConstAction<'a, T: 'a> {
- pub value: T,
- pub cell: Rc<RefCell<&'a mut Vec<T>>>,
-}
-
-pub struct StoreAction<'a, T: 'a> {
- pub cell: Rc<RefCell<&'a mut T>>,
-}
-
-pub struct StoreOptionAction<'a, T: 'a> {
- cell: Rc<RefCell<&'a mut Option<T>>>,
-}
-
-pub struct ListAction<'a, T: 'a> {
- cell: Rc<RefCell<&'a mut Vec<T>>>,
-}
-
-impl<T: 'static + Clone> TypedAction<T> for StoreConst<T> {
- fn bind<'x>(&self, cell: Rc<RefCell<&'x mut T>>) -> Action<'x> {
- let StoreConst(ref val) = *self;
- return Flag(Box::new(StoreConstAction { cell: cell, value: val.clone() }));
- }
-}
-
-impl<T: 'static + Clone> TypedAction<Vec<T>> for PushConst<T> {
- fn bind<'x>(&self, cell: Rc<RefCell<&'x mut Vec<T>>>) -> Action<'x> {
- let PushConst(ref val) = *self;
- return Flag(Box::new(PushConstAction { cell: cell, value: val.clone() }));
- }
-}
-
-impl<T: 'static + FromStr> TypedAction<T> for Store {
- fn bind<'x>(&self, cell: Rc<RefCell<&'x mut T>>) -> Action<'x> {
- return Single(Box::new(StoreAction { cell: cell }));
- }
-}
-
-impl<T: 'static + FromStr> TypedAction<Option<T>> for StoreOption {
- fn bind<'x>(&self, cell: Rc<RefCell<&'x mut Option<T>>>) -> Action<'x> {
- return Single(Box::new(StoreOptionAction { cell: cell }));
- }
-}
-
-impl<T: 'static + FromStr + Clone> TypedAction<Vec<T>> for List {
- fn bind<'x>(&self, cell: Rc<RefCell<&'x mut Vec<T>>>) -> Action<'x> {
- return Many(Box::new(ListAction { cell: cell }));
- }
-}
-
-impl<T: 'static + FromStr + Clone> TypedAction<Vec<T>> for Collect {
- fn bind<'x>(&self, cell: Rc<RefCell<&'x mut Vec<T>>>) -> Action<'x> {
- return Push(Box::new(ListAction { cell: cell }));
- }
-}
-
-impl<'a, T: Clone> IFlagAction for StoreConstAction<'a, T> {
- fn parse_flag(&self) -> ParseResult {
- let mut targ = self.cell.borrow_mut();
- **targ = self.value.clone();
- return Parsed;
- }
-}
-
-impl<'a, T: Clone> IFlagAction for PushConstAction<'a, T> {
- fn parse_flag(&self) -> ParseResult {
- let mut targ = self.cell.borrow_mut();
- targ.push(self.value.clone());
- return Parsed;
- }
-}
-
-impl<'a, T: FromStr> IArgAction for StoreAction<'a, T> {
- fn parse_arg(&self, arg: &str) -> ParseResult {
- match FromStr::from_str(arg) {
- Ok(x) => {
- **self.cell.borrow_mut() = x;
- return Parsed;
- }
- Err(_) => {
- return Error(format!("Bad value {}", arg));
- }
- }
- }
-}
-
-impl<'a, T: FromStr> IArgAction for StoreOptionAction<'a, T> {
- fn parse_arg(&self, arg: &str) -> ParseResult {
- match FromStr::from_str(arg) {
- Ok(x) => {
- **self.cell.borrow_mut() = Some(x);
- return Parsed;
- }
- Err(_) => {
- return Error(format!("Bad value {}", arg));
- }
- }
- }
-}
-
-impl<'a, T: FromStr + Clone> IArgsAction for ListAction<'a, T> {
- fn parse_args(&self, args: &[&str]) -> ParseResult {
- let mut result = vec!();
- for arg in args.iter() {
- match FromStr::from_str(*arg) {
- Ok(x) => {
- result.push(x);
- }
- Err(_) => {
- return Error(format!("Bad value {}", arg));
- }
- }
- }
- **self.cell.borrow_mut() = result;
- return Parsed;
- }
-}
-
diff --git a/argparse/src/help.rs b/argparse/src/help.rs
deleted file mode 100644
index c7145be..0000000
--- a/argparse/src/help.rs
+++ /dev/null
@@ -1,93 +0,0 @@
-use std::str::CharIndices;
-use std::io::Result as IoResult;
-use std::io::Write;
-
-use super::action::{IFlagAction, ParseResult};
-use super::action::ParseResult::Help;
-
-pub struct HelpAction;
-
-impl IFlagAction for HelpAction {
- fn parse_flag(&self) -> ParseResult {
- return Help;
- }
-}
-
-
-struct WordsIter<'a> {
- data: &'a str,
- iter: CharIndices<'a>,
-}
-
-impl<'a> WordsIter<'a> {
- fn new(data: &'a str) -> WordsIter<'a> {
- return WordsIter {
- data: data,
- iter: data.char_indices(),
- };
- }
-}
-
-impl<'a> Iterator for WordsIter<'a> {
- type Item = &'a str;
- fn next(&mut self) -> Option<&'a str> {
- let word_start;
- loop {
- let (idx, ch) = match self.iter.next() {
- None => return None,
- Some((idx, ch)) => ((idx, ch)),
- };
- match ch {
- ' ' | '\t' | '\r' | '\n' => continue,
- _ => {
- word_start = idx;
- break;
- }
- }
- }
- loop {
- let (idx, ch) = match self.iter.next() {
- None => break,
- Some((idx, ch)) => ((idx, ch)),
- };
- match ch {
- ' ' | '\t' | '\r' | '\n' => {
- return Some(&self.data[word_start..idx]);
- }
- _ => continue,
- }
- }
- return Some(&self.data[word_start..self.data.len()]);
- }
-}
-
-pub fn wrap_text(buf: &mut Write, data: &str, width: usize, indent: usize)
- -> IoResult<()>
-{
- let mut witer = WordsIter::new(data);
- let mut off = indent;
- match witer.next() {
- None => {
- return Ok(());
- }
- Some(word) => {
- try!(buf.write(word.as_bytes()));
- off += word.len();
- }
- }
- for word in witer {
- if off + word.len() + 1 > width {
- try!(buf.write(b"\n"));
- for _ in 0..indent {
- try!(buf.write(b" "));
- }
- off = indent;
- } else {
- try!(buf.write(b" "));
- off += 1;
- }
- try!(buf.write(word.as_bytes()));
- off += word.len();
- }
- return Ok(());
-}
diff --git a/argparse/src/lib.rs b/argparse/src/lib.rs
deleted file mode 100644
index 62b0cf9..0000000
--- a/argparse/src/lib.rs
+++ /dev/null
@@ -1,64 +0,0 @@
-#![crate_name = "argparse"]
-#![crate_type = "lib"]
-
-pub use self::parser::{ArgumentParser, Ref};
-
-pub mod action;
-pub mod parser;
-mod generic;
-mod custom;
-mod help;
-mod print;
-
-mod bool;
-mod num;
-mod from_cli;
-
-pub trait FromCommandLine: Sized {
- fn from_argument(s: &str) -> Result<Self, String>;
-}
-
-// TODO(tailhook) make consts
-pub struct StoreTrue;
-pub struct StoreFalse;
-
-pub struct StoreConst<T>(pub T);
-
-pub struct PushConst<T>(pub T);
-
-pub struct Store;
-pub struct Parse;
-
-pub struct StoreOption;
-pub struct ParseOption;
-
-pub struct List;
-pub struct ParseList;
-
-pub struct Collect;
-pub struct ParseCollect;
-
-/// Print string and exit with status 0
-///
-/// Particularly useful for `--version` option and similar
-pub struct Print(pub String);
-
-pub struct IncrBy<T>(pub T);
-
-pub struct DecrBy<T>(pub T);
-
-
-#[cfg(test)] mod test_parser;
-#[cfg(test)] mod test_bool;
-#[cfg(test)] mod test_int;
-#[cfg(test)] mod test_float;
-#[cfg(test)] mod test_str;
-#[cfg(test)] mod test_enum;
-#[cfg(test)] mod test_pos;
-#[cfg(test)] mod test_many;
-#[cfg(test)] mod test_optional;
-#[cfg(test)] mod test_usage;
-#[cfg(test)] mod test_help;
-#[cfg(test)] mod test_env;
-#[cfg(test)] mod test_const;
-#[cfg(test)] mod test_path;
diff --git a/argparse/src/num.rs b/argparse/src/num.rs
deleted file mode 100644
index 9f34de7..0000000
--- a/argparse/src/num.rs
+++ /dev/null
@@ -1,58 +0,0 @@
-use std::cell::RefCell;
-use std::rc::Rc;
-use std::ops::{Add, Sub};
-
-use super::{IncrBy, DecrBy};
-use super::action::{TypedAction, Action, ParseResult};
-use super::action::ParseResult::Parsed;
-use super::action::IFlagAction;
-use super::action::Action::Flag;
-
-pub struct IncrByAction<'a, T: 'a> {
- delta: T,
- cell: Rc<RefCell<&'a mut T>>,
-}
-
-pub struct DecrByAction<'a, T: 'a> {
- delta: T,
- cell: Rc<RefCell<&'a mut T>>,
-}
-
-impl<T: 'static + Add<Output = T> + Clone> TypedAction<T> for IncrBy<T> {
- fn bind<'x>(&self, cell: Rc<RefCell<&'x mut T>>) -> Action<'x> {
- let IncrBy(ref delta) = *self;
- return Flag(Box::new(IncrByAction { cell: cell, delta: delta.clone() }));
- }
-}
-
-impl<T: 'static + Sub<Output = T> + Clone> TypedAction<T> for DecrBy<T> {
- fn bind<'x>(&self, cell: Rc<RefCell<&'x mut T>>) -> Action<'x> {
- let DecrBy(ref delta) = *self;
- return Flag(Box::new(DecrByAction { cell: cell, delta: delta.clone() }));
- }
-}
-
-impl<'a, T: Add<Output = T> + Clone> IFlagAction for IncrByAction<'a, T> {
- fn parse_flag(&self) -> ParseResult {
- let oldval = {
- let targ = self.cell.borrow();
- targ.clone()
- };
- let mut targ = self.cell.borrow_mut();
- **targ = oldval + self.delta.clone();
- return Parsed;
- }
-}
-
-impl<'a, T: Sub<Output = T> + Clone> IFlagAction for DecrByAction<'a, T> {
- fn parse_flag(&self) -> ParseResult {
- let oldval = {
- let targ = self.cell.borrow();
- targ.clone()
- };
- let mut targ = self.cell.borrow_mut();
- **targ = oldval - self.delta.clone();
- return Parsed;
- }
-}
-
diff --git a/argparse/src/parser.rs b/argparse/src/parser.rs
deleted file mode 100644
index ac7e3da..0000000
--- a/argparse/src/parser.rs
+++ /dev/null
@@ -1,967 +0,0 @@
-use std::env;
-use std::io::{Write};
-use std::io::Result as IoResult;
-use std::io::{stdout, stderr};
-use std::rc::Rc;
-use std::cell::RefCell;
-use std::iter::Peekable;
-use std::slice::Iter;
-use std::hash::Hash;
-use std::hash::Hasher;
-use std::str::FromStr;
-use std::process::exit;
-
-#[allow(unused_imports)] #[allow(deprecated)]
-use std::ascii::AsciiExt;
-
-use std::collections::HashMap;
-use std::collections::hash_map::Entry;
-use std::collections::HashSet;
-
-use super::action::{Action, ParseResult};
-use super::action::ParseResult::{Parsed, Help, Exit, Error};
-use super::action::TypedAction;
-use super::action::Action::{Flag, Single, Push, Many};
-use super::action::IArgAction;
-use super::generic::StoreAction;
-use super::help::{HelpAction, wrap_text};
-use action::IFlagAction;
-
-use self::ArgumentKind::{Positional, ShortOption, LongOption, Delimiter};
-
-
-static OPTION_WIDTH: usize = 24;
-static TOTAL_WIDTH: usize = 79;
-
-
-enum ArgumentKind {
- Positional,
- ShortOption,
- LongOption,
- Delimiter, // Barely "--"
-}
-
-
-impl ArgumentKind {
- fn check(name: &str) -> ArgumentKind {
- let mut iter = name.chars();
- let char1 = iter.next();
- let char2 = iter.next();
- let char3 = iter.next();
- return match char1 {
- Some('-') => match char2 {
- Some('-') => match char3 {
- Some(_) => LongOption, // --opt
- None => Delimiter, // just --
- },
- Some(_) => ShortOption, // -opts
- None => Positional, // single dash
- },
- Some(_) | None => Positional,
- }
- }
-}
-
-struct GenericArgument<'parser> {
- id: usize,
- varid: usize,
- name: &'parser str,
- help: &'parser str,
- action: Action<'parser>,
-}
-
-struct GenericOption<'parser> {
- id: usize,
- varid: Option<usize>,
- names: Vec<&'parser str>,
- help: &'parser str,
- action: Action<'parser>,
-}
-
-struct EnvVar<'parser> {
- varid: usize,
- name: &'parser str,
- action: Box<IArgAction + 'parser>,
-}
-
-impl<'a> Hash for GenericOption<'a> {
- fn hash<H>(&self, state: &mut H) where H: Hasher {
- self.id.hash(state);
- }
-}
-
-impl<'a> PartialEq for GenericOption<'a> {
- fn eq(&self, other: &GenericOption<'a>) -> bool {
- return self.id == other.id;
- }
-}
-
-impl<'a> Eq for GenericOption<'a> {}
-
-impl<'a> Hash for GenericArgument<'a> {
- fn hash<H>(&self, state: &mut H) where H: Hasher {
- self.id.hash(state);
- }
-}
-
-impl<'a> PartialEq for GenericArgument<'a> {
- fn eq(&self, other: &GenericArgument<'a>) -> bool {
- return self.id == other.id;
- }
-}
-
-impl<'a> Eq for GenericArgument<'a> {}
-
-pub struct Var {
- id: usize,
- metavar: String,
- required: bool,
-}
-
-impl Hash for Var {
- fn hash<H>(&self, state: &mut H) where H: Hasher {
- self.id.hash(state);
- }
-}
-
-impl PartialEq for Var {
- fn eq(&self, other: &Var) -> bool {
- return self.id == other.id;
- }
-}
-
-impl Eq for Var {}
-
-struct Context<'ctx, 'parser: 'ctx> {
- parser: &'ctx ArgumentParser<'parser>,
- set_vars: HashSet<usize>,
- list_options: HashMap<Rc<GenericOption<'parser>>, Vec<&'ctx str>>,
- list_arguments: HashMap<Rc<GenericArgument<'parser>>, Vec<&'ctx str>>,
- arguments: Vec<&'ctx str>,
- iter: Peekable<Iter<'ctx, String>>,
- stderr: &'ctx mut (Write + 'ctx),
-}
-
-impl<'a, 'b> Context<'a, 'b> {
-
- fn parse_option(&mut self, opt: Rc<GenericOption<'b>>,
- optarg: Option<&'a str>)
- -> ParseResult
- {
- let value = match optarg {
- Some(value) => value,
- None => match self.iter.next() {
- Some(value) => {
- &value[..]
- }
- None => {
- return match opt.action {
- Many(_) => Parsed,
- _ => Error(format!(
- // TODO(tailhook) is {:?} ok?
- "Option {:?} requires an argument", opt.names)),
- };
- }
- },
- };
- match opt.varid {
- Some(varid) => { self.set_vars.insert(varid); }
- None => {}
- }
- match opt.action {
- Single(ref action) => {
- return action.parse_arg(value);
- }
- Push(_) => {
- (match self.list_options.entry(opt.clone()) {
- Entry::Occupied(occ) => occ.into_mut(),
- Entry::Vacant(vac) => vac.insert(Vec::new()),
- }).push(value);
- return Parsed;
- }
- Many(_) => {
- let vec = match self.list_options.entry(opt.clone()) {
- Entry::Occupied(occ) => occ.into_mut(),
- Entry::Vacant(vac) => vac.insert(Vec::new()),
- };
- vec.push(value);
- match optarg {
- Some(_) => return Parsed,
- _ => {}
- }
- loop {
- match self.iter.peek() {
- None => { break; }
- Some(arg) if arg.starts_with("-") => {
- break;
- }
- Some(value) => {
- vec.push(&value[..]);
- }
- }
- self.iter.next();
- }
- return Parsed;
- }
- _ => panic!(),
- };
- }
-
- fn parse_long_option(&mut self, arg: &'a str) -> ParseResult {
- let mut equals_iter = arg.splitn(2, '=');
- let optname = equals_iter.next().unwrap();
- let valueref = equals_iter.next();
- let opt = self.parser.long_options.get(&optname.to_string());
- match opt {
- Some(opt) => {
- match opt.action {
- Flag(ref action) => {
- match valueref {
- Some(_) => {
- return Error(format!(
- "Option {} does not accept an argument",
- optname));
- }
- None => {
- match opt.varid {
- Some(varid) => {
- self.set_vars.insert(varid);
- }
- None => {}
- }
- return action.parse_flag();
- }
- }
- }
- Single(_) | Push(_) | Many(_) => {
- return self.parse_option(opt.clone(), valueref);
- }
- }
- }
- None => {
- return Error(format!("Unknown option {}", arg));
- }
- }
- }
-
- fn parse_short_options<'x>(&'x mut self, arg: &'a str) -> ParseResult {
- let mut iter = arg.char_indices();
- iter.next();
- for (idx, ch) in iter {
- let opt = match self.parser.short_options.get(&ch) {
- Some(opt) => { opt }
- None => {
- return Error(format!("Unknown short option \"{}\"", ch));
- }
- };
- let res = match opt.action {
- Flag(ref action) => {
- match opt.varid {
- Some(varid) => { self.set_vars.insert(varid); }
- None => {}
- }
- action.parse_flag()
- }
- Single(_) | Push(_) | Many(_) => {
- let value;
- if idx + 1 < arg.len() {
- value = Some(&arg[idx+1..arg.len()]);
- } else {
- value = None;
- }
- return self.parse_option(opt.clone(), value);
- }
- };
- match res {
- Parsed => { continue; }
- x => { return x; }
- }
- }
- return Parsed;
- }
-
- fn postpone_argument(&mut self, arg: &'a str) {
- self.arguments.push(arg);
- }
-
- fn parse_options(&mut self) -> ParseResult {
- self.iter.next(); // Command name
- loop {
- let next = self.iter.next();
- let arg = match next {
- Some(arg) => { arg }
- None => { break; }
- };
- let res = match ArgumentKind::check(&arg[..]) {
- Positional => {
- self.postpone_argument(&arg[..]);
- if self.parser.stop_on_first_argument {
- break;
- }
- continue;
- }
- LongOption => self.parse_long_option(&arg[..]),
- ShortOption => self.parse_short_options(&arg[..]),
- Delimiter => {
- if !self.parser.silence_double_dash {
- self.postpone_argument("--");
- }
- break;
- }
- };
- match res {
- Parsed => continue,
- _ => return res,
- }
- }
-
- loop {
- match self.iter.next() {
- None => break,
- Some(arg) => self.postpone_argument(&arg[..]),
- }
- }
- return Parsed;
- }
-
- fn parse_arguments(&mut self) -> ParseResult {
- let mut pargs = self.parser.arguments.iter();
- for arg in self.arguments.iter() {
- let opt;
- loop {
- match pargs.next() {
- Some(option) => {
- if self.set_vars.contains(&option.varid) {
- continue;
- }
- opt = option;
- break;
- }
- None => match self.parser.catchall_argument {
- Some(ref option) => {
- opt = option;
- break;
- }
- None => return Error(format!(
- "Unexpected argument {}", arg)),
- }
- };
- }
- let res = match opt.action {
- Single(ref act) => {
- self.set_vars.insert(opt.varid);
- act.parse_arg(*arg)
- },
- Many(_) | Push(_) => {
- (match self.list_arguments.entry(opt.clone()) {
- Entry::Occupied(occ) => occ.into_mut(),
- Entry::Vacant(vac) => vac.insert(Vec::new()),
- }).push(*arg);
- Parsed
- },
- _ => unreachable!(),
- };
- match res {
- Parsed => continue,
- _ => return res,
- }
- }
- return Parsed;
- }
-
- fn parse_list_vars(&mut self) -> ParseResult {
- for (opt, lst) in self.list_options.iter() {
- match opt.action {
- Push(ref act) | Many(ref act) => {
- let res = act.parse_args(&lst[..]);
- match res {
- Parsed => continue,
- _ => return res,
- }
- }
- _ => panic!(),
- }
- }
- for (opt, lst) in self.list_arguments.iter() {
- match opt.action {
- Push(ref act) | Many(ref act) => {
- let res = act.parse_args(&lst[..]);
- match res {
- Parsed => continue,
- _ => return res,
- }
- }
- _ => panic!(),
- }
- }
- return Parsed;
- }
-
- fn parse_env_vars(&mut self) -> ParseResult {
- for evar in self.parser.env_vars.iter() {
- match env::var(evar.name) {
- Ok(val) => {
- match evar.action.parse_arg(&val[..]) {
- Parsed => {
- self.set_vars.insert(evar.varid);
- continue;
- }
- Error(err) => {
- write!(self.stderr,
- "WARNING: Environment variable {}: {}\n",
- evar.name, err).ok();
- }
- _ => unreachable!(),
- }
- }
- Err(_) => {}
- }
- }
- return Parsed;
- }
-
- fn check_required(&mut self) -> ParseResult {
- // Check for required arguments
- for var in self.parser.vars.iter() {
- if var.required && !self.set_vars.contains(&var.id) {
- // First try positional arguments
- for opt in self.parser.arguments.iter() {
- if opt.varid == var.id {
- return Error(format!(
- "Argument {} is required", opt.name));
- }
- }
- // Then options
- let mut all_options = vec!();
- for opt in self.parser.options.iter() {
- match opt.varid {
- Some(varid) if varid == var.id => {}
- _ => { continue }
- }
- all_options.extend(opt.names.clone().into_iter());
- }
- if all_options.len() > 1 {
- return Error(format!(
- "One of the options {:?} is required", all_options));
- } else if all_options.len() == 1 {
- return Error(format!(
- "Option {:?} is required", all_options));
- }
- // Then envvars
- for envvar in self.parser.env_vars.iter() {
- if envvar.varid == var.id {
- return Error(format!(
- "Environment var {} is required", envvar.name));
- }
- }
- }
- }
- return Parsed;
- }
-
- fn parse(parser: &ArgumentParser, args: &Vec<String>, stderr: &mut Write)
- -> ParseResult
- {
- let mut ctx = Context {
- parser: parser,
- iter: args.iter().peekable(),
- set_vars: HashSet::new(),
- list_options: HashMap::new(),
- list_arguments: HashMap::new(),
- arguments: Vec::new(),
- stderr: stderr,
- };
-
- match ctx.parse_env_vars() {
- Parsed => {}
- x => { return x; }
- }
-
- match ctx.parse_options() {
- Parsed => {}
- x => { return x; }
- }
-
- match ctx.parse_arguments() {
- Parsed => {}
- x => { return x; }
- }
-
- match ctx.parse_list_vars() {
- Parsed => {}
- x => { return x; }
- }
-
- match ctx.check_required() {
- Parsed => {}
- x => { return x; }
- }
-
- return Parsed;
- }
-}
-
-pub struct Ref<'parser:'refer, 'refer, T: 'parser> {
- cell: Rc<RefCell<&'parser mut T>>,
- varid: usize,
- parser: &'refer mut ArgumentParser<'parser>,
-}
-
-impl<'parser, 'refer, T> Ref<'parser, 'refer, T> {
-
- pub fn add_option<'x, A: TypedAction<T>>(&'x mut self,
- names: &[&'parser str], action: A, help: &'parser str)
- -> &'x mut Ref<'parser, 'refer, T>
- {
- {
- let var = &mut self.parser.vars[self.varid];
- if var.metavar.len() == 0 {
- let mut longest_name = names[0];
- let mut llen = longest_name.len();
- for name in names.iter() {
- if name.len() > llen {
- longest_name = *name;
- llen = longest_name.len();
- }
- }
- if llen > 2 {
- var.metavar = longest_name[2..llen]
- .to_ascii_uppercase().replace("-", "_");
- }
- }
- }
- self.parser.add_option_for(Some(self.varid), names,
- action.bind(self.cell.clone()),
- help);
- return self;
- }
-
- pub fn add_argument<'x, A: TypedAction<T>>(&'x mut self,
- name: &'parser str, action: A, help: &'parser str)
- -> &'x mut Ref<'parser, 'refer, T>
- {
- let act = action.bind(self.cell.clone());
- let opt = Rc::new(GenericArgument {
- id: self.parser.arguments.len(),
- varid: self.varid,
- name: name,
- help: help,
- action: act,
- });
- match opt.action {
- Flag(_) => panic!("Flag arguments can't be positional"),
- Many(_) | Push(_) => {
- match self.parser.catchall_argument {
- Some(ref y) => panic!(format!(
- "Option {} conflicts with option {}",
- name, y.name)),
- None => {},
- }
- self.parser.catchall_argument = Some(opt);
- }
- Single(_) => {
- self.parser.arguments.push(opt);
- }
- }
- {
- let var = &mut self.parser.vars[self.varid];
- if var.metavar.len() == 0 {
- var.metavar = name.to_string();
- }
- }
- return self;
- }
-
- pub fn metavar<'x>(&'x mut self, name: &str)
- -> &'x mut Ref<'parser, 'refer, T>
- {
- {
- let var = &mut self.parser.vars[self.varid];
- var.metavar = name.to_string();
- }
- return self;
- }
-
- pub fn required<'x>(&'x mut self)
- -> &'x mut Ref<'parser, 'refer, T>
- {
- {
- let var = &mut self.parser.vars[self.varid];
- var.required = true;
- }
- return self;
- }
-}
-
-impl<'parser, 'refer, T: 'static + FromStr> Ref<'parser, 'refer, T> {
- pub fn envvar<'x>(&'x mut self, varname: &'parser str)
- -> &'x mut Ref<'parser, 'refer, T>
- {
- self.parser.env_vars.push(Rc::new(EnvVar {
- varid: self.varid,
- name: varname,
- action: Box::new(StoreAction { cell: self.cell.clone() }),
- }));
- return self;
- }
-}
-
-/// The main argument parser class
-pub struct ArgumentParser<'parser> {
- description: &'parser str,
- vars: Vec<Box<Var>>,
- options: Vec<Rc<GenericOption<'parser>>>,
- arguments: Vec<Rc<GenericArgument<'parser>>>,
- env_vars: Vec<Rc<EnvVar<'parser>>>,
- catchall_argument: Option<Rc<GenericArgument<'parser>>>,
- short_options: HashMap<char, Rc<GenericOption<'parser>>>,
- long_options: HashMap<String, Rc<GenericOption<'parser>>>,
- stop_on_first_argument: bool,
- silence_double_dash: bool,
-}
-
-
-
-impl<'parser> ArgumentParser<'parser> {
-
- /// Create an empty argument parser
- pub fn new() -> ArgumentParser<'parser> {
-
- let mut ap = ArgumentParser {
- description: "",
- vars: Vec::new(),
- env_vars: Vec::new(),
- arguments: Vec::new(),
- catchall_argument: None,
- options: Vec::new(),
- short_options: HashMap::new(),
- long_options: HashMap::new(),
- stop_on_first_argument: false,
- silence_double_dash: true,
- };
- ap.add_option_for(None, &["-h", "--help"], Flag(Box::new(HelpAction)),
- "Show this help message and exit");
- return ap;
- }
-
- /// Borrow mutable variable for an argument
- ///
- /// This returns `Ref` object which should be used configure the option
- pub fn refer<'x, T>(&'x mut self, val: &'parser mut T)
- -> Box<Ref<'parser, 'x, T>>
- {
- let cell = Rc::new(RefCell::new(val));
- let id = self.vars.len();
- self.vars.push(Box::new(Var {
- id: id,
- required: false,
- metavar: "".to_string(),
- }));
- return Box::new(Ref {
- cell: cell.clone(),
- varid: id,
- parser: self,
- });
- }
-
- /// Add option to argument parser
- ///
- /// This is only useful for options that don't store value. For
- /// example `Print(...)`
- pub fn add_option<F:IFlagAction + 'parser>(&mut self,
- names: &[&'parser str], action: F, help: &'parser str)
- {
- self.add_option_for(None, names, Flag(Box::new(action)), help);
- }
-
- /// Set description of the command
- pub fn set_description(&mut self, descr: &'parser str) {
- self.description = descr;
- }
-
- fn add_option_for(&mut self, var: Option<usize>,
- names: &[&'parser str],
- action: Action<'parser>, help: &'parser str)
- {
- let opt = Rc::new(GenericOption {
- id: self.options.len(),
- varid: var,
- names: names.to_vec(),
- help: help,
- action: action,
- });
-
- if names.len() < 1 {
- panic!("At least one name for option must be specified");
- }
- for nameptr in names.iter() {
- let name = *nameptr;
- match ArgumentKind::check(name) {
- Positional|Delimiter => {
- panic!("Bad argument name {}", name);
- }
- LongOption => {
- self.long_options.insert(
- name.to_string(), opt.clone());
- }
- ShortOption => {
- if name.len() > 2 {
- panic!("Bad short argument {}", name);
- }
- self.short_options.insert(
- name.as_bytes()[1] as char, opt.clone());
- }
- }
- }
- self.options.push(opt);
- }
-
- /// Print help
- ///
- /// Usually command-line option is used for printing help,
- /// this is here for any awkward cases
- pub fn print_help(&self, name: &str, writer: &mut Write) -> IoResult<()> {
- return HelpFormatter::print_help(self, name, writer);
- }
-
- /// Print usage
- ///
- /// Usually printed into stderr on error of command-line parsing
- pub fn print_usage(&self, name: &str, writer: &mut Write) -> IoResult<()>
- {
- return HelpFormatter::print_usage(self, name, writer);
- }
-
- /// Parse arguments
- ///
- /// This is most powerful method. Usually you need `parse_args`
- /// or `parse_args_or_exit` instead
- pub fn parse(&self, args: Vec<String>,
- stdout: &mut Write, stderr: &mut Write)
- -> Result<(), i32>
- {
- let name = if args.len() > 0 { &args[0][..] } else { "unknown" };
- match Context::parse(self, &args, stderr) {
- Parsed => return Ok(()),
- Exit => return Err(0),
- Help => {
- self.print_help(name, stdout).unwrap();
- return Err(0);
- }
- Error(message) => {
- self.error(&name[..], &message[..], stderr);
- return Err(2);
- }
- }
- }
-
- /// Write an error similar to one produced by the library itself
- ///
- /// Only needed if you like to do some argument validation that is out
- /// of scope of the argparse
- pub fn error(&self, command: &str, message: &str, writer: &mut Write) {
- self.print_usage(command, writer).unwrap();
- write!(writer, "{}: {}\n", command, message).ok();
- }
-
- /// Configure parser to ignore options when first non-option argument is
- /// encountered.
- ///
- /// Useful for commands that want to pass following options to the
- /// subcommand or subprocess, but need some options to be set before
- /// command is specified.
- pub fn stop_on_first_argument(&mut self, want_stop: bool) {
- self.stop_on_first_argument = want_stop;
- }
-
- /// Do not put double-dash (bare `--`) into argument
- ///
- /// The double-dash is used to stop parsing options and treat all the
- /// following tokens as the arguments regardless of whether they start
- /// with dash (minus) or not.
- ///
- /// The method only useful for `List` arguments. On by default. The method
- /// allows to set option to `false` so that `cmd xx -- yy` will get
- /// ``xx -- yy`` as arguments instead of ``xx yy`` by default. This is
- /// useful if your ``--`` argument is meaningful. Only first double-dash
- /// is ignored by default.
- pub fn silence_double_dash(&mut self, silence: bool) {
- self.silence_double_dash = silence;
- }
-
- /// Convenience method to parse arguments
- ///
- /// On error returns error code that is supposed to be returned by
- /// an application. (i.e. zero on `--help` and `2` on argument error)
- pub fn parse_args(&self) -> Result<(), i32> {
- // TODO(tailhook) can we get rid of collect?
- return self.parse(env::args().collect(),
- &mut stdout(), &mut stderr());
- }
-
- /// The simplest conveninece method
- ///
- /// The method returns only in case of successful parsing or exits with
- /// appropriate code (including successful on `--help`) otherwise.
- pub fn parse_args_or_exit(&self) {
- // TODO(tailhook) can we get rid of collect?
- self.parse(env::args().collect(), &mut stdout(), &mut stderr())
- .map_err(|c| exit(c))
- .ok();
- }
-}
-
-struct HelpFormatter<'a, 'b: 'a> {
- name: &'a str,
- parser: &'a ArgumentParser<'b>,
- buf: &'a mut (Write + 'a),
-}
-
-impl<'a, 'b> HelpFormatter<'a, 'b> {
- pub fn print_usage(parser: &ArgumentParser, name: &str, writer: &mut Write)
- -> IoResult<()>
- {
- return HelpFormatter { parser: parser, name: name, buf: writer }
- .write_usage();
- }
-
- pub fn print_help(parser: &ArgumentParser, name: &str, writer: &mut Write)
- -> IoResult<()>
- {
- return HelpFormatter { parser: parser, name: name, buf: writer }
- .write_help();
- }
-
- pub fn print_argument(&mut self, arg: &GenericArgument<'b>)
- -> IoResult<()>
- {
- let mut num = 2;
- try!(write!(self.buf, " {}", arg.name));
- num += arg.name.len();
- if num >= OPTION_WIDTH {
- try!(write!(self.buf, "\n"));
- for _ in 0..OPTION_WIDTH {
- try!(write!(self.buf, " "));
- }
- } else {
- for _ in num..OPTION_WIDTH {
- try!(write!(self.buf, " "));
- }
- }
- try!(wrap_text(self.buf, arg.help, TOTAL_WIDTH, OPTION_WIDTH));
- try!(write!(self.buf, "\n"));
- return Ok(());
- }
-
- pub fn print_option(&mut self, opt: &GenericOption<'b>) -> IoResult<()> {
- let mut num = 2;
- try!(write!(self.buf, " "));
- let mut niter = opt.names.iter();
- let name = niter.next().unwrap();
- try!(write!(self.buf, "{}", name));
- num += name.len();
- for name in niter {
- try!(write!(self.buf, ","));
- try!(write!(self.buf, "{}", name));
- num += name.len() + 1;
- }
- match opt.action {
- Flag(_) => {}
- Single(_) | Push(_) | Many(_) => {
- try!(write!(self.buf, " "));
- let var = &self.parser.vars[opt.varid.unwrap()];
- try!(write!(self.buf, "{}", &var.metavar[..]));
- num += var.metavar.len() + 1;
- }
- }
- if num >= OPTION_WIDTH {
- try!(write!(self.buf, "\n"));
- for _ in 0..OPTION_WIDTH {
- try!(write!(self.buf, " "));
- }
- } else {
- for _ in num..OPTION_WIDTH {
- try!(write!(self.buf, " "));
- }
- }
- try!(wrap_text(self.buf, opt.help, TOTAL_WIDTH, OPTION_WIDTH));
- try!(write!(self.buf, "\n"));
- return Ok(());
- }
-
- fn write_help(&mut self) -> IoResult<()> {
- try!(self.write_usage());
- try!(write!(self.buf, "\n"));
- if self.parser.description.len() > 0 {
- try!(wrap_text(self.buf, self.parser.description,TOTAL_WIDTH, 0));
- try!(write!(self.buf, "\n"));
- }
- if self.parser.arguments.len() > 0
- || self.parser.catchall_argument.is_some()
- {
- try!(write!(self.buf, "\nPositional arguments:\n"));
- for arg in self.parser.arguments.iter() {
- try!(self.print_argument(&**arg));
- }
- match self.parser.catchall_argument {
- Some(ref opt) => {
- try!(self.print_argument(&**opt));
- }
- None => {}
- }
- }
- if self.parser.short_options.len() > 0
- || self.parser.long_options.len() > 0
- {
- try!(write!(self.buf, "\nOptional arguments:\n"));
- for opt in self.parser.options.iter() {
- try!(self.print_option(&**opt));
- }
- }
- return Ok(());
- }
-
- fn write_usage(&mut self) -> IoResult<()> {
- try!(write!(self.buf, "Usage:\n "));
- try!(write!(self.buf, "{}", self.name));
- if self.parser.options.len() != 0 {
- if self.parser.short_options.len() > 1
- || self.parser.long_options.len() > 1
- {
- try!(write!(self.buf, " [OPTIONS]"));
- }
- for opt in self.parser.arguments.iter() {
- let var = &self.parser.vars[opt.varid];
- try!(write!(self.buf, " "));
- if !var.required {
- try!(write!(self.buf, "["));
- }
- try!(write!(self.buf, "{}",
- &opt.name.to_ascii_uppercase()[..]));
- if !var.required {
- try!(write!(self.buf, "]"));
- }
- }
- match self.parser.catchall_argument {
- Some(ref opt) => {
- let var = &self.parser.vars[opt.varid];
- try!(write!(self.buf, " "));
- if !var.required {
- try!(write!(self.buf, "["));
- }
- try!(write!(self.buf, "{}",
- &opt.name.to_ascii_uppercase()[..]));
- if !var.required {
- try!(write!(self.buf, " ...]"));
- } else {
- try!(write!(self.buf, " [...]"));
- }
- }
- None => {}
- }
- }
- try!(write!(self.buf, "\n"));
- return Ok(());
- }
-
-}
diff --git a/argparse/src/print.rs b/argparse/src/print.rs
deleted file mode 100644
index d0335c5..0000000
--- a/argparse/src/print.rs
+++ /dev/null
@@ -1,13 +0,0 @@
-use Print;
-use action::{IFlagAction, ParseResult};
-
-impl IFlagAction for Print {
- fn parse_flag(&self) -> ParseResult {
- if self.0.ends_with("\n") {
- print!("{}", self.0);
- } else {
- println!("{}", self.0);
- }
- return ParseResult::Exit;
- }
-}
diff --git a/argparse/src/test_bool.rs b/argparse/src/test_bool.rs
deleted file mode 100644
index a30cf3c..0000000
--- a/argparse/src/test_bool.rs
+++ /dev/null
@@ -1,98 +0,0 @@
-use parser::ArgumentParser;
-use super::Store;
-use super::{StoreTrue, StoreFalse};
-use test_parser::{check_ok};
-
-fn store_true(args: &[&str]) -> bool {
- let mut verbose = false;
- {
- let mut ap = ArgumentParser::new();
- ap.refer(&mut verbose)
- .add_option(&["-t", "--true"], StoreTrue,
- "Store true action");
- check_ok(&ap, args);
- }
- return verbose;
-}
-
-#[test]
-fn test_store_true() {
- assert!(!store_true(&["./argparse_test"]));
- assert!(store_true(&["./argparse_test", "--true"]));
-}
-
-fn store_false(args: &[&str]) -> bool {
- let mut verbose = true;
- {
- let mut ap = ArgumentParser::new();
- ap.refer(&mut verbose)
- .add_option(&["-f", "--false"], StoreFalse,
- "Store false action");
- check_ok(&ap, args);
- }
- return verbose;
-}
-#[test]
-fn test_store_false() {
- assert!(store_false(&["./argparse_test"]));
- assert!(!store_false(&["./argparse_test", "--false"]));
-}
-
-fn store_bool(args: &[&str]) -> bool {
- let mut verbose = false;
- {
- let mut ap = ArgumentParser::new();
- ap.refer(&mut verbose)
- .add_option(&["-f", "--false"], StoreFalse,
- "Store false action")
- .add_option(&["-t", "--true"], StoreTrue,
- "Store false action");
- check_ok(&ap, args);
- }
- return verbose;
-}
-
-#[test]
-fn test_bool() {
- assert!(!store_bool(&["./argparse_test"]));
- assert!(store_bool(&["./argparse_test", "-t"]));
- assert!(!store_bool(&["./argparse_test", "-f"]));
- assert!(store_bool(&["./argparse_test", "-fft"]));
- assert!(!store_bool(&["./argparse_test", "-fffft", "-f"]));
- assert!(store_bool(&["./argparse_test", "--false", "-fffft", "-f",
- "--true"]));
-}
-
-fn set_bool(args: &[&str]) -> bool {
- let mut verbose = false;
- {
- let mut ap = ArgumentParser::new();
- ap.refer(&mut verbose)
- .add_option(&["-s", "--set"], Store,
- "Set boolean value");
- check_ok(&ap, args);
- }
- return verbose;
-}
-
-
-#[test]
-fn test_set_bool() {
- assert!(!set_bool(&["./argparse_test"]));
- assert!(set_bool(&["./argparse_test", "-strue"]));
- assert!(!set_bool(&["./argparse_test", "-sfalse"]));
-
- // Unfortunately other values do not work
-}
-
-#[test]
-#[should_panic(expected="Bad value yes")]
-fn test_bad_bools1() {
- assert!(!set_bool(&["./argparse_test", "-syes"]));
-}
-
-#[test]
-#[should_panic(expected="Bad value no")]
-fn test_bad_bools2() {
- assert!(!set_bool(&["./argparse_test", "-sno"]));
-}
diff --git a/argparse/src/test_const.rs b/argparse/src/test_const.rs
deleted file mode 100644
index b12e3d8..0000000
--- a/argparse/src/test_const.rs
+++ /dev/null
@@ -1,28 +0,0 @@
-use parser::ArgumentParser;
-use super::{PushConst};
-use test_parser::{check_ok};
-
-
-fn push_const(args: &[&str]) -> Vec<u32> {
- let mut res = vec!();
- {
- let mut ap = ArgumentParser::new();
- ap.refer(&mut res)
- .add_option(&["-o", "--one"], PushConst(1),
- "Add one to the list")
- .add_option(&["-t", "--two"], PushConst(2),
- "Add two to the list")
- .add_option(&["-3", "--three"], PushConst(3),
- "Add three to the list");
- check_ok(&ap, args);
- }
- return res;
-}
-
-#[test]
-fn test_push() {
- assert_eq!(push_const(&["./argparse_test"]), vec!());
- assert_eq!(push_const(&["./argparse_test", "--one"]), vec!(1));
- assert_eq!(push_const(&["./argparse_test", "-3"]), vec!(3));
- assert_eq!(push_const(&["./argparse_test", "-oo3tt"]), vec!(1, 1, 3, 2, 2));
-}
diff --git a/argparse/src/test_enum.rs b/argparse/src/test_enum.rs
deleted file mode 100644
index 5205738..0000000
--- a/argparse/src/test_enum.rs
+++ /dev/null
@@ -1,51 +0,0 @@
-use std::str::FromStr;
-
-use parser::ArgumentParser;
-use super::Store;
-use test_parser::{check_ok};
-
-use self::Greeting::{Hello, Hi, NoGreeting};
-
-
-#[derive(PartialEq, Eq, Debug)]
-enum Greeting {
- Hello,
- Hi,
- NoGreeting,
-}
-
-impl FromStr for Greeting {
- type Err = ();
- fn from_str(src: &str) -> Result<Greeting, ()> {
- return match src {
- "hello" => Ok(Hello),
- "hi" => Ok(Hi),
- _ => Err(()),
- };
- }
-}
-
-fn parse_enum(args: &[&str]) -> Greeting {
- let mut val = NoGreeting;
- {
- let mut ap = ArgumentParser::new();
- ap.refer(&mut val)
- .add_option(&["-g"], Store,
- "Greeting");
- check_ok(&ap, args);
- }
- return val;
-}
-
-#[test]
-fn test_parse_enum() {
- assert_eq!(parse_enum(&["./argparse_test"]), NoGreeting);
- assert_eq!(parse_enum(&["./argparse_test", "-ghello"]), Hello);
- assert_eq!(parse_enum(&["./argparse_test", "-ghi"]), Hi);
-}
-
-#[test]
-#[should_panic]
-fn test_parse_error() {
- parse_enum(&["./argparse_test", "-ghell"]);
-}
diff --git a/argparse/src/test_env.rs b/argparse/src/test_env.rs
deleted file mode 100644
index 2e1b649..0000000
--- a/argparse/src/test_env.rs
+++ /dev/null
@@ -1,43 +0,0 @@
-use std::env;
-
-use parser::ArgumentParser;
-use super::Store;
-use test_parser::{check_ok};
-
-
-fn required(args: &[&str]) -> (isize, isize) {
- let mut val1 = 1isize;
- let mut val2 = 2isize;
- {
- let mut ap = ArgumentParser::new();
- ap.refer(&mut val1)
- .add_option(&["--v1"], Store, "The value 1")
- .add_argument("v1", Store, "The value 1")
- .envvar("TEST_ENV_REQUIRED_V1")
- .required();
- ap.refer(&mut val2)
- .add_argument("v2", Store, "The value 2");
- check_ok(&ap, args);
- }
- return (val1, val2)
-}
-
-#[test]
-#[should_panic]
-fn test_required() {
- env::set_var("TEST_ENV_REQUIRED_V1", "some_crap");
- required(&["./argparse_test"]);
- env::remove_var("TEST_ENV_REQUIRED_V1");
-}
-
-#[test]
-fn test_req() {
- env::set_var("TEST_ENV_REQUIRED_V1", "some_crap");
- assert_eq!(required(&["./argparse_test", "10"]), (10, 2));
- assert_eq!(required(&["./argparse_test", "11", "21"]), (11, 21));
- assert_eq!(required(&["./argparse_test", "--v1=7"]), (7, 2));
- env::set_var("TEST_ENV_REQUIRED_V1", "9");
- assert_eq!(required(&["./argparse_test", "10"]), (9, 10));
- assert_eq!(required(&["./argparse_test", "7", "--v1=15"]), (15, 7));
- env::remove_var("TEST_ENV_REQUIRED_V1");
-}
diff --git a/argparse/src/test_float.rs b/argparse/src/test_float.rs
deleted file mode 100644
index 9ef0f56..0000000
--- a/argparse/src/test_float.rs
+++ /dev/null
@@ -1,50 +0,0 @@
-use parser::ArgumentParser;
-use super::{IncrBy,DecrBy};
-use super::Store;
-use test_parser::{check_ok};
-
-fn incr_decr(args: &[&str]) -> f32 {
- let mut val = 0f32;
- {
- let mut ap = ArgumentParser::new();
- ap.refer(&mut val)
- .add_option(&["-d", "--decr"], DecrBy(0.25f32),
- "Decrement value")
- .add_option(&["-i", "--incr"], IncrBy(0.5f32),
- "Increment value");
- check_ok(&ap, args);
- }
- return val;
-}
-
-#[test]
-fn test_incr_decr() {
- assert_eq!(incr_decr(&["./argparse_test",
- "--incr", "-iii"]), 2.0);
- assert_eq!(incr_decr(&["./argparse_test",
- "-iiddd", "--incr", "-iii"]), 2.25);
-}
-
-#[test]
-fn test_float() {
- let mut val = 0.1;
- {
- let mut ap = ArgumentParser::new();
- ap.refer(&mut val)
- .add_option(&["-s", "--set"], Store,
- "Set float value");
- check_ok(&ap, &["./argparse_test", "-s", "15.125"]);
- }
- assert_eq!(val, 15.125);
-}
-
-#[test]
-#[should_panic]
-fn test_fail() {
- let mut val = 0.1;
- let mut ap = ArgumentParser::new();
- ap.refer(&mut val)
- .add_option(&["-s", "--set"], Store,
- "Set float value");
- check_ok(&ap, &["./argparse_test", "-s", "test"]);
-}
diff --git a/argparse/src/test_help.rs b/argparse/src/test_help.rs
deleted file mode 100644
index f23b14b..0000000
--- a/argparse/src/test_help.rs
+++ /dev/null
@@ -1,154 +0,0 @@
-use std::str::from_utf8;
-
-use parser::ArgumentParser;
-use super::{Store, List};
-
-#[test]
-fn test_empty() {
- let mut ap = ArgumentParser::new();
- let mut buf = Vec::<u8>::new();
- ap.set_description("Test program");
- assert!(ap.print_help("./argparse_test", &mut buf).is_ok());
- assert_eq!("Usage:\n".to_string()
- + " ./argparse_test\n"
- + "\n"
- + "Test program\n"
- + "\n"
- + "Optional arguments:\n"
- + " -h,--help Show this help message and exit\n"
- , from_utf8(&buf[..]).unwrap().to_string());
-}
-
-#[test]
-fn test_options() {
- let mut val = 0;
- let mut val2 = 0;
- let mut ap = ArgumentParser::new();
- ap.set_description("Test program. The description of the program is ought
- to be very long, because we want to test how word wrapping works for
- it. So some more text would be ok for the test");
- ap.refer(&mut val)
- .add_option(&["--value"], Store,
- "Set integer value");
- ap.refer(&mut val2)
- .add_option(&["-L", "--long-option"], Store,
- "Long option value");
- let mut buf = Vec::<u8>::new();
- assert!(ap.print_help("./argparse_test", &mut buf).is_ok());
- assert_eq!("Usage:\n".to_string()
- + " ./argparse_test [OPTIONS]
-
-Test program. The description of the program is ought to be very long, because
-we want to test how word wrapping works for it. So some more text would be ok
-for the test\n"
- + "\n"
- + "Optional arguments:\n"
- + " -h,--help Show this help message and exit\n"
- + " --value VALUE Set integer value\n"
- + " -L,--long-option LONG_OPTION\n"
- + " Long option value\n"
- , from_utf8(&buf[..]).unwrap().to_string());
-}
-
-#[test]
-fn test_argument() {
- let mut val = 0;
- let mut ap = ArgumentParser::new();
- ap.set_description("Test program");
- ap.refer(&mut val)
- .add_argument("value", Store,
- "Integer value");
- let mut buf = Vec::<u8>::new();
- assert!(ap.print_help("./argparse_test", &mut buf).is_ok());
- assert_eq!("Usage:\n".to_string()
- + " ./argparse_test [VALUE]\n"
- + "\n"
- + "Test program\n"
- + "\n"
- + "Positional arguments:\n"
- + " value Integer value\n"
- + "\n"
- + "Optional arguments:\n"
- + " -h,--help Show this help message and exit\n"
- , from_utf8(&buf[..]).unwrap().to_string());
-}
-
-#[test]
-fn test_arguments() {
- let mut v1 = 0;
- let mut v2 = Vec::<u32>::new();
- let mut ap = ArgumentParser::new();
- ap.set_description("Test program");
- ap.refer(&mut v1)
- .add_argument("v1", Store,
- "Integer value 1");
- ap.refer(&mut v2)
- .add_argument("v2", List,
- "More values");
- let mut buf = Vec::<u8>::new();
- assert!(ap.print_help("./argparse_test", &mut buf).is_ok());
- assert_eq!("Usage:\n".to_string()
- + " ./argparse_test [V1] [V2 ...]\n"
- + "\n"
- + "Test program\n"
- + "\n"
- + "Positional arguments:\n"
- + " v1 Integer value 1\n"
- + " v2 More values\n"
- + "\n"
- + "Optional arguments:\n"
- + " -h,--help Show this help message and exit\n"
- , from_utf8(&buf[..]).unwrap().to_string());
-}
-
-#[test]
-fn test_req_arguments() {
- let mut v1 = 0;
- let mut v2 = Vec::<u32>::new();
- let mut ap = ArgumentParser::new();
- ap.set_description("Test program");
- ap.refer(&mut v1)
- .add_argument("v1", Store,
- "Integer value 1")
- .required();
- ap.refer(&mut v2)
- .add_argument("v2", List,
- "More values")
- .required();
- let mut buf = Vec::<u8>::new();
- assert!(ap.print_help("./argparse_test", &mut buf).is_ok());
- assert_eq!("Usage:\n".to_string()
- + " ./argparse_test V1 V2 [...]\n"
- + "\n"
- + "Test program\n"
- + "\n"
- + "Positional arguments:\n"
- + " v1 Integer value 1\n"
- + " v2 More values\n"
- + "\n"
- + "Optional arguments:\n"
- + " -h,--help Show this help message and exit\n"
- , from_utf8(&buf[..]).unwrap().to_string());
-}
-
-#[test]
-fn test_metavar() {
- let mut val2 = 0;
- let mut ap = ArgumentParser::new();
- ap.set_description("Test program.");
- ap.refer(&mut val2)
- .add_option(&["-L", "--long-option"], Store,
- "Long option value")
- .metavar("VAL");
- let mut buf = Vec::<u8>::new();
- assert!(ap.print_help("./argparse_test", &mut buf).is_ok());
- assert_eq!("Usage:\n".to_string()
- + " ./argparse_test [OPTIONS]\n"
- + "\n"
- + "Test program.\n"
- + "\n"
- + "Optional arguments:\n"
- + " -h,--help Show this help message and exit\n"
- + " -L,--long-option VAL Long option value\n"
- , from_utf8(&buf[..]).unwrap().to_string());
-}
diff --git a/argparse/src/test_int.rs b/argparse/src/test_int.rs
deleted file mode 100644
index 1826eaf..0000000
--- a/argparse/src/test_int.rs
+++ /dev/null
@@ -1,107 +0,0 @@
-use parser::ArgumentParser;
-use super::{IncrBy,DecrBy};
-use super::Store;
-use test_parser::{check_ok};
-
-fn incr_int(args: &[&str]) -> usize {
- let mut val = 0;
- {
- let mut ap = ArgumentParser::new();
- ap.refer(&mut val)
- .add_option(&["-i", "--incr"], IncrBy(1usize),
- "Increment value");
- check_ok(&ap, args);
- }
- return val;
-}
-
-#[test]
-fn test_incr_int() {
- assert_eq!(incr_int(&["./argparse_test"]), 0);
- assert_eq!(incr_int(&["./argparse_test", "--incr"]), 1);
- assert_eq!(incr_int(&["./argparse_test", "-iiiii"]), 5);
-}
-
-fn decr_int(args: &[&str]) -> isize {
- let mut val = 5;
- {
- let mut ap = ArgumentParser::new();
- ap.refer(&mut val)
- .add_option(&["-d", "--decr"], DecrBy(1isize),
- "Decrement value");
- check_ok(&ap, args);
- }
- return val;
-}
-
-#[test]
-fn test_decr_int() {
- assert_eq!(decr_int(&["./argparse_test"]), 5);
- assert_eq!(decr_int(&["./argparse_test", "--decr"]), 4);
- assert_eq!(decr_int(&["./argparse_test", "-dddddd"]), -1);
-}
-
-#[test]
-fn test_incr_decr() {
- let mut val = 0;
- {
- let mut ap = ArgumentParser::new();
- ap.refer(&mut val)
- .add_option(&["-d", "--decr"], DecrBy(1isize),
- "Decrement value")
- .add_option(&["-i", "--incr"], IncrBy(1isize),
- "Increment value");
- check_ok(&ap, &["./argparse_test",
- "-iiddd", "--incr", "-iii"]);
- }
- assert_eq!(val, 3);
-}
-
-fn set_int(args: &[&str]) -> isize {
- let mut val = 0;
- {
- let mut ap = ArgumentParser::new();
- ap.refer(&mut val)
- .add_option(&["-s", "--set"], Store,
- "Set integer value");
- check_ok(&ap, args);
- }
- return val;
-}
-
-#[test]
-fn test_set_int() {
- assert_eq!(set_int(&["./argparse_test", "-s", "10"]), 10);
- assert_eq!(set_int(&["./argparse_test", "--set", "99"]), 99);
- assert_eq!(set_int(&["./argparse_test", "-s", "7", "-s77"]), 77);
- assert_eq!(set_int(&["./argparse_test", "-s333", "--set=123"]), 123);
-}
-
-#[test]
-#[should_panic(expected="Bad value 1.5")]
-fn test_set_int_bad() {
- set_int(&["./argparse_test", "-s1.5"]);
-}
-
-fn set_i16(args: &[&str]) -> i16 {
- let mut val = 0;
- {
- let mut ap = ArgumentParser::new();
- ap.refer(&mut val)
- .add_option(&["-s", "--set"], Store,
- "Set integer value");
- check_ok(&ap, args);
- }
- return val;
-}
-
-#[test]
-fn test_i16() {
- assert_eq!(set_i16(&["./argparse_test", "-s", "124"]), 124);
-}
-
-#[test]
-#[should_panic(expected="Bad value 1000000")]
-fn test_i16_big() {
- set_i16(&["./argparse_test", "-s", "1000000"]);
-}
diff --git a/argparse/src/test_many.rs b/argparse/src/test_many.rs
deleted file mode 100644
index 68e2cec..0000000
--- a/argparse/src/test_many.rs
+++ /dev/null
@@ -1,95 +0,0 @@
-use parser::ArgumentParser;
-use super::{List, Store, Collect};
-use test_parser::{check_ok};
-
-fn pos_list(args: &[&str]) -> (isize, Vec<isize>) {
- let mut val1 = 1;
- let mut val2 = Vec::new();
- {
- let mut ap = ArgumentParser::new();
- ap.refer(&mut val1).add_argument("v1", Store, "The value 1");
- ap.refer(&mut val2).add_argument("v2", List, "The list of vals");
- check_ok(&ap, args);
- }
- return (val1, val2);
-}
-
-#[test]
-fn test_pos_list() {
- assert_eq!(pos_list(&["./argparse_test", "10"]), (10, vec!()));
- assert_eq!(pos_list(&["./argparse_test", "11", "21"]), (11, vec!(21)));
- assert_eq!(pos_list(&["./argparse_test", "10", "20", "30"]),
- (10, vec!(20, 30)));
-}
-
-fn pos_collect(args: &[&str]) -> Vec<isize> {
- let mut lst = Vec::new();
- {
- let mut ap = ArgumentParser::new();
- ap.refer(&mut lst)
- .add_argument("v", Collect, "The list of vals");
- check_ok(&ap, args);
- }
- return lst;
-}
-
-#[test]
-fn test_pos_collect() {
- assert_eq!(pos_collect(&["./argparse_test", "10"]), vec!(10));
- assert_eq!(pos_collect(&["./argparse_test", "11", "21"]), vec!(11, 21));
- assert_eq!(pos_collect(&["./argparse_test", "10", "20", "30"]),
- vec!(10, 20, 30));
-}
-
-#[test]
-#[should_panic]
-fn wrong_type() {
- pos_collect(&["./argparse_test", "10", "20", "test"]);
-}
-
-fn collect(args: &[&str]) -> Vec<isize> {
- let mut lst = Vec::new();
- {
- let mut ap = ArgumentParser::new();
- ap.refer(&mut lst).add_option(&["-a", "--add"], Collect,
- "The list of vals");
- check_ok(&ap, args);
- }
- return lst;
-}
-
-#[test]
-fn test_collect() {
- assert_eq!(collect(&["./argparse_test", "-a10"]), vec!(10));
- assert_eq!(collect(&["./argparse_test", "--add=11", "-a", "21"]),
- vec!(11, 21));
- assert_eq!(collect(&["./argparse_test",
- "-a", "10", "--add=20", "--add", "30"]), vec!(10, 20, 30));
-}
-
-#[test]
-#[should_panic]
-fn test_extra() {
- collect(&["./argparse_test", "-a", "10", "20", "30"]);
-}
-
-fn list(args: &[&str]) -> Vec<isize> {
- let mut vec = Vec::new();
- {
- let mut ap = ArgumentParser::new();
- ap.refer(&mut vec).add_option(&["-a", "--add"], List,
- "The list of vals");
- check_ok(&ap, args);
- }
- return vec;
-}
-
-#[test]
-#[should_panic]
-fn test_list() {
- assert_eq!(list(&["./argparse_test", "-a10"]), vec!(10));
- assert_eq!(list(&["./argparse_test", "--add", "11", "21"]), vec!(11, 21));
- assert_eq!(list(&["./argparse_test", "-a", "10", "20", "30"]),
- vec!(10, 20, 30));
- assert_eq!(list(&["./argparse_test", "10", "20", "30"]), vec!(10, 20, 30));
-}
diff --git a/argparse/src/test_optional.rs b/argparse/src/test_optional.rs
deleted file mode 100644
index 5f4c35e..0000000
--- a/argparse/src/test_optional.rs
+++ /dev/null
@@ -1,54 +0,0 @@
-use parser::ArgumentParser;
-use super::StoreOption;
-use test_parser::{check_ok};
-
-fn opt(args: &[&str]) -> Option<isize> {
- let mut val = None;
- {
- let mut ap = ArgumentParser::new();
- ap.refer(&mut val)
- .add_option(&["-s", "--set"], StoreOption,
- "Set int value");
- check_ok(&ap, args);
- }
- return val;
-}
-
-#[test]
-fn test_opt() {
- assert_eq!(opt(&["./argparse_test"]), None);
- assert_eq!(opt(&["./argparse_test", "-s", "10"]), Some(10));
- assert_eq!(opt(&["./argparse_test", "--set", "11"]), Some(11));
-}
-
-#[test]
-#[should_panic]
-fn test_opt_no_arg() {
- opt(&["./argparse_test", "--set"]);
-}
-
-fn optstr(args: &[&str]) -> Option<String> {
- let mut val = None;
- {
- let mut ap = ArgumentParser::new();
- ap.refer(&mut val)
- .add_option(&["-s", "--set"], StoreOption,
- "Set string value");
- check_ok(&ap, args);
- }
- return val;
-}
-
-#[test]
-fn test_str() {
- assert_eq!(optstr(&["./argparse_test"]), None);
- assert_eq!(optstr(&["./argparse_test", "-s", "10"]), Some(10.to_string()));
- assert_eq!(optstr(&["./argparse_test", "--set", "11"]),
- Some(11.to_string()));
-}
-
-#[test]
-#[should_panic]
-fn test_str_no_art() {
- optstr(&["./argparse_test", "--set"]);
-}
diff --git a/argparse/src/test_parser.rs b/argparse/src/test_parser.rs
deleted file mode 100644
index f60aa64..0000000
--- a/argparse/src/test_parser.rs
+++ /dev/null
@@ -1,64 +0,0 @@
-
-use parser::ArgumentParser;
-
-pub fn check_ok(ap: &ArgumentParser, args: &[&str]) {
- let mut stdout = Vec::<u8>::new();
- let mut stderr = Vec::<u8>::new();
- let mut owned_args = Vec::new();
- for x in args.iter() {
- owned_args.push(x.to_string());
- }
- let res = ap.parse(owned_args, &mut stdout, &mut stderr);
- match res {
- Ok(()) => return,
- Err(x) => panic!(
- String::from_utf8(stderr).unwrap() +
- &format!("Expected ok, but found Exit({})", x)[..]),
- }
-}
-
-pub fn check_exit(ap: &ArgumentParser, args: &[&str]) {
- let mut stdout = Vec::<u8>::new();
- let mut stderr = Vec::<u8>::new();
- let mut owned_args = Vec::new();
- for x in args.iter() {
- owned_args.push(x.to_string());
- }
- let res = ap.parse(owned_args, &mut stdout, &mut stderr);
- match res {
- Err(0) => return,
- Err(x) => panic!(format!("Expected code {} got {}", 0usize, x)),
- Ok(()) => panic!(format!("Expected failure, got success")),
- }
-}
-
-pub fn check_err(ap: &ArgumentParser, args: &[&str]) {
- let mut stdout = Vec::<u8>::new();
- let mut stderr = Vec::<u8>::new();
- let mut owned_args = Vec::new();
- for x in args.iter() {
- owned_args.push(x.to_string());
- }
- let res = ap.parse(owned_args, &mut stdout, &mut stderr);
- match res {
- Err(2) => return,
- Err(x) => panic!(format!("Expected code {} got {}", 2usize, x)),
- Ok(()) => panic!(format!("Expected failure, got success")),
- }
-}
-
-#[test]
-fn test_no_arg() {
- let ap = ArgumentParser::new();
- check_ok(&ap, &["./argparse_test"]);
- check_err(&ap, &["./argparse_test", "a"]);
- check_err(&ap, &["./argparse_test", "-a"]);
- check_err(&ap, &["./argparse_test", "--an-option"]);
-}
-
-#[test]
-fn test_help() {
- let ap = ArgumentParser::new();
- check_ok(&ap, &["./argparse_test"]);
- check_exit(&ap, &["./argparse_test", "--help"]);
-}
diff --git a/argparse/src/test_path.rs b/argparse/src/test_path.rs
deleted file mode 100644
index 868ae8c..0000000
--- a/argparse/src/test_path.rs
+++ /dev/null
@@ -1,30 +0,0 @@
-use std::path::PathBuf;
-use parser::ArgumentParser;
-use super::Parse;
-use test_parser::{check_ok};
-
-fn parse_str(args: &[&str]) -> PathBuf {
- let mut val: PathBuf = From::from("");
- {
- let mut ap = ArgumentParser::new();
- ap.refer(&mut val)
- .add_option(&["-s", "--set"], Parse,
- "Set path value");
- check_ok(&ap, args);
- }
- return val;
-}
-
-#[test]
-fn test_path() {
- assert_eq!(parse_str(&["./argparse_test", "-s", "/hello"]),
- PathBuf::from("/hello"));
- assert_eq!(parse_str(&["./argparse_test", "--set", "a///b/../c"]),
- PathBuf::from("a/b/../c"));
-}
-
-#[test]
-#[should_panic]
-fn test_err() {
- parse_str(&["./argparse_test", "--set"]);
-}
diff --git a/argparse/src/test_pos.rs b/argparse/src/test_pos.rs
deleted file mode 100644
index 2542050..0000000
--- a/argparse/src/test_pos.rs
+++ /dev/null
@@ -1,196 +0,0 @@
-use parser::ArgumentParser;
-use super::{Store, List};
-use test_parser::{check_ok};
-
-fn parse_pos(args: &[&str]) -> isize {
- let mut val = 0;
- {
- let mut ap = ArgumentParser::new();
- ap.refer(&mut val)
- .add_argument("value", Store, "The value");
- check_ok(&ap, args);
- }
- return val;
-}
-
-
-#[test]
-fn test_argument() {
- assert_eq!(parse_pos(&["./argparse_test", "10"]), 10);
-}
-
-#[test]
-#[should_panic]
-fn too_much_args() {
- parse_pos(&["./argparse_test", "10", "20"]);
-}
-
-#[test]
-#[should_panic]
-fn wrong_value() {
- parse_pos(&["./argparse_test", "test", "20"]);
-}
-
-#[test]
-#[should_panic]
-fn float_value() {
- parse_pos(&["./argparse_test", "1.5"]);
-}
-
-fn parse_two(args: &[&str]) -> (isize, isize) {
- let mut val1 = 1;
- let mut val2 = 2;
- {
- let mut ap = ArgumentParser::new();
- ap.refer(&mut val1)
- .add_argument("v1", Store, "The value 1");
- ap.refer(&mut val2)
- .add_argument("v2", Store, "The value 2");
- check_ok(&ap, args);
- }
- return (val1, val2);
-}
-
-#[test]
-fn test_two() {
- assert_eq!(parse_two(&["./argparse_test", "10"]), (10, 2));
- assert_eq!(parse_two(&["./argparse_test", "11", "21"]), (11, 21));
-}
-
-#[test]
-#[should_panic]
-fn test_two_fail_many() {
- parse_two(&["./argparse_test", "10", "20", "30"]);
-}
-
-#[test]
-#[should_panic]
-fn test_two_fail_value() {
- parse_two(&["./argparse_test", "test", "20"]);
-}
-
-#[test]
-#[should_panic]
-fn test_two_fail_float() {
- parse_two(&["./argparse_test", "1.5"]);
-}
-
-fn parse_pos_opt(args: &[&str]) -> (isize, isize) {
- let mut val1 = 1;
- let mut val2 = 2;
- {
- let mut ap = ArgumentParser::new();
- ap.refer(&mut val1)
- .add_option(&["--v1"], Store, "The value 1")
- .add_argument("v1", Store, "The value 1");
- ap.refer(&mut val2)
- .add_argument("v2", Store, "The value 2");
- check_ok(&ap, args);
- }
- return (val1, val2);
-}
-
-#[test]
-fn test_positional_optional() {
- assert_eq!(parse_pos_opt(&["./argparse_test", "10"]), (10, 2));
- assert_eq!(parse_pos_opt(&["./argparse_test", "11", "21"]), (11, 21));
- assert_eq!(parse_pos_opt(&["./argparse_test", "--v1=7", "8"]), (7, 8));
- assert_eq!(parse_pos_opt(&["./argparse_test", "10", "--v1=9"]), (9, 10));
-}
-
-#[test]
-#[should_panic]
-fn test_pos_opt_err() {
- parse_pos_opt(&["./argparse_test", "--v1=10", "20", "30"]);
-}
-
-fn parse_pos_req(args: &[&str]) -> (isize, isize) {
- let mut val1 = 1;
- let mut val2 = 2;
- {
- let mut ap = ArgumentParser::new();
- ap.refer(&mut val1)
- .add_option(&["--v1"], Store, "The value 1")
- .add_argument("v1", Store, "The value 1")
- .required();
- ap.refer(&mut val2)
- .add_argument("v2", Store, "The value 2");
- check_ok(&ap, args);
- }
- return (val1, val2);
-}
-
-#[test]
-fn test_positional_required() {
- assert_eq!(parse_pos_req(&["./argparse_test", "10"]), (10, 2));
- assert_eq!(parse_pos_req(&["./argparse_test", "11", "21"]), (11, 21));
- assert_eq!(parse_pos_req(&["./argparse_test", "--v1=7"]), (7, 2));
- assert_eq!(parse_pos_req(&["./argparse_test", "10", "--v1=9"]), (9, 10));
-}
-
-#[test]
-#[should_panic]
-fn test_pos_extra() {
- parse_pos_req(&["./argparse_test", "--v1=10", "20", "30"]);
-}
-
-#[test]
-#[should_panic]
-fn test_pos_no_req() {
- parse_pos_req(&["./argparse_test"]);
-}
-
-fn pos_stop(args: &[&str]) -> (isize, Vec<String>) {
- let mut val1 = 1;
- let mut val2 = Vec::new();
- {
- let mut ap = ArgumentParser::new();
- ap.refer(&mut val1)
- .add_option(&["--v1"], Store, "The value 1")
- .add_argument("v1", Store, "The value 1")
- .required();
- ap.refer(&mut val2)
- .add_argument("v2", List, "The value 2");
- ap.stop_on_first_argument(true);
- check_ok(&ap, args);
- }
- return (val1, val2);
-}
-
-#[test]
-fn test_pos_stop() {
- assert_eq!(pos_stop(&["./argparse_test", "10"]), (10, vec!()));
- assert_eq!(pos_stop(&["./argparse_test", "11", "21"]),
- (11, vec!("21".to_string())));
- assert_eq!(pos_stop(&["./argparse_test", "--v1=7"]), (7, vec!()));
- assert_eq!(pos_stop(&["./argparse_test", "10", "--v1=9", "--whatever"]),
- (10, vec!("--v1=9".to_string(), "--whatever".to_string())));
-}
-
-#[test]
-#[should_panic]
-fn test_test() {
- pos_stop(&["./argparse_test"]);
-}
-
-fn pos_dash(args: &[&str], dash: bool) -> Vec<String> {
- let mut val = Vec::new();
- {
- let mut ap = ArgumentParser::new();
- ap.refer(&mut val)
- .add_argument("v1", List, "The value");
- ap.silence_double_dash(dash);
- check_ok(&ap, args);
- }
- return val;
-}
-
-#[test]
-fn test_pos_dash() {
- assert_eq!(pos_dash(&["./argparse_test", "1"], true),
- vec!("1".to_string()));
- assert_eq!(pos_dash(&["./argparse_test", "--", "1"], true),
- vec!("1".to_string()));
- assert_eq!(pos_dash(&["./argparse_test", "--", "1"], false),
- vec!("--".to_string(), "1".to_string()));
-}
diff --git a/argparse/src/test_str.rs b/argparse/src/test_str.rs
deleted file mode 100644
index 42db286..0000000
--- a/argparse/src/test_str.rs
+++ /dev/null
@@ -1,28 +0,0 @@
-use parser::ArgumentParser;
-use super::Store;
-use test_parser::{check_ok};
-
-fn parse_str(args: &[&str]) -> String {
- let mut val: String = "".to_string();
- {
- let mut ap = ArgumentParser::new();
- ap.refer(&mut val)
- .add_option(&["-s", "--set"], Store,
- "Set string value");
- check_ok(&ap, args);
- }
- return val;
-}
-
-#[test]
-fn test_str() {
- assert_eq!(parse_str(&["./argparse_test", "-s", "10"]), "10".to_string());
- assert_eq!(parse_str(&["./argparse_test", "--set", "value"]),
- "value".to_string());
-}
-
-#[test]
-#[should_panic]
-fn test_err() {
- parse_str(&["./argparse_test", "--set"]);
-}
diff --git a/argparse/src/test_usage.rs b/argparse/src/test_usage.rs
deleted file mode 100644
index efe89fe..0000000
--- a/argparse/src/test_usage.rs
+++ /dev/null
@@ -1,57 +0,0 @@
-use std::str::from_utf8;
-
-use parser::ArgumentParser;
-use super::{Store, List};
-
-#[test]
-fn test_empty() {
- let ap = ArgumentParser::new();
- let mut buf = Vec::<u8>::new();
- assert!(ap.print_usage("./argparse_test", &mut buf).is_ok());
- assert_eq!("Usage:\n ./argparse_test\n", from_utf8(&buf[..]).unwrap());
-}
-
-#[test]
-fn test_options() {
- let mut val = 0;
- let mut buf = Vec::<u8>::new();
- {
- let mut ap = ArgumentParser::new();
- ap.refer(&mut val)
- .add_option(&["--value"], Store,
- "Set integer value");
- assert!(ap.print_usage("./argparse_test", &mut buf).is_ok());
- }
- assert_eq!("Usage:\n ./argparse_test [OPTIONS]\n",
- from_utf8(&buf[..]).unwrap());
-}
-
-#[test]
-fn test_argument() {
- let mut val = 0;
- let mut ap = ArgumentParser::new();
- ap.refer(&mut val)
- .add_argument("value", Store,
- "Integer value");
- let mut buf = Vec::<u8>::new();
- assert!(ap.print_usage("./argparse_test", &mut buf).is_ok());
- assert_eq!("Usage:\n ./argparse_test [VALUE]\n",
- from_utf8(&buf[..]).unwrap());
-}
-
-#[test]
-fn test_arguments() {
- let mut v1 = 0;
- let mut v2 = Vec::<u32>::new();
- let mut ap = ArgumentParser::new();
- ap.refer(&mut v1)
- .add_argument("v1", Store,
- "Integer value 1");
- ap.refer(&mut v2)
- .add_argument("v2", List,
- "More values");
- let mut buf = Vec::<u8>::new();
- assert!(ap.print_usage("./argparse_test", &mut buf).is_ok());
- assert_eq!("Usage:\n ./argparse_test [V1] [V2 ...]\n",
- from_utf8(&buf[..]).unwrap());
-}
diff --git a/argparse/vagga.yaml b/argparse/vagga.yaml
deleted file mode 100644
index c6e0c52..0000000
--- a/argparse/vagga.yaml
+++ /dev/null
@@ -1,59 +0,0 @@
-containers:
-
- build:
- setup:
- - !Ubuntu bionic
- - !Install [build-essential, ca-certificates, vim]
- - !TarInstall
- url: https://static.rust-lang.org/dist/rust-1.28.0-x86_64-unknown-linux-gnu.tar.gz
- # We install rustc and cargo, but skip rust-docs
- script: "./install.sh --prefix=/usr \
- --components=rustc,rust-std-x86_64-unknown-linux-gnu,cargo"
- - &bulk !Tar
- url: "https://github.com/tailhook/bulk/releases/download/v0.4.12/bulk-v0.4.12.tar.gz"
- sha256: 7deeb4895b3909afea46194ef01bafdeb30ff89fc4a7b6497172ba117734040e
- path: /
- environ:
- HOME: /work/run
- volumes:
- /tmp: !Tmpfs { size: 100Mi }
-
-
-commands:
-
- make: !Command
- description: Build the library
- container: build
- run: [cargo, build]
-
- test: !Command
- description: Run the tests
- container: build
- run: [cargo, test]
-
- cargo: !Command
- container: build
- run: [cargo]
-
- example-greeting: !Command
- description: Build and run "greeting" example
- container: build
- accepts-arguments: true
- run: [cargo, run, --example, greeting, "--"]
-
- example-structure: !Command
- description: Build and run "structure" example
- container: build
- accepts-arguments: true
- run: [cargo, run, --example, structure, "--"]
-
- example-subcommands: !Command
- description: Build and run "subcommands" example
- container: build
- accepts-arguments: true
- run: [cargo, run, --example, subcommands, "--"]
-
- _bulk: !Command
- description: Run `bulk` command (for version bookkeeping)
- container: build
- run: [bulk]
diff --git a/base32/.gitignore b/base32/.gitignore
deleted file mode 100644
index fa8d85a..0000000
--- a/base32/.gitignore
+++ /dev/null
@@ -1,2 +0,0 @@
-Cargo.lock
-target
diff --git a/base32/.travis.yml b/base32/.travis.yml
deleted file mode 100644
index 22761ba..0000000
--- a/base32/.travis.yml
+++ /dev/null
@@ -1 +0,0 @@
-language: rust
diff --git a/base32/Cargo.toml b/base32/Cargo.toml
deleted file mode 100644
index ff63bbe..0000000
--- a/base32/Cargo.toml
+++ /dev/null
@@ -1,16 +0,0 @@
-[package]
-
-name = "base32"
-version = "0.4.0"
-authors = [ "Andreas Ots <qrpth@qrpth.eu>", "Tim Dumol <tim@timdumol.com>" ]
-license = "MIT OR Apache-2.0"
-repository = "https://github.com/andreasots/base32"
-description = "Base32 encoder/decoder for Rust"
-
-[lib]
-
-name = "base32"
-
-[dev-dependencies]
-quickcheck = "0.7.1"
-rand = "0.5.5"
diff --git a/base32/LICENSE-APACHE b/base32/LICENSE-APACHE
deleted file mode 100644
index 8f71f43..0000000
--- a/base32/LICENSE-APACHE
+++ /dev/null
@@ -1,202 +0,0 @@
- Apache License
- Version 2.0, January 2004
- http://www.apache.org/licenses/
-
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
- 1. Definitions.
-
- "License" shall mean the terms and conditions for use, reproduction,
- and distribution as defined by Sections 1 through 9 of this document.
-
- "Licensor" shall mean the copyright owner or entity authorized by
- the copyright owner that is granting the License.
-
- "Legal Entity" shall mean the union of the acting entity and all
- other entities that control, are controlled by, or are under common
- control with that entity. For the purposes of this definition,
- "control" means (i) the power, direct or indirect, to cause the
- direction or management of such entity, whether by contract or
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
- outstanding shares, or (iii) beneficial ownership of such entity.
-
- "You" (or "Your") shall mean an individual or Legal Entity
- exercising permissions granted by this License.
-
- "Source" form shall mean the preferred form for making modifications,
- including but not limited to software source code, documentation
- source, and configuration files.
-
- "Object" form shall mean any form resulting from mechanical
- transformation or translation of a Source form, including but
- not limited to compiled object code, generated documentation,
- and conversions to other media types.
-
- "Work" shall mean the work of authorship, whether in Source or
- Object form, made available under the License, as indicated by a
- copyright notice that is included in or attached to the work
- (an example is provided in the Appendix below).
-
- "Derivative Works" shall mean any work, whether in Source or Object
- form, that is based on (or derived from) the Work and for which the
- editorial revisions, annotations, elaborations, or other modifications
- represent, as a whole, an original work of authorship. For the purposes
- of this License, Derivative Works shall not include works that remain
- separable from, or merely link (or bind by name) to the interfaces of,
- the Work and Derivative Works thereof.
-
- "Contribution" shall mean any work of authorship, including
- the original version of the Work and any modifications or additions
- to that Work or Derivative Works thereof, that is intentionally
- submitted to Licensor for inclusion in the Work by the copyright owner
- or by an individual or Legal Entity authorized to submit on behalf of
- the copyright owner. For the purposes of this definition, "submitted"
- means any form of electronic, verbal, or written communication sent
- to the Licensor or its representatives, including but not limited to
- communication on electronic mailing lists, source code control systems,
- and issue tracking systems that are managed by, or on behalf of, the
- Licensor for the purpose of discussing and improving the Work, but
- excluding communication that is conspicuously marked or otherwise
- designated in writing by the copyright owner as "Not a Contribution."
-
- "Contributor" shall mean Licensor and any individual or Legal Entity
- on behalf of whom a Contribution has been received by Licensor and
- subsequently incorporated within the Work.
-
- 2. Grant of Copyright License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- copyright license to reproduce, prepare Derivative Works of,
- publicly display, publicly perform, sublicense, and distribute the
- Work and such Derivative Works in Source or Object form.
-
- 3. Grant of Patent License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- (except as stated in this section) patent license to make, have made,
- use, offer to sell, sell, import, and otherwise transfer the Work,
- where such license applies only to those patent claims licensable
- by such Contributor that are necessarily infringed by their
- Contribution(s) alone or by combination of their Contribution(s)
- with the Work to which such Contribution(s) was submitted. If You
- institute patent litigation against any entity (including a
- cross-claim or counterclaim in a lawsuit) alleging that the Work
- or a Contribution incorporated within the Work constitutes direct
- or contributory patent infringement, then any patent licenses
- granted to You under this License for that Work shall terminate
- as of the date such litigation is filed.
-
- 4. Redistribution. You may reproduce and distribute copies of the
- Work or Derivative Works thereof in any medium, with or without
- modifications, and in Source or Object form, provided that You
- meet the following conditions:
-
- (a) You must give any other recipients of the Work or
- Derivative Works a copy of this License; and
-
- (b) You must cause any modified files to carry prominent notices
- stating that You changed the files; and
-
- (c) You must retain, in the Source form of any Derivative Works
- that You distribute, all copyright, patent, trademark, and
- attribution notices from the Source form of the Work,
- excluding those notices that do not pertain to any part of
- the Derivative Works; and
-
- (d) If the Work includes a "NOTICE" text file as part of its
- distribution, then any Derivative Works that You distribute must
- include a readable copy of the attribution notices contained
- within such NOTICE file, excluding those notices that do not
- pertain to any part of the Derivative Works, in at least one
- of the following places: within a NOTICE text file distributed
- as part of the Derivative Works; within the Source form or
- documentation, if provided along with the Derivative Works; or,
- within a display generated by the Derivative Works, if and
- wherever such third-party notices normally appear. The contents
- of the NOTICE file are for informational purposes only and
- do not modify the License. You may add Your own attribution
- notices within Derivative Works that You distribute, alongside
- or as an addendum to the NOTICE text from the Work, provided
- that such additional attribution notices cannot be construed
- as modifying the License.
-
- You may add Your own copyright statement to Your modifications and
- may provide additional or different license terms and conditions
- for use, reproduction, or distribution of Your modifications, or
- for any such Derivative Works as a whole, provided Your use,
- reproduction, and distribution of the Work otherwise complies with
- the conditions stated in this License.
-
- 5. Submission of Contributions. Unless You explicitly state otherwise,
- any Contribution intentionally submitted for inclusion in the Work
- by You to the Licensor shall be under the terms and conditions of
- this License, without any additional terms or conditions.
- Notwithstanding the above, nothing herein shall supersede or modify
- the terms of any separate license agreement you may have executed
- with Licensor regarding such Contributions.
-
- 6. Trademarks. This License does not grant permission to use the trade
- names, trademarks, service marks, or product names of the Licensor,
- except as required for reasonable and customary use in describing the
- origin of the Work and reproducing the content of the NOTICE file.
-
- 7. Disclaimer of Warranty. Unless required by applicable law or
- agreed to in writing, Licensor provides the Work (and each
- Contributor provides its Contributions) on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- implied, including, without limitation, any warranties or conditions
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
- PARTICULAR PURPOSE. You are solely responsible for determining the
- appropriateness of using or redistributing the Work and assume any
- risks associated with Your exercise of permissions under this License.
-
- 8. Limitation of Liability. In no event and under no legal theory,
- whether in tort (including negligence), contract, or otherwise,
- unless required by applicable law (such as deliberate and grossly
- negligent acts) or agreed to in writing, shall any Contributor be
- liable to You for damages, including any direct, indirect, special,
- incidental, or consequential damages of any character arising as a
- result of this License or out of the use or inability to use the
- Work (including but not limited to damages for loss of goodwill,
- work stoppage, computer failure or malfunction, or any and all
- other commercial damages or losses), even if such Contributor
- has been advised of the possibility of such damages.
-
- 9. Accepting Warranty or Additional Liability. While redistributing
- the Work or Derivative Works thereof, You may choose to offer,
- and charge a fee for, acceptance of support, warranty, indemnity,
- or other liability obligations and/or rights consistent with this
- License. However, in accepting such obligations, You may act only
- on Your own behalf and on Your sole responsibility, not on behalf
- of any other Contributor, and only if You agree to indemnify,
- defend, and hold each Contributor harmless for any liability
- incurred by, or claims asserted against, such Contributor by reason
- of your accepting any such warranty or additional liability.
-
- END OF TERMS AND CONDITIONS
-
- APPENDIX: How to apply the Apache License to your work.
-
- To apply the Apache License to your work, attach the following
- boilerplate notice, with the fields enclosed by brackets "{}"
- replaced with your own identifying information. (Don't include
- the brackets!) The text should be enclosed in the appropriate
- comment syntax for the file format. We also recommend that a
- file or class name and description of purpose be included on the
- same "printed page" as the copyright notice for easier
- identification within third-party archives.
-
- Copyright {yyyy} {name of copyright owner}
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
diff --git a/base32/LICENSE-MIT b/base32/LICENSE-MIT
deleted file mode 100644
index 2a55a47..0000000
--- a/base32/LICENSE-MIT
+++ /dev/null
@@ -1,19 +0,0 @@
-Copyright (c) 2015 The base32 Developers
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in all
-copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-SOFTWARE.
diff --git a/base32/README.md b/base32/README.md
deleted file mode 100644
index 86d9ad9..0000000
--- a/base32/README.md
+++ /dev/null
@@ -1,35 +0,0 @@
-# base32 [![Build Status](https://travis-ci.org/andreasots/base32.svg?branch=master)](https://travis-ci.org/andreasots/base32)
-
-This library lets you encode and decode in either [RFC4648 Base32](http://en.wikipedia.org/wiki/Base32#RFC_4648_Base32_alphabet) or in [Crockford Base32](http://en.wikipedia.org/wiki/Base32#Crockford.27s_Base32).
-
-# Usage
-
-```rust
-// crockford base32
-assert_eq!(encode(CrockfordBase32, [0xF8, 0x3E, 0x0F, 0x83, 0xE0]), Vec::from_slice("Z0Z0Z0Z0".to_ascii()));
-assert_eq!(decode(CrockfordBase32, "Z0Z0Z0Z0".to_ascii()).unwrap(), vec![0xF8, 0x3E, 0x0F, 0x83, 0xE0]);
-
-// rfc4648 base32
-assert_eq!(encode(RFC4648Base32, [0xF8, 0x3E, 0x7F, 0x83, 0xE7]), Vec::from_slice("7A7H7A7H".to_ascii()));
-assert_eq!(decode(RFC4648Base32, "7A7H7A7H".to_ascii()).unwrap(), vec![0xF8, 0x3E, 0x7F, 0x83, 0xE7]);
-
-// rfc4648 base32 without padding characters (=)
-assert_eq!(encode(UnpaddedRFC4648Base32, [0xF8, 0x3E, 0x7F, 0x83, 0xE7]), Vec::from_slice("7A7H7A7H".to_ascii()));
-assert_eq!(decode(UnpaddedRFC4648Base32, "7A7H7A7H".to_ascii()).unwrap(), vec![0xF8, 0x3E, 0x7F, 0x83, 0xE7]);
-```
-
-## License
-
-Licensed under either of
-
- * Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0)
- * MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT)
-
-at your option.
-
-### Contribution
-
-Unless you explicitly state otherwise, any contribution intentionally
-submitted for inclusion in the work by you, as defined in the Apache-2.0
-license, shall be dual licensed as above, without any additional terms or
-conditions.
diff --git a/base32/src/lib.rs b/base32/src/lib.rs
deleted file mode 100644
index e21cf97..0000000
--- a/base32/src/lib.rs
+++ /dev/null
@@ -1,221 +0,0 @@
-#[cfg(test)]
-extern crate quickcheck;
-#[cfg(test)]
-extern crate rand;
-
-use std::cmp::min;
-
-#[derive(Copy,Clone)]
-pub enum Alphabet {
- RFC4648 { padding: bool },
- Crockford,
-}
-
-const RFC4648_ALPHABET: &'static [u8] = b"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567";
-const CROCKFORD_ALPHABET: &'static [u8] = b"0123456789ABCDEFGHJKMNPQRSTVWXYZ";
-
-pub fn encode(alphabet: Alphabet, data: &[u8]) -> String {
- let (alphabet, padding) = match alphabet {
- Alphabet::RFC4648 { padding } => (RFC4648_ALPHABET, padding),
- Alphabet::Crockford => (CROCKFORD_ALPHABET, false),
- };
- let mut ret = Vec::with_capacity((data.len()+3)/4*5);
-
- for chunk in data.chunks(5) {
- let buf = {
- let mut buf = [0u8; 5];
- for (i, &b) in chunk.iter().enumerate() {
- buf[i] = b;
- }
- buf
- };
- ret.push(alphabet[((buf[0] & 0xF8) >> 3) as usize]);
- ret.push(alphabet[(((buf[0] & 0x07) << 2) | ((buf[1] & 0xC0) >> 6)) as usize]);
- ret.push(alphabet[((buf[1] & 0x3E) >> 1) as usize]);
- ret.push(alphabet[(((buf[1] & 0x01) << 4) | ((buf[2] & 0xF0) >> 4)) as usize]);
- ret.push(alphabet[(((buf[2] & 0x0F) << 1) | (buf[3] >> 7)) as usize]);
- ret.push(alphabet[((buf[3] & 0x7C) >> 2) as usize]);
- ret.push(alphabet[(((buf[3] & 0x03) << 3) | ((buf[4] & 0xE0) >> 5)) as usize]);
- ret.push(alphabet[(buf[4] & 0x1F) as usize]);
- }
-
- if data.len() % 5 != 0 {
- let len = ret.len();
- let num_extra = 8-(data.len()%5*8+4)/5;
- if padding {
- for i in 1..num_extra+1 {
- ret[len-i] = b'=';
- }
- } else {
- ret.truncate(len-num_extra);
- }
- }
-
- String::from_utf8(ret).unwrap()
-}
-
-const RFC4648_INV_ALPHABET: [i8; 43] = [-1, -1, 26, 27, 28, 29, 30, 31, -1, -1, -1, -1, -1, 0, -1, -1, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25];
-const CROCKFORD_INV_ALPHABET: [i8; 43] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, -1, -1, -1, -1, -1, -1, -1, 10, 11, 12, 13, 14, 15, 16, 17, 1, 18, 19, 1, 20, 21, 0, 22, 23, 24, 25, 26, -1, 27, 28, 29, 30, 31];
-
-pub fn decode(alphabet: Alphabet, data: &str) -> Option<Vec<u8>> {
- if !data.is_ascii() {
- return None;
- }
- let data = data.as_bytes();
- let alphabet = match alphabet {
- Alphabet::RFC4648 {..} => RFC4648_INV_ALPHABET,
- Alphabet::Crockford => CROCKFORD_INV_ALPHABET
- };
- let mut unpadded_data_length = data.len();
- for i in 1..min(6, data.len())+1 {
- if data[data.len() - i] != b'=' {
- break;
- }
- unpadded_data_length -= 1;
- }
- let output_length = unpadded_data_length*5/8;
- let mut ret = Vec::with_capacity((output_length+4)/5*5);
- for chunk in data.chunks(8) {
- let buf = {
- let mut buf = [0u8; 8];
- for (i, &c) in chunk.iter().enumerate() {
- match alphabet.get(c.to_ascii_uppercase().wrapping_sub(b'0') as usize) {
- Some(&-1) | None => return None,
- Some(&value) => buf[i] = value as u8,
- };
- }
- buf
- };
- ret.push((buf[0] << 3) | (buf[1] >> 2));
- ret.push((buf[1] << 6) | (buf[2] << 1) | (buf[3] >> 4));
- ret.push((buf[3] << 4) | (buf[4] >> 1));
- ret.push((buf[4] << 7) | (buf[5] << 2) | (buf[6] >> 3));
- ret.push((buf[6] << 5) | buf[7]);
- }
- ret.truncate(output_length);
- Some(ret)
-}
-
-#[cfg(test)]
-#[allow(dead_code, unused_attributes)]
-mod test {
- use super::{encode, decode};
- use super::Alphabet::{Crockford, RFC4648};
- use quickcheck;
- use std;
- use rand::Rng;
-
- #[derive(Clone)]
- struct B32 {
- c: u8
- }
-
- impl quickcheck::Arbitrary for B32 {
- fn arbitrary<G: quickcheck::Gen>(g: &mut G) -> B32 {
- let alphabet = b"0123456789ABCDEFGHJKMNPQRSTVWXYZ";
- B32 {
- c: alphabet[g.gen_range(0, alphabet.len())]
- }
- }
- }
-
- impl std::fmt::Debug for B32 {
- fn fmt(&self, f: &mut std::fmt::Formatter) -> Result<(), std::fmt::Error> {
- (self.c as char).fmt(f)
- }
- }
-
- #[test]
- fn masks_crockford() {
- assert_eq!(encode(Crockford, &[0xF8, 0x3E, 0x0F, 0x83, 0xE0]), "Z0Z0Z0Z0");
- assert_eq!(encode(Crockford, &[0x07, 0xC1, 0xF0, 0x7C, 0x1F]), "0Z0Z0Z0Z");
- assert_eq!(decode(Crockford, "Z0Z0Z0Z0").unwrap(), [0xF8, 0x3E, 0x0F, 0x83, 0xE0]);
- assert_eq!(decode(Crockford, "0Z0Z0Z0Z").unwrap(), [0x07, 0xC1, 0xF0, 0x7C, 0x1F]);
- }
-
- #[test]
- fn masks_rfc4648() {
- assert_eq!(encode(RFC4648 { padding: true }, &[0xF8, 0x3E, 0x7F, 0x83, 0xE7]), "7A7H7A7H");
- assert_eq!(encode(RFC4648 { padding: true }, &[0x77, 0xC1, 0xF7, 0x7C, 0x1F]), "O7A7O7A7");
- assert_eq!(decode(RFC4648 { padding: true }, "7A7H7A7H").unwrap(), [0xF8, 0x3E, 0x7F, 0x83, 0xE7]);
- assert_eq!(decode(RFC4648 { padding: true }, "O7A7O7A7").unwrap(), [0x77, 0xC1, 0xF7, 0x7C, 0x1F]);
- assert_eq!(encode(RFC4648 { padding: true }, &[0xF8, 0x3E, 0x7F, 0x83]), "7A7H7AY=");
- }
-
- #[test]
- fn masks_unpadded_rfc4648() {
- assert_eq!(encode(RFC4648 { padding: false }, &[0xF8, 0x3E, 0x7F, 0x83, 0xE7]), "7A7H7A7H");
- assert_eq!(encode(RFC4648 { padding: false }, &[0x77, 0xC1, 0xF7, 0x7C, 0x1F]), "O7A7O7A7");
- assert_eq!(decode(RFC4648 { padding: false }, "7A7H7A7H").unwrap(), [0xF8, 0x3E, 0x7F, 0x83, 0xE7]);
- assert_eq!(decode(RFC4648 { padding: false }, "O7A7O7A7").unwrap(), [0x77, 0xC1, 0xF7, 0x7C, 0x1F]);
- assert_eq!(encode(RFC4648 { padding: false }, &[0xF8, 0x3E, 0x7F, 0x83]), "7A7H7AY");
- }
-
- #[test]
- fn padding() {
- let num_padding = [0, 6, 4, 3, 1];
- for i in 1..6 {
- let encoded = encode(RFC4648 { padding: true }, (0..(i as u8)).collect::<Vec<u8>>().as_ref());
- assert_eq!(encoded.len(), 8);
- for j in 0..(num_padding[i % 5]) {
- assert_eq!(encoded.as_bytes()[encoded.len()-j-1], b'=');
- }
- for j in 0..(8 - num_padding[i % 5]) {
- assert!(encoded.as_bytes()[j] != b'=');
- }
- }
- }
-
- #[test]
- fn invertible_crockford() {
- fn test(data: Vec<u8>) -> bool {
- decode(Crockford, encode(Crockford, data.as_ref()).as_ref()).unwrap() == data
- }
- quickcheck::quickcheck(test as fn(Vec<u8>) -> bool)
- }
-
- #[test]
- fn invertible_rfc4648() {
- fn test(data: Vec<u8>) -> bool {
- decode(RFC4648 { padding: true }, encode(RFC4648 { padding: true }, data.as_ref()).as_ref()).unwrap() == data
- }
- quickcheck::quickcheck(test as fn(Vec<u8>) -> bool)
- }
- #[test]
- fn invertible_unpadded_rfc4648() {
- fn test(data: Vec<u8>) -> bool {
- decode(RFC4648 { padding: false }, encode(RFC4648 { padding: false }, data.as_ref()).as_ref()).unwrap() == data
- }
- quickcheck::quickcheck(test as fn(Vec<u8>) -> bool)
- }
-
- #[test]
- fn lower_case() {
- fn test(data: Vec<B32>) -> bool {
- let data: String = data.iter().map(|e| e.c as char).collect();
- decode(Crockford, data.as_ref()) == decode(Crockford, data.to_ascii_lowercase().as_ref())
- }
- quickcheck::quickcheck(test as fn(Vec<B32>) -> bool)
- }
-
- #[test]
- #[allow(non_snake_case)]
- fn iIlL1_oO0() {
- assert_eq!(decode(Crockford, "IiLlOo"), decode(Crockford, "111100"));
- }
-
- #[test]
- fn invalid_chars_crockford() {
- assert_eq!(decode(Crockford, ","), None)
- }
-
- #[test]
- fn invalid_chars_rfc4648() {
- assert_eq!(decode(RFC4648 { padding: true }, ","), None)
- }
-
- #[test]
- fn invalid_chars_unpadded_rfc4648() {
- assert_eq!(decode(RFC4648 { padding: false }, ","), None)
- }
-}
diff --git a/cc/.gitignore b/cc/.gitignore
deleted file mode 100644
index 3b874ca..0000000
--- a/cc/.gitignore
+++ /dev/null
@@ -1,4 +0,0 @@
-target
-Cargo.lock
-.idea
-*.iml
diff --git a/cc/Cargo.toml b/cc/Cargo.toml
deleted file mode 100644
index 3a4c83b..0000000
--- a/cc/Cargo.toml
+++ /dev/null
@@ -1,26 +0,0 @@
-[package]
-name = "cc"
-version = "1.0.37"
-authors = ["Alex Crichton <alex@alexcrichton.com>"]
-license = "MIT/Apache-2.0"
-repository = "https://github.com/alexcrichton/cc-rs"
-homepage = "https://github.com/alexcrichton/cc-rs"
-documentation = "https://docs.rs/cc"
-description = """
-A build-time dependency for Cargo build scripts to assist in invoking the native
-C compiler to compile native C code into a static archive to be linked into Rust
-code.
-"""
-keywords = ["build-dependencies"]
-readme = "README.md"
-categories = ["development-tools::build-utils"]
-exclude = ["/.travis.yml", "/appveyor.yml"]
-
-[dependencies]
-rayon = { version = "1.0", optional = true }
-
-[features]
-parallel = ["rayon"]
-
-[dev-dependencies]
-tempdir = "0.3"
diff --git a/cc/LICENSE-APACHE b/cc/LICENSE-APACHE
deleted file mode 100644
index 16fe87b..0000000
--- a/cc/LICENSE-APACHE
+++ /dev/null
@@ -1,201 +0,0 @@
- Apache License
- Version 2.0, January 2004
- http://www.apache.org/licenses/
-
-TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
-1. Definitions.
-
- "License" shall mean the terms and conditions for use, reproduction,
- and distribution as defined by Sections 1 through 9 of this document.
-
- "Licensor" shall mean the copyright owner or entity authorized by
- the copyright owner that is granting the License.
-
- "Legal Entity" shall mean the union of the acting entity and all
- other entities that control, are controlled by, or are under common
- control with that entity. For the purposes of this definition,
- "control" means (i) the power, direct or indirect, to cause the
- direction or management of such entity, whether by contract or
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
- outstanding shares, or (iii) beneficial ownership of such entity.
-
- "You" (or "Your") shall mean an individual or Legal Entity
- exercising permissions granted by this License.
-
- "Source" form shall mean the preferred form for making modifications,
- including but not limited to software source code, documentation
- source, and configuration files.
-
- "Object" form shall mean any form resulting from mechanical
- transformation or translation of a Source form, including but
- not limited to compiled object code, generated documentation,
- and conversions to other media types.
-
- "Work" shall mean the work of authorship, whether in Source or
- Object form, made available under the License, as indicated by a
- copyright notice that is included in or attached to the work
- (an example is provided in the Appendix below).
-
- "Derivative Works" shall mean any work, whether in Source or Object
- form, that is based on (or derived from) the Work and for which the
- editorial revisions, annotations, elaborations, or other modifications
- represent, as a whole, an original work of authorship. For the purposes
- of this License, Derivative Works shall not include works that remain
- separable from, or merely link (or bind by name) to the interfaces of,
- the Work and Derivative Works thereof.
-
- "Contribution" shall mean any work of authorship, including
- the original version of the Work and any modifications or additions
- to that Work or Derivative Works thereof, that is intentionally
- submitted to Licensor for inclusion in the Work by the copyright owner
- or by an individual or Legal Entity authorized to submit on behalf of
- the copyright owner. For the purposes of this definition, "submitted"
- means any form of electronic, verbal, or written communication sent
- to the Licensor or its representatives, including but not limited to
- communication on electronic mailing lists, source code control systems,
- and issue tracking systems that are managed by, or on behalf of, the
- Licensor for the purpose of discussing and improving the Work, but
- excluding communication that is conspicuously marked or otherwise
- designated in writing by the copyright owner as "Not a Contribution."
-
- "Contributor" shall mean Licensor and any individual or Legal Entity
- on behalf of whom a Contribution has been received by Licensor and
- subsequently incorporated within the Work.
-
-2. Grant of Copyright License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- copyright license to reproduce, prepare Derivative Works of,
- publicly display, publicly perform, sublicense, and distribute the
- Work and such Derivative Works in Source or Object form.
-
-3. Grant of Patent License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- (except as stated in this section) patent license to make, have made,
- use, offer to sell, sell, import, and otherwise transfer the Work,
- where such license applies only to those patent claims licensable
- by such Contributor that are necessarily infringed by their
- Contribution(s) alone or by combination of their Contribution(s)
- with the Work to which such Contribution(s) was submitted. If You
- institute patent litigation against any entity (including a
- cross-claim or counterclaim in a lawsuit) alleging that the Work
- or a Contribution incorporated within the Work constitutes direct
- or contributory patent infringement, then any patent licenses
- granted to You under this License for that Work shall terminate
- as of the date such litigation is filed.
-
-4. Redistribution. You may reproduce and distribute copies of the
- Work or Derivative Works thereof in any medium, with or without
- modifications, and in Source or Object form, provided that You
- meet the following conditions:
-
- (a) You must give any other recipients of the Work or
- Derivative Works a copy of this License; and
-
- (b) You must cause any modified files to carry prominent notices
- stating that You changed the files; and
-
- (c) You must retain, in the Source form of any Derivative Works
- that You distribute, all copyright, patent, trademark, and
- attribution notices from the Source form of the Work,
- excluding those notices that do not pertain to any part of
- the Derivative Works; and
-
- (d) If the Work includes a "NOTICE" text file as part of its
- distribution, then any Derivative Works that You distribute must
- include a readable copy of the attribution notices contained
- within such NOTICE file, excluding those notices that do not
- pertain to any part of the Derivative Works, in at least one
- of the following places: within a NOTICE text file distributed
- as part of the Derivative Works; within the Source form or
- documentation, if provided along with the Derivative Works; or,
- within a display generated by the Derivative Works, if and
- wherever such third-party notices normally appear. The contents
- of the NOTICE file are for informational purposes only and
- do not modify the License. You may add Your own attribution
- notices within Derivative Works that You distribute, alongside
- or as an addendum to the NOTICE text from the Work, provided
- that such additional attribution notices cannot be construed
- as modifying the License.
-
- You may add Your own copyright statement to Your modifications and
- may provide additional or different license terms and conditions
- for use, reproduction, or distribution of Your modifications, or
- for any such Derivative Works as a whole, provided Your use,
- reproduction, and distribution of the Work otherwise complies with
- the conditions stated in this License.
-
-5. Submission of Contributions. Unless You explicitly state otherwise,
- any Contribution intentionally submitted for inclusion in the Work
- by You to the Licensor shall be under the terms and conditions of
- this License, without any additional terms or conditions.
- Notwithstanding the above, nothing herein shall supersede or modify
- the terms of any separate license agreement you may have executed
- with Licensor regarding such Contributions.
-
-6. Trademarks. This License does not grant permission to use the trade
- names, trademarks, service marks, or product names of the Licensor,
- except as required for reasonable and customary use in describing the
- origin of the Work and reproducing the content of the NOTICE file.
-
-7. Disclaimer of Warranty. Unless required by applicable law or
- agreed to in writing, Licensor provides the Work (and each
- Contributor provides its Contributions) on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- implied, including, without limitation, any warranties or conditions
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
- PARTICULAR PURPOSE. You are solely responsible for determining the
- appropriateness of using or redistributing the Work and assume any
- risks associated with Your exercise of permissions under this License.
-
-8. Limitation of Liability. In no event and under no legal theory,
- whether in tort (including negligence), contract, or otherwise,
- unless required by applicable law (such as deliberate and grossly
- negligent acts) or agreed to in writing, shall any Contributor be
- liable to You for damages, including any direct, indirect, special,
- incidental, or consequential damages of any character arising as a
- result of this License or out of the use or inability to use the
- Work (including but not limited to damages for loss of goodwill,
- work stoppage, computer failure or malfunction, or any and all
- other commercial damages or losses), even if such Contributor
- has been advised of the possibility of such damages.
-
-9. Accepting Warranty or Additional Liability. While redistributing
- the Work or Derivative Works thereof, You may choose to offer,
- and charge a fee for, acceptance of support, warranty, indemnity,
- or other liability obligations and/or rights consistent with this
- License. However, in accepting such obligations, You may act only
- on Your own behalf and on Your sole responsibility, not on behalf
- of any other Contributor, and only if You agree to indemnify,
- defend, and hold each Contributor harmless for any liability
- incurred by, or claims asserted against, such Contributor by reason
- of your accepting any such warranty or additional liability.
-
-END OF TERMS AND CONDITIONS
-
-APPENDIX: How to apply the Apache License to your work.
-
- To apply the Apache License to your work, attach the following
- boilerplate notice, with the fields enclosed by brackets "[]"
- replaced with your own identifying information. (Don't include
- the brackets!) The text should be enclosed in the appropriate
- comment syntax for the file format. We also recommend that a
- file or class name and description of purpose be included on the
- same "printed page" as the copyright notice for easier
- identification within third-party archives.
-
-Copyright [yyyy] [name of copyright owner]
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
diff --git a/cc/LICENSE-MIT b/cc/LICENSE-MIT
deleted file mode 100644
index 39e0ed6..0000000
--- a/cc/LICENSE-MIT
+++ /dev/null
@@ -1,25 +0,0 @@
-Copyright (c) 2014 Alex Crichton
-
-Permission is hereby granted, free of charge, to any
-person obtaining a copy of this software and associated
-documentation files (the "Software"), to deal in the
-Software without restriction, including without
-limitation the rights to use, copy, modify, merge,
-publish, distribute, sublicense, and/or sell copies of
-the Software, and to permit persons to whom the Software
-is furnished to do so, subject to the following
-conditions:
-
-The above copyright notice and this permission notice
-shall be included in all copies or substantial portions
-of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
-ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
-TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
-PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
-SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
-CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
-IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
-DEALINGS IN THE SOFTWARE.
diff --git a/cc/README.md b/cc/README.md
deleted file mode 100644
index e3c6ad0..0000000
--- a/cc/README.md
+++ /dev/null
@@ -1,202 +0,0 @@
-# cc-rs
-
-A library to compile C/C++/assembly into a Rust library/application.
-
-[![Build Status](https://dev.azure.com/alexcrichton/cc-rs/_apis/build/status/alexcrichton.cc-rs?branchName=master)](https://dev.azure.com/alexcrichton/cc-rs/_build/latest?definitionId=5&branchName=master)
-
-[Documentation](https://docs.rs/cc)
-
-A simple library meant to be used as a build dependency with Cargo packages in
-order to build a set of C/C++ files into a static archive. This crate calls out
-to the most relevant compiler for a platform, for example using `cl` on MSVC.
-
-> **Note**: this crate was recently renamed from the `gcc` crate, so if you're
-> looking for the `gcc` crate you're in the right spot!
-
-## Using cc-rs
-
-First, you'll want to both add a build script for your crate (`build.rs`) and
-also add this crate to your `Cargo.toml` via:
-
-```toml
-[build-dependencies]
-cc = "1.0"
-```
-
-Next up, you'll want to write a build script like so:
-
-```rust,no_run
-// build.rs
-
-extern crate cc;
-
-fn main() {
- cc::Build::new()
- .file("foo.c")
- .file("bar.c")
- .compile("foo");
-}
-```
-
-And that's it! Running `cargo build` should take care of the rest and your Rust
-application will now have the C files `foo.c` and `bar.c` compiled into a file
-named libfoo.a. You can call the functions in Rust by declaring functions in
-your Rust code like so:
-
-```
-extern {
- fn foo_function();
- fn bar_function();
-}
-
-pub fn call() {
- unsafe {
- foo_function();
- bar_function();
- }
-}
-
-fn main() {
- // ...
-}
-```
-
-## External configuration via environment variables
-
-To control the programs and flags used for building, the builder can set a
-number of different environment variables.
-
-* `CFLAGS` - a series of space separated flags passed to compilers. Note that
- individual flags cannot currently contain spaces, so doing
- something like: "-L=foo\ bar" is not possible.
-* `CC` - the actual C compiler used. Note that this is used as an exact
- executable name, so (for example) no extra flags can be passed inside
- this variable, and the builder must ensure that there aren't any
- trailing spaces. This compiler must understand the `-c` flag. For
- certain `TARGET`s, it also is assumed to know about other flags (most
- common is `-fPIC`).
-* `AR` - the `ar` (archiver) executable to use to build the static library.
-* `CRATE_CC_NO_DEFAULTS` - the default compiler flags may cause conflicts in some cross compiling scenarios. Setting this variable will disable the generation of default compiler flags.
-
-Each of these variables can also be supplied with certain prefixes and suffixes,
-in the following prioritized order:
-
-1. `<var>_<target>` - for example, `CC_x86_64-unknown-linux-gnu`
-2. `<var>_<target_with_underscores>` - for example, `CC_x86_64_unknown_linux_gnu`
-3. `<build-kind>_<var>` - for example, `HOST_CC` or `TARGET_CFLAGS`
-4. `<var>` - a plain `CC`, `AR` as above.
-
-If none of these variables exist, cc-rs uses built-in defaults
-
-In addition to the above optional environment variables, `cc-rs` has some
-functions with hard requirements on some variables supplied by [cargo's
-build-script driver][cargo] that it has the `TARGET`, `OUT_DIR`, `OPT_LEVEL`,
-and `HOST` variables.
-
-[cargo]: http://doc.crates.io/build-script.html#inputs-to-the-build-script
-
-## Optional features
-
-### Parallel
-
-Currently cc-rs supports parallel compilation (think `make -jN`) but this
-feature is turned off by default. To enable cc-rs to compile C/C++ in parallel,
-you can change your dependency to:
-
-```toml
-[build-dependencies]
-cc = { version = "1.0", features = ["parallel"] }
-```
-
-By default cc-rs will limit parallelism to `$NUM_JOBS`, or if not present it
-will limit it to the number of cpus on the machine. If you are using cargo,
-use `-jN` option of `build`, `test` and `run` commands as `$NUM_JOBS`
-is supplied by cargo.
-
-## Compile-time Requirements
-
-To work properly this crate needs access to a C compiler when the build script
-is being run. This crate does not ship a C compiler with it. The compiler
-required varies per platform, but there are three broad categories:
-
-* Unix platforms require `cc` to be the C compiler. This can be found by
- installing cc/clang on Linux distributions and Xcode on OSX, for example.
-* Windows platforms targeting MSVC (e.g. your target triple ends in `-msvc`)
- require `cl.exe` to be available and in `PATH`. This is typically found in
- standard Visual Studio installations and the `PATH` can be set up by running
- the appropriate developer tools shell.
-* Windows platforms targeting MinGW (e.g. your target triple ends in `-gnu`)
- require `cc` to be available in `PATH`. We recommend the
- [MinGW-w64](http://mingw-w64.org) distribution, which is using the
- [Win-builds](http://win-builds.org) installation system.
- You may also acquire it via
- [MSYS2](http://msys2.github.io), as explained [here][msys2-help]. Make sure
- to install the appropriate architecture corresponding to your installation of
- rustc. GCC from older [MinGW](http://www.mingw.org) project is compatible
- only with 32-bit rust compiler.
-
-[msys2-help]: http://github.com/rust-lang/rust#building-on-windows
-
-## C++ support
-
-`cc-rs` supports C++ libraries compilation by using the `cpp` method on
-`Build`:
-
-```rust,no_run
-extern crate cc;
-
-fn main() {
- cc::Build::new()
- .cpp(true) // Switch to C++ library compilation.
- .file("foo.cpp")
- .compile("libfoo.a");
-}
-```
-
-When using C++ library compilation switch, the `CXX` and `CXXFLAGS` env
-variables are used instead of `CC` and `CFLAGS` and the C++ standard library is
-linked to the crate target.
-
-## CUDA C++ support
-
-`cc-rs` also supports compiling CUDA C++ libraries by using the `cuda` method
-on `Build` (currently for GNU/Clang toolchains only):
-
-```rust,no_run
-extern crate cc;
-
-fn main() {
- cc::Build::new()
- // Switch to CUDA C++ library compilation using NVCC.
- .cuda(true)
- // Generate code for Maxwell (GTX 970, 980, 980 Ti, Titan X).
- .flag("-gencode").flag("arch=compute_52,code=sm_52")
- // Generate code for Maxwell (Jetson TX1).
- .flag("-gencode").flag("arch=compute_53,code=sm_53")
- // Generate code for Pascal (GTX 1070, 1080, 1080 Ti, Titan Xp).
- .flag("-gencode").flag("arch=compute_61,code=sm_61")
- // Generate code for Pascal (Tesla P100).
- .flag("-gencode").flag("arch=compute_60,code=sm_60")
- // Generate code for Pascal (Jetson TX2).
- .flag("-gencode").flag("arch=compute_62,code=sm_62")
- .file("bar.cu")
- .compile("libbar.a");
-}
-```
-
-## License
-
-This project is licensed under either of
-
- * Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or
- http://www.apache.org/licenses/LICENSE-2.0)
- * MIT license ([LICENSE-MIT](LICENSE-MIT) or
- http://opensource.org/licenses/MIT)
-
-at your option.
-
-### Contribution
-
-Unless you explicitly state otherwise, any contribution intentionally submitted
-for inclusion in cc-rs by you, as defined in the Apache-2.0 license, shall be
-dual licensed as above, without any additional terms or conditions.
diff --git a/cc/azure-pipelines.yml b/cc/azure-pipelines.yml
deleted file mode 100644
index e816196..0000000
--- a/cc/azure-pipelines.yml
+++ /dev/null
@@ -1,101 +0,0 @@
-trigger:
- - master
-
-jobs:
- - job: min_linux
- pool:
- vmImage: ubuntu-16.04
- displayName: Minimum Rust (Linux)
- variables:
- TOOLCHAIN: 1.16.0
- steps:
- - template: ci/azure-install-rust.yml
- - script: cargo build
-
- - job: min_Windows
- pool:
- vmImage: vs2017-win2016
- displayName: Minimum Rust (Windows)
- variables:
- TOOLCHAIN: 1.16.0
- steps:
- - template: ci/azure-install-rust.yml
- - script: cargo build
-
- - job: Linux
- pool:
- vmImage: ubuntu-16.04
- steps:
- - template: ci/azure-steps.yml
- strategy:
- matrix:
- x86_64:
- TARGET: x86_64-unknown-linux-gnu
- i686:
- TARGET: i686-unknown-linux-gnu
- x86_64-beta:
- TARGET: x86_64-unknown-linux-gnu
- TOOLCHAIN: beta
- x86_64-nightly:
- TARGET: x86_64-unknown-linux-gnu
- TOOLCHAIN: nightly
-
- - job: macOS
- pool:
- vmImage: macos-10.13
- steps:
- - template: ci/azure-steps.yml
- strategy:
- matrix:
- x86_64:
- TARGET: x86_64-apple-darwin
- aarch64-ios:
- TARGET: aarch64-apple-ios
- NO_RUN: --no-run
-
- - job: Windows_vs2019
- pool:
- vmImage: windows-2019
- steps:
- - template: ci/azure-steps.yml
- strategy:
- matrix:
- x86_64-msvc:
- TARGET: x86_64-pc-windows-msvc
-
- - job: Windows_vs2017
- pool:
- vmImage: vs2017-win2016
- steps:
- - template: ci/azure-steps.yml
- strategy:
- matrix:
- x86_64-msvc:
- TARGET: x86_64-pc-windows-msvc
- i686-msvc:
- TARGET: i686-pc-windows-msvc
- x86_64-gnu:
- TARGET: x86_64-pc-windows-gnu
- i686-gnu:
- TARGET: i686-pc-windows-gnu
-
- - job: Windows_vs2015
- pool:
- vmImage: vs2015-win2012r2
- steps:
- - template: ci/azure-steps.yml
- strategy:
- matrix:
- x86_64-msvc:
- TARGET: x86_64-pc-windows-msvc
- i686-msvc:
- TARGET: i686-pc-windows-msvc
-
- - job: docs
- steps:
- - template: ci/azure-install-rust.yml
- - script: cargo doc --no-deps --all-features
- - script: curl -LsSf https://git.io/fhJ8n | rustc - && (cd target/doc && ../../rust_out)
- condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/master'))
- env:
- GITHUB_DEPLOY_KEY: $(GITHUB_DEPLOY_KEY)
diff --git a/cc/cc-test/Cargo.toml b/cc/cc-test/Cargo.toml
deleted file mode 100644
index e83416a..0000000
--- a/cc/cc-test/Cargo.toml
+++ /dev/null
@@ -1,15 +0,0 @@
-[package]
-name = "cc-test"
-version = "0.1.0"
-authors = ["Alex Crichton <alex@alexcrichton.com>"]
-
-[lib]
-name = "cc_test"
-doctest = false
-test = false
-
-[build-dependencies]
-cc = { path = ".." }
-
-[features]
-parallel = ["cc/parallel"]
diff --git a/cc/cc-test/build.rs b/cc/cc-test/build.rs
deleted file mode 100644
index 677161e..0000000
--- a/cc/cc-test/build.rs
+++ /dev/null
@@ -1,90 +0,0 @@
-extern crate cc;
-
-use std::env;
-use std::fs;
-use std::path::PathBuf;
-
-fn main() {
- let out = PathBuf::from(env::var_os("OUT_DIR").unwrap());
- fs::remove_dir_all(&out).unwrap();
- fs::create_dir(&out).unwrap();
-
- cc::Build::new()
- .file("src/foo.c")
- .flag_if_supported("-Wall")
- .flag_if_supported("-Wfoo-bar-this-flag-does-not-exist")
- .define("FOO", None)
- .define("BAR", "1")
- .compile("foo");
-
- cc::Build::new()
- .file("src/bar1.c")
- .file("src/bar2.c")
- .include("src/include")
- .compile("bar");
-
- let target = std::env::var("TARGET").unwrap();
- let file = target.split("-").next().unwrap();
- let file = format!(
- "src/{}.{}",
- file,
- if target.contains("msvc") { "asm" } else { "S" }
- );
- cc::Build::new().file(file).compile("asm");
-
- cc::Build::new()
- .file("src/baz.cpp")
- .cpp(true)
- .compile("baz");
-
- if target.contains("windows") {
- cc::Build::new().file("src/windows.c").compile("windows");
- }
-
- // Test that the `windows_registry` module will set PATH by looking for
- // nmake which runs vanilla cl, and then also test it after we remove all
- // the relevant env vars from our own process.
- if target.contains("msvc") {
- let out = out.join("tmp");
- fs::create_dir(&out).unwrap();
- println!("nmake 1");
- let status = cc::windows_registry::find(&target, "nmake.exe")
- .unwrap()
- .env_remove("MAKEFLAGS")
- .arg("/fsrc/NMakefile")
- .env("OUT_DIR", &out)
- .status()
- .unwrap();
- assert!(status.success());
-
- fs::remove_dir_all(&out).unwrap();
- fs::create_dir(&out).unwrap();
-
- env::remove_var("PATH");
- env::remove_var("VCINSTALLDIR");
- env::remove_var("INCLUDE");
- env::remove_var("LIB");
- println!("nmake 2");
- let status = cc::windows_registry::find(&target, "nmake.exe")
- .unwrap()
- .env_remove("MAKEFLAGS")
- .arg("/fsrc/NMakefile")
- .env("OUT_DIR", &out)
- .status()
- .unwrap();
- assert!(status.success());
- println!("cargo:rustc-link-lib=msvc");
- println!("cargo:rustc-link-search={}", out.display());
- }
-
- // This tests whether we can build a library but not link it to the main
- // crate. The test module will do its own linking.
- cc::Build::new()
- .cargo_metadata(false)
- .file("src/opt_linkage.c")
- .compile("OptLinkage");
-
- let out = cc::Build::new().file("src/expand.c").expand();
- let out = String::from_utf8(out).unwrap();
- assert!(out.contains("hello world"));
-}
diff --git a/cc/cc-test/src/NMakefile b/cc/cc-test/src/NMakefile
deleted file mode 100644
index 03c73df..0000000
--- a/cc/cc-test/src/NMakefile
+++ /dev/null
@@ -1,14 +0,0 @@
-all: $(OUT_DIR)/msvc.lib $(OUT_DIR)/msvc.exe
-
-$(OUT_DIR)/msvc.lib: $(OUT_DIR)/msvc.o
- lib -nologo -out:$(OUT_DIR)/msvc.lib $(OUT_DIR)/msvc.o
- rc -h
-
-$(OUT_DIR)/msvc.o: src/msvc.c
- $(CC) -nologo -c -Fo:$@ src/msvc.c -MD
-
-$(OUT_DIR)/msvc.exe: $(OUT_DIR)/msvc2.o
- $(CC) -nologo -Fo:$@ $(OUT_DIR)/msvc2.o
-
-$(OUT_DIR)/msvc2.o: src/msvc.c
- $(CC) -nologo -c -Fo:$@ src/msvc.c -DMAIN -MD
diff --git a/cc/cc-test/src/aarch64.S b/cc/cc-test/src/aarch64.S
deleted file mode 100644
index 1d9062d..0000000
--- a/cc/cc-test/src/aarch64.S
+++ /dev/null
@@ -1,10 +0,0 @@
-.globl asm
-asm:
- mov w0, 7
- ret
-
-.globl _asm
-_asm:
- mov w0, 7
- ret
-
diff --git a/cc/cc-test/src/bar1.c b/cc/cc-test/src/bar1.c
deleted file mode 100644
index 605be33..0000000
--- a/cc/cc-test/src/bar1.c
+++ /dev/null
@@ -1,7 +0,0 @@
-#include <stdint.h>
-#include "foo.h"
-
-int32_t bar1() {
- return 5;
-}
-
diff --git a/cc/cc-test/src/bar2.c b/cc/cc-test/src/bar2.c
deleted file mode 100644
index 9be4291..0000000
--- a/cc/cc-test/src/bar2.c
+++ /dev/null
@@ -1,6 +0,0 @@
-#include <stdint.h>
-
-int32_t bar2() {
- return 6;
-}
-
diff --git a/cc/cc-test/src/baz.cpp b/cc/cc-test/src/baz.cpp
deleted file mode 100644
index 2d4b959..0000000
--- a/cc/cc-test/src/baz.cpp
+++ /dev/null
@@ -1,9 +0,0 @@
-#include <stdint.h>
-
-extern "C" int32_t
-baz() {
- int *a = new int(8);
- int b = *a;
- delete a;
- return b;
-}
diff --git a/cc/cc-test/src/expand.c b/cc/cc-test/src/expand.c
deleted file mode 100644
index 2b492a2..0000000
--- a/cc/cc-test/src/expand.c
+++ /dev/null
@@ -1,4 +0,0 @@
-#define HELLO hello
-#define WORLD world
-
-HELLO WORLD
diff --git a/cc/cc-test/src/foo.c b/cc/cc-test/src/foo.c
deleted file mode 100644
index 541e62c..0000000
--- a/cc/cc-test/src/foo.c
+++ /dev/null
@@ -1,9 +0,0 @@
-#include <stdint.h>
-
-#ifdef FOO
-#if BAR == 1
-int32_t foo() {
- return 4;
-}
-#endif
-#endif
diff --git a/cc/cc-test/src/i686.S b/cc/cc-test/src/i686.S
deleted file mode 100644
index 3ed9e86..0000000
--- a/cc/cc-test/src/i686.S
+++ /dev/null
@@ -1,9 +0,0 @@
-.globl asm
-asm:
- mov $7, %eax
- ret
-
-.globl _asm
-_asm:
- mov $7, %eax
- ret
diff --git a/cc/cc-test/src/i686.asm b/cc/cc-test/src/i686.asm
deleted file mode 100644
index 6bf9676..0000000
--- a/cc/cc-test/src/i686.asm
+++ /dev/null
@@ -1,9 +0,0 @@
-.586
-.MODEL FLAT, C
-.CODE
-
-asm PROC
- MOV EAX, 7
- RET
-asm ENDP
-END
diff --git a/cc/cc-test/src/include/foo.h b/cc/cc-test/src/include/foo.h
deleted file mode 100644
index e69de29..0000000
--- a/cc/cc-test/src/include/foo.h
+++ /dev/null
diff --git a/cc/cc-test/src/lib.rs b/cc/cc-test/src/lib.rs
deleted file mode 100644
index b42ebf7..0000000
--- a/cc/cc-test/src/lib.rs
+++ /dev/null
@@ -1,16 +0,0 @@
-extern "C" {
- pub fn foo() -> i32;
-
- pub fn bar1() -> i32;
- pub fn bar2() -> i32;
-
- pub fn asm() -> i32;
-
- pub fn baz() -> i32;
-
- #[cfg(windows)]
- pub fn windows();
-
- #[cfg(target_env = "msvc")]
- pub fn msvc();
-}
diff --git a/cc/cc-test/src/msvc.c b/cc/cc-test/src/msvc.c
deleted file mode 100644
index dbbc494..0000000
--- a/cc/cc-test/src/msvc.c
+++ /dev/null
@@ -1,7 +0,0 @@
-#include <windows.h>
-
-void msvc() {}
-
-#ifdef MAIN
-int main() {}
-#endif
diff --git a/cc/cc-test/src/opt_linkage.c b/cc/cc-test/src/opt_linkage.c
deleted file mode 100644
index a74af8c..0000000
--- a/cc/cc-test/src/opt_linkage.c
+++ /dev/null
@@ -1,5 +0,0 @@
-#include <stdint.h>
-
-int32_t answer() {
- return 42;
-}
diff --git a/cc/cc-test/src/windows.c b/cc/cc-test/src/windows.c
deleted file mode 100644
index 0896aa0..0000000
--- a/cc/cc-test/src/windows.c
+++ /dev/null
@@ -1,3 +0,0 @@
-#include <windows.h>
-
-void windows() {}
diff --git a/cc/cc-test/src/x86_64.S b/cc/cc-test/src/x86_64.S
deleted file mode 100644
index 3ed9e86..0000000
--- a/cc/cc-test/src/x86_64.S
+++ /dev/null
@@ -1,9 +0,0 @@
-.globl asm
-asm:
- mov $7, %eax
- ret
-
-.globl _asm
-_asm:
- mov $7, %eax
- ret
diff --git a/cc/cc-test/src/x86_64.asm b/cc/cc-test/src/x86_64.asm
deleted file mode 100644
index 1c03101..0000000
--- a/cc/cc-test/src/x86_64.asm
+++ /dev/null
@@ -1,8 +0,0 @@
-_TEXT SEGMENT
-
-asm PROC
- MOV EAX, 7
- RET
-asm ENDP
-
-END
diff --git a/cc/cc-test/tests/all.rs b/cc/cc-test/tests/all.rs
deleted file mode 100644
index 59cb8e4..0000000
--- a/cc/cc-test/tests/all.rs
+++ /dev/null
@@ -1,60 +0,0 @@
-extern crate cc_test;
-
-use cc_test::*;
-
-#[link(name = "OptLinkage", kind = "static")]
-extern "C" {
- fn answer() -> i32;
-}
-
-#[test]
-fn foo_here() {
- unsafe {
- assert_eq!(foo(), 4);
- }
-}
-
-#[test]
-fn bar_here() {
- unsafe {
- assert_eq!(bar1(), 5);
- assert_eq!(bar2(), 6);
- }
-}
-
-#[test]
-fn asm_here() {
- unsafe {
- assert_eq!(asm(), 7);
- }
-}
-
-#[test]
-fn baz_here() {
- unsafe {
- assert_eq!(baz(), 8);
- }
-}
-
-#[test]
-#[cfg(windows)]
-fn windows_here() {
- unsafe {
- windows();
- }
-}
-
-#[test]
-#[cfg(target_env = "msvc")]
-fn msvc_here() {
- unsafe {
- msvc();
- }
-}
-
-#[test]
-fn opt_linkage() {
- unsafe {
- assert_eq!(answer(), 42);
- }
-}
diff --git a/cc/ci/azure-install-rust.yml b/cc/ci/azure-install-rust.yml
deleted file mode 100644
index 118d65e..0000000
--- a/cc/ci/azure-install-rust.yml
+++ /dev/null
@@ -1,24 +0,0 @@
-steps:
- - bash: |
- set -e
- toolchain=$TOOLCHAIN
- if [ "$toolchain" = "" ]; then
- toolchain=stable
- fi
- curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain $toolchain
- echo "##vso[task.prependpath]$HOME/.cargo/bin"
- displayName: Install rust (unix)
- condition: ne( variables['Agent.OS'], 'Windows_NT' )
-
- - script: |
- IF "%TOOLCHAIN%"=="" (SET TOOLCHAIN=stable-%TARGET%)
- curl -sSf -o rustup-init.exe https://win.rustup.rs
- rustup-init.exe -y --default-toolchain %TOOLCHAIN%
- echo ##vso[task.prependpath]%USERPROFILE%\.cargo\bin
- displayName: Install rust (windows)
- condition: eq( variables['Agent.OS'], 'Windows_NT' )
-
- - script: |
- rustc -Vv
- cargo -V
- displayName: Query rust and cargo versions
diff --git a/cc/ci/azure-steps.yml b/cc/ci/azure-steps.yml
deleted file mode 100644
index c240ed0..0000000
--- a/cc/ci/azure-steps.yml
+++ /dev/null
@@ -1,21 +0,0 @@
-steps:
- - template: azure-install-rust.yml
- - bash: rustup target add $TARGET
- displayName: Install Rust target
-
- - bash: sudo apt-get install g++-multilib
- condition: eq( variables['Agent.OS'], 'Linux' )
- displayName: Install g++-multilib
-
- - script: cargo build
- displayName: "Normal build"
- - bash: cargo test $NO_RUN -- --test-threads 1
- displayName: "Crate tests"
- - bash: cargo test $NO_RUN --features parallel -- --test-threads 1
- displayName: "Crate tests (parallel)"
- - bash: cargo test $NO_RUN --manifest-path cc-test/Cargo.toml --target $TARGET
- displayName: "cc-test tests"
- - bash: cargo test $NO_RUN --manifest-path cc-test/Cargo.toml --target $TARGET --features parallel
- displayName: "cc-test tests (parallel)"
- - bash: cargo test $NO_RUN --manifest-path cc-test/Cargo.toml --target $TARGET --release
- displayName: "cc-test tests (release)"
diff --git a/cc/src/bin/gcc-shim.rs b/cc/src/bin/gcc-shim.rs
deleted file mode 100644
index 7fd0ea8..0000000
--- a/cc/src/bin/gcc-shim.rs
+++ /dev/null
@@ -1,23 +0,0 @@
-#![cfg_attr(test, allow(dead_code))]
-
-use std::env;
-use std::fs::File;
-use std::io::prelude::*;
-use std::path::PathBuf;
-
-fn main() {
- let out_dir = PathBuf::from(env::var_os("GCCTEST_OUT_DIR").unwrap());
- for i in 0.. {
- let candidate = out_dir.join(format!("out{}", i));
- if candidate.exists() {
- continue;
- }
- let mut f = File::create(candidate).unwrap();
- for arg in env::args().skip(1) {
- writeln!(f, "{}", arg).unwrap();
- }
-
- File::create(out_dir.join("libfoo.a")).unwrap();
- break;
- }
-}
diff --git a/cc/src/com.rs b/cc/src/com.rs
deleted file mode 100644
index 9b75d47..0000000
--- a/cc/src/com.rs
+++ /dev/null
@@ -1,155 +0,0 @@
-// Copyright © 2017 winapi-rs developers
-// 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.
-// All files in the project carrying such notice may not be copied, modified, or distributed
-// except according to those terms.
-
-#![allow(unused)]
-
-use std::ffi::{OsStr, OsString};
-use std::mem::forget;
-use std::ops::Deref;
-use std::os::windows::ffi::{OsStrExt, OsStringExt};
-use std::ptr::null_mut;
-use std::slice::from_raw_parts;
-use winapi::CoInitializeEx;
-use winapi::IUnknown;
-use winapi::Interface;
-use winapi::BSTR;
-use winapi::COINIT_MULTITHREADED;
-use winapi::{SysFreeString, SysStringLen};
-use winapi::{HRESULT, S_FALSE, S_OK};
-
-pub fn initialize() -> Result<(), HRESULT> {
- let err = unsafe { CoInitializeEx(null_mut(), COINIT_MULTITHREADED) };
- if err != S_OK && err != S_FALSE {
- // S_FALSE just means COM is already initialized
- return Err(err);
- }
- Ok(())
-}
-
-pub struct ComPtr<T>(*mut T)
-where
- T: Interface;
-impl<T> ComPtr<T>
-where
- T: Interface,
-{
- /// Creates a `ComPtr` to wrap a raw pointer.
- /// It takes ownership over the pointer which means it does __not__ call `AddRef`.
- /// `T` __must__ be a COM interface that inherits from `IUnknown`.
- pub unsafe fn from_raw(ptr: *mut T) -> ComPtr<T> {
- assert!(!ptr.is_null());
- ComPtr(ptr)
- }
- /// Casts up the inheritance chain
- pub fn up<U>(self) -> ComPtr<U>
- where
- T: Deref<Target = U>,
- U: Interface,
- {
- ComPtr(self.into_raw() as *mut U)
- }
- /// Extracts the raw pointer.
- /// You are now responsible for releasing it yourself.
- pub fn into_raw(self) -> *mut T {
- let p = self.0;
- forget(self);
- p
- }
- /// For internal use only.
- fn as_unknown(&self) -> &IUnknown {
- unsafe { &*(self.0 as *mut IUnknown) }
- }
- /// Performs QueryInterface fun.
- pub fn cast<U>(&self) -> Result<ComPtr<U>, i32>
- where
- U: Interface,
- {
- let mut obj = null_mut();
- let err = unsafe { self.as_unknown().QueryInterface(&U::uuidof(), &mut obj) };
- if err < 0 {
- return Err(err);
- }
- Ok(unsafe { ComPtr::from_raw(obj as *mut U) })
- }
-}
-impl<T> Deref for ComPtr<T>
-where
- T: Interface,
-{
- type Target = T;
- fn deref(&self) -> &T {
- unsafe { &*self.0 }
- }
-}
-impl<T> Clone for ComPtr<T>
-where
- T: Interface,
-{
- fn clone(&self) -> Self {
- unsafe {
- self.as_unknown().AddRef();
- ComPtr::from_raw(self.0)
- }
- }
-}
-impl<T> Drop for ComPtr<T>
-where
- T: Interface,
-{
- fn drop(&mut self) {
- unsafe {
- self.as_unknown().Release();
- }
- }
-}
-pub struct BStr(BSTR);
-impl BStr {
- pub unsafe fn from_raw(s: BSTR) -> BStr {
- BStr(s)
- }
- pub fn to_osstring(&self) -> OsString {
- let len = unsafe { SysStringLen(self.0) };
- let slice = unsafe { from_raw_parts(self.0, len as usize) };
- OsStringExt::from_wide(slice)
- }
-}
-impl Drop for BStr {
- fn drop(&mut self) {
- unsafe { SysFreeString(self.0) };
- }
-}
-
-pub trait ToWide {
- fn to_wide(&self) -> Vec<u16>;
- fn to_wide_null(&self) -> Vec<u16>;
-}
-impl<T> ToWide for T
-where
- T: AsRef<OsStr>,
-{
- fn to_wide(&self) -> Vec<u16> {
- self.as_ref().encode_wide().collect()
- }
- fn to_wide_null(&self) -> Vec<u16> {
- self.as_ref().encode_wide().chain(Some(0)).collect()
- }
-}
-pub trait FromWide
-where
- Self: Sized,
-{
- fn from_wide(wide: &[u16]) -> Self;
- fn from_wide_null(wide: &[u16]) -> Self {
- let len = wide.iter().take_while(|&&c| c != 0).count();
- Self::from_wide(&wide[..len])
- }
-}
-impl FromWide for OsString {
- fn from_wide(wide: &[u16]) -> OsString {
- OsStringExt::from_wide(wide)
- }
-}
diff --git a/cc/src/lib.rs b/cc/src/lib.rs
deleted file mode 100644
index 9fef147..0000000
--- a/cc/src/lib.rs
+++ /dev/null
@@ -1,2422 +0,0 @@
-//! A library for build scripts to compile custom C code
-//!
-//! This library is intended to be used as a `build-dependencies` entry in
-//! `Cargo.toml`:
-//!
-//! ```toml
-//! [build-dependencies]
-//! cc = "1.0"
-//! ```
-//!
-//! The purpose of this crate is to provide the utility functions necessary to
-//! compile C code into a static archive which is then linked into a Rust crate.
-//! Configuration is available through the `Build` struct.
-//!
-//! This crate will automatically detect situations such as cross compilation or
-//! other environment variables set by Cargo and will build code appropriately.
-//!
-//! The crate is not limited to C code, it can accept any source code that can
-//! be passed to a C or C++ compiler. As such, assembly files with extensions
-//! `.s` (gcc/clang) and `.asm` (MSVC) can also be compiled.
-//!
-//! [`Build`]: struct.Build.html
-//!
-//! # Parallelism
-//!
-//! To parallelize computation, enable the `parallel` feature for the crate.
-//!
-//! ```toml
-//! [build-dependencies]
-//! cc = { version = "1.0", features = ["parallel"] }
-//! ```
-//! To specify the max number of concurrent compilation jobs, set the `NUM_JOBS`
-//! environment variable to the desired amount.
-//!
-//! Cargo will also set this environment variable when executed with the `-jN` flag.
-//!
-//! If `NUM_JOBS` is not set, the `RAYON_NUM_THREADS` environment variable can
-//! also specify the build paralellism.
-//!
-//! # Examples
-//!
-//! Use the `Build` struct to compile `src/foo.c`:
-//!
-//! ```no_run
-//! extern crate cc;
-//!
-//! fn main() {
-//! cc::Build::new()
-//! .file("src/foo.c")
-//! .define("FOO", Some("bar"))
-//! .include("src")
-//! .compile("foo");
-//! }
-//! ```
-
-#![doc(html_root_url = "https://docs.rs/cc/1.0")]
-#![cfg_attr(test, deny(warnings))]
-#![allow(deprecated)]
-#![deny(missing_docs)]
-
-#[cfg(feature = "parallel")]
-extern crate rayon;
-
-use std::collections::HashMap;
-use std::env;
-use std::ffi::{OsStr, OsString};
-use std::fs;
-use std::io::{self, BufRead, BufReader, Read, Write};
-use std::path::{Path, PathBuf};
-use std::process::{Child, Command, Stdio};
-use std::sync::{Arc, Mutex};
-use std::thread::{self, JoinHandle};
-
-// These modules are all glue to support reading the MSVC version from
-// the registry and from COM interfaces
-#[cfg(windows)]
-mod registry;
-#[cfg(windows)]
-#[macro_use]
-mod winapi;
-#[cfg(windows)]
-mod com;
-#[cfg(windows)]
-mod setup_config;
-
-pub mod windows_registry;
-
-/// A builder for compilation of a native static library.
-///
-/// A `Build` is the main type of the `cc` crate and is used to control all the
-/// various configuration options and such of a compile. You'll find more
-/// documentation on each method itself.
-#[derive(Clone, Debug)]
-pub struct Build {
- include_directories: Vec<PathBuf>,
- definitions: Vec<(String, Option<String>)>,
- objects: Vec<PathBuf>,
- flags: Vec<String>,
- flags_supported: Vec<String>,
- known_flag_support_status: Arc<Mutex<HashMap<String, bool>>>,
- files: Vec<PathBuf>,
- cpp: bool,
- cpp_link_stdlib: Option<Option<String>>,
- cpp_set_stdlib: Option<String>,
- cuda: bool,
- target: Option<String>,
- host: Option<String>,
- out_dir: Option<PathBuf>,
- opt_level: Option<String>,
- debug: Option<bool>,
- env: Vec<(OsString, OsString)>,
- compiler: Option<PathBuf>,
- archiver: Option<PathBuf>,
- cargo_metadata: bool,
- pic: Option<bool>,
- use_plt: Option<bool>,
- static_crt: Option<bool>,
- shared_flag: Option<bool>,
- static_flag: Option<bool>,
- warnings_into_errors: bool,
- warnings: Option<bool>,
- extra_warnings: Option<bool>,
- env_cache: Arc<Mutex<HashMap<String, Option<String>>>>,
-}
-
-/// Represents the types of errors that may occur while using cc-rs.
-#[derive(Clone, Debug)]
-enum ErrorKind {
- /// Error occurred while performing I/O.
- IOError,
- /// Invalid architecture supplied.
- ArchitectureInvalid,
- /// Environment variable not found, with the var in question as extra info.
- EnvVarNotFound,
- /// Error occurred while using external tools (ie: invocation of compiler).
- ToolExecError,
- /// Error occurred due to missing external tools.
- ToolNotFound,
-}
-
-/// Represents an internal error that occurred, with an explanation.
-#[derive(Clone, Debug)]
-pub struct Error {
- /// Describes the kind of error that occurred.
- kind: ErrorKind,
- /// More explanation of error that occurred.
- message: String,
-}
-
-impl Error {
- fn new(kind: ErrorKind, message: &str) -> Error {
- Error {
- kind: kind,
- message: message.to_owned(),
- }
- }
-}
-
-impl From<io::Error> for Error {
- fn from(e: io::Error) -> Error {
- Error::new(ErrorKind::IOError, &format!("{}", e))
- }
-}
-
-/// Configuration used to represent an invocation of a C compiler.
-///
-/// This can be used to figure out what compiler is in use, what the arguments
-/// to it are, and what the environment variables look like for the compiler.
-/// This can be used to further configure other build systems (e.g. forward
-/// along CC and/or CFLAGS) or the `to_command` method can be used to run the
-/// compiler itself.
-#[derive(Clone, Debug)]
-pub struct Tool {
- path: PathBuf,
- cc_wrapper_path: Option<PathBuf>,
- cc_wrapper_args: Vec<OsString>,
- args: Vec<OsString>,
- env: Vec<(OsString, OsString)>,
- family: ToolFamily,
- cuda: bool,
- removed_args: Vec<OsString>,
-}
-
-/// Represents the family of tools this tool belongs to.
-///
-/// Each family of tools differs in how and what arguments they accept.
-///
-/// Detection of a family is done on best-effort basis and may not accurately reflect the tool.
-#[derive(Copy, Clone, Debug, PartialEq)]
-enum ToolFamily {
- /// Tool is GNU Compiler Collection-like.
- Gnu,
- /// Tool is Clang-like. It differs from the GCC in a sense that it accepts superset of flags
- /// and its cross-compilation approach is different.
- Clang,
- /// Tool is the MSVC cl.exe.
- Msvc { clang_cl: bool },
-}
-
-impl ToolFamily {
- /// What the flag to request debug info for this family of tools look like
- fn add_debug_flags(&self, cmd: &mut Tool) {
- match *self {
- ToolFamily::Msvc { .. } => {
- cmd.push_cc_arg("/Z7".into());
- }
- ToolFamily::Gnu | ToolFamily::Clang => {
- cmd.push_cc_arg("-g".into());
- cmd.push_cc_arg("-fno-omit-frame-pointer".into());
- }
- }
- }
-
- /// What the flag to include directories into header search path looks like
- fn include_flag(&self) -> &'static str {
- match *self {
- ToolFamily::Msvc { .. } => "/I",
- ToolFamily::Gnu | ToolFamily::Clang => "-I",
- }
- }
-
- /// What the flag to request macro-expanded source output looks like
- fn expand_flag(&self) -> &'static str {
- match *self {
- ToolFamily::Msvc { .. } => "/E",
- ToolFamily::Gnu | ToolFamily::Clang => "-E",
- }
- }
-
- /// What the flags to enable all warnings
- fn warnings_flags(&self) -> &'static str {
- match *self {
- ToolFamily::Msvc { .. } => "/W4",
- ToolFamily::Gnu | ToolFamily::Clang => "-Wall",
- }
- }
-
- /// What the flags to enable extra warnings
- fn extra_warnings_flags(&self) -> Option<&'static str> {
- match *self {
- ToolFamily::Msvc { .. } => None,
- ToolFamily::Gnu | ToolFamily::Clang => Some("-Wextra"),
- }
- }
-
- /// What the flag to turn warning into errors
- fn warnings_to_errors_flag(&self) -> &'static str {
- match *self {
- ToolFamily::Msvc { .. } => "/WX",
- ToolFamily::Gnu | ToolFamily::Clang => "-Werror",
- }
- }
-
- /// NVCC-specific. Device code debug info flag. This is separate from the
- /// debug info flag passed to the C++ compiler.
- fn nvcc_debug_flag(&self) -> &'static str {
- match *self {
- ToolFamily::Msvc { .. } => unimplemented!(),
- ToolFamily::Gnu | ToolFamily::Clang => "-G",
- }
- }
-
- /// NVCC-specific. Redirect the following flag to the underlying C++
- /// compiler.
- fn nvcc_redirect_flag(&self) -> &'static str {
- match *self {
- ToolFamily::Msvc { .. } => unimplemented!(),
- ToolFamily::Gnu | ToolFamily::Clang => "-Xcompiler",
- }
- }
-
- fn verbose_stderr(&self) -> bool {
- *self == ToolFamily::Clang
- }
-}
-
-/// Represents an object.
-///
-/// This is a source file -> object file pair.
-#[derive(Clone, Debug)]
-struct Object {
- src: PathBuf,
- dst: PathBuf,
-}
-
-impl Object {
- /// Create a new source file -> object file pair.
- fn new(src: PathBuf, dst: PathBuf) -> Object {
- Object { src: src, dst: dst }
- }
-}
-
-impl Build {
- /// Construct a new instance of a blank set of configuration.
- ///
- /// This builder is finished with the [`compile`] function.
- ///
- /// [`compile`]: struct.Build.html#method.compile
- pub fn new() -> Build {
- Build {
- include_directories: Vec::new(),
- definitions: Vec::new(),
- objects: Vec::new(),
- flags: Vec::new(),
- flags_supported: Vec::new(),
- known_flag_support_status: Arc::new(Mutex::new(HashMap::new())),
- files: Vec::new(),
- shared_flag: None,
- static_flag: None,
- cpp: false,
- cpp_link_stdlib: None,
- cpp_set_stdlib: None,
- cuda: false,
- target: None,
- host: None,
- out_dir: None,
- opt_level: None,
- debug: None,
- env: Vec::new(),
- compiler: None,
- archiver: None,
- cargo_metadata: true,
- pic: None,
- use_plt: None,
- static_crt: None,
- warnings: None,
- extra_warnings: None,
- warnings_into_errors: false,
- env_cache: Arc::new(Mutex::new(HashMap::new())),
- }
- }
-
- /// Add a directory to the `-I` or include path for headers
- ///
- /// # Example
- ///
- /// ```no_run
- /// use std::path::Path;
- ///
- /// let library_path = Path::new("/path/to/library");
- ///
- /// cc::Build::new()
- /// .file("src/foo.c")
- /// .include(library_path)
- /// .include("src")
- /// .compile("foo");
- /// ```
- pub fn include<P: AsRef<Path>>(&mut self, dir: P) -> &mut Build {
- self.include_directories.push(dir.as_ref().to_path_buf());
- self
- }
-
- /// Specify a `-D` variable with an optional value.
- ///
- /// # Example
- ///
- /// ```no_run
- /// cc::Build::new()
- /// .file("src/foo.c")
- /// .define("FOO", "BAR")
- /// .define("BAZ", None)
- /// .compile("foo");
- /// ```
- pub fn define<'a, V: Into<Option<&'a str>>>(&mut self, var: &str, val: V) -> &mut Build {
- self.definitions
- .push((var.to_string(), val.into().map(|s| s.to_string())));
- self
- }
-
- /// Add an arbitrary object file to link in
- pub fn object<P: AsRef<Path>>(&mut self, obj: P) -> &mut Build {
- self.objects.push(obj.as_ref().to_path_buf());
- self
- }
-
- /// Add an arbitrary flag to the invocation of the compiler
- ///
- /// # Example
- ///
- /// ```no_run
- /// cc::Build::new()
- /// .file("src/foo.c")
- /// .flag("-ffunction-sections")
- /// .compile("foo");
- /// ```
- pub fn flag(&mut self, flag: &str) -> &mut Build {
- self.flags.push(flag.to_string());
- self
- }
-
- fn ensure_check_file(&self) -> Result<PathBuf, Error> {
- let out_dir = self.get_out_dir()?;
- let src = if self.cuda {
- assert!(self.cpp);
- out_dir.join("flag_check.cu")
- } else if self.cpp {
- out_dir.join("flag_check.cpp")
- } else {
- out_dir.join("flag_check.c")
- };
-
- if !src.exists() {
- let mut f = fs::File::create(&src)?;
- write!(f, "int main(void) {{ return 0; }}")?;
- }
-
- Ok(src)
- }
-
- /// Run the compiler to test if it accepts the given flag.
- ///
- /// For a convenience method for setting flags conditionally,
- /// see `flag_if_supported()`.
- ///
- /// It may return error if it's unable to run the compilier with a test file
- /// (e.g. the compiler is missing or a write to the `out_dir` failed).
- ///
- /// Note: Once computed, the result of this call is stored in the
- /// `known_flag_support` field. If `is_flag_supported(flag)`
- /// is called again, the result will be read from the hash table.
- pub fn is_flag_supported(&self, flag: &str) -> Result<bool, Error> {
- let mut known_status = self.known_flag_support_status.lock().unwrap();
- if let Some(is_supported) = known_status.get(flag).cloned() {
- return Ok(is_supported);
- }
-
- let out_dir = self.get_out_dir()?;
- let src = self.ensure_check_file()?;
- let obj = out_dir.join("flag_check");
- let target = self.get_target()?;
- let host = self.get_host()?;
- let mut cfg = Build::new();
- cfg.flag(flag)
- .target(&target)
- .opt_level(0)
- .host(&host)
- .debug(false)
- .cpp(self.cpp)
- .cuda(self.cuda);
- let mut compiler = cfg.try_get_compiler()?;
-
- // Clang uses stderr for verbose output, which yields a false positive
- // result if the CFLAGS/CXXFLAGS include -v to aid in debugging.
- if compiler.family.verbose_stderr() {
- compiler.remove_arg("-v".into());
- }
-
- let mut cmd = compiler.to_command();
- let is_arm = target.contains("aarch64") || target.contains("arm");
- command_add_output_file(&mut cmd, &obj, target.contains("msvc"), false, is_arm);
-
- // We need to explicitly tell msvc not to link and create an exe
- // in the root directory of the crate
- if target.contains("msvc") {
- cmd.arg("/c");
- }
-
- cmd.arg(&src);
-
- let output = cmd.output()?;
- let is_supported = output.stderr.is_empty();
-
- known_status.insert(flag.to_owned(), is_supported);
- Ok(is_supported)
- }
-
- /// Add an arbitrary flag to the invocation of the compiler if it supports it
- ///
- /// # Example
- ///
- /// ```no_run
- /// cc::Build::new()
- /// .file("src/foo.c")
- /// .flag_if_supported("-Wlogical-op") // only supported by GCC
- /// .flag_if_supported("-Wunreachable-code") // only supported by clang
- /// .compile("foo");
- /// ```
- pub fn flag_if_supported(&mut self, flag: &str) -> &mut Build {
- self.flags_supported.push(flag.to_string());
- self
- }
-
- /// Set the `-shared` flag.
- ///
- /// When enabled, the compiler will produce a shared object which can
- /// then be linked with other objects to form an executable.
- ///
- /// # Example
- ///
- /// ```no_run
- /// cc::Build::new()
- /// .file("src/foo.c")
- /// .shared_flag(true)
- /// .compile("libfoo.so");
- /// ```
-
- pub fn shared_flag(&mut self, shared_flag: bool) -> &mut Build {
- self.shared_flag = Some(shared_flag);
- self
- }
-
- /// Set the `-static` flag.
- ///
- /// When enabled on systems that support dynamic linking, this prevents
- /// linking with the shared libraries.
- ///
- /// # Example
- ///
- /// ```no_run
- /// cc::Build::new()
- /// .file("src/foo.c")
- /// .shared_flag(true)
- /// .static_flag(true)
- /// .compile("foo");
- /// ```
- pub fn static_flag(&mut self, static_flag: bool) -> &mut Build {
- self.static_flag = Some(static_flag);
- self
- }
-
- /// Add a file which will be compiled
- pub fn file<P: AsRef<Path>>(&mut self, p: P) -> &mut Build {
- self.files.push(p.as_ref().to_path_buf());
- self
- }
-
- /// Add files which will be compiled
- pub fn files<P>(&mut self, p: P) -> &mut Build
- where
- P: IntoIterator,
- P::Item: AsRef<Path>,
- {
- for file in p.into_iter() {
- self.file(file);
- }
- self
- }
-
- /// Set C++ support.
- ///
- /// The other `cpp_*` options will only become active if this is set to
- /// `true`.
- pub fn cpp(&mut self, cpp: bool) -> &mut Build {
- self.cpp = cpp;
- self
- }
-
- /// Set CUDA C++ support.
- ///
- /// Enabling CUDA will pass the detected C/C++ toolchain as an argument to
- /// the CUDA compiler, NVCC. NVCC itself accepts some limited GNU-like args;
- /// any other arguments for the C/C++ toolchain will be redirected using
- /// "-Xcompiler" flags.
- ///
- /// If enabled, this also implicitly enables C++ support.
- pub fn cuda(&mut self, cuda: bool) -> &mut Build {
- self.cuda = cuda;
- if cuda {
- self.cpp = true;
- }
- self
- }
-
- /// Set warnings into errors flag.
- ///
- /// Disabled by default.
- ///
- /// Warning: turning warnings into errors only make sense
- /// if you are a developer of the crate using cc-rs.
- /// Some warnings only appear on some architecture or
- /// specific version of the compiler. Any user of this crate,
- /// or any other crate depending on it, could fail during
- /// compile time.
- ///
- /// # Example
- ///
- /// ```no_run
- /// cc::Build::new()
- /// .file("src/foo.c")
- /// .warnings_into_errors(true)
- /// .compile("libfoo.a");
- /// ```
- pub fn warnings_into_errors(&mut self, warnings_into_errors: bool) -> &mut Build {
- self.warnings_into_errors = warnings_into_errors;
- self
- }
-
- /// Set warnings flags.
- ///
- /// Adds some flags:
- /// - "/Wall" for MSVC.
- /// - "-Wall", "-Wextra" for GNU and Clang.
- ///
- /// Enabled by default.
- ///
- /// # Example
- ///
- /// ```no_run
- /// cc::Build::new()
- /// .file("src/foo.c")
- /// .warnings(false)
- /// .compile("libfoo.a");
- /// ```
- pub fn warnings(&mut self, warnings: bool) -> &mut Build {
- self.warnings = Some(warnings);
- self.extra_warnings = Some(warnings);
- self
- }
-
- /// Set extra warnings flags.
- ///
- /// Adds some flags:
- /// - nothing for MSVC.
- /// - "-Wextra" for GNU and Clang.
- ///
- /// Enabled by default.
- ///
- /// # Example
- ///
- /// ```no_run
- /// // Disables -Wextra, -Wall remains enabled:
- /// cc::Build::new()
- /// .file("src/foo.c")
- /// .extra_warnings(false)
- /// .compile("libfoo.a");
- /// ```
- pub fn extra_warnings(&mut self, warnings: bool) -> &mut Build {
- self.extra_warnings = Some(warnings);
- self
- }
-
- /// Set the standard library to link against when compiling with C++
- /// support.
- ///
- /// The default value of this property depends on the current target: On
- /// OS X `Some("c++")` is used, when compiling for a Visual Studio based
- /// target `None` is used and for other targets `Some("stdc++")` is used.
- /// If the `CXXSTDLIB` environment variable is set, its value will
- /// override the default value.
- ///
- /// A value of `None` indicates that no automatic linking should happen,
- /// otherwise cargo will link against the specified library.
- ///
- /// The given library name must not contain the `lib` prefix.
- ///
- /// Common values:
- /// - `stdc++` for GNU
- /// - `c++` for Clang
- ///
- /// # Example
- ///
- /// ```no_run
- /// cc::Build::new()
- /// .file("src/foo.c")
- /// .shared_flag(true)
- /// .cpp_link_stdlib("stdc++")
- /// .compile("libfoo.so");
- /// ```
- pub fn cpp_link_stdlib<'a, V: Into<Option<&'a str>>>(
- &mut self,
- cpp_link_stdlib: V,
- ) -> &mut Build {
- self.cpp_link_stdlib = Some(cpp_link_stdlib.into().map(|s| s.into()));
- self
- }
-
- /// Force the C++ compiler to use the specified standard library.
- ///
- /// Setting this option will automatically set `cpp_link_stdlib` to the same
- /// value.
- ///
- /// The default value of this option is always `None`.
- ///
- /// This option has no effect when compiling for a Visual Studio based
- /// target.
- ///
- /// This option sets the `-stdlib` flag, which is only supported by some
- /// compilers (clang, icc) but not by others (gcc). The library will not
- /// detect which compiler is used, as such it is the responsibility of the
- /// caller to ensure that this option is only used in conjuction with a
- /// compiler which supports the `-stdlib` flag.
- ///
- /// A value of `None` indicates that no specific C++ standard library should
- /// be used, otherwise `-stdlib` is added to the compile invocation.
- ///
- /// The given library name must not contain the `lib` prefix.
- ///
- /// Common values:
- /// - `stdc++` for GNU
- /// - `c++` for Clang
- ///
- /// # Example
- ///
- /// ```no_run
- /// cc::Build::new()
- /// .file("src/foo.c")
- /// .cpp_set_stdlib("c++")
- /// .compile("libfoo.a");
- /// ```
- pub fn cpp_set_stdlib<'a, V: Into<Option<&'a str>>>(
- &mut self,
- cpp_set_stdlib: V,
- ) -> &mut Build {
- let cpp_set_stdlib = cpp_set_stdlib.into();
- self.cpp_set_stdlib = cpp_set_stdlib.map(|s| s.into());
- self.cpp_link_stdlib(cpp_set_stdlib);
- self
- }
-
- /// Configures the target this configuration will be compiling for.
- ///
- /// This option is automatically scraped from the `TARGET` environment
- /// variable by build scripts, so it's not required to call this function.
- ///
- /// # Example
- ///
- /// ```no_run
- /// cc::Build::new()
- /// .file("src/foo.c")
- /// .target("aarch64-linux-android")
- /// .compile("foo");
- /// ```
- pub fn target(&mut self, target: &str) -> &mut Build {
- self.target = Some(target.to_string());
- self
- }
-
- /// Configures the host assumed by this configuration.
- ///
- /// This option is automatically scraped from the `HOST` environment
- /// variable by build scripts, so it's not required to call this function.
- ///
- /// # Example
- ///
- /// ```no_run
- /// cc::Build::new()
- /// .file("src/foo.c")
- /// .host("arm-linux-gnueabihf")
- /// .compile("foo");
- /// ```
- pub fn host(&mut self, host: &str) -> &mut Build {
- self.host = Some(host.to_string());
- self
- }
-
- /// Configures the optimization level of the generated object files.
- ///
- /// This option is automatically scraped from the `OPT_LEVEL` environment
- /// variable by build scripts, so it's not required to call this function.
- pub fn opt_level(&mut self, opt_level: u32) -> &mut Build {
- self.opt_level = Some(opt_level.to_string());
- self
- }
-
- /// Configures the optimization level of the generated object files.
- ///
- /// This option is automatically scraped from the `OPT_LEVEL` environment
- /// variable by build scripts, so it's not required to call this function.
- pub fn opt_level_str(&mut self, opt_level: &str) -> &mut Build {
- self.opt_level = Some(opt_level.to_string());
- self
- }
-
- /// Configures whether the compiler will emit debug information when
- /// generating object files.
- ///
- /// This option is automatically scraped from the `PROFILE` environment
- /// variable by build scripts (only enabled when the profile is "debug"), so
- /// it's not required to call this function.
- pub fn debug(&mut self, debug: bool) -> &mut Build {
- self.debug = Some(debug);
- self
- }
-
- /// Configures the output directory where all object files and static
- /// libraries will be located.
- ///
- /// This option is automatically scraped from the `OUT_DIR` environment
- /// variable by build scripts, so it's not required to call this function.
- pub fn out_dir<P: AsRef<Path>>(&mut self, out_dir: P) -> &mut Build {
- self.out_dir = Some(out_dir.as_ref().to_owned());
- self
- }
-
- /// Configures the compiler to be used to produce output.
- ///
- /// This option is automatically determined from the target platform or a
- /// number of environment variables, so it's not required to call this
- /// function.
- pub fn compiler<P: AsRef<Path>>(&mut self, compiler: P) -> &mut Build {
- self.compiler = Some(compiler.as_ref().to_owned());
- self
- }
-
- /// Configures the tool used to assemble archives.
- ///
- /// This option is automatically determined from the target platform or a
- /// number of environment variables, so it's not required to call this
- /// function.
- pub fn archiver<P: AsRef<Path>>(&mut self, archiver: P) -> &mut Build {
- self.archiver = Some(archiver.as_ref().to_owned());
- self
- }
- /// Define whether metadata should be emitted for cargo allowing it to
- /// automatically link the binary. Defaults to `true`.
- ///
- /// The emitted metadata is:
- ///
- /// - `rustc-link-lib=static=`*compiled lib*
- /// - `rustc-link-search=native=`*target folder*
- /// - When target is MSVC, the ATL-MFC libs are added via `rustc-link-search=native=`
- /// - When C++ is enabled, the C++ stdlib is added via `rustc-link-lib`
- ///
- pub fn cargo_metadata(&mut self, cargo_metadata: bool) -> &mut Build {
- self.cargo_metadata = cargo_metadata;
- self
- }
-
- /// Configures whether the compiler will emit position independent code.
- ///
- /// This option defaults to `false` for `windows-gnu` targets and
- /// to `true` for all other targets.
- pub fn pic(&mut self, pic: bool) -> &mut Build {
- self.pic = Some(pic);
- self
- }
-
- /// Configures whether the Procedure Linkage Table is used for indirect
- /// calls into shared libraries.
- ///
- /// The PLT is used to provide features like lazy binding, but introduces
- /// a small performance loss due to extra pointer indirection. Setting
- /// `use_plt` to `false` can provide a small performance increase.
- ///
- /// Note that skipping the PLT requires a recent version of GCC/Clang.
- ///
- /// This only applies to ELF targets. It has no effect on other platforms.
- pub fn use_plt(&mut self, use_plt: bool) -> &mut Build {
- self.use_plt = Some(use_plt);
- self
- }
-
- /// Configures whether the /MT flag or the /MD flag will be passed to msvc build tools.
- ///
- /// This option defaults to `false`, and affect only msvc targets.
- pub fn static_crt(&mut self, static_crt: bool) -> &mut Build {
- self.static_crt = Some(static_crt);
- self
- }
-
- #[doc(hidden)]
- pub fn __set_env<A, B>(&mut self, a: A, b: B) -> &mut Build
- where
- A: AsRef<OsStr>,
- B: AsRef<OsStr>,
- {
- self.env
- .push((a.as_ref().to_owned(), b.as_ref().to_owned()));
- self
- }
-
- /// Run the compiler, generating the file `output`
- ///
- /// This will return a result instead of panicing; see compile() for the complete description.
- pub fn try_compile(&self, output: &str) -> Result<(), Error> {
- let (lib_name, gnu_lib_name) = if output.starts_with("lib") && output.ends_with(".a") {
- (&output[3..output.len() - 2], output.to_owned())
- } else {
- let mut gnu = String::with_capacity(5 + output.len());
- gnu.push_str("lib");
- gnu.push_str(&output);
- gnu.push_str(".a");
- (output, gnu)
- };
- let dst = self.get_out_dir()?;
-
- let mut objects = Vec::new();
- for file in self.files.iter() {
- let obj = dst.join(file).with_extension("o");
- let obj = if !obj.starts_with(&dst) {
- dst.join(obj.file_name().ok_or_else(|| {
- Error::new(ErrorKind::IOError, "Getting object file details failed.")
- })?)
- } else {
- obj
- };
-
- match obj.parent() {
- Some(s) => fs::create_dir_all(s)?,
- None => {
- return Err(Error::new(
- ErrorKind::IOError,
- "Getting object file details failed.",
- ));
- }
- };
-
- objects.push(Object::new(file.to_path_buf(), obj));
- }
- self.compile_objects(&objects)?;
- self.assemble(lib_name, &dst.join(gnu_lib_name), &objects)?;
-
- if self.get_target()?.contains("msvc") {
- let compiler = self.get_base_compiler()?;
- let atlmfc_lib = compiler
- .env()
- .iter()
- .find(|&&(ref var, _)| var.as_os_str() == OsStr::new("LIB"))
- .and_then(|&(_, ref lib_paths)| {
- env::split_paths(lib_paths).find(|path| {
- let sub = Path::new("atlmfc/lib");
- path.ends_with(sub) || path.parent().map_or(false, |p| p.ends_with(sub))
- })
- });
-
- if let Some(atlmfc_lib) = atlmfc_lib {
- self.print(&format!(
- "cargo:rustc-link-search=native={}",
- atlmfc_lib.display()
- ));
- }
- }
-
- self.print(&format!("cargo:rustc-link-lib=static={}", lib_name));
- self.print(&format!("cargo:rustc-link-search=native={}", dst.display()));
-
- // Add specific C++ libraries, if enabled.
- if self.cpp {
- if let Some(stdlib) = self.get_cpp_link_stdlib()? {
- self.print(&format!("cargo:rustc-link-lib={}", stdlib));
- }
- }
-
- Ok(())
- }
-
- /// Run the compiler, generating the file `output`
- ///
- /// The name `output` should be the name of the library. For backwards compatibility,
- /// the `output` may start with `lib` and end with `.a`. The Rust compilier will create
- /// the assembly with the lib prefix and .a extension. MSVC will create a file without prefix,
- /// ending with `.lib`.
- ///
- /// # Panics
- ///
- /// Panics if `output` is not formatted correctly or if one of the underlying
- /// compiler commands fails. It can also panic if it fails reading file names
- /// or creating directories.
- pub fn compile(&self, output: &str) {
- if let Err(e) = self.try_compile(output) {
- fail(&e.message);
- }
- }
-
- #[cfg(feature = "parallel")]
- fn compile_objects(&self, objs: &[Object]) -> Result<(), Error> {
- use self::rayon::prelude::*;
-
- if let Some(amt) = self.getenv("NUM_JOBS") {
- if let Ok(amt) = amt.parse() {
- let _ = rayon::ThreadPoolBuilder::new()
- .num_threads(amt)
- .build_global();
- }
- }
-
- // Check for any errors and return the first one found.
- objs.par_iter()
- .with_max_len(1)
- .map(|obj| self.compile_object(obj))
- .collect()
- }
-
- #[cfg(not(feature = "parallel"))]
- fn compile_objects(&self, objs: &[Object]) -> Result<(), Error> {
- for obj in objs {
- self.compile_object(obj)?;
- }
- Ok(())
- }
-
- fn compile_object(&self, obj: &Object) -> Result<(), Error> {
- let is_asm = obj.src.extension().and_then(|s| s.to_str()) == Some("asm");
- let target = self.get_target()?;
- let msvc = target.contains("msvc");
- let (mut cmd, name) = if msvc && is_asm {
- self.msvc_macro_assembler()?
- } else {
- let compiler = self.try_get_compiler()?;
- let mut cmd = compiler.to_command();
- for &(ref a, ref b) in self.env.iter() {
- cmd.env(a, b);
- }
- (
- cmd,
- compiler
- .path
- .file_name()
- .ok_or_else(|| Error::new(ErrorKind::IOError, "Failed to get compiler path."))?
- .to_string_lossy()
- .into_owned(),
- )
- };
- let is_arm = target.contains("aarch64") || target.contains("arm");
- command_add_output_file(&mut cmd, &obj.dst, msvc, is_asm, is_arm);
- // armasm and armasm64 don't requrie -c option
- if !msvc || !is_asm || !is_arm {
- cmd.arg(if msvc { "/c" } else { "-c" });
- }
- cmd.arg(&obj.src);
-
- run(&mut cmd, &name)?;
- Ok(())
- }
-
- /// This will return a result instead of panicing; see expand() for the complete description.
- pub fn try_expand(&self) -> Result<Vec<u8>, Error> {
- let compiler = self.try_get_compiler()?;
- let mut cmd = compiler.to_command();
- for &(ref a, ref b) in self.env.iter() {
- cmd.env(a, b);
- }
- cmd.arg(compiler.family.expand_flag());
-
- assert!(
- self.files.len() <= 1,
- "Expand may only be called for a single file"
- );
-
- for file in self.files.iter() {
- cmd.arg(file);
- }
-
- let name = compiler
- .path
- .file_name()
- .ok_or_else(|| Error::new(ErrorKind::IOError, "Failed to get compiler path."))?
- .to_string_lossy()
- .into_owned();
-
- Ok(run_output(&mut cmd, &name)?)
- }
-
- /// Run the compiler, returning the macro-expanded version of the input files.
- ///
- /// This is only relevant for C and C++ files.
- ///
- /// # Panics
- /// Panics if more than one file is present in the config, or if compiler
- /// path has an invalid file name.
- ///
- /// # Example
- /// ```no_run
- /// let out = cc::Build::new().file("src/foo.c").expand();
- /// ```
- pub fn expand(&self) -> Vec<u8> {
- match self.try_expand() {
- Err(e) => fail(&e.message),
- Ok(v) => v,
- }
- }
-
- /// Get the compiler that's in use for this configuration.
- ///
- /// This function will return a `Tool` which represents the culmination
- /// of this configuration at a snapshot in time. The returned compiler can
- /// be inspected (e.g. the path, arguments, environment) to forward along to
- /// other tools, or the `to_command` method can be used to invoke the
- /// compiler itself.
- ///
- /// This method will take into account all configuration such as debug
- /// information, optimization level, include directories, defines, etc.
- /// Additionally, the compiler binary in use follows the standard
- /// conventions for this path, e.g. looking at the explicitly set compiler,
- /// environment variables (a number of which are inspected here), and then
- /// falling back to the default configuration.
- ///
- /// # Panics
- ///
- /// Panics if an error occurred while determining the architecture.
- pub fn get_compiler(&self) -> Tool {
- match self.try_get_compiler() {
- Ok(tool) => tool,
- Err(e) => fail(&e.message),
- }
- }
-
- /// Get the compiler that's in use for this configuration.
- ///
- /// This will return a result instead of panicing; see get_compiler() for the complete description.
- pub fn try_get_compiler(&self) -> Result<Tool, Error> {
- let opt_level = self.get_opt_level()?;
- let target = self.get_target()?;
-
- let mut cmd = self.get_base_compiler()?;
- let envflags = self.envflags(if self.cpp { "CXXFLAGS" } else { "CFLAGS" });
-
- // Disable default flag generation via environment variable or when
- // certain cross compiling arguments are set
- let use_defaults = self.getenv("CRATE_CC_NO_DEFAULTS").is_none();
-
- if use_defaults {
- self.add_default_flags(&mut cmd, &target, &opt_level)?;
- } else {
- println!("Info: default compiler flags are disabled");
- }
-
- for arg in envflags {
- cmd.push_cc_arg(arg.into());
- }
-
- for directory in self.include_directories.iter() {
- cmd.args.push(cmd.family.include_flag().into());
- cmd.args.push(directory.into());
- }
-
- // If warnings and/or extra_warnings haven't been explicitly set,
- // then we set them only if the environment doesn't already have
- // CFLAGS/CXXFLAGS, since those variables presumably already contain
- // the desired set of warnings flags.
-
- if self
- .warnings
- .unwrap_or(if self.has_flags() { false } else { true })
- {
- let wflags = cmd.family.warnings_flags().into();
- cmd.push_cc_arg(wflags);
- }
-
- if self
- .extra_warnings
- .unwrap_or(if self.has_flags() { false } else { true })
- {
- if let Some(wflags) = cmd.family.extra_warnings_flags() {
- cmd.push_cc_arg(wflags.into());
- }
- }
-
- for flag in self.flags.iter() {
- cmd.args.push(flag.into());
- }
-
- for flag in self.flags_supported.iter() {
- if self.is_flag_supported(flag).unwrap_or(false) {
- cmd.push_cc_arg(flag.into());
- }
- }
-
- for &(ref key, ref value) in self.definitions.iter() {
- let lead = if let ToolFamily::Msvc { .. } = cmd.family {
- "/"
- } else {
- "-"
- };
- if let Some(ref value) = *value {
- cmd.args.push(format!("{}D{}={}", lead, key, value).into());
- } else {
- cmd.args.push(format!("{}D{}", lead, key).into());
- }
- }
-
- if self.warnings_into_errors {
- let warnings_to_errors_flag = cmd.family.warnings_to_errors_flag().into();
- cmd.push_cc_arg(warnings_to_errors_flag);
- }
-
- Ok(cmd)
- }
-
- fn add_default_flags(
- &self,
- cmd: &mut Tool,
- target: &str,
- opt_level: &str,
- ) -> Result<(), Error> {
- // Non-target flags
- // If the flag is not conditioned on target variable, it belongs here :)
- match cmd.family {
- ToolFamily::Msvc { .. } => {
- assert!(!self.cuda,
- "CUDA C++ compilation not supported for MSVC, yet... but you are welcome to implement it :)");
-
- cmd.args.push("/nologo".into());
-
- let crt_flag = match self.static_crt {
- Some(true) => "/MT",
- Some(false) => "/MD",
- None => {
- let features = self
- .getenv("CARGO_CFG_TARGET_FEATURE")
- .unwrap_or(String::new());
- if features.contains("crt-static") {
- "/MT"
- } else {
- "/MD"
- }
- }
- };
- cmd.args.push(crt_flag.into());
-
- match &opt_level[..] {
- // Msvc uses /O1 to enable all optimizations that minimize code size.
- "z" | "s" | "1" => cmd.push_opt_unless_duplicate("/O1".into()),
- // -O3 is a valid value for gcc and clang compilers, but not msvc. Cap to /O2.
- "2" | "3" => cmd.push_opt_unless_duplicate("/O2".into()),
- _ => {}
- }
- }
- ToolFamily::Gnu | ToolFamily::Clang => {
- // arm-linux-androideabi-gcc 4.8 shipped with Android NDK does
- // not support '-Oz'
- if opt_level == "z" && cmd.family != ToolFamily::Clang {
- cmd.push_opt_unless_duplicate("-Os".into());
- } else {
- cmd.push_opt_unless_duplicate(format!("-O{}", opt_level).into());
- }
-
- if !target.contains("-ios") {
- cmd.push_cc_arg("-ffunction-sections".into());
- cmd.push_cc_arg("-fdata-sections".into());
- }
- if self.pic.unwrap_or(!target.contains("windows-gnu")) {
- cmd.push_cc_arg("-fPIC".into());
- // PLT only applies if code is compiled with PIC support,
- // and only for ELF targets.
- if target.contains("linux") && !self.use_plt.unwrap_or(true) {
- cmd.push_cc_arg("-fno-plt".into());
- }
- }
- }
- }
-
- if self.get_debug() {
- if self.cuda {
- let nvcc_debug_flag = cmd.family.nvcc_debug_flag().into();
- cmd.args.push(nvcc_debug_flag);
- }
- let family = cmd.family;
- family.add_debug_flags(cmd);
- }
-
- // Target flags
- match cmd.family {
- ToolFamily::Clang => {
- cmd.args.push(format!("--target={}", target).into());
- }
- ToolFamily::Msvc { clang_cl } => {
- if clang_cl {
- if target.contains("x86_64") {
- cmd.args.push("-m64".into());
- } else if target.contains("86") {
- cmd.args.push("-m32".into());
- cmd.args.push("/arch:IA32".into());
- } else {
- cmd.args.push(format!("--target={}", target).into());
- }
- } else {
- if target.contains("i586") {
- cmd.args.push("/ARCH:IA32".into());
- }
- }
-
- // There is a check in corecrt.h that will generate a
- // compilation error if
- // _ARM_WINAPI_PARTITION_DESKTOP_SDK_AVAILABLE is
- // not defined to 1. The check was added in Windows
- // 8 days because only store apps were allowed on ARM.
- // This changed with the release of Windows 10 IoT Core.
- // The check will be going away in future versions of
- // the SDK, but for all released versions of the
- // Windows SDK it is required.
- if target.contains("arm") || target.contains("thumb") {
- cmd.args
- .push("/D_ARM_WINAPI_PARTITION_DESKTOP_SDK_AVAILABLE=1".into());
- }
- }
- ToolFamily::Gnu => {
- if target.contains("i686") || target.contains("i586") {
- cmd.args.push("-m32".into());
- } else if target == "x86_64-unknown-linux-gnux32" {
- cmd.args.push("-mx32".into());
- } else if target.contains("x86_64") || target.contains("powerpc64") {
- cmd.args.push("-m64".into());
- }
-
- if self.static_flag.is_none() {
- let features = self
- .getenv("CARGO_CFG_TARGET_FEATURE")
- .unwrap_or(String::new());
- if features.contains("crt-static") {
- cmd.args.push("-static".into());
- }
- }
-
- // armv7 targets get to use armv7 instructions
- if (target.starts_with("armv7") || target.starts_with("thumbv7"))
- && target.contains("-linux-")
- {
- cmd.args.push("-march=armv7-a".into());
- }
-
- // (x86 Android doesn't say "eabi")
- if target.contains("-androideabi") && target.contains("v7") {
- // -march=armv7-a handled above
- cmd.args.push("-mthumb".into());
- if !target.contains("neon") {
- // On android we can guarantee some extra float instructions
- // (specified in the android spec online)
- // NEON guarantees even more; see below.
- cmd.args.push("-mfpu=vfpv3-d16".into());
- }
- cmd.args.push("-mfloat-abi=softfp".into());
- }
-
- if target.contains("neon") {
- cmd.args.push("-mfpu=neon-vfpv4".into());
- }
-
- if target.starts_with("armv4t-unknown-linux-") {
- cmd.args.push("-march=armv4t".into());
- cmd.args.push("-marm".into());
- cmd.args.push("-mfloat-abi=soft".into());
- }
-
- if target.starts_with("armv5te-unknown-linux-") {
- cmd.args.push("-march=armv5te".into());
- cmd.args.push("-marm".into());
- cmd.args.push("-mfloat-abi=soft".into());
- }
-
- // For us arm == armv6 by default
- if target.starts_with("arm-unknown-linux-") {
- cmd.args.push("-march=armv6".into());
- cmd.args.push("-marm".into());
- if target.ends_with("hf") {
- cmd.args.push("-mfpu=vfp".into());
- } else {
- cmd.args.push("-mfloat-abi=soft".into());
- }
- }
-
- // We can guarantee some settings for FRC
- if target.starts_with("arm-frc-") {
- cmd.args.push("-march=armv7-a".into());
- cmd.args.push("-mcpu=cortex-a9".into());
- cmd.args.push("-mfpu=vfpv3".into());
- cmd.args.push("-mfloat-abi=softfp".into());
- cmd.args.push("-marm".into());
- }
-
- // Turn codegen down on i586 to avoid some instructions.
- if target.starts_with("i586-unknown-linux-") {
- cmd.args.push("-march=pentium".into());
- }
-
- // Set codegen level for i686 correctly
- if target.starts_with("i686-unknown-linux-") {
- cmd.args.push("-march=i686".into());
- }
-
- // Looks like `musl-gcc` makes is hard for `-m32` to make its way
- // all the way to the linker, so we need to actually instruct the
- // linker that we're generating 32-bit executables as well. This'll
- // typically only be used for build scripts which transitively use
- // these flags that try to compile executables.
- if target == "i686-unknown-linux-musl" || target == "i586-unknown-linux-musl" {
- cmd.args.push("-Wl,-melf_i386".into());
- }
-
- if target.starts_with("thumb") {
- cmd.args.push("-mthumb".into());
-
- if target.ends_with("eabihf") {
- cmd.args.push("-mfloat-abi=hard".into())
- }
- }
- if target.starts_with("thumbv6m") {
- cmd.args.push("-march=armv6s-m".into());
- }
- if target.starts_with("thumbv7em") {
- cmd.args.push("-march=armv7e-m".into());
-
- if target.ends_with("eabihf") {
- cmd.args.push("-mfpu=fpv4-sp-d16".into())
- }
- }
- if target.starts_with("thumbv7m") {
- cmd.args.push("-march=armv7-m".into());
- }
- if target.starts_with("thumbv8m.base") {
- cmd.args.push("-march=armv8-m.base".into());
- }
- if target.starts_with("thumbv8m.main") {
- cmd.args.push("-march=armv8-m.main".into());
-
- if target.ends_with("eabihf") {
- cmd.args.push("-mfpu=fpv5-sp-d16".into())
- }
- }
- if target.starts_with("armebv7r") | target.starts_with("armv7r") {
- if target.starts_with("armeb") {
- cmd.args.push("-mbig-endian".into());
- } else {
- cmd.args.push("-mlittle-endian".into());
- }
-
- // ARM mode
- cmd.args.push("-marm".into());
-
- // R Profile
- cmd.args.push("-march=armv7-r".into());
-
- if target.ends_with("eabihf") {
- // Calling convention
- cmd.args.push("-mfloat-abi=hard".into());
-
- // lowest common denominator FPU
- // (see Cortex-R4 technical reference manual)
- cmd.args.push("-mfpu=vfpv3-d16".into())
- } else {
- // Calling convention
- cmd.args.push("-mfloat-abi=soft".into());
- }
- }
- }
- }
-
- if target.contains("-ios") {
- // FIXME: potential bug. iOS is always compiled with Clang, but Gcc compiler may be
- // detected instead.
- self.ios_flags(cmd)?;
- }
-
- if self.static_flag.unwrap_or(false) {
- cmd.args.push("-static".into());
- }
- if self.shared_flag.unwrap_or(false) {
- cmd.args.push("-shared".into());
- }
-
- if self.cpp {
- match (self.cpp_set_stdlib.as_ref(), cmd.family) {
- (None, _) => {}
- (Some(stdlib), ToolFamily::Gnu) | (Some(stdlib), ToolFamily::Clang) => {
- cmd.push_cc_arg(format!("-stdlib=lib{}", stdlib).into());
- }
- _ => {
- println!(
- "cargo:warning=cpp_set_stdlib is specified, but the {:?} compiler \
- does not support this option, ignored",
- cmd.family
- );
- }
- }
- }
-
- Ok(())
- }
-
- fn has_flags(&self) -> bool {
- let flags_env_var_name = if self.cpp { "CXXFLAGS" } else { "CFLAGS" };
- let flags_env_var_value = self.get_var(flags_env_var_name);
- if let Ok(_) = flags_env_var_value {
- true
- } else {
- false
- }
- }
-
- fn msvc_macro_assembler(&self) -> Result<(Command, String), Error> {
- let target = self.get_target()?;
- let tool = if target.contains("x86_64") {
- "ml64.exe"
- } else if target.contains("arm") {
- "armasm.exe"
- } else if target.contains("aarch64") {
- "armasm64.exe"
- } else {
- "ml.exe"
- };
- let mut cmd = windows_registry::find(&target, tool).unwrap_or_else(|| self.cmd(tool));
- for directory in self.include_directories.iter() {
- cmd.arg("/I").arg(directory);
- }
- for &(ref key, ref value) in self.definitions.iter() {
- if let Some(ref value) = *value {
- cmd.arg(&format!("/D{}={}", key, value));
- } else {
- cmd.arg(&format!("/D{}", key));
- }
- }
-
- if target.contains("i686") || target.contains("i586") {
- cmd.arg("/safeseh");
- }
- for flag in self.flags.iter() {
- cmd.arg(flag);
- }
-
- Ok((cmd, tool.to_string()))
- }
-
- fn assemble(&self, lib_name: &str, dst: &Path, objs: &[Object]) -> Result<(), Error> {
- // Delete the destination if it exists as the `ar` tool at least on Unix
- // appends to it, which we don't want.
- let _ = fs::remove_file(&dst);
-
- let objects: Vec<_> = objs.iter().map(|obj| obj.dst.clone()).collect();
- let target = self.get_target()?;
- if target.contains("msvc") {
- let (mut cmd, program) = self.get_ar()?;
- let mut out = OsString::from("/OUT:");
- out.push(dst);
- cmd.arg(out).arg("/nologo");
-
- // Similar to https://github.com/rust-lang/rust/pull/47507
- // and https://github.com/rust-lang/rust/pull/48548
- let estimated_command_line_len = objects
- .iter()
- .chain(&self.objects)
- .map(|a| a.as_os_str().len())
- .sum::<usize>();
- if estimated_command_line_len > 1024 * 6 {
- let mut args = String::from("\u{FEFF}"); // BOM
- for arg in objects.iter().chain(&self.objects) {
- args.push('"');
- for c in arg.to_str().unwrap().chars() {
- if c == '"' {
- args.push('\\')
- }
- args.push(c)
- }
- args.push('"');
- args.push('\n');
- }
-
- let mut utf16le = Vec::new();
- for code_unit in args.encode_utf16() {
- utf16le.push(code_unit as u8);
- utf16le.push((code_unit >> 8) as u8);
- }
-
- let mut args_file = OsString::from(dst);
- args_file.push(".args");
- fs::File::create(&args_file)
- .unwrap()
- .write_all(&utf16le)
- .unwrap();
-
- let mut args_file_arg = OsString::from("@");
- args_file_arg.push(args_file);
- cmd.arg(args_file_arg);
- } else {
- cmd.args(&objects).args(&self.objects);
- }
- run(&mut cmd, &program)?;
-
- // The Rust compiler will look for libfoo.a and foo.lib, but the
- // MSVC linker will also be passed foo.lib, so be sure that both
- // exist for now.
- let lib_dst = dst.with_file_name(format!("{}.lib", lib_name));
- let _ = fs::remove_file(&lib_dst);
- match fs::hard_link(&dst, &lib_dst).or_else(|_| {
- // if hard-link fails, just copy (ignoring the number of bytes written)
- fs::copy(&dst, &lib_dst).map(|_| ())
- }) {
- Ok(_) => (),
- Err(_) => {
- return Err(Error::new(
- ErrorKind::IOError,
- "Could not copy or create a hard-link to the generated lib file.",
- ));
- }
- };
- } else {
- let (mut ar, cmd) = self.get_ar()?;
- run(
- ar.arg("crs").arg(dst).args(&objects).args(&self.objects),
- &cmd,
- )?;
- }
-
- Ok(())
- }
-
- fn ios_flags(&self, cmd: &mut Tool) -> Result<(), Error> {
- enum ArchSpec {
- Device(&'static str),
- Simulator(&'static str),
- }
-
- let target = self.get_target()?;
- let arch = target.split('-').nth(0).ok_or_else(|| {
- Error::new(
- ErrorKind::ArchitectureInvalid,
- "Unknown architecture for iOS target.",
- )
- })?;
- let arch = match arch {
- "arm" | "armv7" | "thumbv7" => ArchSpec::Device("armv7"),
- "armv7s" | "thumbv7s" => ArchSpec::Device("armv7s"),
- "arm64" | "aarch64" => ArchSpec::Device("arm64"),
- "i386" | "i686" => ArchSpec::Simulator("-m32"),
- "x86_64" => ArchSpec::Simulator("-m64"),
- _ => {
- return Err(Error::new(
- ErrorKind::ArchitectureInvalid,
- "Unknown architecture for iOS target.",
- ));
- }
- };
-
- let sdk = match arch {
- ArchSpec::Device(arch) => {
- cmd.args.push("-arch".into());
- cmd.args.push(arch.into());
- cmd.args.push("-miphoneos-version-min=7.0".into());
- "iphoneos"
- }
- ArchSpec::Simulator(arch) => {
- cmd.args.push(arch.into());
- cmd.args.push("-mios-simulator-version-min=7.0".into());
- "iphonesimulator"
- }
- };
-
- self.print(&format!("Detecting iOS SDK path for {}", sdk));
- let sdk_path = self
- .cmd("xcrun")
- .arg("--show-sdk-path")
- .arg("--sdk")
- .arg(sdk)
- .stderr(Stdio::inherit())
- .output()?
- .stdout;
-
- let sdk_path = match String::from_utf8(sdk_path) {
- Ok(p) => p,
- Err(_) => {
- return Err(Error::new(
- ErrorKind::IOError,
- "Unable to determine iOS SDK path.",
- ));
- }
- };
-
- cmd.args.push("-isysroot".into());
- cmd.args.push(sdk_path.trim().into());
- cmd.args.push("-fembed-bitcode".into());
- /*
- * TODO we probably ultimatedly want the -fembed-bitcode-marker flag
- * but can't have it now because of an issue in LLVM:
- * https://github.com/alexcrichton/cc-rs/issues/301
- * https://github.com/rust-lang/rust/pull/48896#comment-372192660
- */
- /*
- if self.get_opt_level()? == "0" {
- cmd.args.push("-fembed-bitcode-marker".into());
- }
- */
-
- Ok(())
- }
-
- fn cmd<P: AsRef<OsStr>>(&self, prog: P) -> Command {
- let mut cmd = Command::new(prog);
- for &(ref a, ref b) in self.env.iter() {
- cmd.env(a, b);
- }
- cmd
- }
-
- fn get_base_compiler(&self) -> Result<Tool, Error> {
- if let Some(ref c) = self.compiler {
- return Ok(Tool::new(c.clone()));
- }
- let host = self.get_host()?;
- let target = self.get_target()?;
- let (env, msvc, gnu, traditional, clang) = if self.cpp {
- ("CXX", "cl.exe", "g++", "c++", "clang++")
- } else {
- ("CC", "cl.exe", "gcc", "cc", "clang")
- };
-
- // On Solaris, c++/cc unlikely to exist or be correct.
- let default = if host.contains("solaris") {
- gnu
- } else {
- traditional
- };
-
- let cl_exe = windows_registry::find_tool(&target, "cl.exe");
-
- let tool_opt: Option<Tool> = self
- .env_tool(env)
- .map(|(tool, cc, args)| {
- // chop off leading/trailing whitespace to work around
- // semi-buggy build scripts which are shared in
- // makefiles/configure scripts (where spaces are far more
- // lenient)
- let mut t = Tool::new(PathBuf::from(tool.trim()));
- if let Some(cc) = cc {
- t.cc_wrapper_path = Some(PathBuf::from(cc));
- }
- for arg in args {
- t.cc_wrapper_args.push(arg.into());
- }
- t
- })
- .or_else(|| {
- if target.contains("emscripten") {
- let tool = if self.cpp { "em++" } else { "emcc" };
- // Windows uses bat file so we have to be a bit more specific
- if cfg!(windows) {
- let mut t = Tool::new(PathBuf::from("cmd"));
- t.args.push("/c".into());
- t.args.push(format!("{}.bat", tool).into());
- Some(t)
- } else {
- Some(Tool::new(PathBuf::from(tool)))
- }
- } else {
- None
- }
- })
- .or_else(|| cl_exe.clone());
-
- let tool = match tool_opt {
- Some(t) => t,
- None => {
- let compiler = if host.contains("windows") && target.contains("windows") {
- if target.contains("msvc") {
- msvc.to_string()
- } else {
- format!("{}.exe", gnu)
- }
- } else if target.contains("android") {
- let target = target
- .replace("armv7neon", "arm")
- .replace("armv7", "arm")
- .replace("thumbv7neon", "arm")
- .replace("thumbv7", "arm");
- let gnu_compiler = format!("{}-{}", target, gnu);
- let clang_compiler = format!("{}-{}", target, clang);
- // Check if gnu compiler is present
- // if not, use clang
- if Command::new(&gnu_compiler).spawn().is_ok() {
- gnu_compiler
- } else {
- clang_compiler
- }
- } else if target.contains("cloudabi") {
- format!("{}-{}", target, traditional)
- } else if target == "wasm32-wasi" ||
- target == "wasm32-unknown-wasi" ||
- target == "wasm32-unknown-unknown" {
- "clang".to_string()
- } else if self.get_host()? != target {
- // CROSS_COMPILE is of the form: "arm-linux-gnueabi-"
- let cc_env = self.getenv("CROSS_COMPILE");
- let cross_compile = cc_env.as_ref().map(|s| s.trim_right_matches('-'));
- let prefix = cross_compile.or(match &target[..] {
- "aarch64-unknown-linux-gnu" => Some("aarch64-linux-gnu"),
- "aarch64-unknown-linux-musl" => Some("aarch64-linux-musl"),
- "aarch64-unknown-netbsd" => Some("aarch64--netbsd"),
- "arm-unknown-linux-gnueabi" => Some("arm-linux-gnueabi"),
- "armv4t-unknown-linux-gnueabi" => Some("arm-linux-gnueabi"),
- "armv5te-unknown-linux-gnueabi" => Some("arm-linux-gnueabi"),
- "arm-frc-linux-gnueabi" => Some("arm-frc-linux-gnueabi"),
- "arm-unknown-linux-gnueabihf" => Some("arm-linux-gnueabihf"),
- "arm-unknown-linux-musleabi" => Some("arm-linux-musleabi"),
- "arm-unknown-linux-musleabihf" => Some("arm-linux-musleabihf"),
- "arm-unknown-netbsd-eabi" => Some("arm--netbsdelf-eabi"),
- "armv6-unknown-netbsd-eabihf" => Some("armv6--netbsdelf-eabihf"),
- "armv7-unknown-linux-gnueabihf" => Some("arm-linux-gnueabihf"),
- "armv7-unknown-linux-musleabihf" => Some("arm-linux-musleabihf"),
- "armv7neon-unknown-linux-gnueabihf" => Some("arm-linux-gnueabihf"),
- "armv7neon-unknown-linux-musleabihf" => Some("arm-linux-musleabihf"),
- "thumbv7-unknown-linux-gnueabihf" => Some("arm-linux-gnueabihf"),
- "thumbv7-unknown-linux-musleabihf" => Some("arm-linux-musleabihf"),
- "thumbv7neon-unknown-linux-gnueabihf" => Some("arm-linux-gnueabihf"),
- "thumbv7neon-unknown-linux-musleabihf" => Some("arm-linux-musleabihf"),
- "armv7-unknown-netbsd-eabihf" => Some("armv7--netbsdelf-eabihf"),
- "i586-unknown-linux-musl" => Some("musl"),
- "i686-pc-windows-gnu" => Some("i686-w64-mingw32"),
- "i686-unknown-linux-musl" => Some("musl"),
- "i686-unknown-netbsd" => Some("i486--netbsdelf"),
- "mips-unknown-linux-gnu" => Some("mips-linux-gnu"),
- "mipsel-unknown-linux-gnu" => Some("mipsel-linux-gnu"),
- "mips64-unknown-linux-gnuabi64" => Some("mips64-linux-gnuabi64"),
- "mips64el-unknown-linux-gnuabi64" => Some("mips64el-linux-gnuabi64"),
- "mipsisa32r6-unknown-linux-gnu" => Some("mipsisa32r6-linux-gnu"),
- "mipsisa32r6el-unknown-linux-gnu" => Some("mipsisa32r6el-linux-gnu"),
- "mipsisa64r6-unknown-linux-gnuabi64" => Some("mipsisa64r6-linux-gnuabi64"),
- "mipsisa64r6el-unknown-linux-gnuabi64" => {
- Some("mipsisa64r6el-linux-gnuabi64")
- }
- "powerpc-unknown-linux-gnu" => Some("powerpc-linux-gnu"),
- "powerpc-unknown-linux-gnuspe" => Some("powerpc-linux-gnuspe"),
- "powerpc-unknown-netbsd" => Some("powerpc--netbsd"),
- "powerpc64-unknown-linux-gnu" => Some("powerpc-linux-gnu"),
- "powerpc64le-unknown-linux-gnu" => Some("powerpc64le-linux-gnu"),
- "s390x-unknown-linux-gnu" => Some("s390x-linux-gnu"),
- "sparc-unknown-linux-gnu" => Some("sparc-linux-gnu"),
- "sparc64-unknown-linux-gnu" => Some("sparc64-linux-gnu"),
- "sparc64-unknown-netbsd" => Some("sparc64--netbsd"),
- "sparcv9-sun-solaris" => Some("sparcv9-sun-solaris"),
- "armebv7r-none-eabi" => Some("arm-none-eabi"),
- "armebv7r-none-eabihf" => Some("arm-none-eabi"),
- "armv7r-none-eabi" => Some("arm-none-eabi"),
- "armv7r-none-eabihf" => Some("arm-none-eabi"),
- "thumbv6m-none-eabi" => Some("arm-none-eabi"),
- "thumbv7em-none-eabi" => Some("arm-none-eabi"),
- "thumbv7em-none-eabihf" => Some("arm-none-eabi"),
- "thumbv7m-none-eabi" => Some("arm-none-eabi"),
- "thumbv8m.base-none-eabi" => Some("arm-none-eabi"),
- "thumbv8m.main-none-eabi" => Some("arm-none-eabi"),
- "thumbv8m.main-none-eabihf" => Some("arm-none-eabi"),
- "x86_64-pc-windows-gnu" => Some("x86_64-w64-mingw32"),
- "x86_64-rumprun-netbsd" => Some("x86_64-rumprun-netbsd"),
- "x86_64-unknown-linux-musl" => Some("musl"),
- "x86_64-unknown-netbsd" => Some("x86_64--netbsd"),
- _ => None,
- });
- match prefix {
- Some(prefix) => format!("{}-{}", prefix, gnu),
- None => default.to_string(),
- }
- } else {
- default.to_string()
- };
- Tool::new(PathBuf::from(compiler))
- }
- };
-
- let mut tool = if self.cuda {
- assert!(
- tool.args.is_empty(),
- "CUDA compilation currently assumes empty pre-existing args"
- );
- let nvcc = match self.get_var("NVCC") {
- Err(_) => "nvcc".into(),
- Ok(nvcc) => nvcc,
- };
- let mut nvcc_tool = Tool::with_features(PathBuf::from(nvcc), self.cuda);
- nvcc_tool
- .args
- .push(format!("-ccbin={}", tool.path.display()).into());
- nvcc_tool
- } else {
- tool
- };
-
- // If we found `cl.exe` in our environment, the tool we're returning is
- // an MSVC-like tool, *and* no env vars were set then set env vars for
- // the tool that we're returning.
- //
- // Env vars are needed for things like `link.exe` being put into PATH as
- // well as header include paths sometimes. These paths are automatically
- // included by default but if the `CC` or `CXX` env vars are set these
- // won't be used. This'll ensure that when the env vars are used to
- // configure for invocations like `clang-cl` we still get a "works out
- // of the box" experience.
- if let Some(cl_exe) = cl_exe {
- if tool.family == (ToolFamily::Msvc { clang_cl: true })
- && tool.env.len() == 0
- && target.contains("msvc")
- {
- for &(ref k, ref v) in cl_exe.env.iter() {
- tool.env.push((k.to_owned(), v.to_owned()));
- }
- }
- }
-
- Ok(tool)
- }
-
- fn get_var(&self, var_base: &str) -> Result<String, Error> {
- let target = self.get_target()?;
- let host = self.get_host()?;
- let kind = if host == target { "HOST" } else { "TARGET" };
- let target_u = target.replace("-", "_");
- let res = self
- .getenv(&format!("{}_{}", var_base, target))
- .or_else(|| self.getenv(&format!("{}_{}", var_base, target_u)))
- .or_else(|| self.getenv(&format!("{}_{}", kind, var_base)))
- .or_else(|| self.getenv(var_base));
-
- match res {
- Some(res) => Ok(res),
- None => Err(Error::new(
- ErrorKind::EnvVarNotFound,
- &format!("Could not find environment variable {}.", var_base),
- )),
- }
- }
-
- fn envflags(&self, name: &str) -> Vec<String> {
- self.get_var(name)
- .unwrap_or(String::new())
- .split(|c: char| c.is_whitespace())
- .filter(|s| !s.is_empty())
- .map(|s| s.to_string())
- .collect()
- }
-
- /// Returns compiler path, optional modifier name from whitelist, and arguments vec
- fn env_tool(&self, name: &str) -> Option<(String, Option<String>, Vec<String>)> {
- let tool = match self.get_var(name) {
- Ok(tool) => tool,
- Err(_) => return None,
- };
-
- // If this is an exact path on the filesystem we don't want to do any
- // interpretation at all, just pass it on through. This'll hopefully get
- // us to support spaces-in-paths.
- if Path::new(&tool).exists() {
- return Some((tool, None, Vec::new()));
- }
-
- // Ok now we want to handle a couple of scenarios. We'll assume from
- // here on out that spaces are splitting separate arguments. Two major
- // features we want to support are:
- //
- // CC='sccache cc'
- //
- // aka using `sccache` or any other wrapper/caching-like-thing for
- // compilations. We want to know what the actual compiler is still,
- // though, because our `Tool` API support introspection of it to see
- // what compiler is in use.
- //
- // additionally we want to support
- //
- // CC='cc -flag'
- //
- // where the CC env var is used to also pass default flags to the C
- // compiler.
- //
- // It's true that everything here is a bit of a pain, but apparently if
- // you're not literally make or bash then you get a lot of bug reports.
- let known_wrappers = ["ccache", "distcc", "sccache", "icecc"];
-
- let mut parts = tool.split_whitespace();
- let maybe_wrapper = match parts.next() {
- Some(s) => s,
- None => return None,
- };
-
- let file_stem = Path::new(maybe_wrapper)
- .file_stem()
- .unwrap()
- .to_str()
- .unwrap();
- if known_wrappers.contains(&file_stem) {
- if let Some(compiler) = parts.next() {
- return Some((
- compiler.to_string(),
- Some(maybe_wrapper.to_string()),
- parts.map(|s| s.to_string()).collect(),
- ));
- }
- }
-
- Some((
- maybe_wrapper.to_string(),
- None,
- parts.map(|s| s.to_string()).collect(),
- ))
- }
-
- /// Returns the default C++ standard library for the current target: `libc++`
- /// for OS X and `libstdc++` for anything else.
- fn get_cpp_link_stdlib(&self) -> Result<Option<String>, Error> {
- match self.cpp_link_stdlib.clone() {
- Some(s) => Ok(s),
- None => {
- if let Ok(stdlib) = self.get_var("CXXSTDLIB") {
- if stdlib.is_empty() {
- Ok(None)
- } else {
- Ok(Some(stdlib))
- }
- } else {
- let target = self.get_target()?;
- if target.contains("msvc") {
- Ok(None)
- } else if target.contains("apple") {
- Ok(Some("c++".to_string()))
- } else if target.contains("freebsd") {
- Ok(Some("c++".to_string()))
- } else if target.contains("openbsd") {
- Ok(Some("c++".to_string()))
- } else {
- Ok(Some("stdc++".to_string()))
- }
- }
- }
- }
- }
-
- fn get_ar(&self) -> Result<(Command, String), Error> {
- if let Some(ref p) = self.archiver {
- let name = p.file_name().and_then(|s| s.to_str()).unwrap_or("ar");
- return Ok((self.cmd(p), name.to_string()));
- }
- if let Ok(p) = self.get_var("AR") {
- return Ok((self.cmd(&p), p));
- }
- let target = self.get_target()?;
- let program = if target.contains("android") {
- format!("{}-ar", target.replace("armv7", "arm"))
- } else if target.contains("emscripten") {
- // Windows use bat files so we have to be a bit more specific
- if cfg!(windows) {
- let mut cmd = self.cmd("cmd");
- cmd.arg("/c").arg("emar.bat");
- return Ok((cmd, "emar.bat".to_string()));
- }
-
- "emar".to_string()
- } else if target.contains("msvc") {
- match windows_registry::find(&target, "lib.exe") {
- Some(t) => return Ok((t, "lib.exe".to_string())),
- None => "lib.exe".to_string(),
- }
- } else {
- "ar".to_string()
- };
- Ok((self.cmd(&program), program))
- }
-
- fn get_target(&self) -> Result<String, Error> {
- match self.target.clone() {
- Some(t) => Ok(t),
- None => Ok(self.getenv_unwrap("TARGET")?),
- }
- }
-
- fn get_host(&self) -> Result<String, Error> {
- match self.host.clone() {
- Some(h) => Ok(h),
- None => Ok(self.getenv_unwrap("HOST")?),
- }
- }
-
- fn get_opt_level(&self) -> Result<String, Error> {
- match self.opt_level.as_ref().cloned() {
- Some(ol) => Ok(ol),
- None => Ok(self.getenv_unwrap("OPT_LEVEL")?),
- }
- }
-
- fn get_debug(&self) -> bool {
- self.debug.unwrap_or_else(|| match self.getenv("DEBUG") {
- Some(s) => s != "false",
- None => false,
- })
- }
-
- fn get_out_dir(&self) -> Result<PathBuf, Error> {
- match self.out_dir.clone() {
- Some(p) => Ok(p),
- None => Ok(env::var_os("OUT_DIR").map(PathBuf::from).ok_or_else(|| {
- Error::new(
- ErrorKind::EnvVarNotFound,
- "Environment variable OUT_DIR not defined.",
- )
- })?),
- }
- }
-
- fn getenv(&self, v: &str) -> Option<String> {
- let mut cache = self.env_cache.lock().unwrap();
- if let Some(val) = cache.get(v) {
- return val.clone();
- }
- let r = env::var(v).ok();
- self.print(&format!("{} = {:?}", v, r));
- cache.insert(v.to_string(), r.clone());
- r
- }
-
- fn getenv_unwrap(&self, v: &str) -> Result<String, Error> {
- match self.getenv(v) {
- Some(s) => Ok(s),
- None => Err(Error::new(
- ErrorKind::EnvVarNotFound,
- &format!("Environment variable {} not defined.", v.to_string()),
- )),
- }
- }
-
- fn print(&self, s: &str) {
- if self.cargo_metadata {
- println!("{}", s);
- }
- }
-}
-
-impl Default for Build {
- fn default() -> Build {
- Build::new()
- }
-}
-
-impl Tool {
- fn new(path: PathBuf) -> Tool {
- Tool::with_features(path, false)
- }
-
- fn with_features(path: PathBuf, cuda: bool) -> Tool {
- // Try to detect family of the tool from its name, falling back to Gnu.
- let family = if let Some(fname) = path.file_name().and_then(|p| p.to_str()) {
- if fname.contains("clang-cl") {
- ToolFamily::Msvc { clang_cl: true }
- } else if fname.contains("cl")
- && !fname.contains("cloudabi")
- && !fname.contains("uclibc")
- && !fname.contains("clang")
- {
- ToolFamily::Msvc { clang_cl: false }
- } else if fname.contains("clang") {
- ToolFamily::Clang
- } else {
- ToolFamily::Gnu
- }
- } else {
- ToolFamily::Gnu
- };
- Tool {
- path: path,
- cc_wrapper_path: None,
- cc_wrapper_args: Vec::new(),
- args: Vec::new(),
- env: Vec::new(),
- family: family,
- cuda: cuda,
- removed_args: Vec::new(),
- }
- }
-
- /// Add an argument to be stripped from the final command arguments.
- fn remove_arg(&mut self, flag: OsString) {
- self.removed_args.push(flag);
- }
-
- /// Add a flag, and optionally prepend the NVCC wrapper flag "-Xcompiler".
- ///
- /// Currently this is only used for compiling CUDA sources, since NVCC only
- /// accepts a limited set of GNU-like flags, and the rest must be prefixed
- /// with a "-Xcompiler" flag to get passed to the underlying C++ compiler.
- fn push_cc_arg(&mut self, flag: OsString) {
- if self.cuda {
- self.args.push(self.family.nvcc_redirect_flag().into());
- }
- self.args.push(flag);
- }
-
- fn is_duplicate_opt_arg(&self, flag: &OsString) -> bool {
- let flag = flag.to_str().unwrap();
- let mut chars = flag.chars();
-
- // Only duplicate check compiler flags
- if self.is_like_msvc() {
- if chars.next() != Some('/') {
- return false;
- }
- } else if self.is_like_gnu() || self.is_like_clang() {
- if chars.next() != Some('-') {
- return false;
- }
- }
-
- // Check for existing optimization flags (-O, /O)
- if chars.next() == Some('O') {
- return self
- .args()
- .iter()
- .any(|ref a| a.to_str().unwrap_or("").chars().nth(1) == Some('O'));
- }
-
- // TODO Check for existing -m..., -m...=..., /arch:... flags
- return false;
- }
-
- /// Don't push optimization arg if it conflicts with existing args
- fn push_opt_unless_duplicate(&mut self, flag: OsString) {
- if self.is_duplicate_opt_arg(&flag) {
- println!("Info: Ignoring duplicate arg {:?}", &flag);
- } else {
- self.push_cc_arg(flag);
- }
- }
-
- /// Converts this compiler into a `Command` that's ready to be run.
- ///
- /// This is useful for when the compiler needs to be executed and the
- /// command returned will already have the initial arguments and environment
- /// variables configured.
- pub fn to_command(&self) -> Command {
- let mut cmd = match self.cc_wrapper_path {
- Some(ref cc_wrapper_path) => {
- let mut cmd = Command::new(&cc_wrapper_path);
- cmd.arg(&self.path);
- cmd
- }
- None => Command::new(&self.path),
- };
- cmd.args(&self.cc_wrapper_args);
-
- let value = self
- .args
- .iter()
- .filter(|a| !self.removed_args.contains(a))
- .collect::<Vec<_>>();
- cmd.args(&value);
-
- for &(ref k, ref v) in self.env.iter() {
- cmd.env(k, v);
- }
- cmd
- }
-
- /// Returns the path for this compiler.
- ///
- /// Note that this may not be a path to a file on the filesystem, e.g. "cc",
- /// but rather something which will be resolved when a process is spawned.
- pub fn path(&self) -> &Path {
- &self.path
- }
-
- /// Returns the default set of arguments to the compiler needed to produce
- /// executables for the target this compiler generates.
- pub fn args(&self) -> &[OsString] {
- &self.args
- }
-
- /// Returns the set of environment variables needed for this compiler to
- /// operate.
- ///
- /// This is typically only used for MSVC compilers currently.
- pub fn env(&self) -> &[(OsString, OsString)] {
- &self.env
- }
-
- /// Returns the compiler command in format of CC environment variable.
- /// Or empty string if CC env was not present
- ///
- /// This is typically used by configure script
- pub fn cc_env(&self) -> OsString {
- match self.cc_wrapper_path {
- Some(ref cc_wrapper_path) => {
- let mut cc_env = cc_wrapper_path.as_os_str().to_owned();
- cc_env.push(" ");
- cc_env.push(self.path.to_path_buf().into_os_string());
- for arg in self.cc_wrapper_args.iter() {
- cc_env.push(" ");
- cc_env.push(arg);
- }
- cc_env
- }
- None => OsString::from(""),
- }
- }
-
- /// Returns the compiler flags in format of CFLAGS environment variable.
- /// Important here - this will not be CFLAGS from env, its internal gcc's flags to use as CFLAGS
- /// This is typically used by configure script
- pub fn cflags_env(&self) -> OsString {
- let mut flags = OsString::new();
- for (i, arg) in self.args.iter().enumerate() {
- if i > 0 {
- flags.push(" ");
- }
- flags.push(arg);
- }
- flags
- }
-
- /// Whether the tool is GNU Compiler Collection-like.
- pub fn is_like_gnu(&self) -> bool {
- self.family == ToolFamily::Gnu
- }
-
- /// Whether the tool is Clang-like.
- pub fn is_like_clang(&self) -> bool {
- self.family == ToolFamily::Clang
- }
-
- /// Whether the tool is MSVC-like.
- pub fn is_like_msvc(&self) -> bool {
- match self.family {
- ToolFamily::Msvc { .. } => true,
- _ => false,
- }
- }
-}
-
-fn run(cmd: &mut Command, program: &str) -> Result<(), Error> {
- let (mut child, print) = spawn(cmd, program)?;
- let status = match child.wait() {
- Ok(s) => s,
- Err(_) => {
- return Err(Error::new(
- ErrorKind::ToolExecError,
- &format!(
- "Failed to wait on spawned child process, command {:?} with args {:?}.",
- cmd, program
- ),
- ));
- }
- };
- print.join().unwrap();
- println!("{}", status);
-
- if status.success() {
- Ok(())
- } else {
- Err(Error::new(
- ErrorKind::ToolExecError,
- &format!(
- "Command {:?} with args {:?} did not execute successfully (status code {}).",
- cmd, program, status
- ),
- ))
- }
-}
-
-fn run_output(cmd: &mut Command, program: &str) -> Result<Vec<u8>, Error> {
- cmd.stdout(Stdio::piped());
- let (mut child, print) = spawn(cmd, program)?;
- let mut stdout = vec![];
- child
- .stdout
- .take()
- .unwrap()
- .read_to_end(&mut stdout)
- .unwrap();
- let status = match child.wait() {
- Ok(s) => s,
- Err(_) => {
- return Err(Error::new(
- ErrorKind::ToolExecError,
- &format!(
- "Failed to wait on spawned child process, command {:?} with args {:?}.",
- cmd, program
- ),
- ));
- }
- };
- print.join().unwrap();
- println!("{}", status);
-
- if status.success() {
- Ok(stdout)
- } else {
- Err(Error::new(
- ErrorKind::ToolExecError,
- &format!(
- "Command {:?} with args {:?} did not execute successfully (status code {}).",
- cmd, program, status
- ),
- ))
- }
-}
-
-fn spawn(cmd: &mut Command, program: &str) -> Result<(Child, JoinHandle<()>), Error> {
- println!("running: {:?}", cmd);
-
- // Capture the standard error coming from these programs, and write it out
- // with cargo:warning= prefixes. Note that this is a bit wonky to avoid
- // requiring the output to be UTF-8, we instead just ship bytes from one
- // location to another.
- match cmd.stderr(Stdio::piped()).spawn() {
- Ok(mut child) => {
- let stderr = BufReader::new(child.stderr.take().unwrap());
- let print = thread::spawn(move || {
- for line in stderr.split(b'\n').filter_map(|l| l.ok()) {
- print!("cargo:warning=");
- std::io::stdout().write_all(&line).unwrap();
- println!("");
- }
- });
- Ok((child, print))
- }
- Err(ref e) if e.kind() == io::ErrorKind::NotFound => {
- let extra = if cfg!(windows) {
- " (see https://github.com/alexcrichton/cc-rs#compile-time-requirements \
- for help)"
- } else {
- ""
- };
- Err(Error::new(
- ErrorKind::ToolNotFound,
- &format!("Failed to find tool. Is `{}` installed?{}", program, extra),
- ))
- }
- Err(_) => Err(Error::new(
- ErrorKind::ToolExecError,
- &format!("Command {:?} with args {:?} failed to start.", cmd, program),
- )),
- }
-}
-
-fn fail(s: &str) -> ! {
- let _ = writeln!(io::stderr(), "\n\nerror occurred: {}\n\n", s);
- std::process::exit(1);
-}
-
-fn command_add_output_file(cmd: &mut Command, dst: &Path, msvc: bool, is_asm: bool, is_arm: bool) {
- if msvc && is_asm && is_arm {
- cmd.arg("-o").arg(&dst);
- } else if msvc && is_asm {
- cmd.arg("/Fo").arg(dst);
- } else if msvc {
- let mut s = OsString::from("/Fo");
- s.push(&dst);
- cmd.arg(s);
- } else {
- cmd.arg("-o").arg(&dst);
- }
-}
diff --git a/cc/src/registry.rs b/cc/src/registry.rs
deleted file mode 100644
index 2ac2fa6..0000000
--- a/cc/src/registry.rs
+++ /dev/null
@@ -1,204 +0,0 @@
-// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-use std::ffi::{OsStr, OsString};
-use std::io;
-use std::ops::RangeFrom;
-use std::os::raw;
-use std::os::windows::prelude::*;
-
-pub struct RegistryKey(Repr);
-
-type HKEY = *mut u8;
-type DWORD = u32;
-type LPDWORD = *mut DWORD;
-type LPCWSTR = *const u16;
-type LPWSTR = *mut u16;
-type LONG = raw::c_long;
-type PHKEY = *mut HKEY;
-type PFILETIME = *mut u8;
-type LPBYTE = *mut u8;
-type REGSAM = u32;
-
-const ERROR_SUCCESS: DWORD = 0;
-const ERROR_NO_MORE_ITEMS: DWORD = 259;
-const HKEY_LOCAL_MACHINE: HKEY = 0x80000002 as HKEY;
-const REG_SZ: DWORD = 1;
-const KEY_READ: DWORD = 0x20019;
-const KEY_WOW64_32KEY: DWORD = 0x200;
-
-#[link(name = "advapi32")]
-extern "system" {
- fn RegOpenKeyExW(
- key: HKEY,
- lpSubKey: LPCWSTR,
- ulOptions: DWORD,
- samDesired: REGSAM,
- phkResult: PHKEY,
- ) -> LONG;
- fn RegEnumKeyExW(
- key: HKEY,
- dwIndex: DWORD,
- lpName: LPWSTR,
- lpcName: LPDWORD,
- lpReserved: LPDWORD,
- lpClass: LPWSTR,
- lpcClass: LPDWORD,
- lpftLastWriteTime: PFILETIME,
- ) -> LONG;
- fn RegQueryValueExW(
- hKey: HKEY,
- lpValueName: LPCWSTR,
- lpReserved: LPDWORD,
- lpType: LPDWORD,
- lpData: LPBYTE,
- lpcbData: LPDWORD,
- ) -> LONG;
- fn RegCloseKey(hKey: HKEY) -> LONG;
-}
-
-struct OwnedKey(HKEY);
-
-enum Repr {
- Const(HKEY),
- Owned(OwnedKey),
-}
-
-pub struct Iter<'a> {
- idx: RangeFrom<DWORD>,
- key: &'a RegistryKey,
-}
-
-unsafe impl Sync for Repr {}
-unsafe impl Send for Repr {}
-
-pub static LOCAL_MACHINE: RegistryKey = RegistryKey(Repr::Const(HKEY_LOCAL_MACHINE));
-
-impl RegistryKey {
- fn raw(&self) -> HKEY {
- match self.0 {
- Repr::Const(val) => val,
- Repr::Owned(ref val) => val.0,
- }
- }
-
- pub fn open(&self, key: &OsStr) -> io::Result<RegistryKey> {
- let key = key.encode_wide().chain(Some(0)).collect::<Vec<_>>();
- let mut ret = 0 as *mut _;
- let err = unsafe {
- RegOpenKeyExW(
- self.raw(),
- key.as_ptr(),
- 0,
- KEY_READ | KEY_WOW64_32KEY,
- &mut ret,
- )
- };
- if err == ERROR_SUCCESS as LONG {
- Ok(RegistryKey(Repr::Owned(OwnedKey(ret))))
- } else {
- Err(io::Error::from_raw_os_error(err as i32))
- }
- }
-
- pub fn iter(&self) -> Iter {
- Iter {
- idx: 0..,
- key: self,
- }
- }
-
- pub fn query_str(&self, name: &str) -> io::Result<OsString> {
- let name: &OsStr = name.as_ref();
- let name = name.encode_wide().chain(Some(0)).collect::<Vec<_>>();
- let mut len = 0;
- let mut kind = 0;
- unsafe {
- let err = RegQueryValueExW(
- self.raw(),
- name.as_ptr(),
- 0 as *mut _,
- &mut kind,
- 0 as *mut _,
- &mut len,
- );
- if err != ERROR_SUCCESS as LONG {
- return Err(io::Error::from_raw_os_error(err as i32));
- }
- if kind != REG_SZ {
- return Err(io::Error::new(
- io::ErrorKind::Other,
- "registry key wasn't a string",
- ));
- }
-
- // The length here is the length in bytes, but we're using wide
- // characters so we need to be sure to halve it for the capacity
- // passed in.
- let mut v = Vec::with_capacity(len as usize / 2);
- let err = RegQueryValueExW(
- self.raw(),
- name.as_ptr(),
- 0 as *mut _,
- 0 as *mut _,
- v.as_mut_ptr() as *mut _,
- &mut len,
- );
- if err != ERROR_SUCCESS as LONG {
- return Err(io::Error::from_raw_os_error(err as i32));
- }
- v.set_len(len as usize / 2);
-
- // Some registry keys may have a terminating nul character, but
- // we're not interested in that, so chop it off if it's there.
- if v[v.len() - 1] == 0 {
- v.pop();
- }
- Ok(OsString::from_wide(&v))
- }
- }
-}
-
-impl Drop for OwnedKey {
- fn drop(&mut self) {
- unsafe {
- RegCloseKey(self.0);
- }
- }
-}
-
-impl<'a> Iterator for Iter<'a> {
- type Item = io::Result<OsString>;
-
- fn next(&mut self) -> Option<io::Result<OsString>> {
- self.idx.next().and_then(|i| unsafe {
- let mut v = Vec::with_capacity(256);
- let mut len = v.capacity() as DWORD;
- let ret = RegEnumKeyExW(
- self.key.raw(),
- i,
- v.as_mut_ptr(),
- &mut len,
- 0 as *mut _,
- 0 as *mut _,
- 0 as *mut _,
- 0 as *mut _,
- );
- if ret == ERROR_NO_MORE_ITEMS as LONG {
- None
- } else if ret != ERROR_SUCCESS as LONG {
- Some(Err(io::Error::from_raw_os_error(ret as i32)))
- } else {
- v.set_len(len as usize);
- Some(Ok(OsString::from_wide(&v)))
- }
- })
- }
-}
diff --git a/cc/src/setup_config.rs b/cc/src/setup_config.rs
deleted file mode 100644
index 56fe114..0000000
--- a/cc/src/setup_config.rs
+++ /dev/null
@@ -1,283 +0,0 @@
-// Copyright © 2017 winapi-rs developers
-// 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.
-// All files in the project carrying such notice may not be copied, modified, or distributed
-// except according to those terms.
-
-#![allow(bad_style)]
-#![allow(unused)]
-
-use std::ffi::OsString;
-use std::ptr::null_mut;
-use winapi::Interface;
-use winapi::BSTR;
-use winapi::LPCOLESTR;
-use winapi::LPSAFEARRAY;
-use winapi::S_FALSE;
-use winapi::{CoCreateInstance, CLSCTX_ALL};
-use winapi::{IUnknown, IUnknownVtbl};
-use winapi::{HRESULT, LCID, LPCWSTR, PULONGLONG};
-use winapi::{LPFILETIME, ULONG};
-
-use com::{BStr, ComPtr};
-
-// Bindings to the Setup.Configuration stuff
-pub type InstanceState = u32;
-
-pub const eNone: InstanceState = 0;
-pub const eLocal: InstanceState = 1;
-pub const eRegistered: InstanceState = 2;
-pub const eNoRebootRequired: InstanceState = 4;
-pub const eComplete: InstanceState = -1i32 as u32;
-
-RIDL! {#[uuid(0xb41463c3, 0x8866, 0x43b5, 0xbc, 0x33, 0x2b, 0x06, 0x76, 0xf7, 0xf4, 0x2e)]
-interface ISetupInstance(ISetupInstanceVtbl): IUnknown(IUnknownVtbl) {
- fn GetInstanceId(
- pbstrInstanceId: *mut BSTR,
- ) -> HRESULT,
- fn GetInstallDate(
- pInstallDate: LPFILETIME,
- ) -> HRESULT,
- fn GetInstallationName(
- pbstrInstallationName: *mut BSTR,
- ) -> HRESULT,
- fn GetInstallationPath(
- pbstrInstallationPath: *mut BSTR,
- ) -> HRESULT,
- fn GetInstallationVersion(
- pbstrInstallationVersion: *mut BSTR,
- ) -> HRESULT,
- fn GetDisplayName(
- lcid: LCID,
- pbstrDisplayName: *mut BSTR,
- ) -> HRESULT,
- fn GetDescription(
- lcid: LCID,
- pbstrDescription: *mut BSTR,
- ) -> HRESULT,
- fn ResolvePath(
- pwszRelativePath: LPCOLESTR,
- pbstrAbsolutePath: *mut BSTR,
- ) -> HRESULT,
-}}
-
-RIDL! {#[uuid(0x89143c9a, 0x05af, 0x49b0, 0xb7, 0x17, 0x72, 0xe2, 0x18, 0xa2, 0x18, 0x5c)]
-interface ISetupInstance2(ISetupInstance2Vtbl): ISetupInstance(ISetupInstanceVtbl) {
- fn GetState(
- pState: *mut InstanceState,
- ) -> HRESULT,
- fn GetPackages(
- ppsaPackages: *mut LPSAFEARRAY,
- ) -> HRESULT,
- fn GetProduct(
- ppPackage: *mut *mut ISetupPackageReference,
- ) -> HRESULT,
- fn GetProductPath(
- pbstrProductPath: *mut BSTR,
- ) -> HRESULT,
-}}
-
-RIDL! {#[uuid(0x6380bcff, 0x41d3, 0x4b2e, 0x8b, 0x2e, 0xbf, 0x8a, 0x68, 0x10, 0xc8, 0x48)]
-interface IEnumSetupInstances(IEnumSetupInstancesVtbl): IUnknown(IUnknownVtbl) {
- fn Next(
- celt: ULONG,
- rgelt: *mut *mut ISetupInstance,
- pceltFetched: *mut ULONG,
- ) -> HRESULT,
- fn Skip(
- celt: ULONG,
- ) -> HRESULT,
- fn Reset() -> HRESULT,
- fn Clone(
- ppenum: *mut *mut IEnumSetupInstances,
- ) -> HRESULT,
-}}
-
-RIDL! {#[uuid(0x42843719, 0xdb4c, 0x46c2, 0x8e, 0x7c, 0x64, 0xf1, 0x81, 0x6e, 0xfd, 0x5b)]
-interface ISetupConfiguration(ISetupConfigurationVtbl): IUnknown(IUnknownVtbl) {
- fn EnumInstances(
- ppEnumInstances: *mut *mut IEnumSetupInstances,
- ) -> HRESULT,
- fn GetInstanceForCurrentProcess(
- ppInstance: *mut *mut ISetupInstance,
- ) -> HRESULT,
- fn GetInstanceForPath(
- wzPath: LPCWSTR,
- ppInstance: *mut *mut ISetupInstance,
- ) -> HRESULT,
-}}
-
-RIDL! {#[uuid(0x26aab78c, 0x4a60, 0x49d6, 0xaf, 0x3b, 0x3c, 0x35, 0xbc, 0x93, 0x36, 0x5d)]
-interface ISetupConfiguration2(ISetupConfiguration2Vtbl):
- ISetupConfiguration(ISetupConfigurationVtbl) {
- fn EnumAllInstances(
- ppEnumInstances: *mut *mut IEnumSetupInstances,
- ) -> HRESULT,
-}}
-
-RIDL! {#[uuid(0xda8d8a16, 0xb2b6, 0x4487, 0xa2, 0xf1, 0x59, 0x4c, 0xcc, 0xcd, 0x6b, 0xf5)]
-interface ISetupPackageReference(ISetupPackageReferenceVtbl): IUnknown(IUnknownVtbl) {
- fn GetId(
- pbstrId: *mut BSTR,
- ) -> HRESULT,
- fn GetVersion(
- pbstrVersion: *mut BSTR,
- ) -> HRESULT,
- fn GetChip(
- pbstrChip: *mut BSTR,
- ) -> HRESULT,
- fn GetLanguage(
- pbstrLanguage: *mut BSTR,
- ) -> HRESULT,
- fn GetBranch(
- pbstrBranch: *mut BSTR,
- ) -> HRESULT,
- fn GetType(
- pbstrType: *mut BSTR,
- ) -> HRESULT,
- fn GetUniqueId(
- pbstrUniqueId: *mut BSTR,
- ) -> HRESULT,
-}}
-
-RIDL! {#[uuid(0x42b21b78, 0x6192, 0x463e, 0x87, 0xbf, 0xd5, 0x77, 0x83, 0x8f, 0x1d, 0x5c)]
-interface ISetupHelper(ISetupHelperVtbl): IUnknown(IUnknownVtbl) {
- fn ParseVersion(
- pwszVersion: LPCOLESTR,
- pullVersion: PULONGLONG,
- ) -> HRESULT,
- fn ParseVersionRange(
- pwszVersionRange: LPCOLESTR,
- pullMinVersion: PULONGLONG,
- pullMaxVersion: PULONGLONG,
- ) -> HRESULT,
-}}
-
-DEFINE_GUID! {CLSID_SetupConfiguration,
-0x177f0c4a, 0x1cd3, 0x4de7, 0xa3, 0x2c, 0x71, 0xdb, 0xbb, 0x9f, 0xa3, 0x6d}
-
-// Safe wrapper around the COM interfaces
-pub struct SetupConfiguration(ComPtr<ISetupConfiguration>);
-
-impl SetupConfiguration {
- pub fn new() -> Result<SetupConfiguration, i32> {
- let mut obj = null_mut();
- let err = unsafe {
- CoCreateInstance(
- &CLSID_SetupConfiguration,
- null_mut(),
- CLSCTX_ALL,
- &ISetupConfiguration::uuidof(),
- &mut obj,
- )
- };
- if err < 0 {
- return Err(err);
- }
- let obj = unsafe { ComPtr::from_raw(obj as *mut ISetupConfiguration) };
- Ok(SetupConfiguration(obj))
- }
- pub fn get_instance_for_current_process(&self) -> Result<SetupInstance, i32> {
- let mut obj = null_mut();
- let err = unsafe { self.0.GetInstanceForCurrentProcess(&mut obj) };
- if err < 0 {
- return Err(err);
- }
- Ok(unsafe { SetupInstance::from_raw(obj) })
- }
- pub fn enum_instances(&self) -> Result<EnumSetupInstances, i32> {
- let mut obj = null_mut();
- let err = unsafe { self.0.EnumInstances(&mut obj) };
- if err < 0 {
- return Err(err);
- }
- Ok(unsafe { EnumSetupInstances::from_raw(obj) })
- }
- pub fn enum_all_instances(&self) -> Result<EnumSetupInstances, i32> {
- let mut obj = null_mut();
- let this = try!(self.0.cast::<ISetupConfiguration2>());
- let err = unsafe { this.EnumAllInstances(&mut obj) };
- if err < 0 {
- return Err(err);
- }
- Ok(unsafe { EnumSetupInstances::from_raw(obj) })
- }
-}
-
-pub struct SetupInstance(ComPtr<ISetupInstance>);
-
-impl SetupInstance {
- pub unsafe fn from_raw(obj: *mut ISetupInstance) -> SetupInstance {
- SetupInstance(ComPtr::from_raw(obj))
- }
- pub fn instance_id(&self) -> Result<OsString, i32> {
- let mut s = null_mut();
- let err = unsafe { self.0.GetInstanceId(&mut s) };
- let bstr = unsafe { BStr::from_raw(s) };
- if err < 0 {
- return Err(err);
- }
- Ok(bstr.to_osstring())
- }
- pub fn installation_name(&self) -> Result<OsString, i32> {
- let mut s = null_mut();
- let err = unsafe { self.0.GetInstallationName(&mut s) };
- let bstr = unsafe { BStr::from_raw(s) };
- if err < 0 {
- return Err(err);
- }
- Ok(bstr.to_osstring())
- }
- pub fn installation_path(&self) -> Result<OsString, i32> {
- let mut s = null_mut();
- let err = unsafe { self.0.GetInstallationPath(&mut s) };
- let bstr = unsafe { BStr::from_raw(s) };
- if err < 0 {
- return Err(err);
- }
- Ok(bstr.to_osstring())
- }
- pub fn installation_version(&self) -> Result<OsString, i32> {
- let mut s = null_mut();
- let err = unsafe { self.0.GetInstallationVersion(&mut s) };
- let bstr = unsafe { BStr::from_raw(s) };
- if err < 0 {
- return Err(err);
- }
- Ok(bstr.to_osstring())
- }
- pub fn product_path(&self) -> Result<OsString, i32> {
- let mut s = null_mut();
- let this = try!(self.0.cast::<ISetupInstance2>());
- let err = unsafe { this.GetProductPath(&mut s) };
- let bstr = unsafe { BStr::from_raw(s) };
- if err < 0 {
- return Err(err);
- }
- Ok(bstr.to_osstring())
- }
-}
-
-pub struct EnumSetupInstances(ComPtr<IEnumSetupInstances>);
-
-impl EnumSetupInstances {
- pub unsafe fn from_raw(obj: *mut IEnumSetupInstances) -> EnumSetupInstances {
- EnumSetupInstances(ComPtr::from_raw(obj))
- }
-}
-
-impl Iterator for EnumSetupInstances {
- type Item = Result<SetupInstance, i32>;
- fn next(&mut self) -> Option<Result<SetupInstance, i32>> {
- let mut obj = null_mut();
- let err = unsafe { self.0.Next(1, &mut obj, null_mut()) };
- if err < 0 {
- return Some(Err(err));
- }
- if err == S_FALSE {
- return None;
- }
- Some(Ok(unsafe { SetupInstance::from_raw(obj) }))
- }
-}
diff --git a/cc/src/winapi.rs b/cc/src/winapi.rs
deleted file mode 100644
index c416325..0000000
--- a/cc/src/winapi.rs
+++ /dev/null
@@ -1,218 +0,0 @@
-// Copyright © 2015-2017 winapi-rs developers
-// 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.
-// All files in the project carrying such notice may not be copied, modified, or distributed
-// except according to those terms.
-
-#![allow(bad_style)]
-
-use std::os::raw;
-
-pub type wchar_t = u16;
-
-pub type UINT = raw::c_uint;
-pub type LPUNKNOWN = *mut IUnknown;
-pub type REFIID = *const IID;
-pub type IID = GUID;
-pub type REFCLSID = *const IID;
-pub type PVOID = *mut raw::c_void;
-pub type USHORT = raw::c_ushort;
-pub type ULONG = raw::c_ulong;
-pub type LONG = raw::c_long;
-pub type DWORD = u32;
-pub type LPVOID = *mut raw::c_void;
-pub type HRESULT = raw::c_long;
-pub type LPFILETIME = *mut FILETIME;
-pub type BSTR = *mut OLECHAR;
-pub type OLECHAR = WCHAR;
-pub type WCHAR = wchar_t;
-pub type LPCOLESTR = *const OLECHAR;
-pub type LCID = DWORD;
-pub type LPCWSTR = *const WCHAR;
-pub type PULONGLONG = *mut ULONGLONG;
-pub type ULONGLONG = u64;
-
-pub const S_OK: HRESULT = 0;
-pub const S_FALSE: HRESULT = 1;
-pub const COINIT_MULTITHREADED: u32 = 0x0;
-
-pub type CLSCTX = u32;
-
-pub const CLSCTX_INPROC_SERVER: CLSCTX = 0x1;
-pub const CLSCTX_INPROC_HANDLER: CLSCTX = 0x2;
-pub const CLSCTX_LOCAL_SERVER: CLSCTX = 0x4;
-pub const CLSCTX_REMOTE_SERVER: CLSCTX = 0x10;
-
-pub const CLSCTX_ALL: CLSCTX =
- CLSCTX_INPROC_SERVER | CLSCTX_INPROC_HANDLER | CLSCTX_LOCAL_SERVER | CLSCTX_REMOTE_SERVER;
-
-#[repr(C)]
-#[derive(Copy, Clone)]
-pub struct GUID {
- pub Data1: raw::c_ulong,
- pub Data2: raw::c_ushort,
- pub Data3: raw::c_ushort,
- pub Data4: [raw::c_uchar; 8],
-}
-
-#[repr(C)]
-#[derive(Copy, Clone)]
-pub struct FILETIME {
- pub dwLowDateTime: DWORD,
- pub dwHighDateTime: DWORD,
-}
-
-pub trait Interface {
- fn uuidof() -> GUID;
-}
-
-#[link(name = "ole32")]
-#[link(name = "oleaut32")]
-extern "C" {}
-
-extern "system" {
- pub fn CoInitializeEx(pvReserved: LPVOID, dwCoInit: DWORD) -> HRESULT;
- pub fn CoCreateInstance(
- rclsid: REFCLSID,
- pUnkOuter: LPUNKNOWN,
- dwClsContext: DWORD,
- riid: REFIID,
- ppv: *mut LPVOID,
- ) -> HRESULT;
- pub fn SysFreeString(bstrString: BSTR);
- pub fn SysStringLen(pbstr: BSTR) -> UINT;
-}
-
-#[repr(C)]
-#[derive(Copy, Clone)]
-pub struct SAFEARRAYBOUND {
- pub cElements: ULONG,
- pub lLbound: LONG,
-}
-
-#[repr(C)]
-#[derive(Copy, Clone)]
-pub struct SAFEARRAY {
- pub cDims: USHORT,
- pub fFeatures: USHORT,
- pub cbElements: ULONG,
- pub cLocks: ULONG,
- pub pvData: PVOID,
- pub rgsabound: [SAFEARRAYBOUND; 1],
-}
-
-pub type LPSAFEARRAY = *mut SAFEARRAY;
-
-macro_rules! DEFINE_GUID {
- (
- $name:ident, $l:expr, $w1:expr, $w2:expr,
- $b1:expr, $b2:expr, $b3:expr, $b4:expr, $b5:expr, $b6:expr, $b7:expr, $b8:expr
- ) => {
- pub const $name: $crate::winapi::GUID = $crate::winapi::GUID {
- Data1: $l,
- Data2: $w1,
- Data3: $w2,
- Data4: [$b1, $b2, $b3, $b4, $b5, $b6, $b7, $b8],
- };
- };
-}
-
-macro_rules! RIDL {
- (#[uuid($($uuid:expr),+)]
- interface $interface:ident ($vtbl:ident) {$(
- fn $method:ident($($p:ident : $t:ty,)*) -> $rtr:ty,
- )+}) => (
- #[repr(C)]
- pub struct $vtbl {
- $(pub $method: unsafe extern "system" fn(
- This: *mut $interface,
- $($p: $t),*
- ) -> $rtr,)+
- }
- #[repr(C)]
- pub struct $interface {
- pub lpVtbl: *const $vtbl,
- }
- RIDL!{@impl $interface {$(fn $method($($p: $t,)*) -> $rtr,)+}}
- RIDL!{@uuid $interface $($uuid),+}
- );
- (#[uuid($($uuid:expr),+)]
- interface $interface:ident ($vtbl:ident) : $pinterface:ident ($pvtbl:ident) {
- }) => (
- #[repr(C)]
- pub struct $vtbl {
- pub parent: $pvtbl,
- }
- #[repr(C)]
- pub struct $interface {
- pub lpVtbl: *const $vtbl,
- }
- RIDL!{@deref $interface $pinterface}
- RIDL!{@uuid $interface $($uuid),+}
- );
- (#[uuid($($uuid:expr),+)]
- interface $interface:ident ($vtbl:ident) : $pinterface:ident ($pvtbl:ident) {$(
- fn $method:ident($($p:ident : $t:ty,)*) -> $rtr:ty,
- )+}) => (
- #[repr(C)]
- pub struct $vtbl {
- pub parent: $pvtbl,
- $(pub $method: unsafe extern "system" fn(
- This: *mut $interface,
- $($p: $t,)*
- ) -> $rtr,)+
- }
- #[repr(C)]
- pub struct $interface {
- pub lpVtbl: *const $vtbl,
- }
- RIDL!{@impl $interface {$(fn $method($($p: $t,)*) -> $rtr,)+}}
- RIDL!{@deref $interface $pinterface}
- RIDL!{@uuid $interface $($uuid),+}
- );
- (@deref $interface:ident $pinterface:ident) => (
- impl ::std::ops::Deref for $interface {
- type Target = $pinterface;
- #[inline]
- fn deref(&self) -> &$pinterface {
- unsafe { &*(self as *const $interface as *const $pinterface) }
- }
- }
- );
- (@impl $interface:ident {$(
- fn $method:ident($($p:ident : $t:ty,)*) -> $rtr:ty,
- )+}) => (
- impl $interface {
- $(#[inline] pub unsafe fn $method(&self, $($p: $t,)*) -> $rtr {
- ((*self.lpVtbl).$method)(self as *const _ as *mut _, $($p,)*)
- })+
- }
- );
- (@uuid $interface:ident
- $l:expr, $w1:expr, $w2:expr,
- $b1:expr, $b2:expr, $b3:expr, $b4:expr, $b5:expr, $b6:expr, $b7:expr, $b8:expr
- ) => (
- impl $crate::winapi::Interface for $interface {
- #[inline]
- fn uuidof() -> $crate::winapi::GUID {
- $crate::winapi::GUID {
- Data1: $l,
- Data2: $w1,
- Data3: $w2,
- Data4: [$b1, $b2, $b3, $b4, $b5, $b6, $b7, $b8],
- }
- }
- }
- );
-}
-
-RIDL! {#[uuid(0x00000000, 0x0000, 0x0000, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46)]
-interface IUnknown(IUnknownVtbl) {
- fn QueryInterface(
- riid: REFIID,
- ppvObject: *mut *mut raw::c_void,
- ) -> HRESULT,
- fn AddRef() -> ULONG,
- fn Release() -> ULONG,
-}}
diff --git a/cc/src/windows_registry.rs b/cc/src/windows_registry.rs
deleted file mode 100644
index af812a7..0000000
--- a/cc/src/windows_registry.rs
+++ /dev/null
@@ -1,759 +0,0 @@
-// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-//! A helper module to probe the Windows Registry when looking for
-//! windows-specific tools.
-
-use std::process::Command;
-
-use Tool;
-
-#[cfg(windows)]
-macro_rules! otry {
- ($expr:expr) => {
- match $expr {
- Some(val) => val,
- None => return None,
- }
- };
-}
-
-/// Attempts to find a tool within an MSVC installation using the Windows
-/// registry as a point to search from.
-///
-/// The `target` argument is the target that the tool should work for (e.g.
-/// compile or link for) and the `tool` argument is the tool to find (e.g.
-/// `cl.exe` or `link.exe`).
-///
-/// This function will return `None` if the tool could not be found, or it will
-/// return `Some(cmd)` which represents a command that's ready to execute the
-/// tool with the appropriate environment variables set.
-///
-/// Note that this function always returns `None` for non-MSVC targets.
-pub fn find(target: &str, tool: &str) -> Option<Command> {
- find_tool(target, tool).map(|c| c.to_command())
-}
-
-/// Similar to the `find` function above, this function will attempt the same
-/// operation (finding a MSVC tool in a local install) but instead returns a
-/// `Tool` which may be introspected.
-#[cfg(not(windows))]
-pub fn find_tool(_target: &str, _tool: &str) -> Option<Tool> {
- None
-}
-
-/// Documented above.
-#[cfg(windows)]
-pub fn find_tool(target: &str, tool: &str) -> Option<Tool> {
- use std::env;
-
- // This logic is all tailored for MSVC, if we're not that then bail out
- // early.
- if !target.contains("msvc") {
- return None;
- }
-
- // Looks like msbuild isn't located in the same location as other tools like
- // cl.exe and lib.exe. To handle this we probe for it manually with
- // dedicated registry keys.
- if tool.contains("msbuild") {
- return impl_::find_msbuild(target);
- }
-
- if tool.contains("devenv") {
- return impl_::find_devenv(target);
- }
-
- // If VCINSTALLDIR is set, then someone's probably already run vcvars and we
- // should just find whatever that indicates.
- if env::var_os("VCINSTALLDIR").is_some() {
- return env::var_os("PATH")
- .and_then(|path| {
- env::split_paths(&path)
- .map(|p| p.join(tool))
- .find(|p| p.exists())
- })
- .map(|path| Tool::new(path.into()));
- }
-
- // Ok, if we're here, now comes the fun part of the probing. Default shells
- // or shells like MSYS aren't really configured to execute `cl.exe` and the
- // various compiler tools shipped as part of Visual Studio. Here we try to
- // first find the relevant tool, then we also have to be sure to fill in
- // environment variables like `LIB`, `INCLUDE`, and `PATH` to ensure that
- // the tool is actually usable.
-
- return impl_::find_msvc_15(tool, target)
- .or_else(|| impl_::find_msvc_14(tool, target))
- .or_else(|| impl_::find_msvc_12(tool, target))
- .or_else(|| impl_::find_msvc_11(tool, target));
-}
-
-/// A version of Visual Studio
-#[derive(Debug, PartialEq, Eq, Copy, Clone)]
-pub enum VsVers {
- /// Visual Studio 12 (2013)
- Vs12,
- /// Visual Studio 14 (2015)
- Vs14,
- /// Visual Studio 15 (2017)
- Vs15,
- /// Visual Studio 16 (2019)
- Vs16,
-
- /// Hidden variant that should not be matched on. Callers that want to
- /// handle an enumeration of `VsVers` instances should always have a default
- /// case meaning that it's a VS version they don't understand.
- #[doc(hidden)]
- #[allow(bad_style)]
- __Nonexhaustive_do_not_match_this_or_your_code_will_break,
-}
-
-/// Find the most recent installed version of Visual Studio
-///
-/// This is used by the cmake crate to figure out the correct
-/// generator.
-#[cfg(not(windows))]
-pub fn find_vs_version() -> Result<VsVers, String> {
- Err(format!("not windows"))
-}
-
-/// Documented above
-#[cfg(windows)]
-pub fn find_vs_version() -> Result<VsVers, String> {
- use std::env;
-
- match env::var("VisualStudioVersion") {
- Ok(version) => match &version[..] {
- "16.0" => Ok(VsVers::Vs16),
- "15.0" => Ok(VsVers::Vs15),
- "14.0" => Ok(VsVers::Vs14),
- "12.0" => Ok(VsVers::Vs12),
- vers => Err(format!(
- "\n\n\
- unsupported or unknown VisualStudio version: {}\n\
- if another version is installed consider running \
- the appropriate vcvars script before building this \
- crate\n\
- ",
- vers
- )),
- },
- _ => {
- // Check for the presense of a specific registry key
- // that indicates visual studio is installed.
- if impl_::has_msbuild_version("16.0") {
- Ok(VsVers::Vs16)
- } else if impl_::has_msbuild_version("15.0") {
- Ok(VsVers::Vs15)
- } else if impl_::has_msbuild_version("14.0") {
- Ok(VsVers::Vs14)
- } else if impl_::has_msbuild_version("12.0") {
- Ok(VsVers::Vs12)
- } else {
- Err(format!(
- "\n\n\
- couldn't determine visual studio generator\n\
- if VisualStudio is installed, however, consider \
- running the appropriate vcvars script before building \
- this crate\n\
- "
- ))
- }
- }
- }
-}
-
-#[cfg(windows)]
-mod impl_ {
- use com;
- use registry::{RegistryKey, LOCAL_MACHINE};
- use setup_config::{EnumSetupInstances, SetupConfiguration, SetupInstance};
- use std::env;
- use std::ffi::OsString;
- use std::fs::File;
- use std::io::Read;
- use std::mem;
- use std::iter;
- use std::path::{Path, PathBuf};
-
- use Tool;
-
- struct MsvcTool {
- tool: PathBuf,
- libs: Vec<PathBuf>,
- path: Vec<PathBuf>,
- include: Vec<PathBuf>,
- }
-
- impl MsvcTool {
- fn new(tool: PathBuf) -> MsvcTool {
- MsvcTool {
- tool: tool,
- libs: Vec::new(),
- path: Vec::new(),
- include: Vec::new(),
- }
- }
-
- fn into_tool(self) -> Tool {
- let MsvcTool {
- tool,
- libs,
- path,
- include,
- } = self;
- let mut tool = Tool::new(tool.into());
- add_env(&mut tool, "LIB", libs);
- add_env(&mut tool, "PATH", path);
- add_env(&mut tool, "INCLUDE", include);
- tool
- }
- }
-
- fn vs16_instances() -> Box<Iterator<Item=PathBuf>> {
- let instances = if let Some(instances) = vs15_instances() {
- instances
- } else {
- return Box::new(iter::empty());
- };
- Box::new(instances.filter_map(|instance| {
- let instance = otry!(instance.ok());
- let installation_name = otry!(instance.installation_name().ok());
- if otry!(installation_name.to_str()).starts_with("VisualStudio/16.") {
- Some(PathBuf::from(otry!(instance.installation_path().ok())))
- } else {
- None
- }
- }))
- }
-
- fn find_tool_in_vs16_path(tool: &str, target: &str) -> Option<Tool> {
- vs16_instances().filter_map(|path| {
- let path = path.join(tool);
- if !path.is_file() {
- return None;
- }
- let mut tool = Tool::new(path);
- if target.contains("x86_64") {
- tool.env.push(("Platform".into(), "X64".into()));
- }
- Some(tool)
- }).next()
- }
-
- fn find_msbuild_vs16(target: &str) -> Option<Tool> {
- find_tool_in_vs16_path(r"MSBuild\Current\Bin\MSBuild.exe", target)
- }
-
- // In MSVC 15 (2017) MS once again changed the scheme for locating
- // the tooling. Now we must go through some COM interfaces, which
- // is super fun for Rust.
- //
- // Note that much of this logic can be found [online] wrt paths, COM, etc.
- //
- // [online]: https://blogs.msdn.microsoft.com/vcblog/2017/03/06/finding-the-visual-c-compiler-tools-in-visual-studio-2017/
- fn vs15_instances() -> Option<EnumSetupInstances> {
- otry!(com::initialize().ok());
-
- let config = otry!(SetupConfiguration::new().ok());
- config.enum_all_instances().ok()
- }
-
- pub fn find_msvc_15(tool: &str, target: &str) -> Option<Tool> {
- let iter = otry!(vs15_instances());
- for instance in iter {
- let instance = otry!(instance.ok());
- let tool = tool_from_vs15_instance(tool, target, &instance);
- if tool.is_some() {
- return tool;
- }
- }
-
- None
- }
-
- // While the paths to Visual Studio 2017's devenv and MSBuild could
- // potentially be retrieved from the registry, finding them via
- // SetupConfiguration has shown to be [more reliable], and is preferred
- // according to Microsoft. To help head off potential regressions though,
- // we keep the registry method as a fallback option.
- //
- // [more reliable]: https://github.com/alexcrichton/cc-rs/pull/331
- fn find_tool_in_vs15_path(tool: &str, target: &str) -> Option<Tool> {
- let mut path = match vs15_instances() {
- Some(instances) => instances
- .filter_map(|instance| {
- instance
- .ok()
- .and_then(|instance| instance.installation_path().ok())
- })
- .map(|path| PathBuf::from(path).join(tool))
- .find(|ref path| path.is_file()),
- None => None,
- };
-
- if path.is_none() {
- let key = r"SOFTWARE\WOW6432Node\Microsoft\VisualStudio\SxS\VS7";
- path = LOCAL_MACHINE
- .open(key.as_ref())
- .ok()
- .and_then(|key| key.query_str("15.0").ok())
- .map(|path| PathBuf::from(path).join(tool))
- .and_then(|path| if path.is_file() { Some(path) } else { None });
- }
-
- path.map(|path| {
- let mut tool = Tool::new(path);
- if target.contains("x86_64") {
- tool.env.push(("Platform".into(), "X64".into()));
- }
- tool
- })
- }
-
- fn tool_from_vs15_instance(tool: &str, target: &str, instance: &SetupInstance) -> Option<Tool> {
- let (bin_path, host_dylib_path, lib_path, include_path) =
- otry!(vs15_vc_paths(target, instance));
- let tool_path = bin_path.join(tool);
- if !tool_path.exists() {
- return None;
- };
-
- let mut tool = MsvcTool::new(tool_path);
- tool.path.push(host_dylib_path);
- tool.libs.push(lib_path);
- tool.include.push(include_path);
-
- if let Some((atl_lib_path, atl_include_path)) = atl_paths(target, &bin_path) {
- tool.libs.push(atl_lib_path);
- tool.include.push(atl_include_path);
- }
-
- otry!(add_sdks(&mut tool, target));
-
- Some(tool.into_tool())
- }
-
- fn vs15_vc_paths(
- target: &str,
- instance: &SetupInstance,
- ) -> Option<(PathBuf, PathBuf, PathBuf, PathBuf)> {
- let instance_path: PathBuf = otry!(instance.installation_path().ok()).into();
- let version_path =
- instance_path.join(r"VC\Auxiliary\Build\Microsoft.VCToolsVersion.default.txt");
- let mut version_file = otry!(File::open(version_path).ok());
- let mut version = String::new();
- otry!(version_file.read_to_string(&mut version).ok());
- let version = version.trim();
- let host = match host_arch() {
- X86 => "X86",
- X86_64 => "X64",
- _ => return None,
- };
- let target = otry!(lib_subdir(target));
- // The directory layout here is MSVC/bin/Host$host/$target/
- let path = instance_path.join(r"VC\Tools\MSVC").join(version);
- // This is the path to the toolchain for a particular target, running
- // on a given host
- let bin_path = path
- .join("bin")
- .join(&format!("Host{}", host))
- .join(&target);
- // But! we also need PATH to contain the target directory for the host
- // architecture, because it contains dlls like mspdb140.dll compiled for
- // the host architecture.
- let host_dylib_path = path
- .join("bin")
- .join(&format!("Host{}", host))
- .join(&host.to_lowercase());
- let lib_path = path.join("lib").join(&target);
- let include_path = path.join("include");
- Some((bin_path, host_dylib_path, lib_path, include_path))
- }
-
- fn atl_paths(target: &str, path: &Path) -> Option<(PathBuf, PathBuf)> {
- let atl_path = path.join("atlfmc");
- let sub = otry!(lib_subdir(target));
- if atl_path.exists() {
- Some((atl_path.join("lib").join(sub), atl_path.join("include")))
- } else {
- None
- }
- }
-
- // For MSVC 14 we need to find the Universal CRT as well as either
- // the Windows 10 SDK or Windows 8.1 SDK.
- pub fn find_msvc_14(tool: &str, target: &str) -> Option<Tool> {
- let vcdir = otry!(get_vc_dir("14.0"));
- let mut tool = otry!(get_tool(tool, &vcdir, target));
- otry!(add_sdks(&mut tool, target));
- Some(tool.into_tool())
- }
-
- fn add_sdks(tool: &mut MsvcTool, target: &str) -> Option<()> {
- let sub = otry!(lib_subdir(target));
- let (ucrt, ucrt_version) = otry!(get_ucrt_dir());
-
- tool.path
- .push(ucrt.join("bin").join(&ucrt_version).join(sub));
-
- let ucrt_include = ucrt.join("include").join(&ucrt_version);
- tool.include.push(ucrt_include.join("ucrt"));
-
- let ucrt_lib = ucrt.join("lib").join(&ucrt_version);
- tool.libs.push(ucrt_lib.join("ucrt").join(sub));
-
- if let Some((sdk, version)) = get_sdk10_dir() {
- tool.path.push(sdk.join("bin").join(sub));
- let sdk_lib = sdk.join("lib").join(&version);
- tool.libs.push(sdk_lib.join("um").join(sub));
- let sdk_include = sdk.join("include").join(&version);
- tool.include.push(sdk_include.join("um"));
- tool.include.push(sdk_include.join("cppwinrt"));
- tool.include.push(sdk_include.join("winrt"));
- tool.include.push(sdk_include.join("shared"));
- } else if let Some(sdk) = get_sdk81_dir() {
- tool.path.push(sdk.join("bin").join(sub));
- let sdk_lib = sdk.join("lib").join("winv6.3");
- tool.libs.push(sdk_lib.join("um").join(sub));
- let sdk_include = sdk.join("include");
- tool.include.push(sdk_include.join("um"));
- tool.include.push(sdk_include.join("winrt"));
- tool.include.push(sdk_include.join("shared"));
- }
-
- Some(())
- }
-
- // For MSVC 12 we need to find the Windows 8.1 SDK.
- pub fn find_msvc_12(tool: &str, target: &str) -> Option<Tool> {
- let vcdir = otry!(get_vc_dir("12.0"));
- let mut tool = otry!(get_tool(tool, &vcdir, target));
- let sub = otry!(lib_subdir(target));
- let sdk81 = otry!(get_sdk81_dir());
- tool.path.push(sdk81.join("bin").join(sub));
- let sdk_lib = sdk81.join("lib").join("winv6.3");
- tool.libs.push(sdk_lib.join("um").join(sub));
- let sdk_include = sdk81.join("include");
- tool.include.push(sdk_include.join("shared"));
- tool.include.push(sdk_include.join("um"));
- tool.include.push(sdk_include.join("winrt"));
- Some(tool.into_tool())
- }
-
- // For MSVC 11 we need to find the Windows 8 SDK.
- pub fn find_msvc_11(tool: &str, target: &str) -> Option<Tool> {
- let vcdir = otry!(get_vc_dir("11.0"));
- let mut tool = otry!(get_tool(tool, &vcdir, target));
- let sub = otry!(lib_subdir(target));
- let sdk8 = otry!(get_sdk8_dir());
- tool.path.push(sdk8.join("bin").join(sub));
- let sdk_lib = sdk8.join("lib").join("win8");
- tool.libs.push(sdk_lib.join("um").join(sub));
- let sdk_include = sdk8.join("include");
- tool.include.push(sdk_include.join("shared"));
- tool.include.push(sdk_include.join("um"));
- tool.include.push(sdk_include.join("winrt"));
- Some(tool.into_tool())
- }
-
- fn add_env(tool: &mut Tool, env: &str, paths: Vec<PathBuf>) {
- let prev = env::var_os(env).unwrap_or(OsString::new());
- let prev = env::split_paths(&prev);
- let new = paths.into_iter().chain(prev);
- tool.env
- .push((env.to_string().into(), env::join_paths(new).unwrap()));
- }
-
- // Given a possible MSVC installation directory, we look for the linker and
- // then add the MSVC library path.
- fn get_tool(tool: &str, path: &Path, target: &str) -> Option<MsvcTool> {
- bin_subdir(target)
- .into_iter()
- .map(|(sub, host)| {
- (
- path.join("bin").join(sub).join(tool),
- path.join("bin").join(host),
- )
- })
- .filter(|&(ref path, _)| path.is_file())
- .map(|(path, host)| {
- let mut tool = MsvcTool::new(path);
- tool.path.push(host);
- tool
- })
- .filter_map(|mut tool| {
- let sub = otry!(vc_lib_subdir(target));
- tool.libs.push(path.join("lib").join(sub));
- tool.include.push(path.join("include"));
- let atlmfc_path = path.join("atlmfc");
- if atlmfc_path.exists() {
- tool.libs.push(atlmfc_path.join("lib").join(sub));
- tool.include.push(atlmfc_path.join("include"));
- }
- Some(tool)
- })
- .next()
- }
-
- // To find MSVC we look in a specific registry key for the version we are
- // trying to find.
- fn get_vc_dir(ver: &str) -> Option<PathBuf> {
- let key = r"SOFTWARE\Microsoft\VisualStudio\SxS\VC7";
- let key = otry!(LOCAL_MACHINE.open(key.as_ref()).ok());
- let path = otry!(key.query_str(ver).ok());
- Some(path.into())
- }
-
- // To find the Universal CRT we look in a specific registry key for where
- // all the Universal CRTs are located and then sort them asciibetically to
- // find the newest version. While this sort of sorting isn't ideal, it is
- // what vcvars does so that's good enough for us.
- //
- // Returns a pair of (root, version) for the ucrt dir if found
- fn get_ucrt_dir() -> Option<(PathBuf, String)> {
- let key = r"SOFTWARE\Microsoft\Windows Kits\Installed Roots";
- let key = otry!(LOCAL_MACHINE.open(key.as_ref()).ok());
- let root = otry!(key.query_str("KitsRoot10").ok());
- let readdir = otry!(Path::new(&root).join("lib").read_dir().ok());
- let max_libdir = otry!(readdir
- .filter_map(|dir| dir.ok())
- .map(|dir| dir.path())
- .filter(|dir| dir
- .components()
- .last()
- .and_then(|c| c.as_os_str().to_str())
- .map(|c| c.starts_with("10.") && dir.join("ucrt").is_dir())
- .unwrap_or(false))
- .max());
- let version = max_libdir.components().last().unwrap();
- let version = version.as_os_str().to_str().unwrap().to_string();
- Some((root.into(), version))
- }
-
- // Vcvars finds the correct version of the Windows 10 SDK by looking
- // for the include `um\Windows.h` because sometimes a given version will
- // only have UCRT bits without the rest of the SDK. Since we only care about
- // libraries and not includes, we instead look for `um\x64\kernel32.lib`.
- // Since the 32-bit and 64-bit libraries are always installed together we
- // only need to bother checking x64, making this code a tiny bit simpler.
- // Like we do for the Universal CRT, we sort the possibilities
- // asciibetically to find the newest one as that is what vcvars does.
- fn get_sdk10_dir() -> Option<(PathBuf, String)> {
- let key = r"SOFTWARE\Microsoft\Microsoft SDKs\Windows\v10.0";
- let key = otry!(LOCAL_MACHINE.open(key.as_ref()).ok());
- let root = otry!(key.query_str("InstallationFolder").ok());
- let readdir = otry!(Path::new(&root).join("lib").read_dir().ok());
- let mut dirs = readdir
- .filter_map(|dir| dir.ok())
- .map(|dir| dir.path())
- .collect::<Vec<_>>();
- dirs.sort();
- let dir = otry!(dirs
- .into_iter()
- .rev()
- .filter(|dir| dir.join("um").join("x64").join("kernel32.lib").is_file())
- .next());
- let version = dir.components().last().unwrap();
- let version = version.as_os_str().to_str().unwrap().to_string();
- Some((root.into(), version))
- }
-
- // Interestingly there are several subdirectories, `win7` `win8` and
- // `winv6.3`. Vcvars seems to only care about `winv6.3` though, so the same
- // applies to us. Note that if we were targetting kernel mode drivers
- // instead of user mode applications, we would care.
- fn get_sdk81_dir() -> Option<PathBuf> {
- let key = r"SOFTWARE\Microsoft\Microsoft SDKs\Windows\v8.1";
- let key = otry!(LOCAL_MACHINE.open(key.as_ref()).ok());
- let root = otry!(key.query_str("InstallationFolder").ok());
- Some(root.into())
- }
-
- fn get_sdk8_dir() -> Option<PathBuf> {
- let key = r"SOFTWARE\Microsoft\Microsoft SDKs\Windows\v8.0";
- let key = otry!(LOCAL_MACHINE.open(key.as_ref()).ok());
- let root = otry!(key.query_str("InstallationFolder").ok());
- Some(root.into())
- }
-
- const PROCESSOR_ARCHITECTURE_INTEL: u16 = 0;
- const PROCESSOR_ARCHITECTURE_AMD64: u16 = 9;
- const X86: u16 = PROCESSOR_ARCHITECTURE_INTEL;
- const X86_64: u16 = PROCESSOR_ARCHITECTURE_AMD64;
-
- // When choosing the tool to use, we have to choose the one which matches
- // the target architecture. Otherwise we end up in situations where someone
- // on 32-bit Windows is trying to cross compile to 64-bit and it tries to
- // invoke the native 64-bit compiler which won't work.
- //
- // For the return value of this function, the first member of the tuple is
- // the folder of the tool we will be invoking, while the second member is
- // the folder of the host toolchain for that tool which is essential when
- // using a cross linker. We return a Vec since on x64 there are often two
- // linkers that can target the architecture we desire. The 64-bit host
- // linker is preferred, and hence first, due to 64-bit allowing it more
- // address space to work with and potentially being faster.
- fn bin_subdir(target: &str) -> Vec<(&'static str, &'static str)> {
- let arch = target.split('-').next().unwrap();
- match (arch, host_arch()) {
- ("i586", X86) | ("i686", X86) => vec![("", "")],
- ("i586", X86_64) | ("i686", X86_64) => vec![("amd64_x86", "amd64"), ("", "")],
- ("x86_64", X86) => vec![("x86_amd64", "")],
- ("x86_64", X86_64) => vec![("amd64", "amd64"), ("x86_amd64", "")],
- ("arm", X86) | ("thumbv7a", X86) => vec![("x86_arm", "")],
- ("arm", X86_64) | ("thumbv7a", X86_64) => vec![("amd64_arm", "amd64"), ("x86_arm", "")],
- _ => vec![],
- }
- }
-
- fn lib_subdir(target: &str) -> Option<&'static str> {
- let arch = target.split('-').next().unwrap();
- match arch {
- "i586" | "i686" => Some("x86"),
- "x86_64" => Some("x64"),
- "arm" | "thumbv7a" => Some("arm"),
- "aarch64" => Some("arm64"),
- _ => None,
- }
- }
-
- // MSVC's x86 libraries are not in a subfolder
- fn vc_lib_subdir(target: &str) -> Option<&'static str> {
- let arch = target.split('-').next().unwrap();
- match arch {
- "i586" | "i686" => Some(""),
- "x86_64" => Some("amd64"),
- "arm" | "thumbv7a" => Some("arm"),
- "aarch64" => Some("arm64"),
- _ => None,
- }
- }
-
- #[allow(bad_style)]
- fn host_arch() -> u16 {
- type DWORD = u32;
- type WORD = u16;
- type LPVOID = *mut u8;
- type DWORD_PTR = usize;
-
- #[repr(C)]
- struct SYSTEM_INFO {
- wProcessorArchitecture: WORD,
- _wReserved: WORD,
- _dwPageSize: DWORD,
- _lpMinimumApplicationAddress: LPVOID,
- _lpMaximumApplicationAddress: LPVOID,
- _dwActiveProcessorMask: DWORD_PTR,
- _dwNumberOfProcessors: DWORD,
- _dwProcessorType: DWORD,
- _dwAllocationGranularity: DWORD,
- _wProcessorLevel: WORD,
- _wProcessorRevision: WORD,
- }
-
- extern "system" {
- fn GetNativeSystemInfo(lpSystemInfo: *mut SYSTEM_INFO);
- }
-
- unsafe {
- let mut info = mem::zeroed();
- GetNativeSystemInfo(&mut info);
- info.wProcessorArchitecture
- }
- }
-
- // Given a registry key, look at all the sub keys and find the one which has
- // the maximal numeric value.
- //
- // Returns the name of the maximal key as well as the opened maximal key.
- fn max_version(key: &RegistryKey) -> Option<(OsString, RegistryKey)> {
- let mut max_vers = 0;
- let mut max_key = None;
- for subkey in key.iter().filter_map(|k| k.ok()) {
- let val = subkey
- .to_str()
- .and_then(|s| s.trim_left_matches("v").replace(".", "").parse().ok());
- let val = match val {
- Some(s) => s,
- None => continue,
- };
- if val > max_vers {
- if let Ok(k) = key.open(&subkey) {
- max_vers = val;
- max_key = Some((subkey, k));
- }
- }
- }
- max_key
- }
-
- pub fn has_msbuild_version(version: &str) -> bool {
- match version {
- "16.0" => {
- find_msbuild_vs16("x86_64-pc-windows-msvc").is_some()
- || find_msbuild_vs16("i686-pc-windows-msvc").is_some()
- }
- "15.0" => {
- find_msbuild_vs15("x86_64-pc-windows-msvc").is_some()
- || find_msbuild_vs15("i686-pc-windows-msvc").is_some()
- }
- "12.0" | "14.0" => LOCAL_MACHINE
- .open(&OsString::from(format!(
- "SOFTWARE\\Microsoft\\MSBuild\\ToolsVersions\\{}",
- version
- )))
- .is_ok(),
- _ => false,
- }
- }
-
- pub fn find_devenv(target: &str) -> Option<Tool> {
- find_devenv_vs15(&target)
- }
-
- fn find_devenv_vs15(target: &str) -> Option<Tool> {
- find_tool_in_vs15_path(r"Common7\IDE\devenv.exe", target)
- }
-
- // see http://stackoverflow.com/questions/328017/path-to-msbuild
- pub fn find_msbuild(target: &str) -> Option<Tool> {
- // VS 15 (2017) changed how to locate msbuild
- if let Some(r) = find_msbuild_vs15(target) {
- return Some(r);
- } else {
- find_old_msbuild(target)
- }
- }
-
- fn find_msbuild_vs15(target: &str) -> Option<Tool> {
- find_tool_in_vs15_path(r"MSBuild\15.0\Bin\MSBuild.exe", target)
- }
-
- fn find_old_msbuild(target: &str) -> Option<Tool> {
- let key = r"SOFTWARE\Microsoft\MSBuild\ToolsVersions";
- LOCAL_MACHINE
- .open(key.as_ref())
- .ok()
- .and_then(|key| {
- max_version(&key).and_then(|(_vers, key)| key.query_str("MSBuildToolsPath").ok())
- })
- .map(|path| {
- let mut path = PathBuf::from(path);
- path.push("MSBuild.exe");
- let mut tool = Tool::new(path);
- if target.contains("x86_64") {
- tool.env.push(("Platform".into(), "X64".into()));
- }
- tool
- })
- }
-}
diff --git a/cc/tests/cc_env.rs b/cc/tests/cc_env.rs
deleted file mode 100644
index e862fea..0000000
--- a/cc/tests/cc_env.rs
+++ /dev/null
@@ -1,121 +0,0 @@
-extern crate cc;
-extern crate tempdir;
-
-use std::env;
-use std::ffi::OsString;
-use std::path::Path;
-
-mod support;
-use support::Test;
-
-#[test]
-fn main() {
- ccache();
- distcc();
- ccache_spaces();
- ccache_env_flags();
- leading_spaces();
- extra_flags();
- path_to_ccache();
- more_spaces();
-}
-
-fn ccache() {
- let test = Test::gnu();
-
- env::set_var("CC", "ccache cc");
- let compiler = test.gcc().file("foo.c").get_compiler();
-
- assert_eq!(compiler.path(), Path::new("cc"));
-}
-
-fn ccache_spaces() {
- let test = Test::gnu();
- test.shim("ccache");
-
- env::set_var("CC", "ccache cc");
- let compiler = test.gcc().file("foo.c").get_compiler();
- assert_eq!(compiler.path(), Path::new("cc"));
-}
-
-fn distcc() {
- let test = Test::gnu();
- test.shim("distcc");
-
- env::set_var("CC", "distcc cc");
- let compiler = test.gcc().file("foo.c").get_compiler();
- assert_eq!(compiler.path(), Path::new("cc"));
-}
-
-fn ccache_env_flags() {
- let test = Test::gnu();
- test.shim("ccache");
-
- env::set_var("CC", "ccache lol-this-is-not-a-compiler");
- let compiler = test.gcc().file("foo.c").get_compiler();
- assert_eq!(compiler.path(), Path::new("lol-this-is-not-a-compiler"));
- assert_eq!(
- compiler.cc_env(),
- OsString::from("ccache lol-this-is-not-a-compiler")
- );
- assert!(
- compiler
- .cflags_env()
- .into_string()
- .unwrap()
- .contains("ccache")
- == false
- );
- assert!(
- compiler
- .cflags_env()
- .into_string()
- .unwrap()
- .contains(" lol-this-is-not-a-compiler")
- == false
- );
-
- env::set_var("CC", "");
-}
-
-fn leading_spaces() {
- let test = Test::gnu();
- test.shim("ccache");
-
- env::set_var("CC", " test ");
- let compiler = test.gcc().file("foo.c").get_compiler();
- assert_eq!(compiler.path(), Path::new("test"));
-
- env::set_var("CC", "");
-}
-
-fn extra_flags() {
- let test = Test::gnu();
- test.shim("ccache");
-
- env::set_var("CC", "ccache cc -m32");
- let compiler = test.gcc().file("foo.c").get_compiler();
- assert_eq!(compiler.path(), Path::new("cc"));
-}
-
-fn path_to_ccache() {
- let test = Test::gnu();
- test.shim("ccache");
-
- env::set_var("CC", "/path/to/ccache.exe cc -m32");
- let compiler = test.gcc().file("foo.c").get_compiler();
- assert_eq!(compiler.path(), Path::new("cc"));
- assert_eq!(
- compiler.cc_env(),
- OsString::from("/path/to/ccache.exe cc -m32"),
- );
-}
-
-fn more_spaces() {
- let test = Test::gnu();
- test.shim("ccache");
-
- env::set_var("CC", "cc -m32");
- let compiler = test.gcc().file("foo.c").get_compiler();
- assert_eq!(compiler.path(), Path::new("cc"));
-}
diff --git a/cc/tests/support/mod.rs b/cc/tests/support/mod.rs
deleted file mode 100644
index 72ca3fa..0000000
--- a/cc/tests/support/mod.rs
+++ /dev/null
@@ -1,133 +0,0 @@
-#![allow(dead_code)]
-
-use std::env;
-use std::ffi::OsStr;
-use std::fs::{self, File};
-use std::io::prelude::*;
-use std::path::PathBuf;
-
-use cc;
-use tempdir::TempDir;
-
-pub struct Test {
- pub td: TempDir,
- pub gcc: PathBuf,
- pub msvc: bool,
-}
-
-pub struct Execution {
- args: Vec<String>,
-}
-
-impl Test {
- pub fn new() -> Test {
- let mut gcc = PathBuf::from(env::current_exe().unwrap());
- gcc.pop();
- if gcc.ends_with("deps") {
- gcc.pop();
- }
- gcc.push(format!("gcc-shim{}", env::consts::EXE_SUFFIX));
- Test {
- td: TempDir::new("gcc-test").unwrap(),
- gcc: gcc,
- msvc: false,
- }
- }
-
- pub fn gnu() -> Test {
- let t = Test::new();
- t.shim("cc").shim("c++").shim("ar");
- t
- }
-
- pub fn msvc() -> Test {
- let mut t = Test::new();
- t.shim("cl").shim("lib.exe");
- t.msvc = true;
- t
- }
-
- pub fn shim(&self, name: &str) -> &Test {
- let fname = format!("{}{}", name, env::consts::EXE_SUFFIX);
- fs::hard_link(&self.gcc, self.td.path().join(&fname))
- .or_else(|_| fs::copy(&self.gcc, self.td.path().join(&fname)).map(|_| ()))
- .unwrap();
- self
- }
-
- pub fn gcc(&self) -> cc::Build {
- let mut cfg = cc::Build::new();
- let mut path = env::split_paths(&env::var_os("PATH").unwrap()).collect::<Vec<_>>();
- path.insert(0, self.td.path().to_owned());
- let target = if self.msvc {
- "x86_64-pc-windows-msvc"
- } else {
- "x86_64-unknown-linux-gnu"
- };
-
- cfg.target(target)
- .host(target)
- .opt_level(2)
- .debug(false)
- .out_dir(self.td.path())
- .__set_env("PATH", env::join_paths(path).unwrap())
- .__set_env("GCCTEST_OUT_DIR", self.td.path());
- if self.msvc {
- cfg.compiler(self.td.path().join("cl"));
- cfg.archiver(self.td.path().join("lib.exe"));
- }
- cfg
- }
-
- pub fn cmd(&self, i: u32) -> Execution {
- let mut s = String::new();
- File::open(self.td.path().join(format!("out{}", i)))
- .unwrap()
- .read_to_string(&mut s)
- .unwrap();
- Execution {
- args: s.lines().map(|s| s.to_string()).collect(),
- }
- }
-}
-
-impl Execution {
- pub fn must_have<P: AsRef<OsStr>>(&self, p: P) -> &Execution {
- if !self.has(p.as_ref()) {
- panic!("didn't find {:?} in {:?}", p.as_ref(), self.args);
- } else {
- self
- }
- }
-
- pub fn must_not_have<P: AsRef<OsStr>>(&self, p: P) -> &Execution {
- if self.has(p.as_ref()) {
- panic!("found {:?}", p.as_ref());
- } else {
- self
- }
- }
-
- pub fn has(&self, p: &OsStr) -> bool {
- self.args.iter().any(|arg| OsStr::new(arg) == p)
- }
-
- pub fn must_have_in_order(&self, before: &str, after: &str) -> &Execution {
- let before_position = self
- .args
- .iter()
- .rposition(|x| OsStr::new(x) == OsStr::new(before));
- let after_position = self
- .args
- .iter()
- .rposition(|x| OsStr::new(x) == OsStr::new(after));
- match (before_position, after_position) {
- (Some(b), Some(a)) if b < a => {}
- (b, a) => panic!(
- "{:?} (last position: {:?}) did not appear before {:?} (last position: {:?})",
- before, b, after, a
- ),
- };
- self
- }
-}
diff --git a/cc/tests/test.rs b/cc/tests/test.rs
deleted file mode 100644
index 5147b77..0000000
--- a/cc/tests/test.rs
+++ /dev/null
@@ -1,371 +0,0 @@
-extern crate cc;
-extern crate tempdir;
-
-use std::env;
-use support::Test;
-
-mod support;
-
-#[test]
-fn gnu_smoke() {
- let test = Test::gnu();
- test.gcc().file("foo.c").compile("foo");
-
- test.cmd(0)
- .must_have("-O2")
- .must_have("foo.c")
- .must_not_have("-g")
- .must_have("-c")
- .must_have("-ffunction-sections")
- .must_have("-fdata-sections");
- test.cmd(1).must_have(test.td.path().join("foo.o"));
-}
-
-#[test]
-fn gnu_opt_level_1() {
- let test = Test::gnu();
- test.gcc().opt_level(1).file("foo.c").compile("foo");
-
- test.cmd(0).must_have("-O1").must_not_have("-O2");
-}
-
-#[test]
-fn gnu_opt_level_s() {
- let test = Test::gnu();
- test.gcc().opt_level_str("s").file("foo.c").compile("foo");
-
- test.cmd(0)
- .must_have("-Os")
- .must_not_have("-O1")
- .must_not_have("-O2")
- .must_not_have("-O3")
- .must_not_have("-Oz");
-}
-
-#[test]
-fn gnu_debug() {
- let test = Test::gnu();
- test.gcc().debug(true).file("foo.c").compile("foo");
- test.cmd(0).must_have("-g");
-}
-
-#[test]
-fn gnu_warnings_into_errors() {
- let test = Test::gnu();
- test.gcc()
- .warnings_into_errors(true)
- .file("foo.c")
- .compile("foo");
-
- test.cmd(0).must_have("-Werror");
-}
-
-#[test]
-fn gnu_warnings() {
- let test = Test::gnu();
- test.gcc()
- .warnings(true)
- .flag("-Wno-missing-field-initializers")
- .file("foo.c")
- .compile("foo");
-
- test.cmd(0).must_have("-Wall").must_have("-Wextra");
-}
-
-#[test]
-fn gnu_extra_warnings0() {
- let test = Test::gnu();
- test.gcc()
- .warnings(true)
- .extra_warnings(false)
- .flag("-Wno-missing-field-initializers")
- .file("foo.c")
- .compile("foo");
-
- test.cmd(0).must_have("-Wall").must_not_have("-Wextra");
-}
-
-#[test]
-fn gnu_extra_warnings1() {
- let test = Test::gnu();
- test.gcc()
- .warnings(false)
- .extra_warnings(true)
- .flag("-Wno-missing-field-initializers")
- .file("foo.c")
- .compile("foo");
-
- test.cmd(0).must_not_have("-Wall").must_have("-Wextra");
-}
-
-#[test]
-fn gnu_warnings_overridable() {
- let test = Test::gnu();
- test.gcc()
- .warnings(true)
- .flag("-Wno-missing-field-initializers")
- .file("foo.c")
- .compile("foo");
-
- test.cmd(0)
- .must_have_in_order("-Wall", "-Wno-missing-field-initializers");
-}
-
-#[test]
-fn gnu_no_warnings_if_cflags() {
- env::set_var("CFLAGS", "-Wflag-does-not-exist");
- let test = Test::gnu();
- test.gcc().file("foo.c").compile("foo");
-
- test.cmd(0).must_not_have("-Wall").must_not_have("-Wextra");
- env::set_var("CFLAGS", "");
-}
-
-#[test]
-fn gnu_no_warnings_if_cxxflags() {
- env::set_var("CXXFLAGS", "-Wflag-does-not-exist");
- let test = Test::gnu();
- test.gcc().file("foo.c").compile("foo");
-
- test.cmd(0).must_not_have("-Wall").must_not_have("-Wextra");
- env::set_var("CXXFLAGS", "");
-}
-
-#[test]
-fn gnu_x86_64() {
- for vendor in &["unknown-linux-gnu", "apple-darwin"] {
- let target = format!("x86_64-{}", vendor);
- let test = Test::gnu();
- test.gcc()
- .target(&target)
- .host(&target)
- .file("foo.c")
- .compile("foo");
-
- test.cmd(0).must_have("-fPIC").must_have("-m64");
- }
-}
-
-#[test]
-fn gnu_x86_64_no_pic() {
- for vendor in &["unknown-linux-gnu", "apple-darwin"] {
- let target = format!("x86_64-{}", vendor);
- let test = Test::gnu();
- test.gcc()
- .pic(false)
- .target(&target)
- .host(&target)
- .file("foo.c")
- .compile("foo");
-
- test.cmd(0).must_not_have("-fPIC");
- }
-}
-
-#[test]
-fn gnu_i686() {
- for vendor in &["unknown-linux-gnu", "apple-darwin"] {
- let target = format!("i686-{}", vendor);
- let test = Test::gnu();
- test.gcc()
- .target(&target)
- .host(&target)
- .file("foo.c")
- .compile("foo");
-
- test.cmd(0).must_have("-m32");
- }
-}
-
-#[test]
-fn gnu_i686_pic() {
- for vendor in &["unknown-linux-gnu", "apple-darwin"] {
- let target = format!("i686-{}", vendor);
- let test = Test::gnu();
- test.gcc()
- .pic(true)
- .target(&target)
- .host(&target)
- .file("foo.c")
- .compile("foo");
-
- test.cmd(0).must_have("-fPIC");
- }
-}
-
-#[test]
-fn gnu_x86_64_no_plt() {
- let target = "x86_64-unknown-linux-gnu";
- let test = Test::gnu();
- test.gcc()
- .pic(true)
- .use_plt(false)
- .target(&target)
- .host(&target)
- .file("foo.c")
- .compile("foo");
- test.cmd(0).must_have("-fno-plt");
-}
-
-#[test]
-fn gnu_set_stdlib() {
- let test = Test::gnu();
- test.gcc()
- .cpp_set_stdlib(Some("foo"))
- .file("foo.c")
- .compile("foo");
-
- test.cmd(0).must_not_have("-stdlib=foo");
-}
-
-#[test]
-fn gnu_include() {
- let test = Test::gnu();
- test.gcc().include("foo/bar").file("foo.c").compile("foo");
-
- test.cmd(0).must_have("-I").must_have("foo/bar");
-}
-
-#[test]
-fn gnu_define() {
- let test = Test::gnu();
- test.gcc()
- .define("FOO", "bar")
- .define("BAR", None)
- .file("foo.c")
- .compile("foo");
-
- test.cmd(0).must_have("-DFOO=bar").must_have("-DBAR");
-}
-
-#[test]
-fn gnu_compile_assembly() {
- let test = Test::gnu();
- test.gcc().file("foo.S").compile("foo");
- test.cmd(0).must_have("foo.S");
-}
-
-#[test]
-fn gnu_shared() {
- let test = Test::gnu();
- test.gcc()
- .file("foo.c")
- .shared_flag(true)
- .static_flag(false)
- .compile("foo");
-
- test.cmd(0).must_have("-shared").must_not_have("-static");
-}
-
-#[test]
-fn gnu_flag_if_supported() {
- if cfg!(windows) {
- return;
- }
- let test = Test::gnu();
- test.gcc()
- .file("foo.c")
- .flag("-v")
- .flag_if_supported("-Wall")
- .flag_if_supported("-Wflag-does-not-exist")
- .flag_if_supported("-std=c++11")
- .compile("foo");
-
- test.cmd(0)
- .must_have("-v")
- .must_have("-Wall")
- .must_not_have("-Wflag-does-not-exist")
- .must_not_have("-std=c++11");
-}
-
-#[test]
-fn gnu_flag_if_supported_cpp() {
- if cfg!(windows) {
- return;
- }
- let test = Test::gnu();
- test.gcc()
- .cpp(true)
- .file("foo.cpp")
- .flag_if_supported("-std=c++11")
- .compile("foo");
-
- test.cmd(0).must_have("-std=c++11");
-}
-
-#[test]
-fn gnu_static() {
- let test = Test::gnu();
- test.gcc()
- .file("foo.c")
- .shared_flag(false)
- .static_flag(true)
- .compile("foo");
-
- test.cmd(0).must_have("-static").must_not_have("-shared");
-}
-
-#[test]
-fn msvc_smoke() {
- let test = Test::msvc();
- test.gcc().file("foo.c").compile("foo");
-
- test.cmd(0)
- .must_have("/O2")
- .must_have("foo.c")
- .must_not_have("/Z7")
- .must_have("/c")
- .must_have("/MD");
- test.cmd(1).must_have(test.td.path().join("foo.o"));
-}
-
-#[test]
-fn msvc_opt_level_0() {
- let test = Test::msvc();
- test.gcc().opt_level(0).file("foo.c").compile("foo");
-
- test.cmd(0).must_not_have("/O2");
-}
-
-#[test]
-fn msvc_debug() {
- let test = Test::msvc();
- test.gcc().debug(true).file("foo.c").compile("foo");
- test.cmd(0).must_have("/Z7");
-}
-
-#[test]
-fn msvc_include() {
- let test = Test::msvc();
- test.gcc().include("foo/bar").file("foo.c").compile("foo");
-
- test.cmd(0).must_have("/I").must_have("foo/bar");
-}
-
-#[test]
-fn msvc_define() {
- let test = Test::msvc();
- test.gcc()
- .define("FOO", "bar")
- .define("BAR", None)
- .file("foo.c")
- .compile("foo");
-
- test.cmd(0).must_have("/DFOO=bar").must_have("/DBAR");
-}
-
-#[test]
-fn msvc_static_crt() {
- let test = Test::msvc();
- test.gcc().static_crt(true).file("foo.c").compile("foo");
-
- test.cmd(0).must_have("/MT");
-}
-
-#[test]
-fn msvc_no_static_crt() {
- let test = Test::msvc();
- test.gcc().static_crt(false).file("foo.c").compile("foo");
-
- test.cmd(0).must_have("/MD");
-}
diff --git a/nitrocli/ci/gitlab-ci.yml b/ci/gitlab-ci.yml
index 76ee517..55f0ff6 100644
--- a/nitrocli/ci/gitlab-ci.yml
+++ b/ci/gitlab-ci.yml
@@ -4,33 +4,23 @@
# Official language image. Look for the different tagged releases at:
# https://hub.docker.com/r/library/rust/tags/
# The recipe for this docker image can be found at:
-# https://github.com/rust-lang/docker-rust/blob/e7703b2cf525f2525bdf8d131cd66b5b38b1513c/1.31.0/stretch/Dockerfile
-image: "rust:1.31.0"
+# https://github.com/rust-lang/docker-rust/blob/3898d19194231639f1afc3096bd04702eaf555e7/1.40.0/buster/Dockerfile
+image: "rust:1.40.0"
build-test:cargo:
script:
- apt-get update
- apt-get install --assume-yes libudev-dev libhidapi-dev
- rustc --version && cargo --version
- - cd nitrocli
- cargo build --all --verbose
- cargo test --all --verbose
lint:clippy:
script:
- rustup component add clippy
- # First check and build everything but be very permissive. Then clean
- # only the nitrocli package artifacts. Lastly check once more, but
- # with warnings turned to errors. This last run will only recheck
- # nitrocli (everything else is still up-to-date). That procedure is
- # necessary because consumed dependencies may emit errors otherwise.
- - cd nitrocli
- - cargo clippy --all-targets --all-features -- -A clippy::all
- - cargo clean --package=nitrocli
- cargo clippy --all-targets --all-features -- -D warnings
format:rustfmt:
script:
- rustup component add rustfmt
- - cd nitrocli
- cargo fmt --all -- --check
diff --git a/nitrocli/doc/CONTRIBUTING.md b/doc/CONTRIBUTING.md
index 3ebdfce..3ebdfce 100644
--- a/nitrocli/doc/CONTRIBUTING.md
+++ b/doc/CONTRIBUTING.md
diff --git a/nitrocli/doc/nitrocli.1 b/doc/nitrocli.1
index 9029335..04bfe61 100644
--- a/nitrocli/doc/nitrocli.1
+++ b/doc/nitrocli.1
@@ -1,10 +1,8 @@
-.TH NITROCLI 1 2019-05-26
+.TH NITROCLI 1 2020-01-29
.SH NAME
nitrocli \- access Nitrokey devices
.SH SYNOPSIS
.B nitrocli
-[\fB\-m\fR|\fB\-\-model pro\fR|\fBstorage\fR] \fR[\fB\-v\fR|\fB\-\-verbose\fR]
-[\fB\-V\fR|\fB\-\-version\fR]
\fIcommand\fR
[\fIarguments\fR]
.SH DESCRIPTION
@@ -32,9 +30,20 @@ Print the nitrocli version and exit.
.SH COMMANDS
.SS General
.TP
+.B nitrocli list \fR[\fB-n\fR|\fB\-\-no-connect\fR]
+List all attached Nitrokey devices.
+This command prints a list of the device path, the model and the serial number
+of all attached Nitrokey devices.
+To access the serial number of a Nitrokey Storage device, \fBnitrocli\fR has to
+connect to it.
+To omit the serial number of Nitrokey Storage devices instead of connecting to
+them, set the \fB\-\-no-connect\fR option.
+.TP
.B nitrocli status
Print the status of the connected Nitrokey device, including the stick serial
-number, the firmware version, and the PIN retry count.
+number, the firmware version, and the PIN retry count. If the device is a
+Nitrokey Storage, also print storage related information including the SD card
+serial number, the encryption status, and the status of the volumes.
.TP
.B nitrocli lock
Lock the Nitrokey.
@@ -61,20 +70,24 @@ this overlay (which is required to achieve plausible deniability of the
existence of hidden volumes), the burden of ensuring that data on the encrypted
volume does not overlap with data on one of the hidden volumes is on the user.
.TP
-\fBnitrocli storage open
+\fBnitrocli unencrypted set \fImode\fR
+Change the read-write mode of the volume.
+\fImode\fR is the type of the mode to change to: \fBread-write\fR to make the
+volume readable and writable or \fBread-only\fR to make it only readable.
+This command requires the admin PIN.
+
+Note that this command requires firmware version 0.51 or higher. Earlier
+versions are not supported.
+.TP
+\fBnitrocli encrypted open
Open the encrypted volume on the Nitrokey Storage.
The user PIN that is required to open the volume is queried using
\fBpinentry\fR(1) and cached by \fBgpg\-agent\fR(1).
.TP
-\fBnitrocli storage close
+\fBnitrocli encrypted close
Close the encrypted volume on the Nitrokey Storage.
.TP
-\fBnitrocli storage status
-Print the status of the connected Nitrokey Storage device's storage. The
-printed information includes the SD card serial number, the encryption
-status, and the status of the volumes.
-.TP
-\fBnitrocli storage hidden create \fIslot\fR \fIstart\fR \fIend\fR
+\fBnitrocli hidden create \fIslot\fR \fIstart\fR \fIend\fR
Create a new hidden volume inside the encrypted volume. \fIslot\fR must indicate
one of the four available slots. \fIstart\fR and \fIend\fR represent,
respectively, the start and end position of the hidden volume inside the
@@ -82,14 +95,14 @@ encrypted volume, as a percentage of the encrypted volume's size.
This command requires a password which is later used to look up the hidden
volume to open. Unlike a PIN, this password is not cached by \fBgpg\-agent\fR(1).
.TP
-\fBnitrocli storage hidden open
+\fBnitrocli hidden open
Open a hidden volume. The volume to open is determined based on the password
entered, which must have a minimum of six characters. Only one hidden volume can
be active at any point in time and previously opened volumes will be
automatically closed. Similarly, the encrypted volume will be closed if it was
open.
.TP
-\fBnitrocli storage hidden close
+\fBnitrocli hidden close
Close a hidden volume.
.SS One-time passwords
@@ -278,7 +291,7 @@ The new user PIN to set. This variable is only used by the \fBpin set\fR command
for the \fBuser\fR type.
.TP
.B NITROCLI_PASSWORD
-A password used by commands that require one (e.g., \fBstorage hidden open\fR).
+A password used by commands that require one (e.g., \fBhidden open\fR).
.TP
.B NITROCLI_NO_CACHE
If this variable is present in the environment, do not cache any inquired
@@ -291,7 +304,7 @@ Use the \fBpin clear\fR command to clear secrets from the cache.
.SS Storage
Create a hidden volume in the first available slot, starting at half the size of
the encrypted volume (i.e., 50%) and stretching all the way to its end (100%):
- $ \fBnitrocli storage hidden create 0 50 100\fR
+ $ \fBnitrocli hidden create 0 50 100\fR
.SS One-time passwords
Configure a one-time password slot with a hexadecimal secret representation:
diff --git a/doc/nitrocli.1.pdf b/doc/nitrocli.1.pdf
new file mode 100644
index 0000000..596e794
--- /dev/null
+++ b/doc/nitrocli.1.pdf
Binary files differ
diff --git a/nitrocli/doc/packaging.md b/doc/packaging.md
index 7ed302a..5ff4089 100644
--- a/nitrocli/doc/packaging.md
+++ b/doc/packaging.md
@@ -38,8 +38,8 @@ Debian
described in the `README.rst` file.)
5. Inspect the generated package by running `dpkg-deb --info` and `dpkg-deb
--contents` on it.
-6. If you have push access to the repository, update the `TODO.rst` file to
- indicate that `nitrocli` can be updated.
+6. If you have push access to the repository, create the
+ `src/nitrocli/debian/RFS` file to indicate that `nitrocli` can be updated.
7. Add and commit your changes. If you have push access, push them.
Otherwise create a merge request and indicate that `nitrocli` is ready for
upload in its description.
@@ -47,12 +47,18 @@ Debian
For more information, see the [Teams/RustPackaging][] page in the Debian Wiki
and the [README.rst file][] in the debcargo-conf repository.
+For detailed information on the status of the Debian package, check the [Debian
+Package Tracker][].
+
Ubuntu
------
The `nitrocli` package for Ubuntu is automatically generated from the Debian
-package.
+package. For detailed information on the status of the Ubuntu package, check
+[Launchpad][].
[Arch User Repository]: https://wiki.archlinux.org/index.php/Arch_User_Repository
[Teams/RustPackaging]: https://wiki.debian.org/Teams/RustPackaging
[README.rst file]: https://salsa.debian.org/rust-team/debcargo-conf/blob/master/README.rst
+[Debian Package Tracker]: https://tracker.debian.org/pkg/rust-nitrocli
+[Launchpad]: https://launchpad.net/ubuntu/+source/rust-nitrocli
diff --git a/libc/.cirrus.yml b/libc/.cirrus.yml
deleted file mode 100644
index 47807ab..0000000
--- a/libc/.cirrus.yml
+++ /dev/null
@@ -1,27 +0,0 @@
-task:
- name: stable x86_64-unknown-freebsd-11
- freebsd_instance:
- image: freebsd-11-2-release-amd64
- setup_script:
- - pkg install -y curl
- - curl https://sh.rustup.rs -sSf --output rustup.sh
- - sh rustup.sh -y
- - . $HOME/.cargo/env
- - rustup default stable
- test_script:
- - . $HOME/.cargo/env
- - sh ci/run.sh x86_64-unknown-freebsd
-
-task:
- name: nightly x86_64-unknown-freebsd-12
- freebsd_instance:
- image: freebsd-12-0-release-amd64
- setup_script:
- - pkg install -y curl
- - curl https://sh.rustup.rs -sSf --output rustup.sh
- - sh rustup.sh --default-toolchain nightly -y
- - . $HOME/.cargo/env
- - rustup default nightly
- test_script:
- - . $HOME/.cargo/env
- - sh ci/run.sh x86_64-unknown-freebsd
diff --git a/libc/.github/issue_template.md b/libc/.github/issue_template.md
deleted file mode 100644
index 435bf35..0000000
--- a/libc/.github/issue_template.md
+++ /dev/null
@@ -1,24 +0,0 @@
-<!--
-**Help us help you.**
-
-If you are reporting a bug, include:
-
-* a Minimum Working Example without any dependencies (except libc) that shows
- the issue and ideally reproduces in the Rust playground
-* the target triple - libc supports many targets and many APIs
-* instructions to reproduce, logs (e.g. build logs, links to Travis-CI logs,
- uploads to github gists, etc.).
-
-If you are requesting a new API, include:
-
-* the target triple
-* link to the documentation of the API showing the type signatures, how to use
- it, etc.
-
-In general, just please consider that the people who can help you are all very
-busy, they will be helping you in their free time, there are a lot of people in
-need of help so they need to prioritize to which issues they devote their free
-time, etc. So try to give most of the information upfront, be concise, show
-small self-contained examples (nobody has time to create a new cargo project,
-set up dependencies,...), etc. Help us help you.
--->
diff --git a/libc/.gitignore b/libc/.gitignore
deleted file mode 100644
index bbbad4b..0000000
--- a/libc/.gitignore
+++ /dev/null
@@ -1,4 +0,0 @@
-target
-Cargo.lock
-*~
-style
diff --git a/libc/.travis.yml b/libc/.travis.yml
deleted file mode 100644
index ea5e0ac..0000000
--- a/libc/.travis.yml
+++ /dev/null
@@ -1,254 +0,0 @@
-language: rust
-rust: nightly
-sudo: required
-dist: xenial
-services: docker
-
-stages:
- - tools-and-build-and-tier1
- - tier2
-
-matrix:
- include:
- # TOOLS
- - name: "Documentation"
- env: TARGET=x86_64-unknown-linux-gnu
- script: sh ci/dox.sh
- install:
- - travis_retry rustup component add rust-src
- - travis_retry cargo install xargo
- stage: tools-and-build-and-tier1
- - name: "Shellcheck"
- install: true
- script:
- - shellcheck --version
- # FIXME: https://github.com/koalaman/shellcheck/issues/1591
- - shellcheck -e SC2103 ci/*.sh
- stage: tools-and-build-and-tier1
- - name: "Style"
- install: true
- script:
- - rustc ci/style.rs && ./style src
- # Disabled due to rust-lang/rustfmt#3341
- #- |
- # if rustup component add rustfmt-preview ; then
- # cargo fmt --all -- --check
- # fi
- stage: tools-and-build-and-tier1
- - name: "Semver Linux"
- install: travis_retry cargo +nightly install semverver
- script: sh ci/semver.sh
- stage: tools-and-build-and-tier1
- - name: "Semver MacOSX"
- install: travis_retry cargo +nightly install semverver
- script: sh ci/semver.sh
- os: osx
- osx_image: xcode10
- stage: tools-and-build-and-tier1
-
- # BUILD stable, beta, nightly
- - name: "Build Stable Rust"
- script: sh ci/build.sh
- stage: tools-and-build-and-tier1
- rust: stable
- install: true
- - name: "Build Beta Rust"
- script: sh ci/build.sh
- stage: tools-and-build-and-tier1
- rust: beta
- install: true
- - name: "Build Nightly Rust"
- script: sh ci/build.sh
- stage: tools-and-build-and-tier1
- rust: nightly
- install:
- - travis_retry rustup component add rust-src
- - travis_retry cargo install xargo
- - name: "Build Stable Rust"
- script: sh ci/build.sh
- stage: tools-and-build-and-tier1
- rust: stable
- os: osx
- osx_image: xcode10
- install: true
- - name: "Build Beta Rust"
- script: sh ci/build.sh
- stage: tools-and-build-and-tier1
- rust: beta
- os: osx
- osx_image: xcode10
- install: true
- - name: "Build Nightly Rust"
- script: sh ci/build.sh
- stage: tools-and-build-and-tier1
- rust: nightly
- os: osx
- osx_image: xcode10
- install: true
- - name: "Build Stable Rust 1.13.0"
- script: sh ci/build.sh
- stage: tools-and-build-and-tier1
- rust: 1.13.0
- install: true
- - name: "Build Stable Rust 1.19.0"
- script: sh ci/build.sh
- stage: tools-and-build-and-tier1
- rust: 1.19.0
- install: true
- - name: "Build Stable Rust 1.24.0"
- script: sh ci/build.sh
- stage: tools-and-build-and-tier1
- rust: 1.24.0
- install: true
- - name: "Build Stable Rust 1.25.0"
- script: sh ci/build.sh
- stage: tools-and-build-and-tier1
- rust: 1.25.0
- install: true
- - name: "Build Stable Rust 1.30.0"
- script: sh ci/build.sh
- stage: tools-and-build-and-tier1
- rust: 1.30.0
- install: true
- - name: "Build Stable Rust 1.13.0"
- script: sh ci/build.sh
- stage: tools-and-build-and-tier1
- rust: 1.13.0
- os: osx
- osx_image: xcode10
- install: true
- - name: "Build Stable Rust 1.19.0"
- script: sh ci/build.sh
- stage: tools-and-build-and-tier1
- rust: 1.19.0
- os: osx
- osx_image: xcode10
- install: true
- - name: "Build Stable Rust 1.24.0"
- script: sh ci/build.sh
- stage: tools-and-build-and-tier1
- rust: 1.24.0
- os: osx
- osx_image: xcode10
- install: true
- - name: "Build Stable Rust 1.25.0"
- script: sh ci/build.sh
- stage: tools-and-build-and-tier1
- rust: 1.25.0
- os: osx
- osx_image: xcode10
- install: true
- - name: "Build Stable Rust 1.30.0"
- script: sh ci/build.sh
- stage: tools-and-build-and-tier1
- rust: 1.30.0
- os: osx
- osx_image: xcode10
- install: true
- - env: TARGET=i686-apple-darwin
- os: osx
- osx_image: xcode10
- stage: tools-and-build-and-tier1
- - env: TARGET=i686-unknown-linux-gnu
- stage: tools-and-build-and-tier1
- - env: TARGET=x86_64-apple-darwin
- os: osx
- osx_image: xcode10
- install: true
- stage: tools-and-build-and-tier1
- - env: TARGET=x86_64-unknown-linux-gnu
- stage: tools-and-build-and-tier1
- install: true
-
- # Tier 2 targets
- - env: TARGET=aarch64-linux-android
- stage: tier2
- - env: TARGET=aarch64-unknown-linux-gnu
- stage: tier2
- - env: TARGET=aarch64-unknown-linux-musl
- stage: tier2
- - env: TARGET=arm-linux-androideabi
- stage: tier2
- - env: TARGET=arm-unknown-linux-gnueabihf
- stage: tier2
- - env: TARGET=arm-unknown-linux-musleabihf
- stage: tier2
- - env: TARGET=asmjs-unknown-emscripten
- stage: tier2
- - env: TARGET=i686-linux-android
- stage: tier2
- - env: TARGET=i686-unknown-linux-musl
- stage: tier2
- - env: TARGET=mips-unknown-linux-gnu
- stage: tier2
- - env: TARGET=mips-unknown-linux-musl
- stage: tier2
- - env: TARGET=mips64-unknown-linux-gnuabi64
- stage: tier2
- - env: TARGET=mips64el-unknown-linux-gnuabi64
- stage: tier2
- - env: TARGET=mipsel-unknown-linux-musl
- stage: tier2
- - env: TARGET=powerpc-unknown-linux-gnu
- stage: tier2
- - env: TARGET=powerpc64-unknown-linux-gnu
- stage: tier2
- - env: TARGET=powerpc64le-unknown-linux-gnu
- stage: tier2
- - env: TARGET=s390x-unknown-linux-gnu
- stage: tier2
- - env: TARGET=sparc64-unknown-linux-gnu
- stage: tier2
- - env: TARGET=wasm32-unknown-emscripten
- stage: tier2
- - env: TARGET=x86_64-linux-android
- stage: tier2
- - env: TARGET=x86_64-unknown-linux-gnux32 OPT="--release"
- stage: tier2
- - env: TARGET=x86_64-unknown-linux-musl
- stage: tier2
- - env: TARGET=wasm32-wasi
- rust: nightly
- stage: tier2
- - name: "Nintendo Switch - build libcore only"
- rust: nightly
- stage: tier2
- install:
- - rustup component add rust-src
- - (test -x $HOME/.cargo/bin/cargo-xbuild || cargo install cargo-xbuild)
- script:
- - mkdir -p target
- - cd target
- - wget https://github.com/devkitPro/pacman/releases/download/devkitpro-pacman-1.0.1/devkitpro-pacman.deb
- - sudo dpkg -i devkitpro-pacman.deb
- - sudo dkp-pacman -Sy
- - sudo dkp-pacman -Syu
- - sudo dkp-pacman -S -v --noconfirm switch-dev devkitA64
- - export PATH="$PATH:/opt/devkitpro/devkitA64/bin"
- - export PATH="$PATH:/opt/devkitpro/tools/bin"
- - cd ..
- # Pull the target spec up into the current directory and then build
- - mv ci/switch.json switch.json
- - cargo xbuild --target switch.json
-
-
- allow_failures:
- - name: "Semver Linux"
- - name: "Semver MacOSX"
-
-install: travis_retry rustup target add $TARGET
-
-script:
- - cargo generate-lockfile --manifest-path libc-test/Cargo.toml
- - if [[ $TRAVIS_OS_NAME = "linux" ]] && [[ $BUILD_ONLY != "1" ]]; then
- sh ci/run-docker.sh $TARGET;
- else
- sh ci/run.sh $TARGET;
- fi
-env:
- global:
- secure: "e2/3QjgRN9atOuSHp22TrYG7QVKcYUWY48Hi9b60w+r1+BhPkTseIJLte7WefRhdXtqpjjUJTooKDhnurFOeHaCT+nmBgiv+FPU893sBl4bhesY4m0vgUJVbNZcs6lTImYekWVb+aqjGdgV/XAgCw7c3kPmrZV0MzGDWL64Xaps="
-
-notifications:
- email:
- on_success: never
diff --git a/libc/CONTRIBUTING.md b/libc/CONTRIBUTING.md
deleted file mode 100644
index 0e5d0c6..0000000
--- a/libc/CONTRIBUTING.md
+++ /dev/null
@@ -1,66 +0,0 @@
-# Contributing to `libc`
-
-Welcome! If you are reading this document, it means you are interested in contributing
-to the `libc` crate.
-
-## Adding an API
-
-Want to use an API which currently isn't bound in `libc`? It's quite easy to add
-one!
-
-The internal structure of this crate is designed to minimize the number of
-`#[cfg]` attributes in order to easily be able to add new items which apply
-to all platforms in the future. As a result, the crate is organized
-hierarchically based on platform. Each module has a number of `#[cfg]`'d
-children, but only one is ever actually compiled. Each module then reexports all
-the contents of its children.
-
-This means that for each platform that libc supports, the path from a
-leaf module to the root will contain all bindings for the platform in question.
-Consequently, this indicates where an API should be added! Adding an API at a
-particular level in the hierarchy means that it is supported on all the child
-platforms of that level. For example, when adding a Unix API it should be added
-to `src/unix/mod.rs`, but when adding a Linux-only API it should be added to
-`src/unix/notbsd/linux/mod.rs`.
-
-If you're not 100% sure at what level of the hierarchy an API should be added
-at, fear not! This crate has CI support which tests any binding against all
-platforms supported, so you'll see failures if an API is added at the wrong
-level or has different signatures across platforms.
-
-With that in mind, the steps for adding a new API are:
-
-1. Determine where in the module hierarchy your API should be added.
-2. Add the API.
-3. Send a PR to this repo.
-4. Wait for CI to pass, fixing errors.
-5. Wait for a merge!
-
-### Test before you commit
-
-We have two automated tests running on [Travis](https://travis-ci.org/rust-lang/libc):
-
-1. [`libc-test`](https://github.com/alexcrichton/ctest)
- - `cd libc-test && cargo test`
- - Use the `skip_*()` functions in `build.rs` if you really need a workaround.
-2. Style checker
- - `rustc ci/style.rs && ./style src`
-
-### Releasing your change to crates.io
-
-Now that you've done the amazing job of landing your new API or your new
-platform in this crate, the next step is to get that sweet, sweet usage from
-crates.io! The only next step is to bump the version of libc and then publish
-it. If you'd like to get a release out ASAP you can follow these steps:
-
-1. Update the version number in `Cargo.toml`, you'll just be bumping the patch
- version number.
-2. Run `cargo update` to regenerate the lockfile to encode your version bump in
- the lock file. You may pull in some other updated dependencies, that's ok.
-3. Send a PR to this repository. It should [look like this][example], but it'd
- also be nice to fill out the description with a small rationale for the
- release (any rationale is ok though!)
-4. Once merged the release will be tagged and published by one of the libc crate
- maintainers.
-
-[example]: https://github.com/rust-lang/libc/pull/583
diff --git a/libc/Cargo.toml b/libc/Cargo.toml
deleted file mode 100644
index 82ecfe0..0000000
--- a/libc/Cargo.toml
+++ /dev/null
@@ -1,35 +0,0 @@
-[package]
-name = "libc"
-version = "0.2.57"
-authors = ["The Rust Project Developers"]
-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 = """
-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 = ["std"]
-std = []
-align = []
-rustc-dep-of-std = ['align', 'rustc-std-workspace-core']
-extra_traits = []
-# use_std is deprecated, use `std` instead
-use_std = [ 'std' ]
-
-[workspace]
-members = ["libc-test"]
diff --git a/libc/LICENSE-APACHE b/libc/LICENSE-APACHE
deleted file mode 100644
index 16fe87b..0000000
--- a/libc/LICENSE-APACHE
+++ /dev/null
@@ -1,201 +0,0 @@
- Apache License
- Version 2.0, January 2004
- http://www.apache.org/licenses/
-
-TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
-1. Definitions.
-
- "License" shall mean the terms and conditions for use, reproduction,
- and distribution as defined by Sections 1 through 9 of this document.
-
- "Licensor" shall mean the copyright owner or entity authorized by
- the copyright owner that is granting the License.
-
- "Legal Entity" shall mean the union of the acting entity and all
- other entities that control, are controlled by, or are under common
- control with that entity. For the purposes of this definition,
- "control" means (i) the power, direct or indirect, to cause the
- direction or management of such entity, whether by contract or
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
- outstanding shares, or (iii) beneficial ownership of such entity.
-
- "You" (or "Your") shall mean an individual or Legal Entity
- exercising permissions granted by this License.
-
- "Source" form shall mean the preferred form for making modifications,
- including but not limited to software source code, documentation
- source, and configuration files.
-
- "Object" form shall mean any form resulting from mechanical
- transformation or translation of a Source form, including but
- not limited to compiled object code, generated documentation,
- and conversions to other media types.
-
- "Work" shall mean the work of authorship, whether in Source or
- Object form, made available under the License, as indicated by a
- copyright notice that is included in or attached to the work
- (an example is provided in the Appendix below).
-
- "Derivative Works" shall mean any work, whether in Source or Object
- form, that is based on (or derived from) the Work and for which the
- editorial revisions, annotations, elaborations, or other modifications
- represent, as a whole, an original work of authorship. For the purposes
- of this License, Derivative Works shall not include works that remain
- separable from, or merely link (or bind by name) to the interfaces of,
- the Work and Derivative Works thereof.
-
- "Contribution" shall mean any work of authorship, including
- the original version of the Work and any modifications or additions
- to that Work or Derivative Works thereof, that is intentionally
- submitted to Licensor for inclusion in the Work by the copyright owner
- or by an individual or Legal Entity authorized to submit on behalf of
- the copyright owner. For the purposes of this definition, "submitted"
- means any form of electronic, verbal, or written communication sent
- to the Licensor or its representatives, including but not limited to
- communication on electronic mailing lists, source code control systems,
- and issue tracking systems that are managed by, or on behalf of, the
- Licensor for the purpose of discussing and improving the Work, but
- excluding communication that is conspicuously marked or otherwise
- designated in writing by the copyright owner as "Not a Contribution."
-
- "Contributor" shall mean Licensor and any individual or Legal Entity
- on behalf of whom a Contribution has been received by Licensor and
- subsequently incorporated within the Work.
-
-2. Grant of Copyright License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- copyright license to reproduce, prepare Derivative Works of,
- publicly display, publicly perform, sublicense, and distribute the
- Work and such Derivative Works in Source or Object form.
-
-3. Grant of Patent License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- (except as stated in this section) patent license to make, have made,
- use, offer to sell, sell, import, and otherwise transfer the Work,
- where such license applies only to those patent claims licensable
- by such Contributor that are necessarily infringed by their
- Contribution(s) alone or by combination of their Contribution(s)
- with the Work to which such Contribution(s) was submitted. If You
- institute patent litigation against any entity (including a
- cross-claim or counterclaim in a lawsuit) alleging that the Work
- or a Contribution incorporated within the Work constitutes direct
- or contributory patent infringement, then any patent licenses
- granted to You under this License for that Work shall terminate
- as of the date such litigation is filed.
-
-4. Redistribution. You may reproduce and distribute copies of the
- Work or Derivative Works thereof in any medium, with or without
- modifications, and in Source or Object form, provided that You
- meet the following conditions:
-
- (a) You must give any other recipients of the Work or
- Derivative Works a copy of this License; and
-
- (b) You must cause any modified files to carry prominent notices
- stating that You changed the files; and
-
- (c) You must retain, in the Source form of any Derivative Works
- that You distribute, all copyright, patent, trademark, and
- attribution notices from the Source form of the Work,
- excluding those notices that do not pertain to any part of
- the Derivative Works; and
-
- (d) If the Work includes a "NOTICE" text file as part of its
- distribution, then any Derivative Works that You distribute must
- include a readable copy of the attribution notices contained
- within such NOTICE file, excluding those notices that do not
- pertain to any part of the Derivative Works, in at least one
- of the following places: within a NOTICE text file distributed
- as part of the Derivative Works; within the Source form or
- documentation, if provided along with the Derivative Works; or,
- within a display generated by the Derivative Works, if and
- wherever such third-party notices normally appear. The contents
- of the NOTICE file are for informational purposes only and
- do not modify the License. You may add Your own attribution
- notices within Derivative Works that You distribute, alongside
- or as an addendum to the NOTICE text from the Work, provided
- that such additional attribution notices cannot be construed
- as modifying the License.
-
- You may add Your own copyright statement to Your modifications and
- may provide additional or different license terms and conditions
- for use, reproduction, or distribution of Your modifications, or
- for any such Derivative Works as a whole, provided Your use,
- reproduction, and distribution of the Work otherwise complies with
- the conditions stated in this License.
-
-5. Submission of Contributions. Unless You explicitly state otherwise,
- any Contribution intentionally submitted for inclusion in the Work
- by You to the Licensor shall be under the terms and conditions of
- this License, without any additional terms or conditions.
- Notwithstanding the above, nothing herein shall supersede or modify
- the terms of any separate license agreement you may have executed
- with Licensor regarding such Contributions.
-
-6. Trademarks. This License does not grant permission to use the trade
- names, trademarks, service marks, or product names of the Licensor,
- except as required for reasonable and customary use in describing the
- origin of the Work and reproducing the content of the NOTICE file.
-
-7. Disclaimer of Warranty. Unless required by applicable law or
- agreed to in writing, Licensor provides the Work (and each
- Contributor provides its Contributions) on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- implied, including, without limitation, any warranties or conditions
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
- PARTICULAR PURPOSE. You are solely responsible for determining the
- appropriateness of using or redistributing the Work and assume any
- risks associated with Your exercise of permissions under this License.
-
-8. Limitation of Liability. In no event and under no legal theory,
- whether in tort (including negligence), contract, or otherwise,
- unless required by applicable law (such as deliberate and grossly
- negligent acts) or agreed to in writing, shall any Contributor be
- liable to You for damages, including any direct, indirect, special,
- incidental, or consequential damages of any character arising as a
- result of this License or out of the use or inability to use the
- Work (including but not limited to damages for loss of goodwill,
- work stoppage, computer failure or malfunction, or any and all
- other commercial damages or losses), even if such Contributor
- has been advised of the possibility of such damages.
-
-9. Accepting Warranty or Additional Liability. While redistributing
- the Work or Derivative Works thereof, You may choose to offer,
- and charge a fee for, acceptance of support, warranty, indemnity,
- or other liability obligations and/or rights consistent with this
- License. However, in accepting such obligations, You may act only
- on Your own behalf and on Your sole responsibility, not on behalf
- of any other Contributor, and only if You agree to indemnify,
- defend, and hold each Contributor harmless for any liability
- incurred by, or claims asserted against, such Contributor by reason
- of your accepting any such warranty or additional liability.
-
-END OF TERMS AND CONDITIONS
-
-APPENDIX: How to apply the Apache License to your work.
-
- To apply the Apache License to your work, attach the following
- boilerplate notice, with the fields enclosed by brackets "[]"
- replaced with your own identifying information. (Don't include
- the brackets!) The text should be enclosed in the appropriate
- comment syntax for the file format. We also recommend that a
- file or class name and description of purpose be included on the
- same "printed page" as the copyright notice for easier
- identification within third-party archives.
-
-Copyright [yyyy] [name of copyright owner]
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
diff --git a/libc/LICENSE-MIT b/libc/LICENSE-MIT
deleted file mode 100644
index 39d4bdb..0000000
--- a/libc/LICENSE-MIT
+++ /dev/null
@@ -1,25 +0,0 @@
-Copyright (c) 2014 The Rust Project Developers
-
-Permission is hereby granted, free of charge, to any
-person obtaining a copy of this software and associated
-documentation files (the "Software"), to deal in the
-Software without restriction, including without
-limitation the rights to use, copy, modify, merge,
-publish, distribute, sublicense, and/or sell copies of
-the Software, and to permit persons to whom the Software
-is furnished to do so, subject to the following
-conditions:
-
-The above copyright notice and this permission notice
-shall be included in all copies or substantial portions
-of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
-ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
-TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
-PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
-SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
-CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
-IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
-DEALINGS IN THE SOFTWARE.
diff --git a/libc/README.md b/libc/README.md
deleted file mode 100644
index 7bde17d..0000000
--- a/libc/README.md
+++ /dev/null
@@ -1,105 +0,0 @@
-[![Travis-CI Status]][Travis-CI] [![Appveyor Status]][Appveyor] [![Cirrus-CI Status]][Cirrus-CI] [![Latest Version]][crates.io] [![Documentation]][docs.rs] ![License]
-
-libc - Raw FFI bindings to platforms' system libraries
-====
-
-`libc` provides all of the definitions necessary to easily interoperate with C
-code (or "C-like" code) on each of the platforms that Rust supports. This
-includes type definitions (e.g. `c_int`), constants (e.g. `EINVAL`) as well as
-function headers (e.g. `malloc`).
-
-This crate exports all underlying platform types, functions, and constants under
-the crate root, so all items are accessible as `libc::foo`. The types and values
-of all the exported APIs match the platform that libc is compiled for.
-
-More detailed information about the design of this library can be found in its
-[associated RFC][rfc].
-
-[rfc]: https://github.com/rust-lang/rfcs/blob/master/text/1291-promote-libc.md
-
-## Usage
-
-Add the following to your `Cargo.toml`:
-
-```toml
-[dependencies]
-libc = "0.2"
-```
-
-## Features
-
-* `std`: by default `libc` links to the standard library. Disable this
- feature remove this dependency and be able to use `libc` in `#![no_std]`
- crates.
-
-* `extra_traits`: all `struct`s implemented in `libc` are `Copy` and `Clone`.
- This feature derives `Debug`, `Eq`, `Hash`, and `PartialEq`.
-
-* **deprecated**: `use_std` is deprecated, and is equivalent to `std`.
-
-## Rust version support
-
-The minimum supported Rust toolchain version is **Rust 1.13.0** . APIs requiring
-newer Rust features are only available on newer Rust toolchains:
-
-| Feature | Version |
-|----------------------|---------|
-| `union` | 1.19.0 |
-| `const mem::size_of` | 1.24.0 |
-| `repr(align)` | 1.25.0 |
-| `extra_traits` | 1.25.0 |
-| `core::ffi::c_void` | 1.30.0 |
-| `repr(packed(N))` | 1.33.0 |
-
-## Platform support
-
-[Platform-specific documentation (master branch)][docs.master].
-
-See
-[`ci/build.sh`](https://github.com/rust-lang/libc/blob/master/libc-test/build.rs)
-for the platforms on which `libc` is guaranteed to build for each Rust
-toolchain. The test-matrix at [Travis-CI], [Appveyor], and [Cirrus-CI] show the
-platforms in which `libc` tests are run.
-
-<div class="platform_docs"></div>
-
-## License
-
-This project is licensed under either of
-
-* [Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0)
- ([LICENSE-APACHE](LICENSE-APACHE))
-
-* [MIT License](http://opensource.org/licenses/MIT)
- ([LICENSE-MIT](LICENSE-MIT))
-
-at your option.
-
-## Contributing
-
-We welcome all people who want to contribute. Please see the [contributing
-instructions] for more information.
-
-[contributing instructions]: CONTRIBUTING.md
-
-Contributions in any form (issues, pull requests, etc.) to this project
-must adhere to Rust's [Code of Conduct].
-
-[Code of Conduct]: https://www.rust-lang.org/en-US/conduct.html
-
-Unless you explicitly state otherwise, any contribution intentionally submitted
-for inclusion in `libc` by you, as defined in the Apache-2.0 license, shall be
-dual licensed as above, without any additional terms or conditions.
-
-[Travis-CI]: https://travis-ci.com/rust-lang/libc
-[Travis-CI Status]: https://travis-ci.com/rust-lang/libc.svg?branch=master
-[Appveyor]: https://ci.appveyor.com/project/rust-lang-libs/libc
-[Appveyor Status]: https://ci.appveyor.com/api/projects/status/github/rust-lang/libc?svg=true
-[Cirrus-CI]: https://cirrus-ci.com/github/rust-lang/libc
-[Cirrus-CI Status]: https://api.cirrus-ci.com/github/rust-lang/libc.svg
-[crates.io]: https://crates.io/crates/libc
-[Latest Version]: https://img.shields.io/crates/v/libc.svg
-[Documentation]: https://docs.rs/libc/badge.svg
-[docs.rs]: https://docs.rs/libc
-[License]: https://img.shields.io/crates/l/libc.svg
-[docs.master]: https://rust-lang.github.io/libc/#platform-specific-documentation
diff --git a/libc/appveyor.yml b/libc/appveyor.yml
deleted file mode 100644
index b14230a..0000000
--- a/libc/appveyor.yml
+++ /dev/null
@@ -1,28 +0,0 @@
-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 Reqwest which looks to not check for
- # revocation by default like libcurl does.
- RUSTUP_USE_REQWEST: 1
- CARGO_HTTP_CHECK_REVOKE: false
- matrix:
- - TARGET: x86_64-pc-windows-gnu
- MSYS2_BITS: 64
- - TARGET: i686-pc-windows-gnu
- MSYS2_BITS: 32
- - TARGET: x86_64-pc-windows-msvc
- - TARGET: i686-pc-windows-msvc
-install:
- - appveyor-retry appveyor DownloadFile https://win.rustup.rs/ -FileName rustup-init.exe
- - rustup-init.exe -y --default-host %TARGET%
- - set PATH=%PATH%;C:\Users\appveyor\.cargo\bin
- - if defined MSYS2_BITS set PATH=%PATH%;C:\msys64\mingw%MSYS2_BITS%\bin
- - rustc -V
- - cargo -V
-
-build: false
-
-test_script:
- - cargo -vv test --target %TARGET%
- - cargo -vv test --no-default-features --target %TARGET%
- - cargo -vv test --manifest-path libc-test/Cargo.toml --target %TARGET%
diff --git a/libc/build.rs b/libc/build.rs
deleted file mode 100644
index 8452940..0000000
--- a/libc/build.rs
+++ /dev/null
@@ -1,101 +0,0 @@
-use std::env;
-use std::process::Command;
-use std::str;
-
-fn main() {
- let rustc_minor_ver =
- rustc_minor_version().expect("Failed to get rustc version");
- let rustc_dep_of_std =
- std::env::var("CARGO_FEATURE_RUSTC_DEP_OF_STD").is_ok();
- let align_cargo_feature = std::env::var("CARGO_FEATURE_ALIGN").is_ok();
-
- if std::env::var("CARGO_FEATURE_USE_STD").is_ok() {
- println!(
- "cargo:warning=\"libc's use_std cargo feature is deprecated since libc 0.2.55; \
- please consider using the `std` cargo feature instead\""
- );
- }
-
- if std::env::var("LIBC_CI").is_ok() {
- if let Some(12) = which_freebsd() {
- println!("cargo:rustc-cfg=freebsd12");
- }
- }
-
- // Rust >= 1.15 supports private module use:
- if rustc_minor_ver >= 15 || rustc_dep_of_std {
- println!("cargo:rustc-cfg=libc_priv_mod_use");
- }
-
- // Rust >= 1.19 supports unions:
- if rustc_minor_ver >= 19 || rustc_dep_of_std {
- println!("cargo:rustc-cfg=libc_union");
- }
-
- // Rust >= 1.24 supports const mem::size_of:
- if rustc_minor_ver >= 24 || rustc_dep_of_std {
- println!("cargo:rustc-cfg=libc_const_size_of");
- }
-
- // Rust >= 1.25 supports repr(align):
- if rustc_minor_ver >= 25 || rustc_dep_of_std || align_cargo_feature {
- println!("cargo:rustc-cfg=libc_align");
- }
-
- // Rust >= 1.30 supports `core::ffi::c_void`, so libc can just re-export it.
- // Otherwise, it defines an incompatible type to retaining
- // backwards-compatibility.
- if rustc_minor_ver >= 30 || rustc_dep_of_std {
- println!("cargo:rustc-cfg=libc_core_cvoid");
- }
-
- // Rust >= 1.33 supports repr(packed(N))
- if rustc_minor_ver >= 33 || rustc_dep_of_std {
- println!("cargo:rustc-cfg=libc_packedN");
- }
-}
-
-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()
-}
-
-fn which_freebsd() -> Option<i32> {
- let output = std::process::Command::new("freebsd-version").output().ok();
- if output.is_none() {
- return None;
- }
- let output = output.unwrap();
- if !output.status.success() {
- return None;
- }
-
- let stdout = String::from_utf8(output.stdout).ok();
- if stdout.is_none() {
- return None;
- }
- let stdout = stdout.unwrap();
-
- match &stdout {
- s if s.starts_with("11") => Some(11),
- s if s.starts_with("12") => Some(12),
- _ => None,
- }
-}
diff --git a/libc/ci/README.md b/libc/ci/README.md
deleted file mode 100644
index 28152e5..0000000
--- a/libc/ci/README.md
+++ /dev/null
@@ -1,243 +0,0 @@
-The goal of the libc crate is to have CI running everywhere to have the
-strongest guarantees about the definitions that this library contains, and as a
-result the CI is pretty complicated and also pretty large! Hopefully this can
-serve as a guide through the sea of scripts in this directory and elsewhere in
-this project.
-
-# Files
-
-First up, let's talk about the files in this directory:
-
-* `run-travis.sh` - a shell script run by all Travis builders, this is
- responsible for setting up the rest of the environment such as installing new
- packages, downloading Rust target libraries, etc.
-
-* `run.sh` - the actual script which runs tests for a particular architecture.
- Called from the `run-travis.sh` script this will run all tests for the target
- specified.
-
-* `cargo-config` - Cargo configuration of linkers to use copied into place by
- the `run-travis.sh` script before builds are run.
-
-* `dox.sh` - script called from `run-travis.sh` on only the linux 64-bit nightly
- Travis bots to build documentation for this crate.
-
-* `landing-page-*.html` - used by `dox.sh` to generate a landing page for all
- architectures' documentation.
-
-* `run-qemu.sh` - see discussion about QEMU below
-
-* `mips`, `rumprun` - instructions to build the docker image for each respective
- CI target
-
-# CI Systems
-
-Currently this repository leverages a combination of Travis CI and AppVeyor for
-running tests. The triples tested are:
-
-* AppVeyor
- * `{i686,x86_64}-pc-windows-{msvc,gnu}`
-* Travis
- * `{i686,x86_64,mips,aarch64}-unknown-linux-gnu`
- * `{x86_64,aarch64}-unknown-linux-musl`
- * `arm-unknown-linux-gnueabihf`
- * `arm-linux-androideabi`
- * `{i686,x86_64}-apple-{darwin,ios}`
- * `x86_64-rumprun-netbsd`
- * `x86_64-unknown-freebsd`
- * `x86_64-unknown-openbsd`
-
-The Windows triples are all pretty standard, they just set up their environment
-then run tests, no need for downloading any extra target libs (we just download
-the right installer). The Intel Linux/OSX builds are similar in that we just
-download the right target libs and run tests. Note that the Intel Linux/OSX
-builds are run on stable/beta/nightly, but are the only ones that do so.
-
-The remaining architectures look like:
-
-* Android runs in a [docker image][android-docker] with an emulator, the NDK,
- and the SDK already set up. The entire build happens within the docker image.
-* The MIPS, ARM, and AArch64 builds all use the QEMU userspace emulator to run
- the generated binary to actually verify the tests pass.
-* The MUSL build just has to download a MUSL compiler and target libraries and
- then otherwise runs tests normally.
-* iOS builds need an extra linker flag currently, but beyond that they're built
- as standard as everything else.
-* The rumprun target builds an entire kernel from the test suite and then runs
- it inside QEMU using the serial console to test whether it succeeded or
- failed.
-* The BSD builds, currently OpenBSD and FreeBSD, use QEMU to boot up a system
- and compile/run tests. More information on that below.
-
-[android-docker]: https://github.com/rust-lang/rust-buildbot/blob/master/slaves/android/Dockerfile
-
-## QEMU
-
-Lots of the architectures tested here use QEMU in the tests, so it's worth going
-over all the crazy capabilities QEMU has and the various flavors in which we use
-it!
-
-First up, QEMU has userspace emulation where it doesn't boot a full kernel, it
-just runs a binary from another architecture (using the `qemu-<arch>` wrappers).
-We provide it the runtime path for the dynamically loaded system libraries,
-however. This strategy is used for all Linux architectures that aren't intel.
-Note that one downside of this QEMU system is that threads are barely
-implemented, so we're careful to not spawn many threads.
-
-For the rumprun target the only output is a kernel image, so we just use that
-plus the `rumpbake` command to create a full kernel image which is then run from
-within QEMU.
-
-Finally, the fun part, the BSDs. Quite a few hoops are jumped through to get CI
-working for these platforms, but the gist of it looks like:
-
-* Cross compiling from Linux to any of the BSDs seems to be quite non-standard.
- We may be able to get it working but it might be difficult at that point to
- ensure that the libc definitions align with what you'd get on the BSD itself.
- As a result, we try to do compiles within the BSD distro.
-* On Travis we can't run a VM-in-a-VM, so we resort to userspace emulation
- (QEMU).
-* Unfortunately on Travis we also can't use KVM, so the emulation is super slow.
-
-With all that in mind, the way BSD is tested looks like:
-
-1. Download a pre-prepared image for the OS being tested.
-2. Generate the tests for the OS being tested. This involves running the `ctest`
- library over libc to generate a Rust file and a C file which will then be
- compiled into the final test.
-3. Generate a disk image which will later be mounted by the OS being tested.
- This image is mostly just the libc directory, but some modifications are made
- to compile the generated files from step 2.
-4. The kernel is booted in QEMU, and it is configured to detect the libc-test
- image being available, run the test script, and then shut down afterwards.
-5. Look for whether the tests passed in the serial console output of the kernel.
-
-There's some pretty specific instructions for setting up each image (detailed
-below), but the main gist of this is that we must avoid a vanilla `cargo run`
-inside of the `libc-test` directory (which is what it's intended for) because
-that would compile `syntex_syntax`, a large library, with userspace emulation.
-This invariably times out on Travis, so we can't do that.
-
-Once all those hoops are jumped through, however, we can be happy that we're
-testing almost everything!
-
-Below are some details of how to set up the initial OS images which are
-downloaded. Each image must be enabled have input/output over the serial
-console, log in automatically at the serial console, detect if a second drive in
-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 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
-
-* https://en.wikibooks.org/wiki/QEMU/Images
-* https://blog.nekoconeko.nl/blog/2015/06/04/creating-an-openstack-freebsd-image.html
-* https://www.freebsd.org/doc/handbook/serialconsole-setup.html
-
-
-### QEMU setup - OpenBSD
-
-1. Download CD installer
-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 'set tty com0' >> /etc/boot.conf`
-6. `echo 'boot' >> /etc/boot.conf`
-7. Modify /etc/ttys, change the `tty00` at the end from 'unknown off' to
- 'vt220 on secure'
-8. Modify same line in /etc/ttys to have `"/root/foo.sh"` as the shell
-9. Add this script to `/root/foo.sh`
-
-```
-#!/bin/sh
-exec 1>/dev/tty00
-exec 2>&1
-
-if mount -t ext2fs /dev/sd1c /mnt; then
- sh /mnt/run.sh /mnt
- shutdown -ph now
-fi
-
-# limited shell...
-exec /bin/sh < /dev/tty00
-```
-
-10. `chmod +x /root/foo.sh`
-
-Helpful links:
-
-* https://en.wikibooks.org/wiki/QEMU/Images
-* http://www.openbsd.org/faq/faq7.html#SerCon
-
-# Questions?
-
-Hopefully that's at least somewhat of an introduction to everything going on
-here, and feel free to ping @alexcrichton with questions!
-
diff --git a/libc/ci/android-install-ndk.sh b/libc/ci/android-install-ndk.sh
deleted file mode 100644
index 723e719..0000000
--- a/libc/ci/android-install-ndk.sh
+++ /dev/null
@@ -1,50 +0,0 @@
-#!/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.
-#
-# 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.
-
-set -ex
-
-NDK=android-ndk-r19c
-curl --retry 20 -O https://dl.google.com/android/repository/${NDK}-linux-x86_64.zip
-unzip -q ${NDK}-linux-x86_64.zip
-
-case "$1" in
- arm)
- arch=arm
- api=24
- ;;
- armv7)
- arch=arm
- api=24
- ;;
- aarch64)
- arch=arm64
- api=24
- ;;
- i686)
- arch=x86
- api=28
- ;;
- x86_64)
- arch=x86_64
- api=28
- ;;
- *)
- echo "invalid arch: $1"
- exit 1
- ;;
-esac;
-
-${NDK}/build/tools/make_standalone_toolchain.py \
- --install-dir "/android/ndk-${1}" \
- --arch "${arch}" \
- --api ${api}
-
-rm -rf ./${NDK}-linux-x86_64.zip ./${NDK}
diff --git a/libc/ci/android-install-sdk.sh b/libc/ci/android-install-sdk.sh
deleted file mode 100644
index 7f21040..0000000
--- a/libc/ci/android-install-sdk.sh
+++ /dev/null
@@ -1,73 +0,0 @@
-#!/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.
-#
-# 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.
-
-set -ex
-
-# Prep the SDK and emulator
-#
-# Note that the update process requires that we accept a bunch of licenses, and
-# we can't just pipe `yes` into it for some reason, so we take the same strategy
-# located in https://github.com/appunite/docker by just wrapping it in a script
-# which apparently magically accepts the licenses.
-
-SDK=4333796
-mkdir sdk
-curl --retry 20 https://dl.google.com/android/repository/sdk-tools-linux-${SDK}.zip -O
-unzip -q -d sdk sdk-tools-linux-${SDK}.zip
-
-case "$1" in
- arm | armv7)
- api=24
- image="system-images;android-${api};google_apis;armeabi-v7a"
- ;;
- aarch64)
- api=24
- image="system-images;android-${api};google_apis;arm64-v8a"
- ;;
- i686)
- api=28
- image="system-images;android-${api};default;x86"
- ;;
- x86_64)
- api=28
- image="system-images;android-${api};default;x86_64"
- ;;
- *)
- echo "invalid arch: $1"
- exit 1
- ;;
-esac;
-
-# Try to fix warning about missing file.
-# See https://askubuntu.com/a/1078784
-mkdir -p /root/.android/
-echo '### User Sources for Android SDK Manager' >> /root/.android/repositories.cfg
-echo '#Fri Nov 03 10:11:27 CET 2017 count=0' >> /root/.android/repositories.cfg
-
-# Print all available packages
-# yes | ./sdk/tools/bin/sdkmanager --list --verbose
-
-# --no_https avoids
-# javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: No trusted certificate found
-#
-# | grep -v = || true removes the progress bar output from the sdkmanager
-# which produces an insane amount of output.
-yes | ./sdk/tools/bin/sdkmanager --licenses --no_https | grep -v = || true
-yes | ./sdk/tools/bin/sdkmanager --no_https \
- "emulator" \
- "platform-tools" \
- "platforms;android-${api}" \
- "${image}" | grep -v = || true
-
-echo "no" |
- ./sdk/tools/bin/avdmanager create avd \
- --name "${1}" \
- --package "${image}" | grep -v = || true
diff --git a/libc/ci/android-sysimage.sh b/libc/ci/android-sysimage.sh
deleted file mode 100644
index 9eabd7c..0000000
--- a/libc/ci/android-sysimage.sh
+++ /dev/null
@@ -1,56 +0,0 @@
-#!/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.
-#
-# 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.
-
-set -ex
-
-URL=https://dl.google.com/android/repository/sys-img/android
-
-main() {
- local arch="${1}"
- local name="${2}"
- local dest=/system
- local td
- td="$(mktemp -d)"
-
- apt-get install --no-install-recommends e2tools
-
- pushd "${td}"
- curl --retry 5 -O "${URL}/${name}"
- unzip -q "${name}"
-
- 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" ] || [ "${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/"
- fi
-
- # clean up
- apt-get purge --auto-remove -y e2tools
-
- popd
-
- rm -rf "${td}"
-}
-
-main "${@}"
diff --git a/libc/ci/build.sh b/libc/ci/build.sh
deleted file mode 100644
index 707dd4a..0000000
--- a/libc/ci/build.sh
+++ /dev/null
@@ -1,221 +0,0 @@
-#!/usr/bin/env sh
-
-# Checks that libc builds properly for all supported targets on a particular
-# Rust version:
-
-set -ex
-
-RUST=${TRAVIS_RUST_VERSION}
-OS=${TRAVIS_OS_NAME}
-
-echo "Testing Rust ${RUST} on ${OS}"
-
-test_target() {
- CARGO="${1}"
- TARGET="${2}"
- NO_STD="${3}"
-
- opt=
- if [ "${TARGET}" = "x86_64-unknown-linux-gnux32" ]; then
- # FIXME: x86_64-unknown-linux-gnux32 fail to compile without
- # --release
- #
- # See https://github.com/rust-lang/rust/issues/45417
- opt="--release"
- fi
- # FIXME: https://github.com/rust-lang/rust/issues/61174
- if [ "${TARGET}" = "sparcv9-sun-solaris" ] ||
- [ "${TARGET}" = "x86_64-sun-solaris" ]; then
- return 0
- fi
-
- # If there is a std component, fetch it:
- if [ "${NO_STD}" != "1" ]; then
- # FIXME: rustup often fails to download some artifacts due to network
- # issues, so we retry this N times.
- N=5
- n=0
- until [ $n -ge $N ]
- do
- if rustup target add "${TARGET}" --toolchain "${RUST}" ; then
- break
- fi
- n=$((n+1))
- sleep 1
- done
- fi
-
- # Test that libc builds without any default features (no libstd)
- "$CARGO" "+${RUST}" build -vv $opt --no-default-features --target "${TARGET}"
-
- # Test that libc builds with default features (e.g. libstd)
- # if the target supports libstd
- if [ "$NO_STD" != "1" ]; then
- "$CARGO" "+${RUST}" build -vv $opt --target "${TARGET}"
- fi
-
- # Test that libc builds with the `extra_traits` feature
- "$CARGO" "+${RUST}" build -vv $opt --no-default-features --target "${TARGET}" \
- --features extra_traits
-
- # Also test that it builds with `extra_traits` and default features:
- if [ "$NO_STD" != "1" ]; then
- "$CARGO" "+${RUST}" build -vv $opt --target "${TARGET}" \
- --features extra_traits
- fi
-}
-
-RUST_LINUX_TARGETS="\
-aarch64-linux-android \
-aarch64-unknown-linux-gnu \
-arm-linux-androideabi \
-arm-unknown-linux-gnueabi \
-arm-unknown-linux-gnueabihf \
-armv7-linux-androideabi \
-armv7-unknown-linux-gnueabihf \
-i586-unknown-linux-gnu \
-i686-linux-android \
-i686-unknown-freebsd \
-i686-unknown-linux-gnu \
-i686-unknown-linux-musl \
-mips-unknown-linux-gnu \
-mips-unknown-linux-musl \
-mips64-unknown-linux-gnuabi64 \
-mips64el-unknown-linux-gnuabi64 \
-mipsel-unknown-linux-gnu \
-mipsel-unknown-linux-gnu \
-mipsel-unknown-linux-musl \
-powerpc-unknown-linux-gnu \
-powerpc64-unknown-linux-gnu \
-powerpc64le-unknown-linux-gnu \
-s390x-unknown-linux-gnu \
-x86_64-unknown-freebsd \
-x86_64-unknown-linux-gnu \
-x86_64-unknown-linux-musl \
-x86_64-unknown-netbsd \
-"
-
-RUST_GT_1_13_LINUX_TARGETS="\
-arm-unknown-linux-musleabi \
-arm-unknown-linux-musleabihf \
-armv7-unknown-linux-musleabihf \
-sparc64-unknown-linux-gnu \
-wasm32-unknown-emscripten \
-x86_64-linux-android \
-x86_64-rumprun-netbsd \
-"
-RUST_GT_1_19_LINUX_TARGETS="\
-aarch64-unknown-linux-musl \
-sparcv9-sun-solaris \
-wasm32-unknown-unknown \
-x86_64-sun-solaris \
-"
-RUST_GT_1_24_LINUX_TARGETS="\
-i586-unknown-linux-musl \
-x86_64-unknown-cloudabi \
-"
-
-RUST_NIGHTLY_LINUX_TARGETS="\
-aarch64-fuchsia \
-armv5te-unknown-linux-gnueabi \
-armv5te-unknown-linux-musleabi \
-i686-pc-windows-gnu \
-wasm32-wasi \
-x86_64-fortanix-unknown-sgx \
-x86_64-fuchsia \
-x86_64-pc-windows-gnu \
-x86_64-unknown-linux-gnux32 \
-x86_64-unknown-redox \
-"
-
-RUST_OSX_TARGETS="\
-aarch64-apple-ios \
-armv7-apple-ios \
-armv7s-apple-ios \
-i386-apple-ios \
-i686-apple-darwin \
-x86_64-apple-darwin \
-x86_64-apple-ios \
-"
-
-# The targets are listed here alphabetically
-TARGETS=""
-case "${OS}" in
- linux*)
- TARGETS="${RUST_LINUX_TARGETS}"
-
- if [ "${RUST}" != "1.13.0" ]; then
- TARGETS="${TARGETS} ${RUST_GT_1_13_LINUX_TARGETS}"
- if [ "${RUST}" != "1.19.0" ]; then
- TARGETS="${TARGETS} ${RUST_GT_1_19_LINUX_TARGETS}"
- if [ "${RUST}" != "1.24.0" ]; then
- TARGETS="${TARGETS} ${RUST_GT_1_24_LINUX_TARGETS}"
- fi
- fi
- fi
-
- if [ "${RUST}" = "nightly" ]; then
- TARGETS="${TARGETS} ${RUST_NIGHTLY_LINUX_TARGETS}"
- fi
-
- ;;
- osx*)
- TARGETS="${RUST_OSX_TARGETS}"
- ;;
- *)
- ;;
-esac
-
-for TARGET in $TARGETS; do
- test_target cargo "$TARGET"
-done
-
-# FIXME: https://github.com/rust-lang/rust/issues/58564
-# sparc-unknown-linux-gnu
-RUST_LINUX_NO_CORE_TARGETS="\
-aarch64-pc-windows-msvc \
-aarch64-unknown-cloudabi \
-aarch64-unknown-freebsd \
-aarch64-unknown-hermit \
-aarch64-unknown-netbsd \
-aarch64-unknown-openbsd \
-armebv7r-none-eabi \
-armebv7r-none-eabihf \
-armv7-unknown-cloudabi-eabihf \
-armv7r-none-eabi \
-armv7r-none-eabihf \
-i586-pc-windows-msvc \
-i686-pc-windows-msvc \
-i686-unknown-cloudabi \
-i686-unknown-haiku \
-i686-unknown-netbsd \
-i686-unknown-openbsd \
-mips-unknown-linux-uclibc \
-mipsel-unknown-linux-uclibc \
-nvptx64-nvidia-cuda \
-powerpc-unknown-linux-gnuspe \
-powerpc-unknown-netbsd \
-powerpc64-unknown-freebsd \
-riscv32imac-unknown-none-elf \
-riscv32imc-unknown-none-elf \
-sparc64-unknown-netbsd \
-thumbv6m-none-eabi \
-thumbv7em-none-eabi \
-thumbv7em-none-eabihf \
-thumbv7m-none-eabi \
-thumbv7neon-linux-androideabi \
-thumbv7neon-unknown-linux-gnueabihf \
-thumbv8m.main-none-eabi \
-x86_64-pc-windows-msvc
-x86_64-unknown-dragonfly \
-x86_64-unknown-haiku \
-x86_64-unknown-hermit \
-x86_64-unknown-l4re-uclibc \
-x86_64-unknown-openbsd \
-"
-
-if [ "${RUST}" = "nightly" ] && [ "${OS}" = "linux" ]; then
- for TARGET in $RUST_LINUX_NO_CORE_TARGETS; do
- test_target xargo "$TARGET" 1
- done
-fi
diff --git a/libc/ci/docker/aarch64-linux-android/Dockerfile b/libc/ci/docker/aarch64-linux-android/Dockerfile
deleted file mode 100644
index 6751dd9..0000000
--- a/libc/ci/docker/aarch64-linux-android/Dockerfile
+++ /dev/null
@@ -1,45 +0,0 @@
-FROM ubuntu:19.04
-
-RUN dpkg --add-architecture i386 && \
- apt-get update && \
- apt-get install -y --no-install-recommends \
- file \
- curl \
- ca-certificates \
- python \
- unzip \
- expect \
- openjdk-8-jre \
- libstdc++6:i386 \
- libpulse0 \
- gcc \
- libc6-dev
-
-WORKDIR /android/
-COPY android* /android/
-
-ENV ANDROID_ARCH=aarch64
-ENV PATH=$PATH:/android/ndk-$ANDROID_ARCH/bin:/android/sdk/tools:/android/sdk/platform-tools
-
-RUN sh /android/android-install-ndk.sh $ANDROID_ARCH
-RUN sh /android/android-install-sdk.sh $ANDROID_ARCH
-RUN mv /root/.android /tmp
-RUN chmod 777 -R /tmp/.android
-RUN chmod 755 /android/sdk/tools/* /android/sdk/emulator/qemu/linux-x86_64/*
-
-ENV PATH=$PATH:/rust/bin \
- CARGO_TARGET_AARCH64_LINUX_ANDROID_LINKER=aarch64-linux-android-gcc \
- CARGO_TARGET_AARCH64_LINUX_ANDROID_RUNNER=/tmp/runtest \
- HOME=/tmp
-
-ADD runtest-android.rs /tmp/runtest.rs
-ENTRYPOINT [ \
- "bash", \
- "-c", \
- # set SHELL so android can detect a 64bits system, see
- # http://stackoverflow.com/a/41789144
- "SHELL=/bin/dash /android/sdk/emulator/emulator @aarch64 -no-window & \
- rustc /tmp/runtest.rs -o /tmp/runtest && \
- exec \"$@\"", \
- "--" \
-]
diff --git a/libc/ci/docker/aarch64-unknown-linux-gnu/Dockerfile b/libc/ci/docker/aarch64-unknown-linux-gnu/Dockerfile
deleted file mode 100644
index 716a445..0000000
--- a/libc/ci/docker/aarch64-unknown-linux-gnu/Dockerfile
+++ /dev/null
@@ -1,7 +0,0 @@
-FROM ubuntu:19.04
-RUN apt-get update && apt-get install -y --no-install-recommends \
- gcc libc6-dev ca-certificates \
- gcc-aarch64-linux-gnu libc6-dev-arm64-cross qemu-user
-ENV CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc \
- CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_RUNNER="qemu-aarch64 -L /usr/aarch64-linux-gnu" \
- PATH=$PATH:/rust/bin
diff --git a/libc/ci/docker/aarch64-unknown-linux-musl/Dockerfile b/libc/ci/docker/aarch64-unknown-linux-musl/Dockerfile
deleted file mode 100644
index e9634bf..0000000
--- a/libc/ci/docker/aarch64-unknown-linux-musl/Dockerfile
+++ /dev/null
@@ -1,15 +0,0 @@
-FROM ubuntu:19.04
-
-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
-
-COPY install-musl.sh /
-RUN sh /install-musl.sh aarch64
-
-# FIXME: shouldn't need the `-lgcc` here, shouldn't that be in libstd?
-ENV PATH=$PATH:/musl-aarch64/bin:/rust/bin \
- CC_aarch64_unknown_linux_musl=musl-gcc \
- RUSTFLAGS='-Clink-args=-lgcc' \
- CARGO_TARGET_AARCH64_UNKNOWN_LINUX_MUSL_LINKER=musl-gcc \
- CARGO_TARGET_AARCH64_UNKNOWN_LINUX_MUSL_RUNNER="qemu-aarch64 -L /musl-aarch64"
diff --git a/libc/ci/docker/arm-linux-androideabi/Dockerfile b/libc/ci/docker/arm-linux-androideabi/Dockerfile
deleted file mode 100644
index 544d167..0000000
--- a/libc/ci/docker/arm-linux-androideabi/Dockerfile
+++ /dev/null
@@ -1,45 +0,0 @@
-FROM ubuntu:19.04
-
-RUN dpkg --add-architecture i386 && \
- apt-get update && \
- apt-get install -y --no-install-recommends \
- file \
- curl \
- ca-certificates \
- python \
- unzip \
- expect \
- openjdk-8-jre \
- libstdc++6:i386 \
- libpulse0 \
- gcc \
- libc6-dev
-
-WORKDIR /android/
-COPY android* /android/
-
-ENV ANDROID_ARCH=arm
-ENV PATH=$PATH:/android/ndk-$ANDROID_ARCH/bin:/android/sdk/tools:/android/sdk/platform-tools
-
-RUN sh /android/android-install-ndk.sh $ANDROID_ARCH
-RUN sh /android/android-install-sdk.sh $ANDROID_ARCH
-RUN mv /root/.android /tmp
-RUN chmod 777 -R /tmp/.android
-RUN chmod 755 /android/sdk/tools/* /android/sdk/emulator/qemu/linux-x86_64/*
-
-ENV PATH=$PATH:/rust/bin \
- CARGO_TARGET_ARM_LINUX_ANDROIDEABI_LINKER=arm-linux-androideabi-gcc \
- CARGO_TARGET_ARM_LINUX_ANDROIDEABI_RUNNER=/tmp/runtest \
- HOME=/tmp
-
-ADD runtest-android.rs /tmp/runtest.rs
-ENTRYPOINT [ \
- "bash", \
- "-c", \
- # set SHELL so android can detect a 64bits system, see
- # http://stackoverflow.com/a/41789144
- "SHELL=/bin/dash /android/sdk/emulator/emulator @arm -no-window & \
- rustc /tmp/runtest.rs -o /tmp/runtest && \
- exec \"$@\"", \
- "--" \
-]
diff --git a/libc/ci/docker/arm-unknown-linux-gnueabihf/Dockerfile b/libc/ci/docker/arm-unknown-linux-gnueabihf/Dockerfile
deleted file mode 100644
index bcdbb22..0000000
--- a/libc/ci/docker/arm-unknown-linux-gnueabihf/Dockerfile
+++ /dev/null
@@ -1,7 +0,0 @@
-FROM ubuntu:19.04
-RUN apt-get update && apt-get install -y --no-install-recommends \
- gcc libc6-dev ca-certificates \
- gcc-arm-linux-gnueabihf libc6-dev-armhf-cross qemu-user
-ENV CARGO_TARGET_ARM_UNKNOWN_LINUX_GNUEABIHF_LINKER=arm-linux-gnueabihf-gcc \
- CARGO_TARGET_ARM_UNKNOWN_LINUX_GNUEABIHF_RUNNER="qemu-arm -L /usr/arm-linux-gnueabihf" \
- PATH=$PATH:/rust/bin
diff --git a/libc/ci/docker/arm-unknown-linux-musleabihf/Dockerfile b/libc/ci/docker/arm-unknown-linux-musleabihf/Dockerfile
deleted file mode 100644
index 639b141..0000000
--- a/libc/ci/docker/arm-unknown-linux-musleabihf/Dockerfile
+++ /dev/null
@@ -1,13 +0,0 @@
-FROM ubuntu:19.04
-
-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
-
-COPY install-musl.sh /
-RUN sh /install-musl.sh arm
-
-ENV PATH=$PATH:/musl-arm/bin:/rust/bin \
- CC_arm_unknown_linux_musleabihf=musl-gcc \
- CARGO_TARGET_ARM_UNKNOWN_LINUX_MUSLEABIHF_LINKER=musl-gcc \
- CARGO_TARGET_ARM_UNKNOWN_LINUX_MUSLEABIHF_RUNNER="qemu-arm -L /musl-arm"
diff --git a/libc/ci/docker/asmjs-unknown-emscripten/Dockerfile b/libc/ci/docker/asmjs-unknown-emscripten/Dockerfile
deleted file mode 100644
index 6c08340..0000000
--- a/libc/ci/docker/asmjs-unknown-emscripten/Dockerfile
+++ /dev/null
@@ -1,20 +0,0 @@
-FROM ubuntu:19.04
-
-RUN apt-get update && \
- apt-get install -y --no-install-recommends \
- ca-certificates \
- curl \
- gcc \
- git \
- libc6-dev \
- python \
- xz-utils
-
-COPY emscripten.sh /
-RUN bash /emscripten.sh
-
-ENV PATH=$PATH:/rust/bin \
- CARGO_TARGET_ASMJS_UNKNOWN_EMSCRIPTEN_RUNNER=node
-
-COPY emscripten-entry.sh /
-ENTRYPOINT ["/emscripten-entry.sh"]
diff --git a/libc/ci/docker/i686-linux-android/Dockerfile b/libc/ci/docker/i686-linux-android/Dockerfile
deleted file mode 100644
index 5403220..0000000
--- a/libc/ci/docker/i686-linux-android/Dockerfile
+++ /dev/null
@@ -1,45 +0,0 @@
-FROM ubuntu:19.04
-
-RUN dpkg --add-architecture i386 && \
- apt-get update && \
- apt-get install -y --no-install-recommends \
- file \
- curl \
- ca-certificates \
- python \
- unzip \
- expect \
- openjdk-8-jre \
- libstdc++6:i386 \
- libpulse0 \
- gcc \
- libc6-dev
-
-WORKDIR /android/
-COPY android* /android/
-
-ENV ANDROID_ARCH=i686
-ENV PATH=$PATH:/android/ndk-$ANDROID_ARCH/bin:/android/sdk/tools:/android/sdk/platform-tools
-
-RUN sh /android/android-install-ndk.sh $ANDROID_ARCH
-RUN sh /android/android-install-sdk.sh $ANDROID_ARCH
-RUN mv /root/.android /tmp
-RUN chmod 777 -R /tmp/.android
-RUN chmod 755 /android/sdk/tools/* /android/sdk/emulator/qemu/linux-x86_64/*
-
-ENV PATH=$PATH:/rust/bin \
- CARGO_TARGET_I686_LINUX_ANDROID_LINKER=i686-linux-android-gcc \
- CARGO_TARGET_I686_LINUX_ANDROID_RUNNER=/tmp/runtest \
- HOME=/tmp
-
-ADD runtest-android.rs /tmp/runtest.rs
-ENTRYPOINT [ \
- "bash", \
- "-c", \
- # set SHELL so android can detect a 64bits system, see
- # http://stackoverflow.com/a/41789144
- "SHELL=/bin/dash /android/sdk/emulator/emulator @i686 -no-window -no-accel & \
- rustc /tmp/runtest.rs -o /tmp/runtest && \
- exec \"$@\"", \
- "--" \
-]
diff --git a/libc/ci/docker/i686-unknown-linux-gnu/Dockerfile b/libc/ci/docker/i686-unknown-linux-gnu/Dockerfile
deleted file mode 100644
index 5563a7b..0000000
--- a/libc/ci/docker/i686-unknown-linux-gnu/Dockerfile
+++ /dev/null
@@ -1,5 +0,0 @@
-FROM ubuntu:19.04
-RUN apt-get update
-RUN apt-get install -y --no-install-recommends \
- gcc-multilib libc6-dev ca-certificates
-ENV PATH=$PATH:/rust/bin
diff --git a/libc/ci/docker/i686-unknown-linux-musl/Dockerfile b/libc/ci/docker/i686-unknown-linux-musl/Dockerfile
deleted file mode 100644
index ac76a32..0000000
--- a/libc/ci/docker/i686-unknown-linux-musl/Dockerfile
+++ /dev/null
@@ -1,12 +0,0 @@
-FROM ubuntu:19.04
-
-RUN dpkg --add-architecture i386
-RUN apt-get update
-RUN apt-get install -y --no-install-recommends \
- gcc-multilib make libc6-dev git curl ca-certificates libc6:i386
-
-COPY install-musl.sh /
-RUN sh /install-musl.sh i686
-
-ENV PATH=$PATH:/musl-i686/bin:/rust/bin \
- CC_i686_unknown_linux_musl=musl-gcc
diff --git a/libc/ci/docker/mips-unknown-linux-gnu/Dockerfile b/libc/ci/docker/mips-unknown-linux-gnu/Dockerfile
deleted file mode 100644
index c8623a5..0000000
--- a/libc/ci/docker/mips-unknown-linux-gnu/Dockerfile
+++ /dev/null
@@ -1,10 +0,0 @@
-FROM ubuntu:19.04
-
-RUN apt-get update && apt-get install -y --no-install-recommends \
- gcc libc6-dev qemu-user ca-certificates \
- gcc-mips-linux-gnu libc6-dev-mips-cross \
- qemu-system-mips linux-headers-generic
-
-ENV CARGO_TARGET_MIPS_UNKNOWN_LINUX_GNU_LINKER=mips-linux-gnu-gcc \
- CARGO_TARGET_MIPS_UNKNOWN_LINUX_GNU_RUNNER="qemu-mips -L /usr/mips-linux-gnu" \
- PATH=$PATH:/rust/bin
diff --git a/libc/ci/docker/mips-unknown-linux-musl/Dockerfile b/libc/ci/docker/mips-unknown-linux-musl/Dockerfile
deleted file mode 100644
index aee73be..0000000
--- a/libc/ci/docker/mips-unknown-linux-musl/Dockerfile
+++ /dev/null
@@ -1,17 +0,0 @@
-FROM ubuntu:19.04
-
-RUN apt-get update && apt-get install -y --no-install-recommends \
- gcc libc6-dev qemu-user ca-certificates qemu-system-mips curl \
- bzip2
-
-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 --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 \
- CC_mips_unknown_linux_musl=mips-openwrt-linux-gcc \
- CARGO_TARGET_MIPS_UNKNOWN_LINUX_MUSL_LINKER=mips-openwrt-linux-gcc \
- CARGO_TARGET_MIPS_UNKNOWN_LINUX_MUSL_RUNNER="qemu-mips -L /toolchain/staging_dir/toolchain-mips_34kc_gcc-5.3.0_musl-1.1.15"
diff --git a/libc/ci/docker/mips64-unknown-linux-gnuabi64/Dockerfile b/libc/ci/docker/mips64-unknown-linux-gnuabi64/Dockerfile
deleted file mode 100644
index d4b972d..0000000
--- a/libc/ci/docker/mips64-unknown-linux-gnuabi64/Dockerfile
+++ /dev/null
@@ -1,11 +0,0 @@
-FROM ubuntu:19.04
-
-RUN apt-get update && apt-get install -y --no-install-recommends \
- gcc libc6-dev qemu-user ca-certificates \
- gcc-mips64-linux-gnuabi64 libc6-dev-mips64-cross \
- qemu-system-mips64 linux-headers-generic
-
-ENV CARGO_TARGET_MIPS64_UNKNOWN_LINUX_GNUABI64_LINKER=mips64-linux-gnuabi64-gcc \
- CARGO_TARGET_MIPS64_UNKNOWN_LINUX_GNUABI64_RUNNER="qemu-mips64 -L /usr/mips64-linux-gnuabi64" \
- CC_mips64_unknown_linux_gnuabi64=mips64-linux-gnuabi64-gcc \
- PATH=$PATH:/rust/bin
diff --git a/libc/ci/docker/mips64el-unknown-linux-gnuabi64/Dockerfile b/libc/ci/docker/mips64el-unknown-linux-gnuabi64/Dockerfile
deleted file mode 100644
index d0303da..0000000
--- a/libc/ci/docker/mips64el-unknown-linux-gnuabi64/Dockerfile
+++ /dev/null
@@ -1,11 +0,0 @@
-FROM ubuntu:19.04
-
-RUN apt-get update && apt-get install -y --no-install-recommends \
- gcc libc6-dev qemu-user ca-certificates \
- gcc-mips64el-linux-gnuabi64 libc6-dev-mips64el-cross \
- qemu-system-mips64el linux-headers-generic
-
-ENV CARGO_TARGET_MIPS64EL_UNKNOWN_LINUX_GNUABI64_LINKER=mips64el-linux-gnuabi64-gcc \
- CARGO_TARGET_MIPS64EL_UNKNOWN_LINUX_GNUABI64_RUNNER="qemu-mips64el -L /usr/mips64el-linux-gnuabi64" \
- CC_mips64el_unknown_linux_gnuabi64=mips64el-linux-gnuabi64-gcc \
- PATH=$PATH:/rust/bin
diff --git a/libc/ci/docker/mipsel-unknown-linux-musl/Dockerfile b/libc/ci/docker/mipsel-unknown-linux-musl/Dockerfile
deleted file mode 100644
index 03e8357..0000000
--- a/libc/ci/docker/mipsel-unknown-linux-musl/Dockerfile
+++ /dev/null
@@ -1,17 +0,0 @@
-FROM ubuntu:19.04
-
-RUN apt-get update && apt-get install -y --no-install-recommends \
- gcc libc6-dev qemu-user ca-certificates qemu-system-mips curl \
- bzip2
-
-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 --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 \
- CC_mipsel_unknown_linux_musl=mipsel-openwrt-linux-gcc \
- CARGO_TARGET_MIPSEL_UNKNOWN_LINUX_MUSL_LINKER=mipsel-openwrt-linux-gcc \
- CARGO_TARGET_MIPSEL_UNKNOWN_LINUX_MUSL_RUNNER="qemu-mipsel -L /toolchain"
diff --git a/libc/ci/docker/powerpc-unknown-linux-gnu/Dockerfile b/libc/ci/docker/powerpc-unknown-linux-gnu/Dockerfile
deleted file mode 100644
index 9fa05af..0000000
--- a/libc/ci/docker/powerpc-unknown-linux-gnu/Dockerfile
+++ /dev/null
@@ -1,11 +0,0 @@
-FROM ubuntu:19.04
-
-RUN apt-get update && apt-get install -y --no-install-recommends \
- gcc libc6-dev qemu-user ca-certificates \
- gcc-powerpc-linux-gnu libc6-dev-powerpc-cross \
- qemu-system-ppc
-
-ENV CARGO_TARGET_POWERPC_UNKNOWN_LINUX_GNU_LINKER=powerpc-linux-gnu-gcc \
- CARGO_TARGET_POWERPC_UNKNOWN_LINUX_GNU_RUNNER="qemu-ppc -L /usr/powerpc-linux-gnu" \
- CC=powerpc-linux-gnu-gcc \
- PATH=$PATH:/rust/bin
diff --git a/libc/ci/docker/powerpc64-unknown-linux-gnu/Dockerfile b/libc/ci/docker/powerpc64-unknown-linux-gnu/Dockerfile
deleted file mode 100644
index ab40789..0000000
--- a/libc/ci/docker/powerpc64-unknown-linux-gnu/Dockerfile
+++ /dev/null
@@ -1,11 +0,0 @@
-FROM ubuntu:19.04
-
-RUN apt-get update && apt-get install -y --no-install-recommends \
- gcc libc6-dev qemu-user ca-certificates \
- gcc-powerpc64-linux-gnu libc6-dev-ppc64-cross \
- qemu-system-ppc
-
-ENV CARGO_TARGET_POWERPC64_UNKNOWN_LINUX_GNU_LINKER=powerpc64-linux-gnu-gcc \
- CARGO_TARGET_POWERPC64_UNKNOWN_LINUX_GNU_RUNNER="qemu-ppc64 -L /usr/powerpc64-linux-gnu" \
- CC=powerpc64-linux-gnu-gcc \
- PATH=$PATH:/rust/bin
diff --git a/libc/ci/docker/powerpc64le-unknown-linux-gnu/Dockerfile b/libc/ci/docker/powerpc64le-unknown-linux-gnu/Dockerfile
deleted file mode 100644
index 4dcd632..0000000
--- a/libc/ci/docker/powerpc64le-unknown-linux-gnu/Dockerfile
+++ /dev/null
@@ -1,11 +0,0 @@
-FROM ubuntu:19.04
-
-RUN apt-get update && apt-get install -y --no-install-recommends \
- gcc libc6-dev qemu-user ca-certificates \
- gcc-powerpc64le-linux-gnu libc6-dev-ppc64el-cross \
- qemu-system-ppc
-
-ENV CARGO_TARGET_POWERPC64LE_UNKNOWN_LINUX_GNU_LINKER=powerpc64le-linux-gnu-gcc \
- CARGO_TARGET_POWERPC64LE_UNKNOWN_LINUX_GNU_RUNNER="qemu-ppc64le -L /usr/powerpc64le-linux-gnu" \
- CC=powerpc64le-linux-gnu-gcc \
- PATH=$PATH:/rust/bin
diff --git a/libc/ci/docker/s390x-unknown-linux-gnu/Dockerfile b/libc/ci/docker/s390x-unknown-linux-gnu/Dockerfile
deleted file mode 100644
index 75c11c1..0000000
--- a/libc/ci/docker/s390x-unknown-linux-gnu/Dockerfile
+++ /dev/null
@@ -1,18 +0,0 @@
-FROM ubuntu:19.04
-
-RUN apt-get update && apt-get install -y --no-install-recommends \
- curl ca-certificates \
- gcc libc6-dev \
- gcc-s390x-linux-gnu libc6-dev-s390x-cross \
- qemu-system-s390x \
- cpio
-
-COPY linux-s390x.sh /
-RUN bash /linux-s390x.sh
-
-COPY test-runner-linux /
-
-ENV CARGO_TARGET_S390X_UNKNOWN_LINUX_GNU_LINKER=s390x-linux-gnu-gcc \
- CARGO_TARGET_S390X_UNKNOWN_LINUX_GNU_RUNNER="/test-runner-linux s390x" \
- CC_s390x_unknown_linux_gnu=s390x-linux-gnu-gcc \
- PATH=$PATH:/rust/bin
diff --git a/libc/ci/docker/sparc64-unknown-linux-gnu/Dockerfile b/libc/ci/docker/sparc64-unknown-linux-gnu/Dockerfile
deleted file mode 100644
index d1f4503..0000000
--- a/libc/ci/docker/sparc64-unknown-linux-gnu/Dockerfile
+++ /dev/null
@@ -1,18 +0,0 @@
-FROM ubuntu:19.04
-
-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 linux-libc-dev-sparc64-cross
-
-COPY linux-sparc64.sh /
-RUN bash /linux-sparc64.sh
-
-COPY test-runner-linux /
-
-ENV CARGO_TARGET_SPARC64_UNKNOWN_LINUX_GNU_LINKER=sparc64-linux-gnu-gcc \
- CARGO_TARGET_SPARC64_UNKNOWN_LINUX_GNU_RUNNER="/test-runner-linux sparc64" \
- CC_sparc64_unknown_linux_gnu=sparc64-linux-gnu-gcc \
- PATH=$PATH:/rust/bin
diff --git a/libc/ci/docker/wasm32-unknown-emscripten/Dockerfile b/libc/ci/docker/wasm32-unknown-emscripten/Dockerfile
deleted file mode 100644
index c0ce825..0000000
--- a/libc/ci/docker/wasm32-unknown-emscripten/Dockerfile
+++ /dev/null
@@ -1,27 +0,0 @@
-FROM ubuntu:19.04
-
-RUN apt-get update && \
- apt-get install -y --no-install-recommends \
- ca-certificates \
- g++ \
- make \
- file \
- curl \
- gcc \
- git \
- libc6-dev \
- python \
- cmake \
- sudo \
- gdb \
- xz-utils
-
-COPY emscripten.sh /
-RUN bash /emscripten.sh
-
-ENV PATH=$PATH:/rust/bin \
- CARGO_TARGET_WASM32_UNKNOWN_EMSCRIPTEN_RUNNER=node-wrapper.sh
-
-COPY emscripten-entry.sh /
-COPY docker/wasm32-unknown-emscripten/node-wrapper.sh /usr/local/bin/node-wrapper.sh
-ENTRYPOINT ["/emscripten-entry.sh"]
diff --git a/libc/ci/docker/wasm32-unknown-emscripten/node-wrapper.sh b/libc/ci/docker/wasm32-unknown-emscripten/node-wrapper.sh
deleted file mode 100755
index 3122e2e..0000000
--- a/libc/ci/docker/wasm32-unknown-emscripten/node-wrapper.sh
+++ /dev/null
@@ -1,15 +0,0 @@
-#!/bin/sh
-
-set -e
-
-me=$1
-shift
-dir=$(dirname $me)
-file=$(basename $me)
-
-if echo $file | grep -q wasm; then
- exit 0 # FIXME(rust-lang/cargo#4750)
-fi
-
-cd $dir
-exec node $file "$@"
diff --git a/libc/ci/docker/wasm32-wasi/Dockerfile b/libc/ci/docker/wasm32-wasi/Dockerfile
deleted file mode 100644
index d963a44..0000000
--- a/libc/ci/docker/wasm32-wasi/Dockerfile
+++ /dev/null
@@ -1,93 +0,0 @@
-# In the first container we want to assemble the `wasi-sysroot` by compiling it
-# from source. This requires a clang 8.0+ compiler with enough wasm support and
-# then we're just running a standard `make` inside of what we clone.
-FROM ubuntu:18.04 as wasi-sysroot
-
-RUN apt-get update && \
- apt-get install -y --no-install-recommends \
- ca-certificates \
- clang \
- cmake \
- curl \
- g++ \
- git \
- libc6-dev \
- libclang-dev \
- make \
- ssh \
- xz-utils
-
-# Fetch clang 8.0+ which is used to compile the wasi target and link our
-# programs together.
-RUN curl http://releases.llvm.org/8.0.0/clang+llvm-8.0.0-x86_64-linux-gnu-ubuntu-18.04.tar.xz | tar xJf -
-RUN mv /clang+llvm-8.0.0-x86_64-linux-gnu-ubuntu-18.04 /wasmcc
-
-# Note that we're using `git reset --hard` to pin to a specific commit for
-# verification for now. The sysroot is currently in somewhat of a state of flux
-# and is expected to have breaking changes, so this is an attempt to mitigate
-# those breaking changes on `libc`'s own CI
-RUN git clone https://github.com/CraneStation/wasi-sysroot && \
- cd wasi-sysroot && \
- git reset --hard eee6ee7566e26f2535eb6088c8494a112ff423b9
-RUN make -C wasi-sysroot install -j $(nproc) WASM_CC=/wasmcc/bin/clang INSTALL_DIR=/wasi-sysroot
-
-# This is a small wrapper script which executes the actual clang binary in
-# `/wasmcc` and then is sure to pass the right `--sysroot` argument which we
-# just built above.
-COPY docker/wasm32-wasi/clang.sh /wasi-sysroot/bin/clang
-
-# In the second container we're going to build the `wasmtime` binary which is
-# used to execute wasi executables. This is a standard Rust project so we're
-# just checking out a known revision (which pairs with the sysroot one we
-# downlaoded above) and then we're building it with Cargo
-FROM ubuntu:18.04 as wasmtime
-
-RUN apt-get update && \
- apt-get install -y --no-install-recommends \
- ca-certificates \
- clang \
- cmake \
- curl \
- g++ \
- git \
- libclang-dev \
- make \
- ssh
-
-RUN curl -sSf https://sh.rustup.rs | sh -s -- -y
-ENV PATH=/root/.cargo/bin:$PATH
-
-RUN apt-get install -y --no-install-recommends python
-RUN git clone --recursive https://github.com/CraneStation/wasmtime wasmtime && \
- cd wasmtime && \
- git reset --hard 67edb00f29b62864b00179fe4bfa99bc29973285
-RUN cargo build --release --manifest-path wasmtime/Cargo.toml
-
-# And finally in the last image we're going to assemble everything together.
-# We'll install things needed at runtime for now and then copy over the
-# sysroot/wasmtime artifacts into their final location.
-FROM ubuntu:18.04
-
-RUN apt-get update && \
- apt-get install -y --no-install-recommends \
- gcc \
- libc6-dev \
- libxml2 \
- ca-certificates
-
-# Copy over clang we downloaded to link executables ...
-COPY --from=wasi-sysroot /wasmcc /wasmcc/
-# ... and the sysroot we built to link executables against ...
-COPY --from=wasi-sysroot /wasi-sysroot/ /wasi-sysroot/
-# ... and finally wasmtime to actually execute binaries
-COPY --from=wasmtime /wasmtime/target/release/wasmtime /usr/bin/
-
-# Of note here is our clang wrapper which just executes a normal clang
-# executable with the right sysroot, and then we're sure to turn off the
-# crt-static feature to ensure that the CRT that we're specifying with `clang`
-# is used.
-ENV CARGO_TARGET_WASM32_WASI_RUNNER=wasmtime \
- CARGO_TARGET_WASM32_WASI_LINKER=/wasi-sysroot/bin/clang \
- CC_wasm32_wasi=/wasi-sysroot/bin/clang \
- PATH=$PATH:/rust/bin \
- RUSTFLAGS=-Ctarget-feature=-crt-static
diff --git a/libc/ci/docker/wasm32-wasi/clang.sh b/libc/ci/docker/wasm32-wasi/clang.sh
deleted file mode 100755
index 6f29812..0000000
--- a/libc/ci/docker/wasm32-wasi/clang.sh
+++ /dev/null
@@ -1,2 +0,0 @@
-#!/usr/bin/env sh
-exec /wasmcc/bin/clang --target=wasm32-wasi --sysroot /wasi-sysroot "$@"
diff --git a/libc/ci/docker/x86_64-linux-android/Dockerfile b/libc/ci/docker/x86_64-linux-android/Dockerfile
deleted file mode 100644
index b0984c0..0000000
--- a/libc/ci/docker/x86_64-linux-android/Dockerfile
+++ /dev/null
@@ -1,26 +0,0 @@
-FROM ubuntu:19.04
-
-RUN apt-get update && \
- apt-get install -y --no-install-recommends \
- ca-certificates \
- curl \
- gcc \
- libc-dev \
- python \
- unzip
-
-WORKDIR /android/
-ENV ANDROID_ARCH=x86_64
-COPY android-install-ndk.sh /android/
-RUN sh /android/android-install-ndk.sh $ANDROID_ARCH
-
-# We do not run x86_64-linux-android tests on an android emulator.
-# See ci/android-sysimage.sh for informations about how tests are run.
-COPY android-sysimage.sh /android/
-RUN bash /android/android-sysimage.sh x86_64 x86_64-24_r07.zip
-
-ENV PATH=$PATH:/rust/bin:/android/ndk-$ANDROID_ARCH/bin \
- CARGO_TARGET_X86_64_LINUX_ANDROID_LINKER=x86_64-linux-android-gcc \
- CC_x86_64_linux_android=x86_64-linux-android-gcc \
- CXX_x86_64_linux_android=x86_64-linux-android-g++ \
- HOME=/tmp
diff --git a/libc/ci/docker/x86_64-rumprun-netbsd/Dockerfile b/libc/ci/docker/x86_64-rumprun-netbsd/Dockerfile
deleted file mode 100644
index a486d05..0000000
--- a/libc/ci/docker/x86_64-rumprun-netbsd/Dockerfile
+++ /dev/null
@@ -1,10 +0,0 @@
-FROM mato/rumprun-toolchain-hw-x86_64
-USER root
-RUN apt-get update
-RUN apt-get install -y --no-install-recommends \
- qemu
-ENV PATH=$PATH:/rust/bin \
- CARGO_TARGET_X86_64_RUMPRUN_NETBSD_RUNNER=/tmp/runtest
-
-ADD docker/x86_64-rumprun-netbsd/runtest.rs /tmp/
-ENTRYPOINT ["sh", "-c", "rustc /tmp/runtest.rs -o /tmp/runtest && exec \"$@\"", "--"]
diff --git a/libc/ci/docker/x86_64-rumprun-netbsd/runtest.rs b/libc/ci/docker/x86_64-rumprun-netbsd/runtest.rs
deleted file mode 100644
index 7e96fbf..0000000
--- a/libc/ci/docker/x86_64-rumprun-netbsd/runtest.rs
+++ /dev/null
@@ -1,55 +0,0 @@
-use std::env;
-use std::process::{Command, Stdio};
-use std::sync::mpsc;
-use std::thread;
-use std::time::Duration;
-use std::io::{BufRead, BufReader, Read};
-
-fn main() {
- assert_eq!(env::args().len(), 2);
-
- let status = Command::new("rumprun-bake")
- .arg("hw_virtio")
- .arg("/tmp/libc-test.img")
- .arg(env::args().nth(1).unwrap())
- .status()
- .expect("failed to run rumprun-bake");
- assert!(status.success());
-
- let mut child = Command::new("qemu-system-x86_64")
- .arg("-nographic")
- .arg("-vga").arg("none")
- .arg("-m").arg("64")
- .arg("-kernel").arg("/tmp/libc-test.img")
- .stdout(Stdio::piped())
- .stderr(Stdio::piped())
- .spawn()
- .expect("failed to spawn qemu");
-
- let mut stdout = child.stdout.take().unwrap();
- let mut stderr = child.stderr.take().unwrap();
- let (tx, rx) = mpsc::channel();
- let tx2 = tx.clone();
- let t1 = thread::spawn(move || find_ok(&mut stdout, tx));
- let t2 = thread::spawn(move || find_ok(&mut stderr, tx2));
-
- let res = rx.recv_timeout(Duration::new(5, 0));
- child.kill().unwrap();
- t1.join().unwrap();
- t2.join().unwrap();
-
- if res.is_err() {
- panic!("didn't find success");
- }
-}
-
-fn find_ok(input: &mut Read, tx: mpsc::Sender<()>) {
- for line in BufReader::new(input).lines() {
- let line = line.unwrap();
- println!("{}", line);
- if (line.starts_with("PASSED ") && line.contains(" tests")) ||
- line.starts_with("test result: ok"){
- tx.send(()).unwrap();
- }
- }
-}
diff --git a/libc/ci/docker/x86_64-unknown-linux-gnu/Dockerfile b/libc/ci/docker/x86_64-unknown-linux-gnu/Dockerfile
deleted file mode 100644
index bfa2b17..0000000
--- a/libc/ci/docker/x86_64-unknown-linux-gnu/Dockerfile
+++ /dev/null
@@ -1,9 +0,0 @@
-FROM ubuntu:19.04
-RUN apt-get update
-RUN apt-get install -y --no-install-recommends \
- gcc libc6-dev ca-certificates linux-headers-generic
-
-RUN apt search linux-headers
-RUN ls /usr/src
-
-ENV PATH=$PATH:/rust/bin
diff --git a/libc/ci/docker/x86_64-unknown-linux-gnux32/Dockerfile b/libc/ci/docker/x86_64-unknown-linux-gnux32/Dockerfile
deleted file mode 100644
index 5563a7b..0000000
--- a/libc/ci/docker/x86_64-unknown-linux-gnux32/Dockerfile
+++ /dev/null
@@ -1,5 +0,0 @@
-FROM ubuntu:19.04
-RUN apt-get update
-RUN apt-get install -y --no-install-recommends \
- gcc-multilib libc6-dev ca-certificates
-ENV PATH=$PATH:/rust/bin
diff --git a/libc/ci/docker/x86_64-unknown-linux-musl/Dockerfile b/libc/ci/docker/x86_64-unknown-linux-musl/Dockerfile
deleted file mode 100644
index 06a081b..0000000
--- a/libc/ci/docker/x86_64-unknown-linux-musl/Dockerfile
+++ /dev/null
@@ -1,10 +0,0 @@
-FROM ubuntu:19.04
-
-RUN apt-get update
-RUN apt-get install -y --no-install-recommends \
- gcc make libc6-dev git curl ca-certificates
-
-COPY install-musl.sh /
-RUN sh /install-musl.sh x86_64
-
-ENV PATH=$PATH:/musl-x86_64/bin:/rust/bin
diff --git a/libc/ci/dox.sh b/libc/ci/dox.sh
deleted file mode 100644
index ce55081..0000000
--- a/libc/ci/dox.sh
+++ /dev/null
@@ -1,70 +0,0 @@
-#!/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 -ex
-
-TARGET_DOC_DIR=target/doc
-README=README.md
-PLATFORM_SUPPORT=platform-support.md
-
-rm -rf $TARGET_DOC_DIR
-mkdir -p $TARGET_DOC_DIR
-
-# List all targets that do currently build successfully:
-# shellcheck disable=SC1003
-grep '[\d|\w|-]* \\' ci/build.sh > targets
-sed -i.bak 's/ \\//g' targets
-grep '^[_a-zA-Z0-9-]*$' targets > tmp && mv tmp targets
-
-# Create a markdown list of supported platforms in $PLATFORM_SUPPORT
-rm $PLATFORM_SUPPORT || true
-
-printf '### Platform-specific documentation\n' >> $PLATFORM_SUPPORT
-
-while read -r target; do
- echo "documenting ${target}"
-
- case "${target}" in
- *apple*)
- # FIXME:
- # We can't build docs of apple targets from Linux yet.
- continue
- ;;
- *)
- ;;
- esac
-
- rustup target add "${target}" || true
-
- # If cargo doc fails, then try xargo:
- if ! cargo doc --target "${target}" \
- --no-default-features --features extra_traits ; then
- xargo doc --target "${target}" \
- --no-default-features --features extra_traits
- fi
-
- cp -r "target/${target}/doc" "${TARGET_DOC_DIR}/${target}"
-
- echo "* [${target}](${target}/libc/index.html)" >> $PLATFORM_SUPPORT
-done < targets
-
-# Replace <div class="platform_support"></div> with the contents of $PLATFORM_SUPPORT
-cp $README $TARGET_DOC_DIR
-line=$(grep -n '<div class="platform_docs"></div>' $README | cut -d ":" -f 1)
-
-set +x
-{ head -n "$((line-1))" $README; cat $PLATFORM_SUPPORT; tail -n "+$((line+1))" $README; } > $TARGET_DOC_DIR/$README
-set -x
-
-# Copy the licenses
-cp LICENSE-* $TARGET_DOC_DIR/
-
-# 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" $TARGET_DOC_DIR
- 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
deleted file mode 100755
index 0016f56..0000000
--- a/libc/ci/emscripten-entry.sh
+++ /dev/null
@@ -1,20 +0,0 @@
-#!/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.
-#
-# 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.
-
-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
-export PATH="/node-v12.3.1-linux-x64/bin:$PATH"
-
-exec "$@"
diff --git a/libc/ci/emscripten.sh b/libc/ci/emscripten.sh
deleted file mode 100644
index db31323..0000000
--- a/libc/ci/emscripten.sh
+++ /dev/null
@@ -1,56 +0,0 @@
-#!/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.
-#
-# 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.
-
-set -ex
-
-hide_output() {
- set +x
- on_err="
-echo ERROR: An error was encountered with the build.
-cat /tmp/build.log
-exit 1
-"
- trap '$on_err' ERR
- bash -c "while true; do sleep 30; echo \$(date) - building ...; done" &
- PING_LOOP_PID=$!
- "${@}" &> /tmp/build.log
- trap - ERR
- kill $PING_LOOP_PID
- rm -f /tmp/build.log
- set -x
-}
-
-cd /
-curl --retry 5 -L https://s3.amazonaws.com/mozilla-games/emscripten/releases/emsdk-portable.tar.gz | \
- tar -xz
-
-cd /emsdk-portable
-./emsdk update
-hide_output ./emsdk install sdk-1.38.15-64bit
-./emsdk activate sdk-1.38.15-64bit
-
-# Compile and cache libc
-# shellcheck disable=SC1091
-source ./emsdk_env.sh
-echo "main(){}" > a.c
-HOME=/emsdk-portable/ emcc a.c
-HOME=/emsdk-portable/ emcc -s BINARYEN=1 a.c
-rm -f a.*
-
-# Make emsdk usable by any user
-cp /root/.emscripten /emsdk-portable
-chmod a+rxw -R /emsdk-portable
-
-# node 8 is required to run wasm
-cd /
-curl --retry 5 -L https://nodejs.org/dist/v12.3.1/node-v12.3.1-linux-x64.tar.xz | \
- tar -xJ
-
diff --git a/libc/ci/install-musl.sh b/libc/ci/install-musl.sh
deleted file mode 100644
index ab98c4f..0000000
--- a/libc/ci/install-musl.sh
+++ /dev/null
@@ -1,69 +0,0 @@
-#!/usr/bin/env sh
-#
-# Install musl and musl-sanitized linux kernel headers
-# to musl-{$1} directory
-
-set -ex
-
-MUSL_VERSION=1.1.22
-MUSL="musl-${MUSL_VERSION}"
-
-# Download, configure, build, and install musl:
-curl --retry 5 https://www.musl-libc.org/releases/${MUSL}.tar.gz | tar xzf -
-
-cd $MUSL
-case ${1} in
- aarch64)
- musl_arch=aarch64
- kernel_arch=arm64
- CC=aarch64-linux-gnu-gcc \
- ./configure --prefix="/musl-${musl_arch}" --enable-wrapper=yes
- make install -j4
- ;;
- arm)
- musl_arch=arm
- kernel_arch=arm
- CC=arm-linux-gnueabihf-gcc CFLAGS="-march=armv6 -marm -mfpu=vfp" \
- ./configure --prefix="/musl-${musl_arch}" --enable-wrapper=yes
- make install -j4
- ;;
- i686)
- # cross-compile musl for i686 using the system compiler on an x86_64
- # system.
- musl_arch=i686
- kernel_arch=i386
- # Specifically pass -m32 in CFLAGS and override CC when running
- # ./configure, since otherwise the script will fail to find a compiler.
- CC=gcc CFLAGS="-m32" \
- ./configure --prefix="/musl-${musl_arch}" --disable-shared --target=i686
- # unset CROSS_COMPILE when running make; otherwise the makefile will
- # call the non-existent binary 'i686-ar'.
- make CROSS_COMPILE= install -j4
- ;;
- x86_64)
- musl_arch=x86_64
- kernel_arch=x86_64
- ./configure --prefix="/musl-${musl_arch}"
- make install -j4
- ;;
- *)
- echo "Unknown target arch: \"${1}\""
- exit 1
- ;;
-esac
-
-
-# shellcheck disable=SC2103
-cd ..
-rm -rf $MUSL
-
-# Download, configure, build, and install musl-sanitized kernel headers:
-KERNEL_HEADER_VER="4.4.2-2"
-curl --retry 5 -L \
- "https://github.com/sabotage-linux/kernel-headers/archive/v${KERNEL_HEADER_VER}.tar.gz" | \
- tar xzf -
-(
- cd kernel-headers-${KERNEL_HEADER_VER}
- make ARCH="${kernel_arch}" prefix="/musl-${musl_arch}" install -j4
-)
-rm -rf kernel-headers-${KERNEL_HEADER_VER}
diff --git a/libc/ci/ios/deploy_and_run_on_ios_simulator.rs b/libc/ci/ios/deploy_and_run_on_ios_simulator.rs
deleted file mode 100644
index 2075be6..0000000
--- a/libc/ci/ios/deploy_and_run_on_ios_simulator.rs
+++ /dev/null
@@ -1,175 +0,0 @@
-// 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.
-//
-// 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.
-
-// This is a script to deploy and execute a binary on an iOS simulator.
-// The primary use of this is to be able to run unit tests on the simulator and
-// retrieve the results.
-//
-// To do this through Cargo instead, use Dinghy
-// (https://github.com/snipsco/dinghy): cargo dinghy install, then cargo dinghy
-// test.
-
-use std::env;
-use std::fs::{self, File};
-use std::io::Write;
-use std::path::Path;
-use std::process;
-use std::process::Command;
-
-macro_rules! t {
- ($e:expr) => (match $e {
- Ok(e) => e,
- Err(e) => panic!("{} failed with: {}", stringify!($e), e),
- })
-}
-
-// Step one: Wrap as an app
-fn package_as_simulator_app(crate_name: &str, test_binary_path: &Path) {
- println!("Packaging simulator app");
- drop(fs::remove_dir_all("ios_simulator_app"));
- t!(fs::create_dir("ios_simulator_app"));
- t!(fs::copy(test_binary_path,
- Path::new("ios_simulator_app").join(crate_name)));
-
- let mut f = t!(File::create("ios_simulator_app/Info.plist"));
- t!(f.write_all(format!(r#"
- <?xml version="1.0" encoding="UTF-8"?>
- <!DOCTYPE plist PUBLIC
- "-//Apple//DTD PLIST 1.0//EN"
- "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
- <plist version="1.0">
- <dict>
- <key>CFBundleExecutable</key>
- <string>{}</string>
- <key>CFBundleIdentifier</key>
- <string>com.rust.unittests</string>
- </dict>
- </plist>
- "#, crate_name).as_bytes()));
-}
-
-// Step two: Start the iOS simulator
-fn start_simulator() {
- println!("Looking for iOS simulator");
- let output = t!(Command::new("xcrun").arg("simctl").arg("list").output());
- assert!(output.status.success());
- let mut simulator_exists = false;
- let mut simulator_booted = false;
- let mut found_rust_sim = false;
- let stdout = t!(String::from_utf8(output.stdout));
- for line in stdout.lines() {
- if line.contains("rust_ios") {
- if found_rust_sim {
- panic!("Duplicate rust_ios simulators found. Please \
- double-check xcrun simctl list.");
- }
- simulator_exists = true;
- simulator_booted = line.contains("(Booted)");
- found_rust_sim = true;
- }
- }
-
- if simulator_exists == false {
- println!("Creating iOS simulator");
- Command::new("xcrun")
- .arg("simctl")
- .arg("create")
- .arg("rust_ios")
- .arg("com.apple.CoreSimulator.SimDeviceType.iPhone-SE")
- .arg("com.apple.CoreSimulator.SimRuntime.iOS-10-2")
- .check_status();
- } else if simulator_booted == true {
- println!("Shutting down already-booted simulator");
- Command::new("xcrun")
- .arg("simctl")
- .arg("shutdown")
- .arg("rust_ios")
- .check_status();
- }
-
- println!("Starting iOS simulator");
- // We can't uninstall the app (if present) as that will hang if the
- // simulator isn't completely booted; just erase the simulator instead.
- Command::new("xcrun").arg("simctl").arg("erase").arg("rust_ios").check_status();
- Command::new("xcrun").arg("simctl").arg("boot").arg("rust_ios").check_status();
-}
-
-// Step three: Install the app
-fn install_app_to_simulator() {
- println!("Installing app to simulator");
- Command::new("xcrun")
- .arg("simctl")
- .arg("install")
- .arg("booted")
- .arg("ios_simulator_app/")
- .check_status();
-}
-
-// Step four: Run the app
-fn run_app_on_simulator() {
- println!("Running app");
- let output = t!(Command::new("xcrun")
- .arg("simctl")
- .arg("launch")
- .arg("--console")
- .arg("booted")
- .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));
-
- let stdout = String::from_utf8_lossy(&output.stdout);
- let passed = stdout.lines()
- .find(|l|
- (l.contains("PASSED") &&
- l.contains("tests")) ||
- l.contains("test result: ok")
- )
- .unwrap_or(false);
-
- println!("Shutting down simulator");
- Command::new("xcrun")
- .arg("simctl")
- .arg("shutdown")
- .arg("rust_ios")
- .check_status();
- if !passed {
- panic!("tests didn't pass");
- }
-}
-
-trait CheckStatus {
- fn check_status(&mut self);
-}
-
-impl CheckStatus for Command {
- fn check_status(&mut self) {
- println!("\trunning: {:?}", self);
- assert!(t!(self.status()).success());
- }
-}
-
-fn main() {
- let args: Vec<String> = env::args().collect();
- if args.len() != 2 {
- println!("Usage: {} <executable>", args[0]);
- process::exit(-1);
- }
-
- let test_binary_path = Path::new(&args[1]);
- let crate_name = test_binary_path.file_name().unwrap();
-
- package_as_simulator_app(crate_name.to_str().unwrap(), test_binary_path);
- start_simulator();
- install_app_to_simulator();
- run_app_on_simulator();
-}
diff --git a/libc/ci/linux-s390x.sh b/libc/ci/linux-s390x.sh
deleted file mode 100644
index 00a7f88..0000000
--- a/libc/ci/linux-s390x.sh
+++ /dev/null
@@ -1,20 +0,0 @@
-#!/usr/bin/env sh
-
-set -ex
-
-mkdir -m 777 /qemu
-cd /qemu
-
-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/20190410/images/generic/kernel.debian
-curl --retry 5 -LO http://ftp.debian.org/debian/dists/testing/main/installer-s390x/20190410/images/generic/initrd.debian
-
-mv kernel.debian kernel
-mv initrd.debian initrd.gz
-
-mkdir init
-cd init
-gunzip -c ../initrd.gz | cpio -id
-rm ../initrd.gz
-cp /usr/s390x-linux-gnu/lib/libgcc_s.so.1 usr/lib/
-chmod a+w .
diff --git a/libc/ci/linux-sparc64.sh b/libc/ci/linux-sparc64.sh
deleted file mode 100644
index 5580a0e..0000000
--- a/libc/ci/linux-sparc64.sh
+++ /dev/null
@@ -1,19 +0,0 @@
-#!/usr/bin/env sh
-
-set -ex
-
-mkdir -m 777 /qemu
-cd /qemu
-
-curl --retry 5 -LO https://cdimage.debian.org/cdimage/ports/10.0/sparc64/iso-cd/debian-10.0-sparc64-NETINST-1.iso
-7z e debian-10.0-sparc64-NETINST-1.iso boot/initrd.gz
-7z e debian-10.0-sparc64-NETINST-1.iso boot/sparc64
-mv sparc64 kernel
-rm debian-10.0-sparc64-NETINST-1.iso
-
-mkdir init
-cd init
-gunzip -c ../initrd.gz | cpio -id
-rm ../initrd.gz
-cp /usr/sparc64-linux-gnu/lib/libgcc_s.so.1 usr/lib/
-chmod a+w .
diff --git a/libc/ci/run-docker.sh b/libc/ci/run-docker.sh
deleted file mode 100755
index c656f59..0000000
--- a/libc/ci/run-docker.sh
+++ /dev/null
@@ -1,42 +0,0 @@
-#!/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 "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/
- mkdir -p target
- if [ -w /dev/kvm ]; then
- kvm="--volume /dev/kvm:/dev/kvm"
- else
- kvm=""
- fi
-
- docker run \
- --user "$(id -u)":"$(id -g)" \
- --rm \
- --init \
- --volume "${HOME}/.cargo":/cargo \
- $kvm \
- --env CARGO_HOME=/cargo \
- --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}"
-}
-
-if [ -z "${1}" ]; then
- for d in ci/docker/*; do
- run "${d}"
- done
-else
- run "${1}"
-fi
diff --git a/libc/ci/run-qemu.sh b/libc/ci/run-qemu.sh
deleted file mode 100644
index 6fba629..0000000
--- a/libc/ci/run-qemu.sh
+++ /dev/null
@@ -1,34 +0,0 @@
-#!/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.
-#
-# For qemu images we currently need to install Rust manually as this wasn't done
-# by the initial run-travis.sh script
-#
-# FIXME: feels like run-travis.sh should be responsible for downloading the
-# compiler.
-
-set -ex
-
-ROOT="${1}"
-cp -r "${ROOT}/libc" /tmp/libc
-cd /tmp/libc
-
-TARGET="$(cat "${ROOT}/TARGET")"
-export CARGO_TARGET_DIR=/tmp
-
-case $TARGET in
- *-openbsd)
- pkg_add cargo gcc%4.9 rust
- export CC=egcc
- ;;
-
- *)
- echo "Unknown target: ${TARGET}"
- exit 1
- ;;
-esac
-
-exec sh ci/run.sh "${TARGET}"
diff --git a/libc/ci/run.sh b/libc/ci/run.sh
deleted file mode 100755
index 8c56979..0000000
--- a/libc/ci/run.sh
+++ /dev/null
@@ -1,98 +0,0 @@
-#!/usr/bin/env sh
-
-# Builds and runs tests for a particular target passed as an argument to this
-# script.
-
-set -ex
-
-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
-# the current state of this repository, and then run the image.
-#
-# It's assume that all images, when run with two disks, will run the `run.sh`
-# script from the second which we place inside.
-if [ "$QEMU" != "" ]; then
- tmpdir=/tmp/qemu-img-creation
- 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 --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 --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"
-
- # 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}" \
- --test main
- 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"
- genext2fs \
- --root "${tmpdir}/mount" \
- --size-in-blocks 100000 \
- "${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,
- # first is the OS and second is the one we just made. Next the network is
- # configured to work (I'm not entirely sure how), and then finally we turn off
- # graphics and redirect the serial console output to out.log.
- qemu-system-x86_64 \
- -m 1024 \
- -snapshot \
- -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 egrep "^(PASSED)|(test result: ok)" "${CARGO_TARGET_DIR}/out.log"
-fi
-
-# 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
-
-export LIBC_CI=1
-
-cargo test -vv $opt --no-default-features --manifest-path libc-test/Cargo.toml \
- --target "${TARGET}"
-
-cargo test -vv $opt --manifest-path libc-test/Cargo.toml --target "${TARGET}"
-
-cargo test -vv $opt --features extra_traits --manifest-path libc-test/Cargo.toml \
- --target "${TARGET}"
diff --git a/libc/ci/runtest-android.rs b/libc/ci/runtest-android.rs
deleted file mode 100644
index b8030c4..0000000
--- a/libc/ci/runtest-android.rs
+++ /dev/null
@@ -1,47 +0,0 @@
-use std::env;
-use std::process::Command;
-use std::path::{Path, PathBuf};
-
-fn main() {
- let args = env::args_os()
- .skip(1)
- .filter(|arg| arg != "--quiet")
- .collect::<Vec<_>>();
- assert_eq!(args.len(), 1);
- let test = PathBuf::from(&args[0]);
- let dst = Path::new("/data/local/tmp").join(test.file_name().unwrap());
-
- let status = Command::new("adb")
- .arg("wait-for-device")
- .status()
- .expect("failed to run: adb wait-for-device");
- assert!(status.success());
-
- let status = Command::new("adb")
- .arg("push")
- .arg(&test)
- .arg(&dst)
- .status()
- .expect("failed to run: adb pushr");
- assert!(status.success());
-
- let output = Command::new("adb")
- .arg("shell")
- .arg(&dst)
- .output()
- .expect("failed to run: adb shell");
- assert!(status.success());
-
- println!("status: {}\nstdout ---\n{}\nstderr ---\n{}",
- output.status,
- String::from_utf8_lossy(&output.stdout),
- String::from_utf8_lossy(&output.stderr));
-
- let stdout = String::from_utf8_lossy(&output.stdout);
- stdout.lines().find(|l|
- (l.starts_with("PASSED ") && l.contains(" tests")) ||
- l.starts_with("test result: ok")
- ).unwrap_or_else(|| {
- panic!("failed to find successful test run");
- });
-}
diff --git a/libc/ci/semver.sh b/libc/ci/semver.sh
deleted file mode 100644
index ac6be36..0000000
--- a/libc/ci/semver.sh
+++ /dev/null
@@ -1,70 +0,0 @@
-#!/usr/bin/env sh
-
-# Checks that libc does not contain breaking changes for the following targets.
-
-set -ex
-
-OS=${TRAVIS_OS_NAME}
-
-echo "Testing Semver on ${OS}"
-
-TARGETS=
-case "${OS}" in
- *linux*)
- TARGETS="\
-aarch64-fuchsia \
-aarch64-linux-android \
-aarch64-unknown-linux-gnu \
-aarch64-unknown-linux-musl \
-armv7-linux-androideabi \
-armv7-unknown-linux-gnueabihf \
-i586-unknown-linux-gnu \
-i586-unknown-linux-musl \
-i686-linux-android \
-i686-unknown-freebsd \
-i686-unknown-linux-gnu \
-i686-unknown-linux-musl \
-i686-pc-windows-gnu \
-x86_64-unknown-freebsd \
-x86_64-unknown-linux-gnu \
-x86_64-unknown-linux-musl \
-x86_64-unknown-netbsd \
-x86_64-unknown-cloudabi \
-x86_64-sun-solaris \
-x86_64-fuchsia \
-x86_64-pc-windows-gnu \
-x86_64-unknown-linux-gnux32 \
-x86_64-unknown-redox \
-x86_64-fortanix-unknown-sgx \
-wasm32-unknown-unknown \
-"
- ;;
- *osx*)
- TARGETS="\
-aarch64-apple-ios \
-armv7-apple-ios \
-armv7s-apple-ios \
-i386-apple-ios \
-i686-apple-darwin \
-x86_64-apple-darwin \
-x86_64-apple-ios \
-"
- ;;
-esac
-
-for TARGET in $TARGETS; do
- # FIXME: rustup often fails to download some artifacts due to network
- # issues, so we retry this N times.
- N=5
- n=0
- until [ $n -ge $N ]
- do
- if rustup target add "${TARGET}" ; then
- break
- fi
- n=$((n+1))
- sleep 1
- done
-
- cargo +nightly semver --api-guidelines --target="${TARGET}"
-done
diff --git a/libc/ci/style.rs b/libc/ci/style.rs
deleted file mode 100644
index 481f57f..0000000
--- a/libc/ci/style.rs
+++ /dev/null
@@ -1,212 +0,0 @@
-//! Simple script to verify the coding style of this library
-//!
-//! ## How to run
-//!
-//! The first argument to this script is the directory to run on, so running
-//! this script should be as simple as:
-//!
-//! ```notrust
-//! rustc ci/style.rs
-//! ./style src
-//! ```
-//!
-//! ## Guidelines
-//!
-//! The current style is:
-//!
-//! * No trailing whitespace
-//! * No tabs
-//! * 80-character lines
-//! * `extern` instead of `extern "C"`
-//! * Specific module layout:
-//! 1. use directives
-//! 2. typedefs
-//! 3. structs
-//! 4. constants
-//! 5. f! { ... } functions
-//! 6. extern functions
-//! 7. modules + pub use
-//!
-//! Things not verified:
-//!
-//! * alignment
-//! * 4-space tabs
-//! * leading colons on paths
-
-use std::env;
-use std::fs;
-use std::io::prelude::*;
-use std::path::Path;
-
-macro_rules! t {
- ($e:expr) => (match $e {
- Ok(e) => e,
- Err(e) => panic!("{} failed with {}", stringify!($e), e),
- })
-}
-
-fn main() {
- let arg = env::args().skip(1).next().unwrap_or(".".to_string());
-
- let mut errors = Errors { errs: false };
- walk(Path::new(&arg), &mut errors);
-
- if errors.errs {
- panic!("found some lint errors");
- } else {
- println!("good style!");
- }
-}
-
-fn walk(path: &Path, err: &mut Errors) {
- for entry in t!(path.read_dir()).map(|e| t!(e)) {
- let path = entry.path();
- if t!(entry.file_type()).is_dir() {
- walk(&path, err);
- continue
- }
-
- let name = entry.file_name().into_string().unwrap();
- match &name[..] {
- n if !n.ends_with(".rs") => continue,
-
- "dox.rs" |
- "lib.rs" |
- "ctypes.rs" |
- "libc.rs" |
- "macros.rs" => continue,
-
- _ => {}
- }
-
- let mut contents = String::new();
- t!(t!(fs::File::open(&path)).read_to_string(&mut contents));
-
- check_style(&contents, &path, err);
- }
-}
-
-struct Errors {
- errs: bool,
-}
-
-#[derive(Clone, Copy, PartialEq)]
-enum State {
- Start,
- Imports,
- Typedefs,
- Structs,
- Constants,
- FunctionDefinitions,
- Functions,
- Modules,
-}
-
-fn check_style(file: &str, path: &Path, err: &mut Errors) {
- let mut state = State::Start;
- let mut s_macros = 0;
- let mut f_macros = 0;
- let mut prev_blank = false;
-
- for (i, line) in file.lines().enumerate() {
- if line == "" {
- if prev_blank {
- err.error(path, i, "double blank line");
- }
- prev_blank = true;
- } else {
- prev_blank = false;
- }
- if line != line.trim_right() {
- err.error(path, i, "trailing whitespace");
- }
- if line.contains("\t") {
- err.error(path, i, "tab character");
- }
- if line.len() > 80 {
- err.error(path, i, "line longer than 80 chars");
- }
- if line.contains("extern \"C\"") {
- err.error(path, i, "use `extern` instead of `extern \"C\"");
- }
- 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]");
- }
- }
-
- let line = line.trim_left();
- let is_pub = line.starts_with("pub ");
- let line = if is_pub {&line[4..]} else {line};
-
- let line_state = if line.starts_with("use ") {
- if line.contains("c_void") {
- continue;
- }
- if is_pub {
- State::Modules
- } else {
- State::Imports
- }
- } else if line.starts_with("const ") {
- State::Constants
- } else if line.starts_with("type ") {
- State::Typedefs
- } else if line.starts_with("s! {") {
- s_macros += 1;
- State::Structs
- } else if line.starts_with("f! {") {
- f_macros += 1;
- State::FunctionDefinitions
- } else if line.starts_with("extern ") {
- State::Functions
- } else if line.starts_with("mod ") {
- State::Modules
- } else {
- continue
- };
-
- if state as usize > line_state as usize {
- err.error(path, i, &format!("{} found after {} when \
- it belongs before",
- line_state.desc(), state.desc()));
- }
-
- if f_macros == 2 {
- f_macros += 1;
- err.error(path, i, "multiple f! macros in one module");
- }
- if s_macros == 2 {
- s_macros += 1;
- err.error(path, i, "multiple s! macros in one module");
- }
-
- state = line_state;
- }
-}
-
-impl State {
- fn desc(&self) -> &str {
- match *self {
- State::Start => "start",
- State::Imports => "import",
- State::Typedefs => "typedef",
- State::Structs => "struct",
- State::Constants => "constant",
- State::FunctionDefinitions => "function definition",
- State::Functions => "extern function",
- State::Modules => "module",
- }
- }
-}
-
-impl Errors {
- fn error(&mut self, path: &Path, line: usize, msg: &str) {
- self.errs = true;
- println!("{}:{} - {}", path.display(), line + 1, msg);
- }
-}
diff --git a/libc/ci/switch.json b/libc/ci/switch.json
deleted file mode 100644
index bc18948..0000000
--- a/libc/ci/switch.json
+++ /dev/null
@@ -1,37 +0,0 @@
-{
- "family": "unix",
- "env": "newlib",
- "target-env": "newlib",
- "target-family": "unix",
- "target-c-int-width": "32",
- "target-endian": "little",
- "target-pointer-width": "64",
- "os": "horizon",
- "arch": "aarch64",
- "panic-strategy": "unwind",
- "abi-blacklist": [
- "stdcall",
- "fastcall",
- "vectorcall",
- "thiscall",
- "win64",
- "sysv64"
- ],
- "dynamic-linking" : false,
- "features": "+a53,+strict-align",
- "data-layout": "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128",
- "executables": true,
- "position-independent-executables" : true,
- "linker-flavor": "gcc",
- "llvm-target": "aarch64-unknown-none",
- "has-elf-tls" : false,
- "linker-is-gnu" : true,
- "disable-redzone" : true,
- "relocation-model" : "pic",
- "max-atomic-width": 128,
- "exe-suffix": ".elf",
- "staticlib-suffix" : ".a",
- "trap-unreachable" : true,
- "emit-debug-gdb-scripts" : true,
- "requires-uwtable" : true
-} \ No newline at end of file
diff --git a/libc/ci/test-runner-linux b/libc/ci/test-runner-linux
deleted file mode 100755
index cad31ec..0000000
--- a/libc/ci/test-runner-linux
+++ /dev/null
@@ -1,25 +0,0 @@
-#!/bin/sh
-
-set -e
-
-arch=$1
-prog=$2
-
-cd /qemu/init
-echo "#!/bin/sh\n/prog --color=never" > run_prog.sh
-chmod +x run_prog.sh
-cp -f $2 prog
-find . | cpio --create --format='newc' --quiet | gzip > ../initrd.gz
-cd ..
-
-timeout 30s qemu-system-$arch \
- -m 1024 \
- -nographic \
- -kernel kernel \
- -initrd initrd.gz \
- -append init=/run_prog.sh > output || true
-
-# remove kernel messages
-tr -d '\r' < output | egrep -v '^\['
-
-egrep "(PASSED)|(test result: ok)" output > /dev/null
diff --git a/libc/libc-test/Cargo.toml b/libc/libc-test/Cargo.toml
deleted file mode 100644
index 8d2d903..0000000
--- a/libc/libc-test/Cargo.toml
+++ /dev/null
@@ -1,54 +0,0 @@
-[package]
-name = "libc-test"
-version = "0.1.0"
-authors = ["Alex Crichton <alex@alexcrichton.com>"]
-build = "build.rs"
-
-[dependencies.libc]
-path = ".."
-default-features = false
-
-[build-dependencies]
-cc = "1.0"
-ctest = "0.2"
-
-[features]
-default = [ "std" ]
-std = [ "libc/std" ]
-align = [ "libc/align" ]
-extra_traits = [ "libc/extra_traits" ]
-
-[[test]]
-name = "main"
-path = "test/main.rs"
-harness = false
-
-[[test]]
-name = "linux-fcntl"
-path = "test/linux_fcntl.rs"
-harness = false
-
-[[test]]
-name = "linux-ipv6"
-path = "test/linux_ipv6.rs"
-harness = false
-
-[[test]]
-name = "linux-elf"
-path = "test/linux_elf.rs"
-harness = false
-
-[[test]]
-name = "linux-strerror_r"
-path = "test/linux_strerror_r.rs"
-harness = false
-
-[[test]]
-name = "linux-termios"
-path = "test/linux_termios.rs"
-harness = false
-
-[[test]]
-name = "cmsg"
-path = "test/cmsg.rs"
-harness = true
diff --git a/libc/libc-test/build.rs b/libc/libc-test/build.rs
deleted file mode 100644
index 5087906..0000000
--- a/libc/libc-test/build.rs
+++ /dev/null
@@ -1,2393 +0,0 @@
-#![deny(warnings)]
-
-extern crate cc;
-extern crate ctest;
-
-use std::env;
-
-fn do_cc() {
- let target = env::var("TARGET").unwrap();
- if cfg!(unix) && !target.contains("wasi") {
- cc::Build::new().file("src/cmsg.c").compile("cmsg");
- }
-}
-
-fn do_ctest() {
- match &env::var("TARGET").unwrap() {
- t if t.contains("android") => return test_android(t),
- t if t.contains("apple") => return test_apple(t),
- t if t.contains("cloudabi") => return test_cloudabi(t),
- t if t.contains("dragonfly") => return test_dragonflybsd(t),
- t if t.contains("emscripten") => return test_emscripten(t),
- t if t.contains("freebsd") => return test_freebsd(t),
- t if t.contains("linux") => return test_linux(t),
- t if t.contains("netbsd") => return test_netbsd(t),
- t if t.contains("openbsd") => return test_openbsd(t),
- t if t.contains("redox") => return test_redox(t),
- t if t.contains("solaris") => return test_solaris(t),
- t if t.contains("wasi") => return test_wasi(t),
- t if t.contains("windows") => return test_windows(t),
- t => panic!("unknown target {}", t),
- }
-}
-
-fn main() {
- do_cc();
- do_ctest();
-}
-
-macro_rules! headers {
- ($cfg:ident: [$m:expr]: $header:literal) => {
- if $m {
- $cfg.header($header);
- }
- };
- ($cfg:ident: $header:literal) => {
- $cfg.header($header);
- };
- ($($cfg:ident: $([$c:expr]:)* $header:literal,)*) => {
- $(headers!($cfg: $([$c]:)* $header);)*
- };
- ($cfg:ident: $( $([$c:expr]:)* $header:literal,)*) => {
- headers!($($cfg: $([$c]:)* $header,)*);
- };
- ($cfg:ident: $( $([$c:expr]:)* $header:literal),*) => {
- headers!($($cfg: $([$c]:)* $header,)*);
- };
-}
-
-fn test_apple(target: &str) {
- assert!(target.contains("apple"));
- let x86_64 = target.contains("x86_64");
-
- let mut cfg = ctest::TestGenerator::new();
- cfg.flag("-Wno-deprecated-declarations");
- cfg.define("__APPLE_USE_RFC_3542", None);
-
- headers! { cfg:
- "aio.h",
- "ctype.h",
- "dirent.h",
- "dlfcn.h",
- "errno.h",
- "execinfo.h",
- "fcntl.h",
- "glob.h",
- "grp.h",
- "ifaddrs.h",
- "langinfo.h",
- "limits.h",
- "locale.h",
- "mach-o/dyld.h",
- "mach/mach_time.h",
- "malloc/malloc.h",
- "net/bpf.h",
- "net/if.h",
- "net/if_arp.h",
- "net/if_dl.h",
- "net/if_utun.h",
- "net/route.h",
- "net/route.h",
- "netdb.h",
- "netinet/if_ether.h",
- "netinet/in.h",
- "netinet/in.h",
- "netinet/ip.h",
- "netinet/tcp.h",
- "netinet/udp.h",
- "poll.h",
- "pthread.h",
- "pwd.h",
- "resolv.h",
- "sched.h",
- "semaphore.h",
- "signal.h",
- "spawn.h",
- "stddef.h",
- "stdint.h",
- "stdio.h",
- "stdlib.h",
- "string.h",
- "sys/event.h",
- "sys/file.h",
- "sys/ioctl.h",
- "sys/ipc.h",
- "sys/kern_control.h",
- "sys/mman.h",
- "sys/mount.h",
- "sys/proc_info.h",
- "sys/ptrace.h",
- "sys/quota.h",
- "sys/resource.h",
- "sys/sem.h",
- "sys/shm.h",
- "sys/socket.h",
- "sys/stat.h",
- "sys/statvfs.h",
- "sys/sys_domain.h",
- "sys/sysctl.h",
- "sys/time.h",
- "sys/times.h",
- "sys/types.h",
- "sys/uio.h",
- "sys/un.h",
- "sys/utsname.h",
- "sys/wait.h",
- "sys/xattr.h",
- "syslog.h",
- "termios.h",
- "time.h",
- "unistd.h",
- "util.h",
- "utime.h",
- "utmpx.h",
- "wchar.h",
- "xlocale.h",
- [x86_64]: "crt_externs.h",
- }
-
- cfg.skip_struct(move |ty| {
- match ty {
- // FIXME: actually a union
- "sigval" => true,
-
- _ => false,
- }
- });
-
- cfg.skip_const(move |name| {
- match name {
- // These OSX constants are removed in Sierra.
- // https://developer.apple.com/library/content/releasenotes/General/APIDiffsMacOS10_12/Swift/Darwin.html
- "KERN_KDENABLE_BG_TRACE" | "KERN_KDDISABLE_BG_TRACE" => true,
- _ => false,
- }
- });
-
- cfg.skip_fn(move |name| {
- // skip those that are manually verified
- match name {
- // FIXME: https://github.com/rust-lang/libc/issues/1272
- "execv" | "execve" | "execvp" => true,
-
- // close calls the close_nocancel system call
- "close" => true,
-
- _ => false,
- }
- });
-
- cfg.skip_field_type(move |struct_, field| {
- match (struct_, field) {
- // FIXME: actually a union
- ("sigevent", "sigev_value") => true,
- _ => false,
- }
- });
-
- cfg.volatile_item(|i| {
- use ctest::VolatileItemKind::*;
- match i {
- StructField(ref n, ref f) if n == "aiocb" && f == "aio_buf" => {
- true
- }
- _ => false,
- }
- });
-
- cfg.type_name(move |ty, is_struct, is_union| {
- match ty {
- // Just pass all these through, no need for a "struct" prefix
- "FILE" | "DIR" | "Dl_info" => ty.to_string(),
-
- // OSX calls this something else
- "sighandler_t" => "sig_t".to_string(),
-
- t if is_union => format!("union {}", t),
- t if t.ends_with("_t") => t.to_string(),
- t if is_struct => format!("struct {}", t),
- t => t.to_string(),
- }
- });
-
- cfg.field_name(move |struct_, field| {
- match field {
- s if s.ends_with("_nsec") && struct_.starts_with("stat") => {
- s.replace("e_nsec", "espec.tv_nsec")
- }
- // FIXME: sigaction actually contains a union with two variants:
- // a sa_sigaction with type: (*)(int, struct __siginfo *, void *)
- // a sa_handler with type sig_t
- "sa_sigaction" if struct_ == "sigaction" => {
- "sa_handler".to_string()
- }
- s => s.to_string(),
- }
- });
-
- cfg.generate("../src/lib.rs", "main.rs");
-}
-
-fn test_openbsd(target: &str) {
- assert!(target.contains("openbsd"));
-
- let mut cfg = ctest::TestGenerator::new();
- cfg.flag("-Wno-deprecated-declarations");
-
- headers! { cfg:
- "errno.h",
- "fcntl.h",
- "limits.h",
- "locale.h",
- "stddef.h",
- "stdint.h",
- "stdio.h",
- "stdlib.h",
- "sys/stat.h",
- "sys/types.h",
- "time.h",
- "wchar.h",
- "ctype.h",
- "dirent.h",
- "sys/socket.h",
- "net/if.h",
- "net/route.h",
- "net/if_arp.h",
- "netdb.h",
- "netinet/in.h",
- "netinet/ip.h",
- "netinet/tcp.h",
- "netinet/udp.h",
- "resolv.h",
- "pthread.h",
- "dlfcn.h",
- "signal.h",
- "string.h",
- "sys/file.h",
- "sys/ioctl.h",
- "sys/mman.h",
- "sys/resource.h",
- "sys/socket.h",
- "sys/time.h",
- "sys/un.h",
- "sys/wait.h",
- "unistd.h",
- "utime.h",
- "pwd.h",
- "grp.h",
- "sys/utsname.h",
- "sys/ptrace.h",
- "sys/mount.h",
- "sys/uio.h",
- "sched.h",
- "termios.h",
- "poll.h",
- "syslog.h",
- "semaphore.h",
- "sys/statvfs.h",
- "sys/times.h",
- "glob.h",
- "ifaddrs.h",
- "langinfo.h",
- "sys/sysctl.h",
- "utmp.h",
- "sys/event.h",
- "net/if_dl.h",
- "util.h",
- "ufs/ufs/quota.h",
- "pthread_np.h",
- "sys/syscall.h",
- }
-
- cfg.skip_struct(move |ty| {
- match ty {
- // FIXME: actually a union
- "sigval" => true,
-
- _ => false,
- }
- });
-
- cfg.skip_const(move |name| {
- match name {
- // Removed in OpenBSD 6.0
- "KERN_USERMOUNT" | "KERN_ARND" => true,
- _ => false,
- }
- });
-
- cfg.skip_fn(move |name| {
- match name {
- // FIXME: https://github.com/rust-lang/libc/issues/1272
- "execv" | "execve" | "execvp" | "execvpe" => true,
-
- // Removed in OpenBSD 6.5
- // https://marc.info/?l=openbsd-cvs&m=154723400730318
- "mincore" => true,
-
- _ => false,
- }
- });
-
- cfg.type_name(move |ty, is_struct, is_union| {
- match ty {
- // Just pass all these through, no need for a "struct" prefix
- "FILE" | "DIR" | "Dl_info" => ty.to_string(),
-
- // OSX calls this something else
- "sighandler_t" => "sig_t".to_string(),
-
- t if is_union => format!("union {}", t),
- t if t.ends_with("_t") => t.to_string(),
- t if is_struct => format!("struct {}", t),
- t => t.to_string(),
- }
- });
-
- cfg.field_name(move |struct_, field| match field {
- "st_birthtime" if struct_.starts_with("stat") => {
- "__st_birthtime".to_string()
- }
- "st_birthtime_nsec" if struct_.starts_with("stat") => {
- "__st_birthtimensec".to_string()
- }
- s if s.ends_with("_nsec") && struct_.starts_with("stat") => {
- s.replace("e_nsec", ".tv_nsec")
- }
- "sa_sigaction" if struct_ == "sigaction" => "sa_handler".to_string(),
- s => s.to_string(),
- });
-
- cfg.skip_field_type(move |struct_, field| {
- // type siginfo_t.si_addr changed from OpenBSD 6.0 to 6.1
- (struct_ == "siginfo_t" && field == "si_addr")
- });
-
- cfg.generate("../src/lib.rs", "main.rs");
-}
-
-fn test_windows(target: &str) {
- assert!(target.contains("windows"));
- let gnu = target.contains("gnu");
-
- let mut cfg = ctest::TestGenerator::new();
- cfg.define("_WIN32_WINNT", Some("0x8000"));
-
- headers! { cfg:
- "direct.h",
- "errno.h",
- "fcntl.h",
- "io.h",
- "limits.h",
- "locale.h",
- "process.h",
- "signal.h",
- "stddef.h",
- "stdint.h",
- "stdio.h",
- "stdlib.h",
- "sys/stat.h",
- "sys/types.h",
- "sys/utime.h",
- "time.h",
- "wchar.h",
- [gnu]: "ws2tcpip.h",
- [!gnu]: "Winsock2.h",
- }
-
- cfg.type_name(move |ty, is_struct, is_union| {
- match ty {
- // Just pass all these through, no need for a "struct" prefix
- "FILE" | "DIR" | "Dl_info" => ty.to_string(),
-
- // FIXME: these don't exist:
- "time64_t" => "__time64_t".to_string(),
- "ssize_t" => "SSIZE_T".to_string(),
-
- "sighandler_t" if !gnu => "_crt_signal_t".to_string(),
- "sighandler_t" if gnu => "__p_sig_fn_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:
- t if is_struct => {
- if ty.clone().chars().next().unwrap().is_uppercase() {
- t.to_string()
- } else if t == "stat" {
- "struct __stat64".to_string()
- } else if t == "utimbuf" {
- "struct __utimbuf64".to_string()
- } else {
- // put `struct` in front of all structs:
- format!("struct {}", t)
- }
- }
- t => t.to_string(),
- }
- });
-
- cfg.fn_cname(move |name, cname| cname.unwrap_or(name).to_string());
-
- cfg.skip_type(move |name| match name {
- "SSIZE_T" if !gnu => true,
- "ssize_t" if !gnu => true,
- _ => false,
- });
-
- cfg.skip_const(move |name| {
- match name {
- // FIXME: API error:
- // SIG_ERR type is "void (*)(int)", not "int"
- "SIG_ERR" => true,
- _ => false,
- }
- });
-
- // FIXME: All functions point to the wrong addresses?
- cfg.skip_fn_ptrcheck(|_| true);
-
- cfg.skip_signededness(move |c| {
- match c {
- // windows-isms
- n if n.starts_with("P") => true,
- n if n.starts_with("H") => true,
- n if n.starts_with("LP") => true,
- "sighandler_t" if gnu => true,
- _ => false,
- }
- });
-
- cfg.skip_fn(move |name| {
- match name {
- // FIXME: https://github.com/rust-lang/libc/issues/1272
- "execv" | "execve" | "execvp" | "execvpe" => true,
-
- _ => false,
- }
- });
-
- cfg.generate("../src/lib.rs", "main.rs");
-}
-
-fn test_redox(target: &str) {
- assert!(target.contains("redox"));
-
- let mut cfg = ctest::TestGenerator::new();
- cfg.flag("-Wno-deprecated-declarations");
-
- headers! {
- cfg:
- "ctype.h",
- "dirent.h",
- "dlfcn.h",
- "errno.h",
- "execinfo.h",
- "fcntl.h",
- "glob.h",
- "grp.h",
- "ifaddrs.h",
- "langinfo.h",
- "limits.h",
- "locale.h",
- "net/if.h",
- "net/if_arp.h",
- "net/route.h",
- "netdb.h",
- "netinet/in.h",
- "netinet/ip.h",
- "netinet/tcp.h",
- "netinet/udp.h",
- "poll.h",
- "pthread.h",
- "pwd.h",
- "resolv.h",
- "sched.h",
- "semaphore.h",
- "string.h",
- "strings.h",
- "sys/file.h",
- "sys/ioctl.h",
- "sys/mman.h",
- "sys/mount.h",
- "sys/ptrace.h",
- "sys/quota.h",
- "sys/resource.h",
- "sys/socket.h",
- "sys/stat.h",
- "sys/statvfs.h",
- "sys/sysctl.h",
- "sys/time.h",
- "sys/times.h",
- "sys/types.h",
- "sys/uio.h",
- "sys/un.h",
- "sys/utsname.h",
- "sys/wait.h",
- "syslog.h",
- "termios.h",
- "time.h",
- "unistd.h",
- "utime.h",
- "utmpx.h",
- "wchar.h",
- }
-
- cfg.generate("../src/lib.rs", "main.rs");
-}
-
-fn test_cloudabi(target: &str) {
- assert!(target.contains("cloudabi"));
-
- let mut cfg = ctest::TestGenerator::new();
- cfg.flag("-Wno-deprecated-declarations");
-
- headers! {
- cfg:
- "execinfo.h",
- "glob.h",
- "ifaddrs.h",
- "langinfo.h",
- "sys/ptrace.h",
- "sys/quota.h",
- "sys/sysctl.h",
- "utmpx.h",
- "ctype.h",
- "dirent.h",
- "dlfcn.h",
- "errno.h",
- "fcntl.h",
- "grp.h",
- "limits.h",
- "locale.h",
- "net/if.h",
- "net/if_arp.h",
- "net/route.h",
- "netdb.h",
- "netinet/in.h",
- "netinet/ip.h",
- "netinet/tcp.h",
- "netinet/udp.h",
- "poll.h",
- "pthread.h",
- "pwd.h",
- "resolv.h",
- "sched.h",
- "semaphore.h",
- "signal.h",
- "stddef.h",
- "stdint.h",
- "stdio.h",
- "stdlib.h",
- "string.h",
- "strings.h",
- "sys/file.h",
- "sys/ioctl.h",
- "sys/mman.h",
- "sys/mount.h",
- "sys/resource.h",
- "sys/socket.h",
- "sys/stat.h",
- "sys/statvfs.h",
- "sys/time.h",
- "sys/times.h",
- "sys/types.h",
- "sys/uio.h",
- "sys/un.h",
- "sys/utsname.h",
- "sys/wait.h",
- "syslog.h",
- "termios.h",
- "time.h",
- "unistd.h",
- "utime.h",
- "wchar.h",
- }
-
- cfg.generate("../src/lib.rs", "main.rs");
-}
-
-fn test_solaris(target: &str) {
- assert!(target.contains("solaris"));
-
- let mut cfg = ctest::TestGenerator::new();
- cfg.flag("-Wno-deprecated-declarations");
-
- cfg.define("_XOPEN_SOURCE", Some("700"));
- cfg.define("__EXTENSIONS__", None);
- cfg.define("_LCONV_C99", None);
-
- headers! {
- cfg:
- "ctype.h",
- "dirent.h",
- "dlfcn.h",
- "errno.h",
- "execinfo.h",
- "fcntl.h",
- "glob.h",
- "grp.h",
- "ifaddrs.h",
- "langinfo.h",
- "limits.h",
- "locale.h",
- "net/if.h",
- "net/if_arp.h",
- "net/route.h",
- "netdb.h",
- "netinet/in.h",
- "netinet/ip.h",
- "netinet/tcp.h",
- "netinet/udp.h",
- "poll.h",
- "port.h",
- "pthread.h",
- "pwd.h",
- "resolv.h",
- "sched.h",
- "semaphore.h",
- "signal.h",
- "stddef.h",
- "stdint.h",
- "stdio.h",
- "stdlib.h",
- "string.h",
- "sys/epoll.h",
- "sys/file.h",
- "sys/filio.h",
- "sys/ioctl.h",
- "sys/loadavg.h",
- "sys/mman.h",
- "sys/mount.h",
- "sys/resource.h",
- "sys/socket.h",
- "sys/stat.h",
- "sys/statvfs.h",
- "sys/time.h",
- "sys/times.h",
- "sys/types.h",
- "sys/uio.h",
- "sys/un.h",
- "sys/utsname.h",
- "sys/wait.h",
- "syslog.h",
- "termios.h",
- "time.h",
- "ucontext.h",
- "unistd.h",
- "utime.h",
- "utmpx.h",
- "wchar.h",
- }
-
- cfg.skip_const(move |name| match name {
- "DT_FIFO" | "DT_CHR" | "DT_DIR" | "DT_BLK" | "DT_REG" | "DT_LNK"
- | "DT_SOCK" | "USRQUOTA" | "GRPQUOTA" | "PRIO_MIN" | "PRIO_MAX" => {
- true
- }
-
- _ => false,
- });
-
- cfg.skip_fn(move |name| {
- // skip those that are manually verified
- match name {
- // const-ness only added recently
- "dladdr" => true,
-
- // Definition of those functions as changed since unified headers
- // from NDK r14b These changes imply some API breaking changes but
- // are still ABI compatible. We can wait for the next major release
- // to be compliant with the new API.
- //
- // FIXME: unskip these for next major release
- "setpriority" | "personality" => true,
-
- // signal is defined with sighandler_t, so ignore
- "signal" => true,
-
- "cfmakeraw" | "cfsetspeed" => true,
-
- // FIXME: mincore is defined with caddr_t on Solaris.
- "mincore" => true,
-
- _ => false,
- }
- });
-
- cfg.generate("../src/lib.rs", "main.rs");
-}
-
-fn test_netbsd(target: &str) {
- assert!(target.contains("netbsd"));
- let rumprun = target.contains("rumprun");
- let mut cfg = ctest::TestGenerator::new();
-
- cfg.flag("-Wno-deprecated-declarations");
- cfg.define("_NETBSD_SOURCE", Some("1"));
-
- headers! {
- cfg:
- "errno.h",
- "fcntl.h",
- "limits.h",
- "locale.h",
- "stddef.h",
- "stdint.h",
- "stdio.h",
- "stdlib.h",
- "sys/stat.h",
- "sys/types.h",
- "time.h",
- "wchar.h",
- "aio.h",
- "ctype.h",
- "dirent.h",
- "dlfcn.h",
- "glob.h",
- "grp.h",
- "ifaddrs.h",
- "langinfo.h",
- "net/if.h",
- "net/if_arp.h",
- "net/if_dl.h",
- "net/route.h",
- "netdb.h",
- "netinet/in.h",
- "netinet/ip.h",
- "netinet/tcp.h",
- "netinet/udp.h",
- "poll.h",
- "pthread.h",
- "pwd.h",
- "resolv.h",
- "sched.h",
- "semaphore.h",
- "signal.h",
- "string.h",
- "sys/extattr.h",
- "sys/file.h",
- "sys/ioctl.h",
- "sys/ioctl_compat.h",
- "sys/mman.h",
- "sys/mount.h",
- "sys/ptrace.h",
- "sys/resource.h",
- "sys/socket.h",
- "sys/statvfs.h",
- "sys/sysctl.h",
- "sys/time.h",
- "sys/times.h",
- "sys/uio.h",
- "sys/un.h",
- "sys/utsname.h",
- "sys/wait.h",
- "syslog.h",
- "termios.h",
- "ufs/ufs/quota.h",
- "ufs/ufs/quota1.h",
- "unistd.h",
- "util.h",
- "utime.h",
- "mqueue.h",
- "netinet/dccp.h",
- "sys/event.h",
- "sys/quota.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" | "Elf32_Shdr" | "Elf64_Shdr" | "Elf32_Sym"
- | "Elf64_Sym" | "Elf32_Ehdr" | "Elf64_Ehdr" | "Elf32_Chdr"
- | "Elf64_Chdr" => ty.to_string(),
-
- // OSX calls this something else
- "sighandler_t" => "sig_t".to_string(),
-
- t if is_union => format!("union {}", t),
-
- t if t.ends_with("_t") => t.to_string(),
-
- // put `struct` in front of all structs:.
- t if is_struct => format!("struct {}", t),
-
- t => t.to_string(),
- }
- });
-
- cfg.field_name(move |struct_, field| {
- match field {
- // 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") => {
- s.replace("e_nsec", ".tv_nsec")
- }
- "u64" if struct_ == "epoll_event" => "data.u64".to_string(),
- s => s.to_string(),
- }
- });
-
- cfg.skip_type(move |ty| {
- match ty {
- // FIXME: sighandler_t is crazy across platforms
- "sighandler_t" => true,
- _ => false,
- }
- });
-
- cfg.skip_struct(move |ty| {
- match ty {
- // This is actually a union, not a struct
- "sigval" => true,
- // These are tested as part of the linux_fcntl tests since there are
- // header conflicts when including them with all the other structs.
- "termios2" => true,
- _ => false,
- }
- });
-
- cfg.skip_signededness(move |c| {
- match c {
- "LARGE_INTEGER" | "float" | "double" => true,
- n if n.starts_with("pthread") => true,
- // sem_t is a struct or pointer
- "sem_t" => true,
- _ => false,
- }
- });
-
- cfg.skip_const(move |name| {
- match name {
- "SIG_DFL" | "SIG_ERR" | "SIG_IGN" => true, // sighandler_t weirdness
- "SIGUNUSED" => true, // removed in glibc 2.26
-
- // weird signed extension or something like that?
- "MS_NOUSER" => true,
- "MS_RMT_MASK" => true, // updated in glibc 2.22 and musl 1.1.13
- "BOTHER" => true,
-
- _ => false,
- }
- });
-
- cfg.skip_fn(move |name| {
- match name {
- // FIXME: https://github.com/rust-lang/libc/issues/1272
- "execv" | "execve" | "execvp" => true,
-
- "getrlimit" | "getrlimit64" | // non-int in 1st arg
- "setrlimit" | "setrlimit64" | // non-int in 1st arg
- "prlimit" | "prlimit64" | // non-int in 2nd arg
-
- // These functions presumably exist on netbsd but don't look like
- // they're implemented on rumprun yet, just let them slide for now.
- // Some of them look like they have headers but then don't have
- // corresponding actual definitions either...
- "shm_open" |
- "shm_unlink" |
- "syscall" |
- "mq_open" |
- "mq_close" |
- "mq_getattr" |
- "mq_notify" |
- "mq_receive" |
- "mq_send" |
- "mq_setattr" |
- "mq_timedreceive" |
- "mq_timedsend" |
- "mq_unlink" |
- "ptrace" |
- "sigaltstack" if rumprun => true,
-
- _ => false,
- }
- });
-
- cfg.skip_field_type(move |struct_, field| {
- // This is a weird union, don't check the type.
- (struct_ == "ifaddrs" && field == "ifa_ifu") ||
- // sighandler_t type is super weird
- (struct_ == "sigaction" && field == "sa_sigaction") ||
- // sigval is actually a union, but we pretend it's a struct
- (struct_ == "sigevent" && field == "sigev_value") ||
- // aio_buf is "volatile void*" and Rust doesn't understand volatile
- (struct_ == "aiocb" && field == "aio_buf")
- });
-
- cfg.generate("../src/lib.rs", "main.rs");
-}
-
-fn test_dragonflybsd(target: &str) {
- assert!(target.contains("dragonfly"));
- let mut cfg = ctest::TestGenerator::new();
- cfg.flag("-Wno-deprecated-declarations");
-
- headers! {
- cfg:
- "aio.h",
- "ctype.h",
- "dirent.h",
- "dlfcn.h",
- "errno.h",
- "execinfo.h",
- "fcntl.h",
- "glob.h",
- "grp.h",
- "ifaddrs.h",
- "langinfo.h",
- "limits.h",
- "locale.h",
- "mqueue.h",
- "net/if.h",
- "net/if_arp.h",
- "net/if_dl.h",
- "net/route.h",
- "netdb.h",
- "netinet/in.h",
- "netinet/ip.h",
- "netinet/tcp.h",
- "netinet/udp.h",
- "poll.h",
- "pthread.h",
- "pthread_np.h",
- "pwd.h",
- "resolv.h",
- "sched.h",
- "semaphore.h",
- "signal.h",
- "stddef.h",
- "stdint.h",
- "stdio.h",
- "stdlib.h",
- "string.h",
- "sys/event.h",
- "sys/file.h",
- "sys/ioctl.h",
- "sys/mman.h",
- "sys/mount.h",
- "sys/ptrace.h",
- "sys/resource.h",
- "sys/rtprio.h",
- "sys/socket.h",
- "sys/stat.h",
- "sys/statvfs.h",
- "sys/sysctl.h",
- "sys/time.h",
- "sys/times.h",
- "sys/types.h",
- "sys/uio.h",
- "sys/un.h",
- "sys/utsname.h",
- "sys/wait.h",
- "syslog.h",
- "termios.h",
- "time.h",
- "ufs/ufs/quota.h",
- "unistd.h",
- "util.h",
- "utime.h",
- "utmpx.h",
- "wchar.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" | "Elf32_Shdr" | "Elf64_Shdr" | "Elf32_Sym"
- | "Elf64_Sym" | "Elf32_Ehdr" | "Elf64_Ehdr" | "Elf32_Chdr"
- | "Elf64_Chdr" => ty.to_string(),
-
- // FIXME: OSX calls this something else
- "sighandler_t" => "sig_t".to_string(),
-
- t if is_union => format!("union {}", t),
-
- t if t.ends_with("_t") => t.to_string(),
-
- // put `struct` in front of all structs:.
- t if is_struct => format!("struct {}", t),
-
- t => t.to_string(),
- }
- });
-
- cfg.field_name(move |struct_, field| {
- match field {
- // 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") => {
- s.replace("e_nsec", ".tv_nsec")
- }
- "u64" if struct_ == "epoll_event" => "data.u64".to_string(),
- // Field is named `type` in C but that is a Rust keyword,
- // so these fields are translated to `type_` in the bindings.
- "type_" if struct_ == "rtprio" => "type".to_string(),
- s => s.to_string(),
- }
- });
-
- cfg.skip_type(move |ty| {
- match ty {
- // sighandler_t is crazy across platforms
- "sighandler_t" => true,
-
- _ => false,
- }
- });
-
- cfg.skip_struct(move |ty| {
- match ty {
- // This is actually a union, not a struct
- "sigval" => true,
-
- // FIXME: These are tested as part of the linux_fcntl tests since
- // there are header conflicts when including them with all the other
- // structs.
- "termios2" => true,
-
- _ => false,
- }
- });
-
- cfg.skip_signededness(move |c| {
- match c {
- "LARGE_INTEGER" | "float" | "double" => true,
- // uuid_t is a struct, not an integer.
- "uuid_t" => true,
- n if n.starts_with("pthread") => true,
- // sem_t is a struct or pointer
- "sem_t" => true,
- // mqd_t is a pointer on DragonFly
- "mqd_t" => true,
-
- _ => false,
- }
- });
-
- cfg.skip_const(move |name| {
- match name {
- "SIG_DFL" | "SIG_ERR" | "SIG_IGN" => true, // sighandler_t weirdness
-
- // weird signed extension or something like that?
- "MS_NOUSER" => true,
- "MS_RMT_MASK" => true, // updated in glibc 2.22 and musl 1.1.13
-
- // 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,
-
- // 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,
-
- _ => false,
- }
- });
-
- cfg.skip_fn(move |name| {
- // skip those that are manually verified
- match name {
- // FIXME: https://github.com/rust-lang/libc/issues/1272
- "execv" | "execve" | "execvp" => true,
-
- "getrlimit" | "getrlimit64" | // non-int in 1st arg
- "setrlimit" | "setrlimit64" | // non-int in 1st arg
- "prlimit" | "prlimit64" // non-int in 2nd arg
- => true,
-
- _ => false,
- }
- });
-
- cfg.skip_field_type(move |struct_, field| {
- // This is a weird union, don't check the type.
- (struct_ == "ifaddrs" && field == "ifa_ifu") ||
- // sighandler_t type is super weird
- (struct_ == "sigaction" && field == "sa_sigaction") ||
- // sigval is actually a union, but we pretend it's a struct
- (struct_ == "sigevent" && field == "sigev_value") ||
- // aio_buf is "volatile void*" and Rust doesn't understand volatile
- (struct_ == "aiocb" && field == "aio_buf")
- });
-
- cfg.skip_field(move |struct_, field| {
- // this is actually a union on linux, so we can't represent it well and
- // just insert some padding.
- (struct_ == "siginfo_t" && field == "_pad") ||
- // sigev_notify_thread_id is actually part of a sigev_un union
- (struct_ == "sigevent" && field == "sigev_notify_thread_id")
- });
-
- cfg.generate("../src/lib.rs", "main.rs");
-}
-
-fn test_wasi(target: &str) {
- assert!(target.contains("wasi"));
-
- let mut cfg = ctest::TestGenerator::new();
- cfg.define("_GNU_SOURCE", None);
-
- headers! { cfg:
- "ctype.h",
- "dirent.h",
- "errno.h",
- "fcntl.h",
- "limits.h",
- "locale.h",
- "malloc.h",
- "poll.h",
- "sched.h",
- "stdbool.h",
- "stddef.h",
- "stdint.h",
- "stdio.h",
- "stdlib.h",
- "string.h",
- "sys/resource.h",
- "sys/select.h",
- "sys/socket.h",
- "sys/stat.h",
- "sys/times.h",
- "sys/types.h",
- "sys/uio.h",
- "sys/utsname.h",
- "time.h",
- "unistd.h",
- "wasi/core.h",
- "wasi/libc.h",
- "wasi/libc-find-relpath.h",
- "wchar.h",
- }
-
- cfg.type_name(move |ty, is_struct, is_union| match ty {
- "FILE" | "fd_set" | "DIR" => ty.to_string(),
- t if is_union => format!("union {}", t),
- t if t.starts_with("__wasi") && t.ends_with("_u") => {
- format!("union {}", t)
- }
- t if t.starts_with("__wasi") && is_struct => format!("struct {}", t),
- t if t.ends_with("_t") => t.to_string(),
- t if is_struct => format!("struct {}", t),
- t => t.to_string(),
- });
-
- cfg.field_name(move |_struct, field| {
- match field {
- // deal with fields as rust keywords
- "type_" => "type".to_string(),
- s => s.to_string(),
- }
- });
-
- // Looks like LLD doesn't merge duplicate imports, so if the Rust
- // code imports from a module and the C code also imports from a
- // module we end up with two imports of function pointers which
- // import the same thing but have different function pointers
- cfg.skip_fn_ptrcheck(|f| f.starts_with("__wasi"));
-
- // d_name is declared as a flexible array in WASI libc, so it
- // doesn't support sizeof.
- cfg.skip_field(|s, field| s == "dirent" && field == "d_name");
-
- cfg.generate("../src/lib.rs", "main.rs");
-}
-
-fn test_android(target: &str) {
- assert!(target.contains("android"));
- let target_pointer_width = match target {
- t if t.contains("aarch64") || t.contains("x86_64") => 64,
- t if t.contains("i686") || t.contains("arm") => 32,
- t => panic!("unsupported target: {}", t),
- };
- let x86 = target.contains("i686") || target.contains("x86_64");
-
- let mut cfg = ctest::TestGenerator::new();
- cfg.define("_GNU_SOURCE", None);
-
- headers! { cfg:
- "arpa/inet.h",
- "asm/mman.h",
- "ctype.h",
- "dirent.h",
- "dlfcn.h",
- "errno.h",
- "fcntl.h",
- "grp.h",
- "ifaddrs.h",
- "limits.h",
- "linux/dccp.h",
- "linux/futex.h",
- "linux/fs.h",
- "linux/genetlink.h",
- "linux/if_alg.h",
- "linux/if_ether.h",
- "linux/if_tun.h",
- "linux/magic.h",
- "linux/memfd.h",
- "linux/module.h",
- "linux/net_tstamp.h",
- "linux/netfilter/nf_tables.h",
- "linux/netfilter_ipv4.h",
- "linux/netfilter_ipv6.h",
- "linux/netlink.h",
- "linux/quota.h",
- "linux/reboot.h",
- "linux/seccomp.h",
- "linux/sockios.h",
- "locale.h",
- "malloc.h",
- "net/ethernet.h",
- "net/if.h",
- "net/if_arp.h",
- "net/route.h",
- "netdb.h",
- "netinet/in.h",
- "netinet/ip.h",
- "netinet/tcp.h",
- "netinet/udp.h",
- "netpacket/packet.h",
- "poll.h",
- "pthread.h",
- "pty.h",
- "pwd.h",
- "resolv.h",
- "sched.h",
- "semaphore.h",
- "signal.h",
- "stddef.h",
- "stdint.h",
- "stdio.h",
- "stdlib.h",
- "string.h",
- "sys/epoll.h",
- "sys/eventfd.h",
- "sys/file.h",
- "sys/fsuid.h",
- "sys/inotify.h",
- "sys/ioctl.h",
- "sys/mman.h",
- "sys/mount.h",
- "sys/personality.h",
- "sys/prctl.h",
- "sys/ptrace.h",
- "sys/random.h",
- "sys/reboot.h",
- "sys/resource.h",
- "sys/sendfile.h",
- "sys/signalfd.h",
- "sys/socket.h",
- "sys/stat.h",
- "sys/statvfs.h",
- "sys/swap.h",
- "sys/syscall.h",
- "sys/sysinfo.h",
- "sys/time.h",
- "sys/times.h",
- "sys/types.h",
- "sys/uio.h",
- "sys/un.h",
- "sys/utsname.h",
- "sys/vfs.h",
- "sys/xattr.h",
- "sys/wait.h",
- "syslog.h",
- "termios.h",
- "time.h",
- "unistd.h",
- "utime.h",
- "utmp.h",
- "wchar.h",
- "xlocale.h",
- // time64_t is not defined for 64-bit targets If included it will
- // generate the error 'Your time_t is already 64-bit'
- [target_pointer_width == 32]: "time64.h",
- [x86]: "sys/reg.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" => ty.to_string(),
-
- t if is_union => format!("union {}", t),
-
- t if t.ends_with("_t") => t.to_string(),
-
- // sigval is a struct in Rust, but a union in C:
- "sigval" => format!("union sigval"),
-
- // put `struct` in front of all structs:.
- t if is_struct => format!("struct {}", t),
-
- t => t.to_string(),
- }
- });
-
- cfg.field_name(move |struct_, field| {
- match field {
- // 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") => {
- s.to_string()
- }
- // FIXME: appears that `epoll_event.data` is an union
- "u64" if struct_ == "epoll_event" => "data.u64".to_string(),
- s => s.to_string(),
- }
- });
-
- cfg.skip_type(move |ty| {
- match ty {
- // FIXME: `sighandler_t` type is incorrect, see:
- // https://github.com/rust-lang/libc/issues/1359
- "sighandler_t" => true,
- _ => false,
- }
- });
-
- cfg.skip_struct(move |ty| {
- match ty {
- // These are tested as part of the linux_fcntl tests since there are
- // header conflicts when including them with all the other structs.
- "termios2" => true,
-
- _ => false,
- }
- });
-
- cfg.skip_const(move |name| {
- match name {
- // FIXME: deprecated: not available in any header
- // See: https://github.com/rust-lang/libc/issues/1356
- "ENOATTR" => true,
-
- // FIXME: still necessary?
- "SIG_DFL" | "SIG_ERR" | "SIG_IGN" => true, // sighandler_t weirdness
- // FIXME: deprecated - removed in glibc 2.26
- "SIGUNUSED" => true,
-
- _ => false,
- }
- });
-
- cfg.skip_fn(move |name| {
- // skip those that are manually verified
- match name {
- // FIXME: https://github.com/rust-lang/libc/issues/1272
- "execv" | "execve" | "execvp" | "execvpe" | "fexecve" => true,
-
- // There are two versions of the sterror_r function, see
- //
- // https://linux.die.net/man/3/strerror_r
- //
- // An XSI-compliant version provided if:
- //
- // (_POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600) && ! _GNU_SOURCE
- //
- // and a GNU specific version provided if _GNU_SOURCE is defined.
- //
- // libc provides bindings for the XSI-compliant version, which is
- // preferred for portable applications.
- //
- // We skip the test here since here _GNU_SOURCE is defined, and
- // test the XSI version below.
- "strerror_r" => true,
-
- _ => false,
- }
- });
-
- cfg.skip_field_type(move |struct_, field| {
- // This is a weird union, don't check the type.
- (struct_ == "ifaddrs" && field == "ifa_ifu") ||
- // sigval is actually a union, but we pretend it's a struct
- (struct_ == "sigevent" && field == "sigev_value")
- });
-
- cfg.skip_field(move |struct_, field| {
- // this is actually a union on linux, so we can't represent it well and
- // just insert some padding.
- (struct_ == "siginfo_t" && field == "_pad") ||
- // FIXME: `sa_sigaction` has type `sighandler_t` but that type is
- // incorrect, see: https://github.com/rust-lang/libc/issues/1359
- (struct_ == "sigaction" && field == "sa_sigaction") ||
- // sigev_notify_thread_id is actually part of a sigev_un union
- (struct_ == "sigevent" && field == "sigev_notify_thread_id") ||
- // signalfd had SIGSYS fields added in Android 4.19, but CI does not have that version yet.
- (struct_ == "signalfd_siginfo" && (field == "ssi_syscall" ||
- field == "ssi_call_addr" ||
- field == "ssi_arch"))
- });
-
- cfg.generate("../src/lib.rs", "main.rs");
-
- test_linux_like_apis(target);
-}
-
-fn test_freebsd(target: &str) {
- assert!(target.contains("freebsd"));
- let mut cfg = ctest::TestGenerator::new();
-
- let freebsd_ver = which_freebsd();
-
- if let Some(12) = freebsd_ver {
- // If the host is FreeBSD 12, run FreeBSD 12 tests
- cfg.cfg("freebsd12", None);
- }
-
- // Required for `getline`:
- cfg.define("_WITH_GETLINE", None);
- // Required for making freebsd11_stat available in the headers
- cfg.define("_WANT_FREEBSD11_STAT", None);
-
- headers! { cfg:
- "aio.h",
- "arpa/inet.h",
- "ctype.h",
- "dirent.h",
- "dlfcn.h",
- "errno.h",
- "fcntl.h",
- "glob.h",
- "grp.h",
- "ifaddrs.h",
- "langinfo.h",
- "libutil.h",
- "limits.h",
- "locale.h",
- "mqueue.h",
- "net/bpf.h",
- "net/if.h",
- "net/if_arp.h",
- "net/if_dl.h",
- "net/route.h",
- "netdb.h",
- "netinet/ip.h",
- "netinet/in.h",
- "netinet/tcp.h",
- "netinet/udp.h",
- "poll.h",
- "pthread.h",
- "pthread_np.h",
- "pwd.h",
- "resolv.h",
- "sched.h",
- "semaphore.h",
- "signal.h",
- "spawn.h",
- "stddef.h",
- "stdint.h",
- "stdio.h",
- "stdlib.h",
- "string.h",
- "sys/event.h",
- "sys/extattr.h",
- "sys/file.h",
- "sys/ioctl.h",
- "sys/ipc.h",
- "sys/jail.h",
- "sys/mman.h",
- "sys/mount.h",
- "sys/msg.h",
- "sys/procdesc.h",
- "sys/ptrace.h",
- "sys/resource.h",
- "sys/rtprio.h",
- "sys/shm.h",
- "sys/socket.h",
- "sys/stat.h",
- "sys/statvfs.h",
- "sys/sysctl.h",
- "sys/time.h",
- "sys/times.h",
- "sys/types.h",
- "sys/uio.h",
- "sys/un.h",
- "sys/utsname.h",
- "sys/wait.h",
- "syslog.h",
- "termios.h",
- "time.h",
- "ufs/ufs/quota.h",
- "unistd.h",
- "utime.h",
- "utmpx.h",
- "wchar.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" => ty.to_string(),
-
- // FIXME: https://github.com/rust-lang/libc/issues/1273
- "sighandler_t" => "sig_t".to_string(),
-
- t if is_union => format!("union {}", t),
-
- t if t.ends_with("_t") => t.to_string(),
-
- // sigval is a struct in Rust, but a union in C:
- "sigval" => format!("union sigval"),
-
- // put `struct` in front of all structs:.
- t if is_struct => format!("struct {}", t),
-
- t => t.to_string(),
- }
- });
-
- cfg.field_name(move |struct_, field| {
- match field {
- // 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") => {
- s.replace("e_nsec", ".tv_nsec")
- }
- // Field is named `type` in C but that is a Rust keyword,
- // so these fields are translated to `type_` in the bindings.
- "type_" if struct_ == "rtprio" => "type".to_string(),
- s => s.to_string(),
- }
- });
-
- cfg.skip_const(move |name| {
- match name {
- // These constants were introduced in FreeBSD 12:
- "SF_USER_READAHEAD"
- | "EVFILT_EMPTY"
- | "SO_REUSEPORT_LB"
- | "IP_ORIGDSTADDR"
- | "IP_RECVORIGDSTADDR"
- | "IPV6_ORIGDSTADDR"
- | "IPV6_RECVORIGDSTADDR"
- if Some(12) != freebsd_ver =>
- {
- true
- }
-
- // FIXME: There are deprecated - remove in a couple of releases.
- // These constants were removed in FreeBSD 11 (svn r273250) but will
- // still be accepted and ignored at runtime.
- "MAP_RENAME" | "MAP_NORESERVE" if Some(10) != freebsd_ver => true,
-
- // FIXME: There are deprecated - remove in a couple of releases.
- // 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" | "NET_MAXID"
- | "USER_MAXID" => true,
-
- _ => false,
- }
- });
-
- cfg.skip_fn(move |name| {
- // skip those that are manually verified
- match name {
- // FIXME: https://github.com/rust-lang/libc/issues/1272
- "execv" | "execve" | "execvp" | "execvpe" | "fexecve" => true,
-
- // The `uname` function in the `utsname.h` FreeBSD header is a C
- // inline function (has no symbol) that calls the `__xuname` symbol.
- // Therefore the function pointer comparison does not make sense for it.
- "uname" => true,
-
- // FIXME: Our API is unsound. The Rust API allows aliasing
- // pointers, but the C API requires pointers not to alias.
- // We should probably be at least using `&`/`&mut` here, see:
- // https://github.com/gnzlbg/ctest/issues/68
- "lio_listio" => true,
-
- _ => false,
- }
- });
-
- cfg.volatile_item(|i| {
- use ctest::VolatileItemKind::*;
- match i {
- // aio_buf is a volatile void** but since we cannot express that in
- // Rust types, we have to explicitly tell the checker about it here:
- StructField(ref n, ref f) if n == "aiocb" && f == "aio_buf" => {
- true
- }
- _ => false,
- }
- });
-
- cfg.skip_field(move |struct_, field| {
- // FIXME: `sa_sigaction` has type `sighandler_t` but that type is
- // incorrect, see: https://github.com/rust-lang/libc/issues/1359
- (struct_ == "sigaction" && field == "sa_sigaction")
- });
-
- cfg.generate("../src/lib.rs", "main.rs");
-}
-
-fn test_emscripten(target: &str) {
- assert!(target.contains("emscripten"));
-
- let mut cfg = ctest::TestGenerator::new();
- cfg.define("_GNU_SOURCE", None); // FIXME: ??
-
- headers! { cfg:
- "aio.h",
- "ctype.h",
- "dirent.h",
- "dlfcn.h",
- "errno.h",
- "fcntl.h",
- "glob.h",
- "grp.h",
- "ifaddrs.h",
- "langinfo.h",
- "limits.h",
- "locale.h",
- "malloc.h",
- "mntent.h",
- "mqueue.h",
- "net/ethernet.h",
- "net/if.h",
- "net/if_arp.h",
- "net/route.h",
- "netdb.h",
- "netinet/in.h",
- "netinet/ip.h",
- "netinet/tcp.h",
- "netinet/udp.h",
- "netpacket/packet.h",
- "poll.h",
- "pthread.h",
- "pty.h",
- "pwd.h",
- "resolv.h",
- "sched.h",
- "sched.h",
- "semaphore.h",
- "shadow.h",
- "signal.h",
- "stddef.h",
- "stdint.h",
- "stdio.h",
- "stdlib.h",
- "string.h",
- "sys/epoll.h",
- "sys/eventfd.h",
- "sys/file.h",
- "sys/ioctl.h",
- "sys/ipc.h",
- "sys/mman.h",
- "sys/mount.h",
- "sys/msg.h",
- "sys/personality.h",
- "sys/prctl.h",
- "sys/ptrace.h",
- "sys/quota.h",
- "sys/reboot.h",
- "sys/resource.h",
- "sys/sem.h",
- "sys/sendfile.h",
- "sys/shm.h",
- "sys/signalfd.h",
- "sys/socket.h",
- "sys/stat.h",
- "sys/statvfs.h",
- "sys/swap.h",
- "sys/syscall.h",
- "sys/sysctl.h",
- "sys/sysinfo.h",
- "sys/time.h",
- "sys/timerfd.h",
- "sys/times.h",
- "sys/types.h",
- "sys/uio.h",
- "sys/un.h",
- "sys/user.h",
- "sys/utsname.h",
- "sys/vfs.h",
- "sys/wait.h",
- "sys/xattr.h",
- "syslog.h",
- "termios.h",
- "time.h",
- "ucontext.h",
- "unistd.h",
- "utime.h",
- "utmp.h",
- "utmpx.h",
- "wchar.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" => ty.to_string(),
-
- t if is_union => format!("union {}", t),
-
- t if t.ends_with("_t") => t.to_string(),
-
- // put `struct` in front of all structs:.
- t if is_struct => format!("struct {}", t),
-
- t => t.to_string(),
- }
- });
-
- cfg.field_name(move |struct_, field| {
- match field {
- // 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") => {
- s.replace("e_nsec", ".tv_nsec")
- }
- // FIXME: appears that `epoll_event.data` is an union
- "u64" if struct_ == "epoll_event" => "data.u64".to_string(),
- s => s.to_string(),
- }
- });
-
- cfg.skip_type(move |ty| {
- match ty {
- // sighandler_t is crazy across platforms
- // FIXME: is this necessary?
- "sighandler_t" => true,
-
- _ => false,
- }
- });
-
- cfg.skip_struct(move |ty| {
- match ty {
- // This is actually a union, not a struct
- // FIXME: is this necessary?
- "sigval" => true,
-
- _ => false,
- }
- });
-
- cfg.skip_fn(move |name| {
- match name {
- // FIXME: https://github.com/rust-lang/libc/issues/1272
- "execv" | "execve" | "execvp" | "execvpe" | "fexecve" => true,
-
- _ => false,
- }
- });
-
- cfg.skip_const(move |name| {
- match name {
- // FIXME: deprecated - SIGNUNUSED was removed in glibc 2.26
- // users should use SIGSYS instead
- "SIGUNUSED" => true,
-
- // FIXME: emscripten uses different constants to constructs these
- n if n.contains("__SIZEOF_PTHREAD") => true,
-
- _ => false,
- }
- });
-
- cfg.skip_field_type(move |struct_, field| {
- // This is a weird union, don't check the type.
- // FIXME: is this necessary?
- (struct_ == "ifaddrs" && field == "ifa_ifu") ||
- // sighandler_t type is super weird
- // FIXME: is this necessary?
- (struct_ == "sigaction" && field == "sa_sigaction") ||
- // sigval is actually a union, but we pretend it's a struct
- // FIXME: is this necessary?
- (struct_ == "sigevent" && field == "sigev_value") ||
- // aio_buf is "volatile void*" and Rust doesn't understand volatile
- // FIXME: is this necessary?
- (struct_ == "aiocb" && field == "aio_buf")
- });
-
- cfg.skip_field(move |struct_, field| {
- // this is actually a union on linux, so we can't represent it well and
- // just insert some padding.
- // FIXME: is this necessary?
- (struct_ == "siginfo_t" && field == "_pad") ||
- // musl names this __dummy1 but it's still there
- // FIXME: is this necessary?
- (struct_ == "glob_t" && field == "gl_flags") ||
- // musl seems to define this as an *anonymous* bitfield
- // FIXME: is this necessary?
- (struct_ == "statvfs" && field == "__f_unused") ||
- // sigev_notify_thread_id is actually part of a sigev_un union
- (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"))
- });
-
- // FIXME: test linux like
- cfg.generate("../src/lib.rs", "main.rs");
-}
-
-fn test_linux(target: &str) {
- assert!(target.contains("linux"));
-
- // target_env
- let gnu = target.contains("gnu");
- let musl = target.contains("musl");
- let uclibc = target.contains("uclibc");
-
- match (gnu, musl, uclibc) {
- (true, false, false) => (),
- (false, true, false) => (),
- (false, false, true) => (),
- (_, _, _) => panic!(
- "linux target lib is gnu: {}, musl: {}, uclibc: {}",
- gnu, musl, uclibc
- ),
- }
-
- let arm = target.contains("arm");
- let x86_64 = target.contains("x86_64");
- let x86_32 = target.contains("i686");
- let x32 = target.contains("x32");
- let mips = target.contains("mips");
- let mips32_musl = mips && !target.contains("64") && musl;
- let sparc64 = target.contains("sparc64");
-
- let mut cfg = ctest::TestGenerator::new();
- cfg.define("_GNU_SOURCE", None);
- // This macro re-deifnes fscanf,scanf,sscanf to link to the symbols that are
- // deprecated since glibc >= 2.29. This allows Rust binaries to link against
- // glibc versions older than 2.29.
- cfg.define("__GLIBC_USE_DEPRECATED_SCANF", None);
-
- headers! { cfg:
- "ctype.h",
- "dirent.h",
- "dlfcn.h",
- "elf.h",
- "fcntl.h",
- "glob.h",
- "grp.h",
- "ifaddrs.h",
- "langinfo.h",
- "limits.h",
- "link.h",
- "locale.h",
- "malloc.h",
- "mntent.h",
- "mqueue.h",
- "net/ethernet.h",
- "net/if.h",
- "net/if_arp.h",
- "net/route.h",
- "netdb.h",
- "netinet/in.h",
- "netinet/ip.h",
- "netinet/tcp.h",
- "netinet/udp.h",
- "netpacket/packet.h",
- "poll.h",
- "pthread.h",
- "pty.h",
- "pwd.h",
- "resolv.h",
- "sched.h",
- "semaphore.h",
- "shadow.h",
- "signal.h",
- "spawn.h",
- "stddef.h",
- "stdint.h",
- "stdio.h",
- "stdlib.h",
- "string.h",
- "sys/epoll.h",
- "sys/eventfd.h",
- "sys/file.h",
- "sys/fsuid.h",
- "sys/inotify.h",
- "sys/ioctl.h",
- "sys/ipc.h",
- "sys/mman.h",
- "sys/mount.h",
- "sys/msg.h",
- "sys/personality.h",
- "sys/prctl.h",
- "sys/ptrace.h",
- "sys/quota.h",
- // FIXME: the mips-musl CI build jobs use ancient musl 1.0.15:
- [!mips32_musl]: "sys/random.h",
- "sys/reboot.h",
- "sys/resource.h",
- "sys/sem.h",
- "sys/sendfile.h",
- "sys/shm.h",
- "sys/signalfd.h",
- "sys/socket.h",
- "sys/stat.h",
- "sys/statvfs.h",
- "sys/swap.h",
- "sys/syscall.h",
- "sys/time.h",
- "sys/timerfd.h",
- "sys/times.h",
- "sys/types.h",
- "sys/uio.h",
- "sys/un.h",
- "sys/user.h",
- "sys/utsname.h",
- "sys/vfs.h",
- "sys/wait.h",
- "syslog.h",
- "termios.h",
- "time.h",
- "ucontext.h",
- "unistd.h",
- "utime.h",
- "utmp.h",
- "utmpx.h",
- "wchar.h",
- "errno.h",
- // `sys/io.h` is only available on x86*, Alpha, IA64, and 32-bit
- // ARM: https://bugzilla.redhat.com/show_bug.cgi?id=1116162
- [x86_64 || x86_32 || arm]: "sys/io.h",
- // `sys/reg.h` is only available on x86 and x86_64
- [x86_64 || x86_32]: "sys/reg.h",
- // sysctl system call is deprecated and not available on musl
- // It is also unsupported in x32:
- [!(x32 || musl)]: "sys/sysctl.h",
- // <execinfo.h> is not supported by musl:
- // https://www.openwall.com/lists/musl/2015/04/09/3
- [!musl]: "execinfo.h",
- }
-
- // Include linux headers at the end:
- headers! {
- cfg:
- "asm/mman.h",
- "linux/dccp.h",
- "linux/falloc.h",
- "linux/fs.h",
- "linux/futex.h",
- "linux/genetlink.h",
- // FIXME: musl version 1.0.15 used by mips build jobs is ancient
- [!mips32_musl]: "linux/if.h",
- "linux/if_addr.h",
- "linux/if_alg.h",
- "linux/if_ether.h",
- "linux/if_tun.h",
- "linux/input.h",
- "linux/magic.h",
- "linux/memfd.h",
- "linux/module.h",
- "linux/net_tstamp.h",
- "linux/netfilter/nf_tables.h",
- "linux/netfilter_ipv4.h",
- "linux/netfilter_ipv6.h",
- "linux/netlink.h",
- "linux/quota.h",
- "linux/random.h",
- "linux/reboot.h",
- "linux/rtnetlink.h",
- "linux/seccomp.h",
- "linux/sockios.h",
- "sys/auxv.h",
- }
-
- // note: aio.h must be included before sys/mount.h
- headers! {
- cfg:
- "sys/xattr.h",
- "sys/sysinfo.h",
- "aio.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" | "Elf32_Shdr" | "Elf64_Shdr" | "Elf32_Sym"
- | "Elf64_Sym" | "Elf32_Ehdr" | "Elf64_Ehdr" | "Elf32_Chdr"
- | "Elf64_Chdr" => ty.to_string(),
-
- t if is_union => format!("union {}", t),
-
- t if t.ends_with("_t") => t.to_string(),
-
- // put `struct` in front of all structs:.
- t if is_struct => format!("struct {}", t),
-
- t => t.to_string(),
- }
- });
-
- cfg.field_name(move |struct_, field| {
- match field {
- // 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") => {
- s.replace("e_nsec", ".tv_nsec")
- }
- // FIXME: epoll_event.data is actuall a union in C, but in Rust
- // it is only a u64 because we only expose one field
- // http://man7.org/linux/man-pages/man2/epoll_wait.2.html
- "u64" if struct_ == "epoll_event" => "data.u64".to_string(),
- // The following structs have a field called `type` in C,
- // but `type` is a Rust keyword, so these fields are translated
- // to `type_` in Rust.
- "type_"
- if struct_ == "input_event"
- || struct_ == "input_mask"
- || struct_ == "ff_effect" =>
- {
- "type".to_string()
- }
-
- s => s.to_string(),
- }
- });
-
- cfg.skip_type(move |ty| {
- match ty {
- // FIXME: `sighandler_t` type is incorrect, see:
- // https://github.com/rust-lang/libc/issues/1359
- "sighandler_t" => true,
-
- // These cannot be tested when "resolv.h" is included and are tested
- // in the `linux_elf.rs` file.
- "Elf64_Phdr" | "Elf32_Phdr" => true,
-
- // This type is private on Linux. It is implemented as a C `enum`
- // (`c_uint`) and this clashes with the type of the `rlimit` APIs
- // which expect a `c_int` even though both are ABI compatible.
- "__rlimit_resource_t" => true,
-
- _ => false,
- }
- });
-
- cfg.skip_struct(move |ty| {
- match ty {
- // These cannot be tested when "resolv.h" is included and are tested
- // in the `linux_elf.rs` file.
- "Elf64_Phdr" | "Elf32_Phdr" => true,
-
- // On Linux, the type of `ut_tv` field of `struct utmpx`
- // can be an anonymous struct, so an extra struct,
- // which is absent in glibc, has to be defined.
- "__timeval" => true,
-
- // FIXME: This is actually a union, not a struct
- "sigval" => true,
-
- // This type is tested in the `linux_termios.rs` file since there
- // are header conflicts when including them with all the other
- // structs.
- "termios2" => true,
-
- // FIXME: musl version using by mips build jobs 1.0.15 is ancient:
- "ifmap" | "ifreq" | "ifconf" if mips32_musl => true,
-
- _ => false,
- }
- });
-
- cfg.skip_const(move |name| {
- match name {
- // These constants are not available if gnu headers have been included
- // and can therefore not be tested here
- //
- // The IPV6 constants are tested in the `linux_ipv6.rs` tests:
- | "IPV6_FLOWINFO"
- | "IPV6_FLOWLABEL_MGR"
- | "IPV6_FLOWINFO_SEND"
- | "IPV6_FLOWINFO_FLOWLABEL"
- | "IPV6_FLOWINFO_PRIORITY"
- // The F_ fnctl constants are tested in the `linux_fnctl.rs` tests:
- | "F_CANCELLK"
- | "F_ADD_SEALS"
- | "F_GET_SEALS"
- | "F_SEAL_SEAL"
- | "F_SEAL_SHRINK"
- | "F_SEAL_GROW"
- | "F_SEAL_WRITE" => true,
-
- // The musl-sanitized kernel headers used in CI
- // target the Linux kernel 4.4 and do not contain the
- // following constants:
- //
- // Requires Linux kernel 4.9
- | "FALLOC_FL_UNSHARE_RANGE"
- //
- // Require Linux kernel 5.x:
- | "MSG_COPY"
- if musl => true,
- // Require Linux kernel 5.1:
- "F_SEAL_FUTURE_WRITE" => true,
-
- // The musl version 1.0.22 used in CI does not
- // contain these glibc constants yet:
- | "RLIMIT_RTTIME" // should be in `resource.h`
- | "TCP_COOKIE_TRANSACTIONS" // should be in the `netinet/tcp.h` header
- if musl => true,
-
- // FIXME: deprecated: not available in any header
- // See: https://github.com/rust-lang/libc/issues/1356
- "ENOATTR" => true,
-
- // FIXME: SIGUNUSED was removed in glibc 2.26
- // Users should use SIGSYS instead.
- "SIGUNUSED" => true,
-
- // FIXME: conflicts with glibc headers and is tested in
- // `linux_termios.rs` below:
- "BOTHER" => true,
-
- // FIXME: on musl the pthread types are defined a little differently
- // - these constants are used by the glibc implementation.
- n if musl && n.contains("__SIZEOF_PTHREAD") => true,
-
- // FIXME: musl version 1.0.15 used by mips build jobs is ancient
- t if mips32_musl && t.starts_with("IFF") => true,
- "MFD_HUGETLB" | "AF_XDP" | "PF_XDP" if mips32_musl => true,
-
- _ => false,
- }
- });
-
- cfg.skip_fn(move |name| {
- // skip those that are manually verified
- match name {
- // FIXME: https://github.com/rust-lang/libc/issues/1272
- "execv" | "execve" | "execvp" | "execvpe" | "fexecve" => true,
-
- // There are two versions of the sterror_r function, see
- //
- // https://linux.die.net/man/3/strerror_r
- //
- // An XSI-compliant version provided if:
- //
- // (_POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600)
- // && ! _GNU_SOURCE
- //
- // and a GNU specific version provided if _GNU_SOURCE is defined.
- //
- // libc provides bindings for the XSI-compliant version, which is
- // preferred for portable applications.
- //
- // We skip the test here since here _GNU_SOURCE is defined, and
- // test the XSI version below.
- "strerror_r" => true,
-
- // FIXME: Our API is unsound. The Rust API allows aliasing
- // pointers, but the C API requires pointers not to alias.
- // We should probably be at least using `&`/`&mut` here, see:
- // https://github.com/gnzlbg/ctest/issues/68
- "lio_listio" if musl => true,
-
- // FIXME: the glibc version used by the Sparc64 build jobs
- // which use Debian 10.0 is too old.
- "statx" if sparc64 => true,
-
- _ => false,
- }
- });
-
- cfg.skip_field_type(move |struct_, field| {
- // This is a weird union, don't check the type.
- (struct_ == "ifaddrs" && field == "ifa_ifu") ||
- // sighandler_t type is super weird
- (struct_ == "sigaction" && field == "sa_sigaction") ||
- // __timeval type is a patch which doesn't exist in glibc
- (struct_ == "utmpx" && field == "ut_tv") ||
- // sigval is actually a union, but we pretend it's a struct
- (struct_ == "sigevent" && field == "sigev_value") ||
- // this one is an anonymous union
- (struct_ == "ff_effect" && field == "u")
- });
-
- cfg.volatile_item(|i| {
- use ctest::VolatileItemKind::*;
- match i {
- // aio_buf is a volatile void** but since we cannot express that in
- // Rust types, we have to explicitly tell the checker about it here:
- StructField(ref n, ref f) if n == "aiocb" && f == "aio_buf" => {
- true
- }
- _ => false,
- }
- });
-
- cfg.skip_field(move |struct_, field| {
- // this is actually a union on linux, so we can't represent it well and
- // just insert some padding.
- (struct_ == "siginfo_t" && field == "_pad") ||
- // musl names this __dummy1 but it's still there
- (musl && struct_ == "glob_t" && field == "gl_flags") ||
- // 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") ||
- // 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.generate("../src/lib.rs", "main.rs");
-
- test_linux_like_apis(target);
-}
-
-// This function tests APIs that are incompatible to test when other APIs
-// are included (e.g. because including both sets of headers clashes)
-fn test_linux_like_apis(target: &str) {
- let musl = target.contains("musl");
- let linux = target.contains("linux");
- let emscripten = target.contains("emscripten");
- let android = target.contains("android");
- assert!(linux || android || emscripten);
-
- if linux || android || emscripten {
- // test strerror_r from the `string.h` header
- let mut cfg = ctest::TestGenerator::new();
- cfg.skip_type(|_| true).skip_static(|_| true);
-
- headers! { cfg: "string.h" }
- cfg.skip_fn(|f| match f {
- "strerror_r" => false,
- _ => true,
- })
- .skip_const(|_| true)
- .skip_struct(|_| true);
- cfg.generate("../src/lib.rs", "linux_strerror_r.rs");
- }
-
- if linux || android || emscripten {
- // test fcntl - see:
- // http://man7.org/linux/man-pages/man2/fcntl.2.html
- let mut cfg = ctest::TestGenerator::new();
-
- if musl {
- cfg.header("fcntl.h");
- } else {
- cfg.header("linux/fcntl.h");
- }
-
- cfg.skip_type(|_| true)
- .skip_static(|_| true)
- .skip_struct(|_| true)
- .skip_fn(|_| true)
- .skip_const(move |name| match name {
- // test fcntl constants:
- "F_CANCELLK" | "F_ADD_SEALS" | "F_GET_SEALS"
- | "F_SEAL_SEAL" | "F_SEAL_SHRINK" | "F_SEAL_GROW"
- | "F_SEAL_WRITE" => false,
- _ => true,
- })
- .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(),
- });
-
- cfg.generate("../src/lib.rs", "linux_fcntl.rs");
- }
-
- if linux || android {
- // test termios
- let mut cfg = ctest::TestGenerator::new();
- cfg.header("asm/termbits.h");
- cfg.skip_type(|_| true)
- .skip_static(|_| true)
- .skip_fn(|_| true)
- .skip_const(|c| c != "BOTHER")
- .skip_struct(|s| s != "termios2")
- .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(),
- });
- cfg.generate("../src/lib.rs", "linux_termios.rs");
- }
-
- if linux || android {
- // test IPV6_ constants:
- let mut cfg = ctest::TestGenerator::new();
- headers! {
- cfg:
- "linux/in6.h"
- }
- cfg.skip_type(|_| true)
- .skip_static(|_| true)
- .skip_fn(|_| true)
- .skip_const(|_| true)
- .skip_struct(|_| true)
- .skip_const(move |name| match name {
- "IPV6_FLOWINFO"
- | "IPV6_FLOWLABEL_MGR"
- | "IPV6_FLOWINFO_SEND"
- | "IPV6_FLOWINFO_FLOWLABEL"
- | "IPV6_FLOWINFO_PRIORITY" => false,
- _ => true,
- })
- .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(),
- });
- cfg.generate("../src/lib.rs", "linux_ipv6.rs");
- }
-
- if linux || android {
- // Test Elf64_Phdr and Elf32_Phdr
- // These types have a field called `p_type`, but including
- // "resolve.h" defines a `p_type` macro that expands to `__p_type`
- // making the tests for these fails when both are included.
- let mut cfg = ctest::TestGenerator::new();
- cfg.header("elf.h");
- cfg.skip_fn(|_| true)
- .skip_static(|_| true)
- .skip_fn(|_| true)
- .skip_const(|_| true)
- .type_name(move |ty, _is_struct, _is_union| ty.to_string())
- .skip_struct(move |ty| match ty {
- "Elf64_Phdr" | "Elf32_Phdr" => false,
- _ => true,
- })
- .skip_type(move |ty| match ty {
- "Elf64_Phdr" | "Elf32_Phdr" => false,
- _ => true,
- });
- cfg.generate("../src/lib.rs", "linux_elf.rs");
- }
-}
-
-fn which_freebsd() -> Option<i32> {
- let output = std::process::Command::new("freebsd-version")
- .output()
- .ok()?;
- if !output.status.success() {
- return None;
- }
-
- let stdout = String::from_utf8(output.stdout).ok()?;
-
- match &stdout {
- s if s.starts_with("11") => Some(11),
- s if s.starts_with("12") => Some(12),
- _ => None,
- }
-}
diff --git a/libc/libc-test/src/cmsg.c b/libc/libc-test/src/cmsg.c
deleted file mode 100644
index a8b1c37..0000000
--- a/libc/libc-test/src/cmsg.c
+++ /dev/null
@@ -1,28 +0,0 @@
-#include <sys/param.h>
-#include <sys/socket.h>
-
-// Since the cmsg(3) macros are macros instead of functions, they aren't
-// available to FFI. libc must reimplement them, which is error-prone. This
-// file provides FFI access to the actual macros so they can be tested against
-// the Rust reimplementations.
-
-struct cmsghdr *cmsg_firsthdr(struct msghdr *msgh) {
- return CMSG_FIRSTHDR(msgh);
-}
-
-struct cmsghdr *cmsg_nxthdr(struct msghdr *msgh, struct cmsghdr *cmsg) {
- return CMSG_NXTHDR(msgh, cmsg);
-}
-
-size_t cmsg_space(size_t length) {
- return CMSG_SPACE(length);
-}
-
-size_t cmsg_len(size_t length) {
- return CMSG_LEN(length);
-}
-
-unsigned char *cmsg_data(struct cmsghdr *cmsg) {
- return CMSG_DATA(cmsg);
-}
-
diff --git a/libc/libc-test/test/cmsg.rs b/libc/libc-test/test/cmsg.rs
deleted file mode 100644
index 8304163..0000000
--- a/libc/libc-test/test/cmsg.rs
+++ /dev/null
@@ -1,101 +0,0 @@
-//! Compare libc's CMSG(3) family of functions against the actual C macros, for
-//! various inputs.
-
-extern crate libc;
-
-#[cfg(unix)]
-mod t {
-
- use libc::{self, c_uchar, c_uint, c_void, cmsghdr, msghdr};
- use std::mem;
-
- extern "C" {
- pub fn cmsg_firsthdr(msgh: *const msghdr) -> *mut cmsghdr;
- pub fn cmsg_nxthdr(
- mhdr: *const msghdr,
- cmsg: *const cmsghdr,
- ) -> *mut cmsghdr;
- pub fn cmsg_space(length: c_uint) -> usize;
- pub fn cmsg_len(length: c_uint) -> usize;
- pub fn cmsg_data(cmsg: *const cmsghdr) -> *mut c_uchar;
- }
-
- #[test]
- fn test_cmsg_data() {
- for l in 0..128 {
- let pcmsghdr = l as *const cmsghdr;
- unsafe {
- assert_eq!(libc::CMSG_DATA(pcmsghdr), cmsg_data(pcmsghdr));
- }
- }
- }
-
- #[test]
- fn test_cmsg_firsthdr() {
- let mut mhdr: msghdr = unsafe { mem::zeroed() };
- mhdr.msg_control = 0xdeadbeef as *mut c_void;
- let pmhdr = &mhdr as *const msghdr;
- for l in 0..128 {
- mhdr.msg_controllen = l;
- unsafe {
- assert_eq!(libc::CMSG_FIRSTHDR(pmhdr), cmsg_firsthdr(pmhdr));
- }
- }
- }
-
- #[test]
- fn test_cmsg_len() {
- for l in 0..128 {
- unsafe {
- assert_eq!(libc::CMSG_LEN(l) as usize, cmsg_len(l));
- }
- }
- }
-
- // Skip on sparc64
- // https://github.com/rust-lang/libc/issues/1239
- #[cfg(not(target_arch = "sparc64"))]
- #[test]
- fn test_cmsg_nxthdr() {
- use std::ptr;
-
- let mut buffer = [0u8; 256];
- let mut mhdr: msghdr = unsafe { mem::zeroed() };
- let pmhdr = &mhdr as *const msghdr;
- for start_ofs in 0..64 {
- let pcmsghdr = &mut buffer[start_ofs] as *mut u8 as *mut cmsghdr;
- mhdr.msg_control = pcmsghdr as *mut c_void;
- mhdr.msg_controllen = (160 - start_ofs) as _;
- for cmsg_len in 0..64 {
- for next_cmsg_len in 0..32 {
- for i in buffer[start_ofs..].iter_mut() {
- *i = 0;
- }
- unsafe {
- (*pcmsghdr).cmsg_len = cmsg_len;
- let libc_next = libc::CMSG_NXTHDR(pmhdr, pcmsghdr);
- let next = cmsg_nxthdr(pmhdr, pcmsghdr);
- assert_eq!(libc_next, next);
-
- if libc_next != ptr::null_mut() {
- (*libc_next).cmsg_len = next_cmsg_len;
- let libc_next = libc::CMSG_NXTHDR(pmhdr, pcmsghdr);
- let next = cmsg_nxthdr(pmhdr, pcmsghdr);
- assert_eq!(libc_next, next);
- }
- }
- }
- }
- }
- }
-
- #[test]
- fn test_cmsg_space() {
- unsafe {
- for l in 0..128 {
- assert_eq!(libc::CMSG_SPACE(l) as usize, cmsg_space(l));
- }
- }
- }
-
-}
diff --git a/libc/libc-test/test/linux_elf.rs b/libc/libc-test/test/linux_elf.rs
deleted file mode 100644
index d149c9a..0000000
--- a/libc/libc-test/test/linux_elf.rs
+++ /dev/null
@@ -1,12 +0,0 @@
-#![allow(bad_style, improper_ctypes, unused, deprecated)]
-
-extern crate libc;
-use libc::*;
-
-#[cfg(target_os = "linux")]
-include!(concat!(env!("OUT_DIR"), "/linux_elf.rs"));
-
-#[cfg(not(target_os = "linux"))]
-fn main() {
- println!("PASSED 0 tests");
-}
diff --git a/libc/libc-test/test/linux_fcntl.rs b/libc/libc-test/test/linux_fcntl.rs
deleted file mode 100644
index 49c06cc..0000000
--- a/libc/libc-test/test/linux_fcntl.rs
+++ /dev/null
@@ -1,12 +0,0 @@
-#![allow(bad_style, improper_ctypes, unused, deprecated)]
-
-extern crate libc;
-use libc::*;
-
-#[cfg(any(target_os = "linux", target_os = "android"))]
-include!(concat!(env!("OUT_DIR"), "/linux_fcntl.rs"));
-
-#[cfg(not(any(target_os = "linux", target_os = "android")))]
-fn main() {
- println!("PASSED 0 tests");
-}
diff --git a/libc/libc-test/test/linux_ipv6.rs b/libc/libc-test/test/linux_ipv6.rs
deleted file mode 100644
index 83c389c..0000000
--- a/libc/libc-test/test/linux_ipv6.rs
+++ /dev/null
@@ -1,12 +0,0 @@
-#![allow(bad_style, improper_ctypes, unused, deprecated)]
-
-extern crate libc;
-use libc::*;
-
-#[cfg(target_os = "linux")]
-include!(concat!(env!("OUT_DIR"), "/linux_ipv6.rs"));
-
-#[cfg(not(target_os = "linux"))]
-fn main() {
- println!("PASSED 0 tests");
-}
diff --git a/libc/libc-test/test/linux_strerror_r.rs b/libc/libc-test/test/linux_strerror_r.rs
deleted file mode 100644
index 17db959..0000000
--- a/libc/libc-test/test/linux_strerror_r.rs
+++ /dev/null
@@ -1,12 +0,0 @@
-#![allow(bad_style, improper_ctypes, unused, deprecated)]
-
-extern crate libc;
-use libc::*;
-
-#[cfg(any(target_os = "linux", target_os = "android"))]
-include!(concat!(env!("OUT_DIR"), "/linux_strerror_r.rs"));
-
-#[cfg(not(any(target_os = "linux", target_os = "android")))]
-fn main() {
- println!("PASSED 0 tests");
-}
diff --git a/libc/libc-test/test/linux_termios.rs b/libc/libc-test/test/linux_termios.rs
deleted file mode 100644
index 703a9b9..0000000
--- a/libc/libc-test/test/linux_termios.rs
+++ /dev/null
@@ -1,12 +0,0 @@
-#![allow(bad_style, improper_ctypes, unused, deprecated)]
-
-extern crate libc;
-use libc::*;
-
-#[cfg(any(target_os = "linux", target_os = "android"))]
-include!(concat!(env!("OUT_DIR"), "/linux_termios.rs"));
-
-#[cfg(not(any(target_os = "linux", target_os = "android")))]
-fn main() {
- println!("PASSED 0 tests");
-}
diff --git a/libc/libc-test/test/main.rs b/libc/libc-test/test/main.rs
deleted file mode 100644
index 62a587c..0000000
--- a/libc/libc-test/test/main.rs
+++ /dev/null
@@ -1,6 +0,0 @@
-#![allow(bad_style, improper_ctypes, deprecated)]
-extern crate libc;
-
-use libc::*;
-
-include!(concat!(env!("OUT_DIR"), "/main.rs"));
diff --git a/libc/rustfmt.toml b/libc/rustfmt.toml
deleted file mode 100644
index 7ecc610..0000000
--- a/libc/rustfmt.toml
+++ /dev/null
@@ -1,3 +0,0 @@
-max_width = 79
-comment_width = 79
-error_on_line_overflow = true \ No newline at end of file
diff --git a/libc/src/cloudabi/aarch64.rs b/libc/src/cloudabi/aarch64.rs
deleted file mode 100644
index 4caa6d7..0000000
--- a/libc/src/cloudabi/aarch64.rs
+++ /dev/null
@@ -1,4 +0,0 @@
-pub type c_char = u8;
-pub type c_long = i64;
-pub type c_ulong = u64;
-pub type wchar_t = u32;
diff --git a/libc/src/cloudabi/arm.rs b/libc/src/cloudabi/arm.rs
deleted file mode 100644
index eca5360..0000000
--- a/libc/src/cloudabi/arm.rs
+++ /dev/null
@@ -1,4 +0,0 @@
-pub type c_char = u8;
-pub type c_long = i32;
-pub type c_ulong = u32;
-pub type wchar_t = u32;
diff --git a/libc/src/cloudabi/mod.rs b/libc/src/cloudabi/mod.rs
deleted file mode 100644
index 0d86962..0000000
--- a/libc/src/cloudabi/mod.rs
+++ /dev/null
@@ -1,325 +0,0 @@
-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;
-pub type pthread_t = usize;
-pub type sa_family_t = u8;
-pub type socklen_t = usize;
-pub type time_t = i64;
-
-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 in_addr {
- pub s_addr: in_addr_t,
- }
-
- pub struct in6_addr {
- pub s6_addr: [u8; 16],
- }
-
- pub struct pthread_attr_t {
- __detachstate: ::c_int,
- __stacksize: usize,
- }
-
- pub struct sockaddr {
- pub sa_family: sa_family_t,
- pub sa_data: [::c_char; 0],
- }
-
- pub struct sockaddr_in {
- pub sin_family: ::sa_family_t,
- pub sin_port: ::in_port_t,
- pub sin_addr: ::in_addr,
- }
-
- pub struct sockaddr_in6 {
- pub sin6_family: sa_family_t,
- pub sin6_port: ::in_port_t,
- pub sin6_flowinfo: u32,
- pub sin6_addr: ::in6_addr,
- pub sin6_scope_id: u32,
- }
-
- pub struct sockaddr_storage {
- pub ss_family: ::sa_family_t,
- __ss_data: [u8; 32],
- }
-}
-
-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;
-
-pub const AF_INET: ::c_int = 1;
-pub const AF_INET6: ::c_int = 2;
-
-pub const EACCES: ::c_int = 2;
-pub const EADDRINUSE: ::c_int = 3;
-pub const EADDRNOTAVAIL: ::c_int = 4;
-pub const EAGAIN: ::c_int = 6;
-pub const ECONNABORTED: ::c_int = 13;
-pub const ECONNREFUSED: ::c_int = 14;
-pub const ECONNRESET: ::c_int = 15;
-pub const EEXIST: ::c_int = 20;
-pub const EINTR: ::c_int = 27;
-pub const EINVAL: ::c_int = 28;
-pub const ENOENT: ::c_int = 44;
-pub const ENOTCONN: ::c_int = 53;
-pub const EPERM: ::c_int = 63;
-pub const EPIPE: ::c_int = 64;
-pub const ETIMEDOUT: ::c_int = 73;
-pub const EWOULDBLOCK: ::c_int = EAGAIN;
-
-pub const EAI_SYSTEM: ::c_int = 9;
-
-pub const EXIT_FAILURE: ::c_int = 1;
-pub const EXIT_SUCCESS: ::c_int = 0;
-
-pub const PTHREAD_STACK_MIN: ::size_t = 1024;
-
-pub const SOCK_DGRAM: ::c_int = 128;
-pub const SOCK_STREAM: ::c_int = 130;
-
-#[cfg_attr(feature = "extra_traits", derive(Debug))]
-pub enum FILE {}
-impl ::Copy for FILE {}
-impl ::Clone for FILE {
- fn clone(&self) -> FILE { *self }
-}
-#[cfg_attr(feature = "extra_traits", derive(Debug))]
-pub enum fpos_t {} // TODO: fill this out with a struct
-impl ::Copy for fpos_t {}
-impl ::Clone for fpos_t {
- fn clone(&self) -> fpos_t { *self }
-}
-
-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;
- pub fn getaddrinfo(
- node: *const c_char,
- service: *const c_char,
- hints: *const addrinfo,
- res: *mut *mut addrinfo,
- ) -> ::c_int;
- pub fn getsockopt(
- sockfd: ::c_int,
- level: ::c_int,
- optname: ::c_int,
- optval: *mut ::c_void,
- optlen: *mut ::socklen_t,
- ) -> ::c_int;
- pub fn posix_memalign(
- memptr: *mut *mut ::c_void,
- align: ::size_t,
- size: ::size_t,
- ) -> ::c_int;
- pub fn pthread_attr_destroy(attr: *mut ::pthread_attr_t) -> ::c_int;
- pub fn pthread_attr_init(attr: *mut ::pthread_attr_t) -> ::c_int;
- pub fn pthread_attr_setstacksize(
- attr: *mut ::pthread_attr_t,
- stack_size: ::size_t,
- ) -> ::c_int;
- pub fn pthread_create(
- native: *mut ::pthread_t,
- attr: *const ::pthread_attr_t,
- f: extern fn(*mut ::c_void) -> *mut ::c_void,
- value: *mut ::c_void,
- ) -> ::c_int;
- pub fn pthread_detach(thread: ::pthread_t) -> ::c_int;
- pub fn pthread_getspecific(key: pthread_key_t) -> *mut ::c_void;
- pub fn pthread_join(
- native: ::pthread_t,
- value: *mut *mut ::c_void,
- ) -> ::c_int;
- pub fn pthread_key_create(
- key: *mut pthread_key_t,
- dtor: ::Option<unsafe extern fn(*mut ::c_void)>,
- ) -> ::c_int;
- pub fn pthread_key_delete(key: pthread_key_t) -> ::c_int;
- pub fn pthread_setspecific(
- key: pthread_key_t,
- value: *const ::c_void,
- ) -> ::c_int;
- pub fn send(
- socket: ::c_int,
- buf: *const ::c_void,
- len: ::size_t,
- flags: ::c_int,
- ) -> ::ssize_t;
- pub fn sysconf(name: ::c_int) -> ::c_long;
-}
-
-cfg_if! {
- if #[cfg(target_arch = "aarch64")] {
- mod aarch64;
- pub use self::aarch64::*;
- } else if #[cfg(any(target_arch = "arm"))] {
- mod arm;
- pub use self::arm::*;
- } else if #[cfg(any(target_arch = "x86"))] {
- mod x86;
- pub use self::x86::*;
- } else if #[cfg(any(target_arch = "x86_64"))] {
- mod x86_64;
- pub use self::x86_64::*;
- } else {
- // Unknown target_arch
- }
-}
-
-cfg_if! {
- if #[cfg(libc_core_cvoid)] {
- pub use ::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)]
- #[allow(missing_copy_implementations)]
- #[allow(missing_debug_implementations)]
- 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/cloudabi/x86.rs b/libc/src/cloudabi/x86.rs
deleted file mode 100644
index 2f9f39c..0000000
--- a/libc/src/cloudabi/x86.rs
+++ /dev/null
@@ -1,4 +0,0 @@
-pub type c_char = i8;
-pub type c_long = i32;
-pub type c_ulong = u32;
-pub type wchar_t = i32;
diff --git a/libc/src/cloudabi/x86_64.rs b/libc/src/cloudabi/x86_64.rs
deleted file mode 100644
index bb17624..0000000
--- a/libc/src/cloudabi/x86_64.rs
+++ /dev/null
@@ -1,4 +0,0 @@
-pub type c_char = i8;
-pub type c_long = i64;
-pub type c_ulong = u64;
-pub type wchar_t = i32;
diff --git a/libc/src/fixed_width_ints.rs b/libc/src/fixed_width_ints.rs
deleted file mode 100644
index 0c25d28..0000000
--- a/libc/src/fixed_width_ints.rs
+++ /dev/null
@@ -1,44 +0,0 @@
-//! This module contains type aliases for C's fixed-width integer types .
-//!
-//! These aliases are deprecated: use the Rust types instead.
-
-#[deprecated(
- since = "0.2.55",
- note = "Use i8 instead."
-)]
-pub type int8_t = i8;
-#[deprecated(
- since = "0.2.55",
- note = "Use i16 instead."
-)]
-pub type int16_t = i16;
-#[deprecated(
- since = "0.2.55",
- note = "Use i32 instead."
-)]
-pub type int32_t = i32;
-#[deprecated(
- since = "0.2.55",
- note = "Use i64 instead."
-)]
-pub type int64_t = i64;
-#[deprecated(
- since = "0.2.55",
- note = "Use u8 instead."
-)]
-pub type uint8_t = u8;
-#[deprecated(
- since = "0.2.55",
- note = "Use u16 instead."
-)]
-pub type uint16_t = u16;
-#[deprecated(
- since = "0.2.55",
- note = "Use u32 instead."
-)]
-pub type uint32_t = u32;
-#[deprecated(
- since = "0.2.55",
- note = "Use u64 instead."
-)]
-pub type uint64_t = u64;
diff --git a/libc/src/fuchsia/aarch64.rs b/libc/src/fuchsia/aarch64.rs
deleted file mode 100644
index 654e8d1..0000000
--- a/libc/src/fuchsia/aarch64.rs
+++ /dev/null
@@ -1,347 +0,0 @@
-pub type c_char = u8;
-pub type __u64 = ::c_ulonglong;
-pub type wchar_t = u32;
-pub type nlink_t = ::c_ulong;
-pub type blksize_t = ::c_long;
-
-s! {
- pub struct stat {
- pub st_dev: ::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,
- __pad0: ::c_ulong,
- pub st_size: ::off_t,
- pub st_blksize: ::blksize_t,
- __pad1: ::c_int,
- 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_uint; 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,
- __pad0: ::c_ulong,
- pub st_size: ::off_t,
- pub st_blksize: ::blksize_t,
- __pad1: ::c_int,
- 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_uint; 2],
- }
-
- pub struct ipc_perm {
- pub __ipc_perm_key: ::key_t,
- pub uid: ::uid_t,
- pub gid: ::gid_t,
- pub cuid: ::uid_t,
- pub cgid: ::gid_t,
- pub mode: ::mode_t,
- pub __seq: ::c_ushort,
- __unused1: ::c_ulong,
- __unused2: ::c_ulong,
- }
-}
-
-pub const MINSIGSTKSZ: ::size_t = 6144;
-pub const SIGSTKSZ: ::size_t = 12288;
-
-#[doc(hidden)]
-#[deprecated(
- since = "0.2.55",
- note = "If you are using this report to: \
- https://github.com/rust-lang/libc/issues/665"
-)]
-pub const PF_MAX: ::c_int = 43;
-#[doc(hidden)]
-#[deprecated(
- since = "0.2.55",
- note = "If you are using this report to: \
- https://github.com/rust-lang/libc/issues/665"
-)]
-#[allow(deprecated)]
-pub const AF_MAX: ::c_int = PF_MAX;
-
-pub const SYS_io_setup: ::c_long = 0;
-pub const SYS_io_destroy: ::c_long = 1;
-pub const SYS_io_submit: ::c_long = 2;
-pub const SYS_io_cancel: ::c_long = 3;
-pub const SYS_io_getevents: ::c_long = 4;
-pub const SYS_setxattr: ::c_long = 5;
-pub const SYS_lsetxattr: ::c_long = 6;
-pub const SYS_fsetxattr: ::c_long = 7;
-pub const SYS_getxattr: ::c_long = 8;
-pub const SYS_lgetxattr: ::c_long = 9;
-pub const SYS_fgetxattr: ::c_long = 10;
-pub const SYS_listxattr: ::c_long = 11;
-pub const SYS_llistxattr: ::c_long = 12;
-pub const SYS_flistxattr: ::c_long = 13;
-pub const SYS_removexattr: ::c_long = 14;
-pub const SYS_lremovexattr: ::c_long = 15;
-pub const SYS_fremovexattr: ::c_long = 16;
-pub const SYS_getcwd: ::c_long = 17;
-pub const SYS_lookup_dcookie: ::c_long = 18;
-pub const SYS_eventfd2: ::c_long = 19;
-pub const SYS_epoll_create1: ::c_long = 20;
-pub const SYS_epoll_ctl: ::c_long = 21;
-pub const SYS_epoll_pwait: ::c_long = 22;
-pub const SYS_dup: ::c_long = 23;
-pub const SYS_dup3: ::c_long = 24;
-pub const SYS_inotify_init1: ::c_long = 26;
-pub const SYS_inotify_add_watch: ::c_long = 27;
-pub const SYS_inotify_rm_watch: ::c_long = 28;
-pub const SYS_ioctl: ::c_long = 29;
-pub const SYS_ioprio_set: ::c_long = 30;
-pub const SYS_ioprio_get: ::c_long = 31;
-pub const SYS_flock: ::c_long = 32;
-pub const SYS_mknodat: ::c_long = 33;
-pub const SYS_mkdirat: ::c_long = 34;
-pub const SYS_unlinkat: ::c_long = 35;
-pub const SYS_symlinkat: ::c_long = 36;
-pub const SYS_linkat: ::c_long = 37;
-pub const SYS_renameat: ::c_long = 38;
-pub const SYS_umount2: ::c_long = 39;
-pub const SYS_mount: ::c_long = 40;
-pub const SYS_pivot_root: ::c_long = 41;
-pub const SYS_nfsservctl: ::c_long = 42;
-pub const SYS_fallocate: ::c_long = 47;
-pub const SYS_faccessat: ::c_long = 48;
-pub const SYS_chdir: ::c_long = 49;
-pub const SYS_fchdir: ::c_long = 50;
-pub const SYS_chroot: ::c_long = 51;
-pub const SYS_fchmod: ::c_long = 52;
-pub const SYS_fchmodat: ::c_long = 53;
-pub const SYS_fchownat: ::c_long = 54;
-pub const SYS_fchown: ::c_long = 55;
-pub const SYS_openat: ::c_long = 56;
-pub const SYS_close: ::c_long = 57;
-pub const SYS_vhangup: ::c_long = 58;
-pub const SYS_pipe2: ::c_long = 59;
-pub const SYS_quotactl: ::c_long = 60;
-pub const SYS_getdents64: ::c_long = 61;
-pub const SYS_read: ::c_long = 63;
-pub const SYS_write: ::c_long = 64;
-pub const SYS_readv: ::c_long = 65;
-pub const SYS_writev: ::c_long = 66;
-pub const SYS_pread64: ::c_long = 67;
-pub const SYS_pwrite64: ::c_long = 68;
-pub const SYS_preadv: ::c_long = 69;
-pub const SYS_pwritev: ::c_long = 70;
-pub const SYS_pselect6: ::c_long = 72;
-pub const SYS_ppoll: ::c_long = 73;
-pub const SYS_signalfd4: ::c_long = 74;
-pub const SYS_vmsplice: ::c_long = 75;
-pub const SYS_splice: ::c_long = 76;
-pub const SYS_tee: ::c_long = 77;
-pub const SYS_readlinkat: ::c_long = 78;
-pub const SYS_sync: ::c_long = 81;
-pub const SYS_fsync: ::c_long = 82;
-pub const SYS_fdatasync: ::c_long = 83;
-pub const SYS_sync_file_range: ::c_long = 84;
-pub const SYS_timerfd_create: ::c_long = 85;
-pub const SYS_timerfd_settime: ::c_long = 86;
-pub const SYS_timerfd_gettime: ::c_long = 87;
-pub const SYS_utimensat: ::c_long = 88;
-pub const SYS_acct: ::c_long = 89;
-pub const SYS_capget: ::c_long = 90;
-pub const SYS_capset: ::c_long = 91;
-pub const SYS_personality: ::c_long = 92;
-pub const SYS_exit: ::c_long = 93;
-pub const SYS_exit_group: ::c_long = 94;
-pub const SYS_waitid: ::c_long = 95;
-pub const SYS_set_tid_address: ::c_long = 96;
-pub const SYS_unshare: ::c_long = 97;
-pub const SYS_futex: ::c_long = 98;
-pub const SYS_set_robust_list: ::c_long = 99;
-pub const SYS_get_robust_list: ::c_long = 100;
-pub const SYS_nanosleep: ::c_long = 101;
-pub const SYS_getitimer: ::c_long = 102;
-pub const SYS_setitimer: ::c_long = 103;
-pub const SYS_kexec_load: ::c_long = 104;
-pub const SYS_init_module: ::c_long = 105;
-pub const SYS_delete_module: ::c_long = 106;
-pub const SYS_timer_create: ::c_long = 107;
-pub const SYS_timer_gettime: ::c_long = 108;
-pub const SYS_timer_getoverrun: ::c_long = 109;
-pub const SYS_timer_settime: ::c_long = 110;
-pub const SYS_timer_delete: ::c_long = 111;
-pub const SYS_clock_settime: ::c_long = 112;
-pub const SYS_clock_gettime: ::c_long = 113;
-pub const SYS_clock_getres: ::c_long = 114;
-pub const SYS_clock_nanosleep: ::c_long = 115;
-pub const SYS_syslog: ::c_long = 116;
-pub const SYS_ptrace: ::c_long = 117;
-pub const SYS_sched_setparam: ::c_long = 118;
-pub const SYS_sched_setscheduler: ::c_long = 119;
-pub const SYS_sched_getscheduler: ::c_long = 120;
-pub const SYS_sched_getparam: ::c_long = 121;
-pub const SYS_sched_setaffinity: ::c_long = 122;
-pub const SYS_sched_getaffinity: ::c_long = 123;
-pub const SYS_sched_yield: ::c_long = 124;
-pub const SYS_sched_get_priority_max: ::c_long = 125;
-pub const SYS_sched_get_priority_min: ::c_long = 126;
-pub const SYS_sched_rr_get_interval: ::c_long = 127;
-pub const SYS_restart_syscall: ::c_long = 128;
-pub const SYS_kill: ::c_long = 129;
-pub const SYS_tkill: ::c_long = 130;
-pub const SYS_tgkill: ::c_long = 131;
-pub const SYS_sigaltstack: ::c_long = 132;
-pub const SYS_rt_sigsuspend: ::c_long = 133;
-pub const SYS_rt_sigaction: ::c_long = 134;
-pub const SYS_rt_sigprocmask: ::c_long = 135;
-pub const SYS_rt_sigpending: ::c_long = 136;
-pub const SYS_rt_sigtimedwait: ::c_long = 137;
-pub const SYS_rt_sigqueueinfo: ::c_long = 138;
-pub const SYS_rt_sigreturn: ::c_long = 139;
-pub const SYS_setpriority: ::c_long = 140;
-pub const SYS_getpriority: ::c_long = 141;
-pub const SYS_reboot: ::c_long = 142;
-pub const SYS_setregid: ::c_long = 143;
-pub const SYS_setgid: ::c_long = 144;
-pub const SYS_setreuid: ::c_long = 145;
-pub const SYS_setuid: ::c_long = 146;
-pub const SYS_setresuid: ::c_long = 147;
-pub const SYS_getresuid: ::c_long = 148;
-pub const SYS_setresgid: ::c_long = 149;
-pub const SYS_getresgid: ::c_long = 150;
-pub const SYS_setfsuid: ::c_long = 151;
-pub const SYS_setfsgid: ::c_long = 152;
-pub const SYS_times: ::c_long = 153;
-pub const SYS_setpgid: ::c_long = 154;
-pub const SYS_getpgid: ::c_long = 155;
-pub const SYS_getsid: ::c_long = 156;
-pub const SYS_setsid: ::c_long = 157;
-pub const SYS_getgroups: ::c_long = 158;
-pub const SYS_setgroups: ::c_long = 159;
-pub const SYS_uname: ::c_long = 160;
-pub const SYS_sethostname: ::c_long = 161;
-pub const SYS_setdomainname: ::c_long = 162;
-pub const SYS_getrlimit: ::c_long = 163;
-pub const SYS_setrlimit: ::c_long = 164;
-pub const SYS_getrusage: ::c_long = 165;
-pub const SYS_umask: ::c_long = 166;
-pub const SYS_prctl: ::c_long = 167;
-pub const SYS_getcpu: ::c_long = 168;
-pub const SYS_gettimeofday: ::c_long = 169;
-pub const SYS_settimeofday: ::c_long = 170;
-pub const SYS_adjtimex: ::c_long = 171;
-pub const SYS_getpid: ::c_long = 172;
-pub const SYS_getppid: ::c_long = 173;
-pub const SYS_getuid: ::c_long = 174;
-pub const SYS_geteuid: ::c_long = 175;
-pub const SYS_getgid: ::c_long = 176;
-pub const SYS_getegid: ::c_long = 177;
-pub const SYS_gettid: ::c_long = 178;
-pub const SYS_sysinfo: ::c_long = 179;
-pub const SYS_mq_open: ::c_long = 180;
-pub const SYS_mq_unlink: ::c_long = 181;
-pub const SYS_mq_timedsend: ::c_long = 182;
-pub const SYS_mq_timedreceive: ::c_long = 183;
-pub const SYS_mq_notify: ::c_long = 184;
-pub const SYS_mq_getsetattr: ::c_long = 185;
-pub const SYS_msgget: ::c_long = 186;
-pub const SYS_msgctl: ::c_long = 187;
-pub const SYS_msgrcv: ::c_long = 188;
-pub const SYS_msgsnd: ::c_long = 189;
-pub const SYS_semget: ::c_long = 190;
-pub const SYS_semctl: ::c_long = 191;
-pub const SYS_semtimedop: ::c_long = 192;
-pub const SYS_semop: ::c_long = 193;
-pub const SYS_shmget: ::c_long = 194;
-pub const SYS_shmctl: ::c_long = 195;
-pub const SYS_shmat: ::c_long = 196;
-pub const SYS_shmdt: ::c_long = 197;
-pub const SYS_socket: ::c_long = 198;
-pub const SYS_socketpair: ::c_long = 199;
-pub const SYS_bind: ::c_long = 200;
-pub const SYS_listen: ::c_long = 201;
-pub const SYS_accept: ::c_long = 202;
-pub const SYS_connect: ::c_long = 203;
-pub const SYS_getsockname: ::c_long = 204;
-pub const SYS_getpeername: ::c_long = 205;
-pub const SYS_sendto: ::c_long = 206;
-pub const SYS_recvfrom: ::c_long = 207;
-pub const SYS_setsockopt: ::c_long = 208;
-pub const SYS_getsockopt: ::c_long = 209;
-pub const SYS_shutdown: ::c_long = 210;
-pub const SYS_sendmsg: ::c_long = 211;
-pub const SYS_recvmsg: ::c_long = 212;
-pub const SYS_readahead: ::c_long = 213;
-pub const SYS_brk: ::c_long = 214;
-pub const SYS_munmap: ::c_long = 215;
-pub const SYS_mremap: ::c_long = 216;
-pub const SYS_add_key: ::c_long = 217;
-pub const SYS_request_key: ::c_long = 218;
-pub const SYS_keyctl: ::c_long = 219;
-pub const SYS_clone: ::c_long = 220;
-pub const SYS_execve: ::c_long = 221;
-pub const SYS_swapon: ::c_long = 224;
-pub const SYS_swapoff: ::c_long = 225;
-pub const SYS_mprotect: ::c_long = 226;
-pub const SYS_msync: ::c_long = 227;
-pub const SYS_mlock: ::c_long = 228;
-pub const SYS_munlock: ::c_long = 229;
-pub const SYS_mlockall: ::c_long = 230;
-pub const SYS_munlockall: ::c_long = 231;
-pub const SYS_mincore: ::c_long = 232;
-pub const SYS_madvise: ::c_long = 233;
-pub const SYS_remap_file_pages: ::c_long = 234;
-pub const SYS_mbind: ::c_long = 235;
-pub const SYS_get_mempolicy: ::c_long = 236;
-pub const SYS_set_mempolicy: ::c_long = 237;
-pub const SYS_migrate_pages: ::c_long = 238;
-pub const SYS_move_pages: ::c_long = 239;
-pub const SYS_rt_tgsigqueueinfo: ::c_long = 240;
-pub const SYS_perf_event_open: ::c_long = 241;
-pub const SYS_accept4: ::c_long = 242;
-pub const SYS_recvmmsg: ::c_long = 243;
-pub const SYS_wait4: ::c_long = 260;
-pub const SYS_prlimit64: ::c_long = 261;
-pub const SYS_fanotify_init: ::c_long = 262;
-pub const SYS_fanotify_mark: ::c_long = 263;
-pub const SYS_name_to_handle_at: ::c_long = 264;
-pub const SYS_open_by_handle_at: ::c_long = 265;
-pub const SYS_clock_adjtime: ::c_long = 266;
-pub const SYS_syncfs: ::c_long = 267;
-pub const SYS_setns: ::c_long = 268;
-pub const SYS_sendmmsg: ::c_long = 269;
-pub const SYS_process_vm_readv: ::c_long = 270;
-pub const SYS_process_vm_writev: ::c_long = 271;
-pub const SYS_kcmp: ::c_long = 272;
-pub const SYS_finit_module: ::c_long = 273;
-pub const SYS_sched_setattr: ::c_long = 274;
-pub const SYS_sched_getattr: ::c_long = 275;
-pub const SYS_renameat2: ::c_long = 276;
-pub const SYS_seccomp: ::c_long = 277;
-pub const SYS_getrandom: ::c_long = 278;
-pub const SYS_memfd_create: ::c_long = 279;
-pub const SYS_bpf: ::c_long = 280;
-pub const SYS_execveat: ::c_long = 281;
-pub const SYS_userfaultfd: ::c_long = 282;
-pub const SYS_membarrier: ::c_long = 283;
-pub const SYS_mlock2: ::c_long = 284;
-pub const SYS_copy_file_range: ::c_long = 285;
-pub const SYS_preadv2: ::c_long = 286;
-pub const SYS_pwritev2: ::c_long = 287;
-pub const SYS_pkey_mprotect: ::c_long = 288;
-pub const SYS_pkey_alloc: ::c_long = 289;
-pub const SYS_pkey_free: ::c_long = 290;
diff --git a/libc/src/fuchsia/align.rs b/libc/src/fuchsia/align.rs
deleted file mode 100644
index bc97275..0000000
--- a/libc/src/fuchsia/align.rs
+++ /dev/null
@@ -1,142 +0,0 @@
-macro_rules! expand_align {
- () => {
- s! {
- #[cfg_attr(
- any(
- target_pointer_width = "32",
- target_arch = "x86_64"
- ),
- repr(align(4)))]
- #[cfg_attr(
- not(any(
- target_pointer_width = "32",
- target_arch = "x86_64"
- )),
- repr(align(8)))]
- pub struct pthread_mutexattr_t {
- size: [u8; ::__SIZEOF_PTHREAD_MUTEXATTR_T],
- }
-
- #[cfg_attr(target_pointer_width = "32",
- repr(align(4)))]
- #[cfg_attr(target_pointer_width = "64",
- repr(align(8)))]
- pub struct pthread_rwlockattr_t {
- size: [u8; ::__SIZEOF_PTHREAD_RWLOCKATTR_T],
- }
-
- #[repr(align(4))]
- pub struct pthread_condattr_t {
- size: [u8; ::__SIZEOF_PTHREAD_CONDATTR_T],
- }
- }
-
- s_no_extra_traits! {
- #[cfg_attr(all(target_pointer_width = "32",
- any(target_arch = "arm",
- target_arch = "x86_64")),
- repr(align(4)))]
- #[cfg_attr(any(target_pointer_width = "64",
- not(any(target_arch = "arm",
- target_arch = "x86_64"))),
- repr(align(8)))]
- pub struct pthread_mutex_t {
- size: [u8; ::__SIZEOF_PTHREAD_MUTEX_T],
- }
-
- #[cfg_attr(all(target_pointer_width = "32",
- any(target_arch = "arm",
- target_arch = "x86_64")),
- repr(align(4)))]
- #[cfg_attr(any(target_pointer_width = "64",
- not(any(target_arch = "arm",
- target_arch = "x86_64"))),
- repr(align(8)))]
- pub struct pthread_rwlock_t {
- size: [u8; ::__SIZEOF_PTHREAD_RWLOCK_T],
- }
-
- #[cfg_attr(target_pointer_width = "32",
- repr(align(4)))]
- #[cfg_attr(target_pointer_width = "64",
- repr(align(8)))]
- #[cfg_attr(target_arch = "x86",
- repr(align(4)))]
- #[cfg_attr(not(target_arch = "x86"),
- repr(align(8)))]
- pub struct pthread_cond_t {
- size: [u8; ::__SIZEOF_PTHREAD_COND_T],
- }
- }
-
- cfg_if! {
- if #[cfg(feature = "extra_traits")] {
- impl PartialEq for pthread_cond_t {
- fn eq(&self, other: &pthread_cond_t) -> bool {
- self.size
- .iter()
- .zip(other.size.iter())
- .all(|(a,b)| a == b)
- }
- }
- impl Eq for pthread_cond_t {}
- impl ::fmt::Debug for pthread_cond_t {
- fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
- f.debug_struct("pthread_cond_t")
- // FIXME: .field("size", &self.size)
- .finish()
- }
- }
- impl ::hash::Hash for pthread_cond_t {
- fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
- self.size.hash(state);
- }
- }
-
- impl PartialEq for pthread_mutex_t {
- fn eq(&self, other: &pthread_mutex_t) -> bool {
- self.size
- .iter()
- .zip(other.size.iter())
- .all(|(a,b)| a == b)
- }
- }
- impl Eq for pthread_mutex_t {}
- impl ::fmt::Debug for pthread_mutex_t {
- fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
- f.debug_struct("pthread_mutex_t")
- // FIXME: .field("size", &self.size)
- .finish()
- }
- }
- impl ::hash::Hash for pthread_mutex_t {
- fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
- self.size.hash(state);
- }
- }
-
- impl PartialEq for pthread_rwlock_t {
- fn eq(&self, other: &pthread_rwlock_t) -> bool {
- self.size
- .iter()
- .zip(other.size.iter())
- .all(|(a,b)| a == b)
- }
- }
- impl Eq for pthread_rwlock_t {}
- impl ::fmt::Debug for pthread_rwlock_t {
- fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
- f.debug_struct("pthread_rwlock_t")
- // FIXME: .field("size", &self.size)
- .finish()
- }
- }
- impl ::hash::Hash for pthread_rwlock_t {
- fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
- self.size.hash(state);
- }
- }
- }
- }
- }
-}
diff --git a/libc/src/fuchsia/mod.rs b/libc/src/fuchsia/mod.rs
deleted file mode 100644
index 1d68341..0000000
--- a/libc/src/fuchsia/mod.rs
+++ /dev/null
@@ -1,4316 +0,0 @@
-//! Definitions found commonly among almost all Unix derivatives
-//!
-//! More functions and definitions can be found in the more specific modules
-//! according to the platform in question.
-
-// PUB_TYPE
-
-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 locale_t = *mut ::c_void;
-
-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;
-pub type in_addr_t = u32;
-pub type in_port_t = u16;
-pub type sighandler_t = ::size_t;
-pub type cc_t = ::c_uchar;
-pub type sa_family_t = u16;
-pub type pthread_key_t = ::c_uint;
-pub type speed_t = ::c_uint;
-pub type tcflag_t = ::c_uint;
-pub type clockid_t = ::c_int;
-pub type key_t = ::c_int;
-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;
-pub type blkcnt64_t = i64;
-pub type rlim64_t = u64;
-pub type mqd_t = ::c_int;
-pub type nfds_t = ::c_ulong;
-pub type nl_item = ::c_int;
-pub type idtype_t = ::c_uint;
-pub type loff_t = ::c_longlong;
-
-pub type __u8 = ::c_uchar;
-pub type __u16 = ::c_ushort;
-pub type __s16 = ::c_short;
-pub type __u32 = ::c_uint;
-pub type __s32 = ::c_int;
-
-pub type Elf32_Half = u16;
-pub type Elf32_Word = u32;
-pub type Elf32_Off = u32;
-pub type Elf32_Addr = u32;
-
-pub type Elf64_Half = u16;
-pub type Elf64_Word = u32;
-pub type Elf64_Off = u64;
-pub type Elf64_Addr = u64;
-pub type Elf64_Xword = u64;
-
-pub type clock_t = c_long;
-pub type time_t = c_long;
-pub type suseconds_t = c_long;
-pub type ino_t = u64;
-pub type off_t = i64;
-pub type blkcnt_t = i64;
-
-pub type shmatt_t = ::c_ulong;
-pub type msgqnum_t = ::c_ulong;
-pub type msglen_t = ::c_ulong;
-pub type fsblkcnt_t = ::c_ulonglong;
-pub type fsfilcnt_t = ::c_ulonglong;
-pub type rlim_t = ::c_ulonglong;
-
-pub type c_long = i64;
-pub type c_ulong = u64;
-
-// FIXME: why are these uninhabited types? that seems... wrong?
-// Presumably these should be `()` or an `extern type` (when that stabilizes).
-#[cfg_attr(feature = "extra_traits", derive(Debug))]
-pub enum timezone {}
-impl ::Copy for timezone {}
-impl ::Clone for timezone {
- fn clone(&self) -> timezone { *self }
-}
-#[cfg_attr(feature = "extra_traits", derive(Debug))]
-pub enum DIR {}
-impl ::Copy for DIR {}
-impl ::Clone for DIR {
- fn clone(&self) -> DIR { *self }
-}
-
-#[cfg_attr(feature = "extra_traits", derive(Debug))]
-pub enum fpos64_t {} // TODO: fill this out with a struct
-impl ::Copy for fpos64_t {}
-impl ::Clone for fpos64_t {
- fn clone(&self) -> fpos64_t { *self }
-}
-
-// PUB_STRUCT
-
-s! {
- pub struct group {
- pub gr_name: *mut ::c_char,
- pub gr_passwd: *mut ::c_char,
- pub gr_gid: ::gid_t,
- pub gr_mem: *mut *mut ::c_char,
- }
-
- pub struct utimbuf {
- pub actime: time_t,
- pub modtime: time_t,
- }
-
- pub struct timeval {
- pub tv_sec: time_t,
- pub tv_usec: suseconds_t,
- }
-
- pub struct timespec {
- pub tv_sec: time_t,
- 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,
- }
-
- pub struct rusage {
- pub ru_utime: timeval,
- pub ru_stime: timeval,
- pub ru_maxrss: c_long,
- #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
- __pad1: u32,
- pub ru_ixrss: c_long,
- #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
- __pad2: u32,
- pub ru_idrss: c_long,
- #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
- __pad3: u32,
- pub ru_isrss: c_long,
- #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
- __pad4: u32,
- pub ru_minflt: c_long,
- #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
- __pad5: u32,
- pub ru_majflt: c_long,
- #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
- __pad6: u32,
- pub ru_nswap: c_long,
- #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
- __pad7: u32,
- pub ru_inblock: c_long,
- #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
- __pad8: u32,
- pub ru_oublock: c_long,
- #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
- __pad9: u32,
- pub ru_msgsnd: c_long,
- #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
- __pad10: u32,
- pub ru_msgrcv: c_long,
- #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
- __pad11: u32,
- pub ru_nsignals: c_long,
- #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
- __pad12: u32,
- pub ru_nvcsw: c_long,
- #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
- __pad13: u32,
- pub ru_nivcsw: c_long,
- #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
- __pad14: u32,
- }
-
- pub struct in_addr {
- pub s_addr: in_addr_t,
- }
-
- pub struct in6_addr {
- pub s6_addr: [u8; 16],
- }
-
- pub struct ip_mreq {
- pub imr_multiaddr: in_addr,
- pub imr_interface: in_addr,
- }
-
- pub struct ipv6_mreq {
- pub ipv6mr_multiaddr: in6_addr,
- pub ipv6mr_interface: ::c_uint,
- }
-
- pub struct hostent {
- pub h_name: *mut ::c_char,
- pub h_aliases: *mut *mut ::c_char,
- pub h_addrtype: ::c_int,
- pub h_length: ::c_int,
- pub h_addr_list: *mut *mut ::c_char,
- }
-
- pub struct iovec {
- pub iov_base: *mut ::c_void,
- pub iov_len: ::size_t,
- }
-
- pub struct pollfd {
- pub fd: ::c_int,
- pub events: ::c_short,
- pub revents: ::c_short,
- }
-
- pub struct winsize {
- pub ws_row: ::c_ushort,
- pub ws_col: ::c_ushort,
- pub ws_xpixel: ::c_ushort,
- pub ws_ypixel: ::c_ushort,
- }
-
- pub struct linger {
- pub l_onoff: ::c_int,
- pub l_linger: ::c_int,
- }
-
- pub struct sigval {
- // Actually a union of an int and a void*
- pub sival_ptr: *mut ::c_void
- }
-
- // <sys/time.h>
- pub struct itimerval {
- pub it_interval: ::timeval,
- pub it_value: ::timeval,
- }
-
- // <sys/times.h>
- 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 servent {
- pub s_name: *mut ::c_char,
- pub s_aliases: *mut *mut ::c_char,
- pub s_port: ::c_int,
- pub s_proto: *mut ::c_char,
- }
-
- pub struct protoent {
- pub p_name: *mut ::c_char,
- pub p_aliases: *mut *mut ::c_char,
- pub p_proto: ::c_int,
- }
-
- pub struct aiocb {
- pub aio_fildes: ::c_int,
- pub aio_lio_opcode: ::c_int,
- pub aio_reqprio: ::c_int,
- pub aio_buf: *mut ::c_void,
- pub aio_nbytes: ::size_t,
- pub aio_sigevent: ::sigevent,
- __td: *mut ::c_void,
- __lock: [::c_int; 2],
- __err: ::c_int,
- __ret: ::ssize_t,
- pub aio_offset: off_t,
- __next: *mut ::c_void,
- __prev: *mut ::c_void,
- #[cfg(target_pointer_width = "32")]
- __dummy4: [::c_char; 24],
- #[cfg(target_pointer_width = "64")]
- __dummy4: [::c_char; 16],
- }
-
- pub struct sigaction {
- pub sa_sigaction: ::sighandler_t,
- pub sa_mask: ::sigset_t,
- pub sa_flags: ::c_int,
- pub sa_restorer: ::Option<extern fn()>,
- }
-
- pub struct termios {
- pub c_iflag: ::tcflag_t,
- pub c_oflag: ::tcflag_t,
- pub c_cflag: ::tcflag_t,
- pub c_lflag: ::tcflag_t,
- pub c_line: ::cc_t,
- pub c_cc: [::cc_t; ::NCCS],
- pub __c_ispeed: ::speed_t,
- pub __c_ospeed: ::speed_t,
- }
-
- pub struct flock {
- pub l_type: ::c_short,
- pub l_whence: ::c_short,
- pub l_start: ::off_t,
- pub l_len: ::off_t,
- pub l_pid: ::pid_t,
- }
-
- pub struct ucred {
- pub pid: ::pid_t,
- pub uid: ::uid_t,
- pub gid: ::gid_t,
- }
-
- pub struct sockaddr {
- pub sa_family: sa_family_t,
- pub sa_data: [::c_char; 14],
- }
-
- pub struct sockaddr_in {
- pub sin_family: sa_family_t,
- pub sin_port: ::in_port_t,
- pub sin_addr: ::in_addr,
- pub sin_zero: [u8; 8],
- }
-
- pub struct sockaddr_in6 {
- 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 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 sockaddr_ll {
- pub sll_family: ::c_ushort,
- pub sll_protocol: ::c_ushort,
- pub sll_ifindex: ::c_int,
- pub sll_hatype: ::c_ushort,
- pub sll_pkttype: ::c_uchar,
- pub sll_halen: ::c_uchar,
- pub sll_addr: [::c_uchar; 8]
- }
-
- pub struct fd_set {
- fds_bits: [::c_ulong; FD_SETSIZE / ULONG_SIZE],
- }
-
- 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 tm_gmtoff: ::c_long,
- pub tm_zone: *const ::c_char,
- }
-
- pub struct sched_param {
- pub sched_priority: ::c_int,
- pub sched_ss_low_priority: ::c_int,
- pub sched_ss_repl_period: ::timespec,
- pub sched_ss_init_budget: ::timespec,
- pub sched_ss_max_repl: ::c_int,
- }
-
- pub struct Dl_info {
- pub dli_fname: *const ::c_char,
- pub dli_fbase: *mut ::c_void,
- pub dli_sname: *const ::c_char,
- pub dli_saddr: *mut ::c_void,
- }
-
- pub struct epoll_event {
- pub events: u32,
- pub u64: u64,
- }
-
- 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 sigevent {
- pub sigev_value: ::sigval,
- pub sigev_signo: ::c_int,
- pub sigev_notify: ::c_int,
- 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 rlimit64 {
- pub rlim_cur: rlim64_t,
- pub rlim_max: rlim64_t,
- }
-
- pub struct glob_t {
- pub gl_pathc: ::size_t,
- pub gl_pathv: *mut *mut c_char,
- pub gl_offs: ::size_t,
- pub gl_flags: ::c_int,
-
- __unused1: *mut ::c_void,
- __unused2: *mut ::c_void,
- __unused3: *mut ::c_void,
- __unused4: *mut ::c_void,
- __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
- }
-
- pub struct passwd {
- 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 spwd {
- pub sp_namp: *mut ::c_char,
- pub sp_pwdp: *mut ::c_char,
- pub sp_lstchg: ::c_long,
- pub sp_min: ::c_long,
- pub sp_max: ::c_long,
- pub sp_warn: ::c_long,
- pub sp_inact: ::c_long,
- pub sp_expire: ::c_long,
- 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: u64,
- pub dqb_bsoftlimit: u64,
- pub dqb_curspace: u64,
- pub dqb_ihardlimit: u64,
- pub dqb_isoftlimit: u64,
- pub dqb_curinodes: u64,
- pub dqb_btime: u64,
- pub dqb_itime: u64,
- pub dqb_valid: u32,
- }
-
- pub struct signalfd_siginfo {
- pub ssi_signo: u32,
- pub ssi_errno: i32,
- pub ssi_code: i32,
- pub ssi_pid: u32,
- pub ssi_uid: u32,
- pub ssi_fd: i32,
- pub ssi_tid: u32,
- pub ssi_band: u32,
- pub ssi_overrun: u32,
- pub ssi_trapno: u32,
- pub ssi_status: i32,
- pub ssi_int: i32,
- pub ssi_ptr: u64,
- pub ssi_utime: u64,
- pub ssi_stime: u64,
- pub ssi_addr: u64,
- pub ssi_addr_lsb: u16,
- _pad2: u16,
- pub ssi_syscall: i32,
- pub ssi_call_addr: u64,
- pub ssi_arch: u32,
- _pad: [u8; 28],
- }
-
- pub struct itimerspec {
- pub it_interval: ::timespec,
- pub it_value: ::timespec,
- }
-
- pub struct fsid_t {
- __val: [::c_int; 2],
- }
-
- pub struct cpu_set_t {
- #[cfg(all(target_pointer_width = "32",
- not(target_arch = "x86_64")))]
- bits: [u32; 32],
- #[cfg(not(all(target_pointer_width = "32",
- not(target_arch = "x86_64"))))]
- bits: [u64; 16],
- }
-
- pub struct if_nameindex {
- pub if_index: ::c_uint,
- pub if_name: *mut ::c_char,
- }
-
- // System V IPC
- pub struct msginfo {
- pub msgpool: ::c_int,
- pub msgmap: ::c_int,
- pub msgmax: ::c_int,
- pub msgmnb: ::c_int,
- pub msgmni: ::c_int,
- pub msgssz: ::c_int,
- pub msgtql: ::c_int,
- pub msgseg: ::c_ushort,
- }
-
- pub struct mmsghdr {
- pub msg_hdr: ::msghdr,
- pub msg_len: ::c_uint,
- }
-
- pub struct sembuf {
- pub sem_num: ::c_ushort,
- pub sem_op: ::c_short,
- pub sem_flg: ::c_short,
- }
-
- pub struct input_event {
- pub time: ::timeval,
- pub type_: ::__u16,
- pub code: ::__u16,
- pub value: ::__s32,
- }
-
- pub struct input_id {
- pub bustype: ::__u16,
- pub vendor: ::__u16,
- pub product: ::__u16,
- pub version: ::__u16,
- }
-
- pub struct input_absinfo {
- pub value: ::__s32,
- pub minimum: ::__s32,
- pub maximum: ::__s32,
- pub fuzz: ::__s32,
- pub flat: ::__s32,
- pub resolution: ::__s32,
- }
-
- pub struct input_keymap_entry {
- pub flags: ::__u8,
- pub len: ::__u8,
- pub index: ::__u16,
- pub keycode: ::__u32,
- pub scancode: [::__u8; 32],
- }
-
- pub struct input_mask {
- pub type_: ::__u32,
- pub codes_size: ::__u32,
- pub codes_ptr: ::__u64,
- }
-
- pub struct ff_replay {
- pub length: ::__u16,
- pub delay: ::__u16,
- }
-
- pub struct ff_trigger {
- pub button: ::__u16,
- pub interval: ::__u16,
- }
-
- pub struct ff_envelope {
- pub attack_length: ::__u16,
- pub attack_level: ::__u16,
- pub fade_length: ::__u16,
- pub fade_level: ::__u16,
- }
-
- pub struct ff_constant_effect {
- pub level: ::__s16,
- pub envelope: ff_envelope,
- }
-
- pub struct ff_ramp_effect {
- pub start_level: ::__s16,
- pub end_level: ::__s16,
- pub envelope: ff_envelope,
- }
-
- pub struct ff_condition_effect {
- pub right_saturation: ::__u16,
- pub left_saturation: ::__u16,
-
- pub right_coeff: ::__s16,
- pub left_coeff: ::__s16,
-
- pub deadband: ::__u16,
- pub center: ::__s16,
- }
-
- pub struct ff_periodic_effect {
- pub waveform: ::__u16,
- pub period: ::__u16,
- pub magnitude: ::__s16,
- pub offset: ::__s16,
- pub phase: ::__u16,
-
- pub envelope: ff_envelope,
-
- pub custom_len: ::__u32,
- pub custom_data: *mut ::__s16,
- }
-
- pub struct ff_rumble_effect {
- pub strong_magnitude: ::__u16,
- pub weak_magnitude: ::__u16,
- }
-
- pub struct ff_effect {
- pub type_: ::__u16,
- pub id: ::__s16,
- pub direction: ::__u16,
- pub trigger: ff_trigger,
- pub replay: ff_replay,
- // FIXME this is actually a union
- #[cfg(target_pointer_width = "64")]
- pub u: [u64; 4],
- #[cfg(target_pointer_width = "32")]
- pub u: [u32; 7],
- }
-
- pub struct dl_phdr_info {
- #[cfg(target_pointer_width = "64")]
- pub dlpi_addr: Elf64_Addr,
- #[cfg(target_pointer_width = "32")]
- pub dlpi_addr: Elf32_Addr,
-
- pub dlpi_name: *const ::c_char,
-
- #[cfg(target_pointer_width = "64")]
- pub dlpi_phdr: *const Elf64_Phdr,
- #[cfg(target_pointer_width = "32")]
- pub dlpi_phdr: *const Elf32_Phdr,
-
- #[cfg(target_pointer_width = "64")]
- pub dlpi_phnum: Elf64_Half,
- #[cfg(target_pointer_width = "32")]
- pub dlpi_phnum: Elf32_Half,
-
- pub dlpi_adds: ::c_ulonglong,
- pub dlpi_subs: ::c_ulonglong,
- pub dlpi_tls_modid: ::size_t,
- pub dlpi_tls_data: *mut ::c_void,
- }
-
- pub struct Elf32_Phdr {
- pub p_type: Elf32_Word,
- pub p_offset: Elf32_Off,
- pub p_vaddr: Elf32_Addr,
- pub p_paddr: Elf32_Addr,
- pub p_filesz: Elf32_Word,
- pub p_memsz: Elf32_Word,
- pub p_flags: Elf32_Word,
- pub p_align: Elf32_Word,
- }
-
- pub struct Elf64_Phdr {
- pub p_type: Elf64_Word,
- pub p_flags: Elf64_Word,
- pub p_offset: Elf64_Off,
- pub p_vaddr: Elf64_Addr,
- pub p_paddr: Elf64_Addr,
- pub p_filesz: Elf64_Xword,
- pub p_memsz: Elf64_Xword,
- pub p_align: Elf64_Xword,
- }
-
- 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,
- pub f_fsid: ::c_ulong,
- pub f_flag: ::c_ulong,
- pub f_namemax: ::c_ulong,
- __f_spare: [::c_int; 6],
- }
-
- pub struct stack_t {
- pub ss_sp: *mut ::c_void,
- pub ss_flags: ::c_int,
- pub ss_size: ::size_t
- }
-
- pub struct pthread_attr_t {
- __size: [u64; 7]
- }
-
- pub struct sigset_t {
- __val: [::c_ulong; 16],
- }
-
- pub struct shmid_ds {
- pub shm_perm: ::ipc_perm,
- pub shm_segsz: ::size_t,
- pub shm_atime: ::time_t,
- pub shm_dtime: ::time_t,
- pub shm_ctime: ::time_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,
- pub msg_stime: ::time_t,
- pub msg_rtime: ::time_t,
- 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 msghdr {
- pub msg_name: *mut ::c_void,
- pub msg_namelen: ::socklen_t,
- pub msg_iov: *mut ::iovec,
- pub msg_iovlen: ::c_int,
- __pad1: ::c_int,
- pub msg_control: *mut ::c_void,
- pub msg_controllen: ::socklen_t,
- __pad2: ::socklen_t,
- pub msg_flags: ::c_int,
- }
-
- pub struct cmsghdr {
- pub cmsg_len: ::socklen_t,
- pub __pad1: ::c_int,
- pub cmsg_level: ::c_int,
- pub cmsg_type: ::c_int,
- }
-
- pub struct sem_t {
- __val: [::c_int; 8],
- }
-
- 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 termios2 {
- pub c_iflag: ::tcflag_t,
- pub c_oflag: ::tcflag_t,
- pub c_cflag: ::tcflag_t,
- pub c_lflag: ::tcflag_t,
- pub c_line: ::cc_t,
- pub c_cc: [::cc_t; 19],
- pub c_ispeed: ::speed_t,
- pub c_ospeed: ::speed_t,
- }
-}
-
-s_no_extra_traits! {
- pub struct sysinfo {
- pub uptime: ::c_ulong,
- pub loads: [::c_ulong; 3],
- pub totalram: ::c_ulong,
- pub freeram: ::c_ulong,
- pub sharedram: ::c_ulong,
- pub bufferram: ::c_ulong,
- pub totalswap: ::c_ulong,
- pub freeswap: ::c_ulong,
- pub procs: ::c_ushort,
- pub pad: ::c_ushort,
- pub totalhigh: ::c_ulong,
- pub freehigh: ::c_ulong,
- pub mem_unit: ::c_uint,
- pub __reserved: [::c_char; 256],
- }
-
- pub struct sockaddr_un {
- pub sun_family: sa_family_t,
- pub sun_path: [::c_char; 108]
- }
-
- pub struct sockaddr_storage {
- pub ss_family: sa_family_t,
- __ss_align: ::size_t,
- __ss_pad2: [u8; 128 - 2 * 8],
- }
-
- pub struct utsname {
- pub sysname: [::c_char; 65],
- pub nodename: [::c_char; 65],
- pub release: [::c_char; 65],
- pub version: [::c_char; 65],
- pub machine: [::c_char; 65],
- pub domainname: [::c_char; 65]
- }
-
- pub struct dirent {
- pub d_ino: ::ino_t,
- pub d_off: ::off_t,
- pub d_reclen: ::c_ushort,
- pub d_type: ::c_uchar,
- pub d_name: [::c_char; 256],
- }
-
- pub struct dirent64 {
- pub d_ino: ::ino64_t,
- pub d_off: ::off64_t,
- pub d_reclen: ::c_ushort,
- pub d_type: ::c_uchar,
- pub d_name: [::c_char; 256],
- }
-
- // x32 compatibility
- // See https://sourceware.org/bugzilla/show_bug.cgi?id=21279
- pub struct mq_attr {
- #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
- pub mq_flags: i64,
- #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
- pub mq_maxmsg: i64,
- #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
- pub mq_msgsize: i64,
- #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
- pub mq_curmsgs: i64,
- #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
- pad: [i64; 4],
-
- #[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))]
- pub mq_flags: ::c_long,
- #[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))]
- pub mq_maxmsg: ::c_long,
- #[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))]
- pub mq_msgsize: ::c_long,
- #[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))]
- pub mq_curmsgs: ::c_long,
- #[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))]
- pad: [::c_long; 4],
- }
-
- pub struct sockaddr_nl {
- pub nl_family: ::sa_family_t,
- nl_pad: ::c_ushort,
- pub nl_pid: u32,
- pub nl_groups: u32
- }
-}
-
-cfg_if! {
- if #[cfg(feature = "extra_traits")] {
- impl PartialEq for sysinfo {
- fn eq(&self, other: &sysinfo) -> bool {
- self.uptime == other.uptime
- && self.loads == other.loads
- && self.totalram == other.totalram
- && self.freeram == other.freeram
- && self.sharedram == other.sharedram
- && self.bufferram == other.bufferram
- && self.totalswap == other.totalswap
- && self.freeswap == other.freeswap
- && self.procs == other.procs
- && self.pad == other.pad
- && self.totalhigh == other.totalhigh
- && self.freehigh == other.freehigh
- && self.mem_unit == other.mem_unit
- && self
- .__reserved
- .iter()
- .zip(other.__reserved.iter())
- .all(|(a,b)| a == b)
- }
- }
- impl Eq for sysinfo {}
- impl ::fmt::Debug for sysinfo {
- fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
- f.debug_struct("sysinfo")
- .field("uptime", &self.uptime)
- .field("loads", &self.loads)
- .field("totalram", &self.totalram)
- .field("freeram", &self.freeram)
- .field("sharedram", &self.sharedram)
- .field("bufferram", &self.bufferram)
- .field("totalswap", &self.totalswap)
- .field("freeswap", &self.freeswap)
- .field("procs", &self.procs)
- .field("pad", &self.pad)
- .field("totalhigh", &self.totalhigh)
- .field("freehigh", &self.freehigh)
- .field("mem_unit", &self.mem_unit)
- // FIXME: .field("__reserved", &self.__reserved)
- .finish()
- }
- }
- impl ::hash::Hash for sysinfo {
- fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
- self.uptime.hash(state);
- self.loads.hash(state);
- self.totalram.hash(state);
- self.freeram.hash(state);
- self.sharedram.hash(state);
- self.bufferram.hash(state);
- self.totalswap.hash(state);
- self.freeswap.hash(state);
- self.procs.hash(state);
- self.pad.hash(state);
- self.totalhigh.hash(state);
- self.freehigh.hash(state);
- self.mem_unit.hash(state);
- self.__reserved.hash(state);
- }
- }
-
- impl PartialEq for sockaddr_un {
- fn eq(&self, other: &sockaddr_un) -> bool {
- self.sun_family == other.sun_family
- && self
- .sun_path
- .iter()
- .zip(other.sun_path.iter())
- .all(|(a,b)| a == b)
- }
- }
- impl Eq for sockaddr_un {}
- impl ::fmt::Debug for sockaddr_un {
- fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
- f.debug_struct("sockaddr_un")
- .field("sun_family", &self.sun_family)
- // FIXME: .field("sun_path", &self.sun_path)
- .finish()
- }
- }
- impl ::hash::Hash for sockaddr_un {
- fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
- self.sun_family.hash(state);
- self.sun_path.hash(state);
- }
- }
-
- impl PartialEq for sockaddr_storage {
- fn eq(&self, other: &sockaddr_storage) -> bool {
- self.ss_family == other.ss_family
- && self.__ss_align == other.__ss_align
- && self
- .__ss_pad2
- .iter()
- .zip(other.__ss_pad2.iter())
- .all(|(a, b)| a == b)
- }
- }
- impl Eq for sockaddr_storage {}
- impl ::fmt::Debug for sockaddr_storage {
- fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
- f.debug_struct("sockaddr_storage")
- .field("ss_family", &self.ss_family)
- .field("__ss_align", &self.__ss_align)
- // FIXME: .field("__ss_pad2", &self.__ss_pad2)
- .finish()
- }
- }
- impl ::hash::Hash for sockaddr_storage {
- fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
- self.ss_family.hash(state);
- self.__ss_align.hash(state);
- self.__ss_pad2.hash(state);
- }
- }
-
- impl PartialEq for utsname {
- fn eq(&self, other: &utsname) -> bool {
- self.sysname
- .iter()
- .zip(other.sysname.iter())
- .all(|(a,b)| a == b)
- && self
- .nodename
- .iter()
- .zip(other.nodename.iter())
- .all(|(a,b)| a == b)
- && self
- .release
- .iter()
- .zip(other.release.iter())
- .all(|(a,b)| a == b)
- && self
- .version
- .iter()
- .zip(other.version.iter())
- .all(|(a,b)| a == b)
- && self
- .machine
- .iter()
- .zip(other.machine.iter())
- .all(|(a,b)| a == b)
- }
- }
- impl Eq for utsname {}
- impl ::fmt::Debug for utsname {
- fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
- f.debug_struct("utsname")
- // FIXME: .field("sysname", &self.sysname)
- // FIXME: .field("nodename", &self.nodename)
- // FIXME: .field("release", &self.release)
- // FIXME: .field("version", &self.version)
- // FIXME: .field("machine", &self.machine)
- .finish()
- }
- }
- impl ::hash::Hash for utsname {
- fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
- self.sysname.hash(state);
- self.nodename.hash(state);
- self.release.hash(state);
- self.version.hash(state);
- self.machine.hash(state);
- }
- }
-
- impl PartialEq for dirent {
- fn eq(&self, other: &dirent) -> bool {
- self.d_ino == other.d_ino
- && self.d_off == other.d_off
- && self.d_reclen == other.d_reclen
- && self.d_type == other.d_type
- && self
- .d_name
- .iter()
- .zip(other.d_name.iter())
- .all(|(a,b)| a == b)
- }
- }
- impl Eq for dirent {}
- impl ::fmt::Debug for dirent {
- fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
- f.debug_struct("dirent")
- .field("d_ino", &self.d_ino)
- .field("d_off", &self.d_off)
- .field("d_reclen", &self.d_reclen)
- .field("d_type", &self.d_type)
- // FIXME: .field("d_name", &self.d_name)
- .finish()
- }
- }
- impl ::hash::Hash for dirent {
- fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
- self.d_ino.hash(state);
- self.d_off.hash(state);
- self.d_reclen.hash(state);
- self.d_type.hash(state);
- self.d_name.hash(state);
- }
- }
-
- impl PartialEq for dirent64 {
- fn eq(&self, other: &dirent64) -> bool {
- self.d_ino == other.d_ino
- && self.d_off == other.d_off
- && self.d_reclen == other.d_reclen
- && self.d_type == other.d_type
- && self
- .d_name
- .iter()
- .zip(other.d_name.iter())
- .all(|(a,b)| a == b)
- }
- }
- impl Eq for dirent64 {}
- impl ::fmt::Debug for dirent64 {
- fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
- f.debug_struct("dirent64")
- .field("d_ino", &self.d_ino)
- .field("d_off", &self.d_off)
- .field("d_reclen", &self.d_reclen)
- .field("d_type", &self.d_type)
- // FIXME: .field("d_name", &self.d_name)
- .finish()
- }
- }
- impl ::hash::Hash for dirent64 {
- fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
- self.d_ino.hash(state);
- self.d_off.hash(state);
- self.d_reclen.hash(state);
- self.d_type.hash(state);
- self.d_name.hash(state);
- }
- }
-
- impl PartialEq for mq_attr {
- fn eq(&self, other: &mq_attr) -> bool {
- self.mq_flags == other.mq_flags &&
- self.mq_maxmsg == other.mq_maxmsg &&
- self.mq_msgsize == other.mq_msgsize &&
- self.mq_curmsgs == other.mq_curmsgs
- }
- }
- impl Eq for mq_attr {}
- impl ::fmt::Debug for mq_attr {
- fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
- f.debug_struct("mq_attr")
- .field("mq_flags", &self.mq_flags)
- .field("mq_maxmsg", &self.mq_maxmsg)
- .field("mq_msgsize", &self.mq_msgsize)
- .field("mq_curmsgs", &self.mq_curmsgs)
- .finish()
- }
- }
- impl ::hash::Hash for mq_attr {
- fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
- self.mq_flags.hash(state);
- self.mq_maxmsg.hash(state);
- self.mq_msgsize.hash(state);
- self.mq_curmsgs.hash(state);
- }
- }
-
- impl PartialEq for sockaddr_nl {
- fn eq(&self, other: &sockaddr_nl) -> bool {
- self.nl_family == other.nl_family &&
- self.nl_pid == other.nl_pid &&
- self.nl_groups == other.nl_groups
- }
- }
- impl Eq for sockaddr_nl {}
- impl ::fmt::Debug for sockaddr_nl {
- fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
- f.debug_struct("sockaddr_nl")
- .field("nl_family", &self.nl_family)
- .field("nl_pid", &self.nl_pid)
- .field("nl_groups", &self.nl_groups)
- .finish()
- }
- }
- impl ::hash::Hash for sockaddr_nl {
- fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
- self.nl_family.hash(state);
- self.nl_pid.hash(state);
- self.nl_groups.hash(state);
- }
- }
- }
-}
-
-// 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;
-
-pub const DT_FIFO: u8 = 1;
-pub const DT_CHR: u8 = 2;
-pub const DT_DIR: u8 = 4;
-pub const DT_BLK: u8 = 6;
-pub const DT_REG: u8 = 8;
-pub const DT_LNK: u8 = 10;
-pub const DT_SOCK: u8 = 12;
-
-pub const FD_CLOEXEC: ::c_int = 0x1;
-
-pub const USRQUOTA: ::c_int = 0;
-pub const GRPQUOTA: ::c_int = 1;
-
-pub const SIGIOT: ::c_int = 6;
-
-pub const S_ISUID: ::c_int = 0x800;
-pub const S_ISGID: ::c_int = 0x400;
-pub const S_ISVTX: ::c_int = 0x200;
-
-pub const IF_NAMESIZE: ::size_t = 16;
-
-pub const LOG_EMERG: ::c_int = 0;
-pub const LOG_ALERT: ::c_int = 1;
-pub const LOG_CRIT: ::c_int = 2;
-pub const LOG_ERR: ::c_int = 3;
-pub const LOG_WARNING: ::c_int = 4;
-pub const LOG_NOTICE: ::c_int = 5;
-pub const LOG_INFO: ::c_int = 6;
-pub const LOG_DEBUG: ::c_int = 7;
-
-pub const LOG_KERN: ::c_int = 0;
-pub const LOG_USER: ::c_int = 1 << 3;
-pub const LOG_MAIL: ::c_int = 2 << 3;
-pub const LOG_DAEMON: ::c_int = 3 << 3;
-pub const LOG_AUTH: ::c_int = 4 << 3;
-pub const LOG_SYSLOG: ::c_int = 5 << 3;
-pub const LOG_LPR: ::c_int = 6 << 3;
-pub const LOG_NEWS: ::c_int = 7 << 3;
-pub const LOG_UUCP: ::c_int = 8 << 3;
-pub const LOG_LOCAL0: ::c_int = 16 << 3;
-pub const LOG_LOCAL1: ::c_int = 17 << 3;
-pub const LOG_LOCAL2: ::c_int = 18 << 3;
-pub const LOG_LOCAL3: ::c_int = 19 << 3;
-pub const LOG_LOCAL4: ::c_int = 20 << 3;
-pub const LOG_LOCAL5: ::c_int = 21 << 3;
-pub const LOG_LOCAL6: ::c_int = 22 << 3;
-pub const LOG_LOCAL7: ::c_int = 23 << 3;
-
-pub const LOG_PID: ::c_int = 0x01;
-pub const LOG_CONS: ::c_int = 0x02;
-pub const LOG_ODELAY: ::c_int = 0x04;
-pub const LOG_NDELAY: ::c_int = 0x08;
-pub const LOG_NOWAIT: ::c_int = 0x10;
-
-pub const LOG_PRIMASK: ::c_int = 7;
-pub const LOG_FACMASK: ::c_int = 0x3f8;
-
-pub const PRIO_PROCESS: ::c_int = 0;
-pub const PRIO_PGRP: ::c_int = 1;
-pub const PRIO_USER: ::c_int = 2;
-
-pub const PRIO_MIN: ::c_int = -20;
-pub const PRIO_MAX: ::c_int = 20;
-
-pub const IPPROTO_ICMP: ::c_int = 1;
-pub const IPPROTO_ICMPV6: ::c_int = 58;
-pub const IPPROTO_TCP: ::c_int = 6;
-pub const IPPROTO_UDP: ::c_int = 17;
-pub const IPPROTO_IP: ::c_int = 0;
-pub const IPPROTO_IPV6: ::c_int = 41;
-
-pub const INADDR_LOOPBACK: in_addr_t = 2130706433;
-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 EXIT_FAILURE: ::c_int = 1;
-pub const EXIT_SUCCESS: ::c_int = 0;
-pub const RAND_MAX: ::c_int = 2147483647;
-pub const EOF: ::c_int = -1;
-pub const SEEK_SET: ::c_int = 0;
-pub const SEEK_CUR: ::c_int = 1;
-pub const SEEK_END: ::c_int = 2;
-pub const _IOFBF: ::c_int = 0;
-pub const _IONBF: ::c_int = 2;
-pub const _IOLBF: ::c_int = 1;
-
-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;
-
-// Linux-specific fcntls
-pub const F_SETLEASE: ::c_int = 1024;
-pub const F_GETLEASE: ::c_int = 1025;
-pub const F_NOTIFY: ::c_int = 1026;
-pub const F_CANCELLK: ::c_int = 1029;
-pub const F_DUPFD_CLOEXEC: ::c_int = 1030;
-pub const F_SETPIPE_SZ: ::c_int = 1031;
-pub const F_GETPIPE_SZ: ::c_int = 1032;
-pub const F_ADD_SEALS: ::c_int = 1033;
-pub const F_GET_SEALS: ::c_int = 1034;
-
-pub const F_SEAL_SEAL: ::c_int = 0x0001;
-pub const F_SEAL_SHRINK: ::c_int = 0x0002;
-pub const F_SEAL_GROW: ::c_int = 0x0004;
-pub const F_SEAL_WRITE: ::c_int = 0x0008;
-
-// TODO(#235): Include file sealing fcntls once we have a way to verify them.
-
-pub const SIGTRAP: ::c_int = 5;
-
-pub const PTHREAD_CREATE_JOINABLE: ::c_int = 0;
-pub const PTHREAD_CREATE_DETACHED: ::c_int = 1;
-
-pub const CLOCK_REALTIME: ::clockid_t = 0;
-pub const CLOCK_MONOTONIC: ::clockid_t = 1;
-pub const CLOCK_PROCESS_CPUTIME_ID: ::clockid_t = 2;
-pub const CLOCK_THREAD_CPUTIME_ID: ::clockid_t = 3;
-pub const CLOCK_MONOTONIC_RAW: ::clockid_t = 4;
-pub const CLOCK_REALTIME_COARSE: ::clockid_t = 5;
-pub const CLOCK_MONOTONIC_COARSE: ::clockid_t = 6;
-pub const CLOCK_BOOTTIME: ::clockid_t = 7;
-pub const CLOCK_REALTIME_ALARM: ::clockid_t = 8;
-pub const CLOCK_BOOTTIME_ALARM: ::clockid_t = 9;
-// TODO(#247) Someday our Travis shall have glibc 2.21 (released in Sep
-// 2014.) See also musl/mod.rs
-// pub const CLOCK_SGI_CYCLE: ::clockid_t = 10;
-// pub const CLOCK_TAI: ::clockid_t = 11;
-pub const TIMER_ABSTIME: ::c_int = 1;
-
-pub const RLIMIT_CPU: ::c_int = 0;
-pub const RLIMIT_FSIZE: ::c_int = 1;
-pub const RLIMIT_DATA: ::c_int = 2;
-pub const RLIMIT_STACK: ::c_int = 3;
-pub const RLIMIT_CORE: ::c_int = 4;
-pub const RLIMIT_LOCKS: ::c_int = 10;
-pub const RLIMIT_SIGPENDING: ::c_int = 11;
-pub const RLIMIT_MSGQUEUE: ::c_int = 12;
-pub const RLIMIT_NICE: ::c_int = 13;
-pub const RLIMIT_RTPRIO: ::c_int = 14;
-
-pub const RUSAGE_SELF: ::c_int = 0;
-
-pub const O_RDONLY: ::c_int = 0;
-pub const O_WRONLY: ::c_int = 1;
-pub const O_RDWR: ::c_int = 2;
-
-pub const SOCK_CLOEXEC: ::c_int = O_CLOEXEC;
-
-pub const S_IFIFO: ::mode_t = 4096;
-pub const S_IFCHR: ::mode_t = 8192;
-pub const S_IFBLK: ::mode_t = 24576;
-pub const S_IFDIR: ::mode_t = 16384;
-pub const S_IFREG: ::mode_t = 32768;
-pub const S_IFLNK: ::mode_t = 40960;
-pub const S_IFSOCK: ::mode_t = 49152;
-pub const S_IFMT: ::mode_t = 61440;
-pub const S_IRWXU: ::mode_t = 448;
-pub const S_IXUSR: ::mode_t = 64;
-pub const S_IWUSR: ::mode_t = 128;
-pub const S_IRUSR: ::mode_t = 256;
-pub const S_IRWXG: ::mode_t = 56;
-pub const S_IXGRP: ::mode_t = 8;
-pub const S_IWGRP: ::mode_t = 16;
-pub const S_IRGRP: ::mode_t = 32;
-pub const S_IRWXO: ::mode_t = 7;
-pub const S_IXOTH: ::mode_t = 1;
-pub const S_IWOTH: ::mode_t = 2;
-pub const S_IROTH: ::mode_t = 4;
-pub const F_OK: ::c_int = 0;
-pub const R_OK: ::c_int = 4;
-pub const W_OK: ::c_int = 2;
-pub const X_OK: ::c_int = 1;
-pub const STDIN_FILENO: ::c_int = 0;
-pub const STDOUT_FILENO: ::c_int = 1;
-pub const STDERR_FILENO: ::c_int = 2;
-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 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 PROT_NONE: ::c_int = 0;
-pub const PROT_READ: ::c_int = 1;
-pub const PROT_WRITE: ::c_int = 2;
-pub const PROT_EXEC: ::c_int = 4;
-
-pub const LC_CTYPE: ::c_int = 0;
-pub const LC_NUMERIC: ::c_int = 1;
-pub const LC_TIME: ::c_int = 2;
-pub const LC_COLLATE: ::c_int = 3;
-pub const LC_MONETARY: ::c_int = 4;
-pub const LC_MESSAGES: ::c_int = 5;
-pub const LC_ALL: ::c_int = 6;
-pub const LC_CTYPE_MASK: ::c_int = (1 << LC_CTYPE);
-pub const LC_NUMERIC_MASK: ::c_int = (1 << LC_NUMERIC);
-pub const LC_TIME_MASK: ::c_int = (1 << LC_TIME);
-pub const LC_COLLATE_MASK: ::c_int = (1 << LC_COLLATE);
-pub const LC_MONETARY_MASK: ::c_int = (1 << LC_MONETARY);
-pub const LC_MESSAGES_MASK: ::c_int = (1 << LC_MESSAGES);
-// LC_ALL_MASK defined per platform
-
-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_FAILED: *mut ::c_void = !0 as *mut ::c_void;
-
-// MS_ flags for msync(2)
-pub const MS_ASYNC: ::c_int = 0x0001;
-pub const MS_INVALIDATE: ::c_int = 0x0002;
-pub const MS_SYNC: ::c_int = 0x0004;
-
-// MS_ flags for mount(2)
-pub const MS_RDONLY: ::c_ulong = 0x01;
-pub const MS_NOSUID: ::c_ulong = 0x02;
-pub const MS_NODEV: ::c_ulong = 0x04;
-pub const MS_NOEXEC: ::c_ulong = 0x08;
-pub const MS_SYNCHRONOUS: ::c_ulong = 0x10;
-pub const MS_REMOUNT: ::c_ulong = 0x20;
-pub const MS_MANDLOCK: ::c_ulong = 0x40;
-pub const MS_DIRSYNC: ::c_ulong = 0x80;
-pub const MS_NOATIME: ::c_ulong = 0x0400;
-pub const MS_NODIRATIME: ::c_ulong = 0x0800;
-pub const MS_BIND: ::c_ulong = 0x1000;
-pub const MS_MOVE: ::c_ulong = 0x2000;
-pub const MS_REC: ::c_ulong = 0x4000;
-pub const MS_SILENT: ::c_ulong = 0x8000;
-pub const MS_POSIXACL: ::c_ulong = 0x010000;
-pub const MS_UNBINDABLE: ::c_ulong = 0x020000;
-pub const MS_PRIVATE: ::c_ulong = 0x040000;
-pub const MS_SLAVE: ::c_ulong = 0x080000;
-pub const MS_SHARED: ::c_ulong = 0x100000;
-pub const MS_RELATIME: ::c_ulong = 0x200000;
-pub const MS_KERNMOUNT: ::c_ulong = 0x400000;
-pub const MS_I_VERSION: ::c_ulong = 0x800000;
-pub const MS_STRICTATIME: ::c_ulong = 0x1000000;
-pub const MS_ACTIVE: ::c_ulong = 0x40000000;
-pub const MS_NOUSER: ::c_ulong = 0x80000000;
-pub const MS_MGC_VAL: ::c_ulong = 0xc0ed0000;
-pub const MS_MGC_MSK: ::c_ulong = 0xffff0000;
-pub const MS_RMT_MASK: ::c_ulong = 0x800051;
-
-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 ENOTBLK: ::c_int = 15;
-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 EWOULDBLOCK: ::c_int = EAGAIN;
-
-pub const SCM_RIGHTS: ::c_int = 0x01;
-pub const SCM_CREDENTIALS: ::c_int = 0x02;
-
-pub const PROT_GROWSDOWN: ::c_int = 0x1000000;
-pub const PROT_GROWSUP: ::c_int = 0x2000000;
-
-pub const MAP_TYPE: ::c_int = 0x000f;
-
-pub const MADV_NORMAL: ::c_int = 0;
-pub const MADV_RANDOM: ::c_int = 1;
-pub const MADV_SEQUENTIAL: ::c_int = 2;
-pub const MADV_WILLNEED: ::c_int = 3;
-pub const MADV_DONTNEED: ::c_int = 4;
-pub const MADV_FREE: ::c_int = 8;
-pub const MADV_REMOVE: ::c_int = 9;
-pub const MADV_DONTFORK: ::c_int = 10;
-pub const MADV_DOFORK: ::c_int = 11;
-pub const MADV_MERGEABLE: ::c_int = 12;
-pub const MADV_UNMERGEABLE: ::c_int = 13;
-pub const MADV_HUGEPAGE: ::c_int = 14;
-pub const MADV_NOHUGEPAGE: ::c_int = 15;
-pub const MADV_DONTDUMP: ::c_int = 16;
-pub const MADV_DODUMP: ::c_int = 17;
-pub const MADV_HWPOISON: ::c_int = 100;
-pub const MADV_SOFT_OFFLINE: ::c_int = 101;
-
-pub const IFF_UP: ::c_int = 0x1;
-pub const IFF_BROADCAST: ::c_int = 0x2;
-pub const IFF_DEBUG: ::c_int = 0x4;
-pub const IFF_LOOPBACK: ::c_int = 0x8;
-pub const IFF_POINTOPOINT: ::c_int = 0x10;
-pub const IFF_NOTRAILERS: ::c_int = 0x20;
-pub const IFF_RUNNING: ::c_int = 0x40;
-pub const IFF_NOARP: ::c_int = 0x80;
-pub const IFF_PROMISC: ::c_int = 0x100;
-pub const IFF_ALLMULTI: ::c_int = 0x200;
-pub const IFF_MASTER: ::c_int = 0x400;
-pub const IFF_SLAVE: ::c_int = 0x800;
-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;
-pub const SOL_UDP: ::c_int = 17;
-pub const SOL_IPV6: ::c_int = 41;
-pub const SOL_ICMPV6: ::c_int = 58;
-pub const SOL_RAW: ::c_int = 255;
-pub const SOL_DECNET: ::c_int = 261;
-pub const SOL_X25: ::c_int = 262;
-pub const SOL_PACKET: ::c_int = 263;
-pub const SOL_ATM: ::c_int = 264;
-pub const SOL_AAL: ::c_int = 265;
-pub const SOL_IRDA: ::c_int = 266;
-pub const SOL_NETBEUI: ::c_int = 267;
-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 AF_UNSPEC: ::c_int = 0;
-pub const AF_UNIX: ::c_int = 1;
-pub const AF_LOCAL: ::c_int = 1;
-pub const AF_INET: ::c_int = 2;
-pub const AF_AX25: ::c_int = 3;
-pub const AF_IPX: ::c_int = 4;
-pub const AF_APPLETALK: ::c_int = 5;
-pub const AF_NETROM: ::c_int = 6;
-pub const AF_BRIDGE: ::c_int = 7;
-pub const AF_ATMPVC: ::c_int = 8;
-pub const AF_X25: ::c_int = 9;
-pub const AF_INET6: ::c_int = 10;
-pub const AF_ROSE: ::c_int = 11;
-pub const AF_DECnet: ::c_int = 12;
-pub const AF_NETBEUI: ::c_int = 13;
-pub const AF_SECURITY: ::c_int = 14;
-pub const AF_KEY: ::c_int = 15;
-pub const AF_NETLINK: ::c_int = 16;
-pub const AF_ROUTE: ::c_int = AF_NETLINK;
-pub const AF_PACKET: ::c_int = 17;
-pub const AF_ASH: ::c_int = 18;
-pub const AF_ECONET: ::c_int = 19;
-pub const AF_ATMSVC: ::c_int = 20;
-pub const AF_RDS: ::c_int = 21;
-pub const AF_SNA: ::c_int = 22;
-pub const AF_IRDA: ::c_int = 23;
-pub const AF_PPPOX: ::c_int = 24;
-pub const AF_WANPIPE: ::c_int = 25;
-pub const AF_LLC: ::c_int = 26;
-pub const AF_CAN: ::c_int = 29;
-pub const AF_TIPC: ::c_int = 30;
-pub const AF_BLUETOOTH: ::c_int = 31;
-pub const AF_IUCV: ::c_int = 32;
-pub const AF_RXRPC: ::c_int = 33;
-pub const AF_ISDN: ::c_int = 34;
-pub const AF_PHONET: ::c_int = 35;
-pub const AF_IEEE802154: ::c_int = 36;
-pub const AF_CAIF: ::c_int = 37;
-pub const AF_ALG: ::c_int = 38;
-
-pub const PF_UNSPEC: ::c_int = AF_UNSPEC;
-pub const PF_UNIX: ::c_int = AF_UNIX;
-pub const PF_LOCAL: ::c_int = AF_LOCAL;
-pub const PF_INET: ::c_int = AF_INET;
-pub const PF_AX25: ::c_int = AF_AX25;
-pub const PF_IPX: ::c_int = AF_IPX;
-pub const PF_APPLETALK: ::c_int = AF_APPLETALK;
-pub const PF_NETROM: ::c_int = AF_NETROM;
-pub const PF_BRIDGE: ::c_int = AF_BRIDGE;
-pub const PF_ATMPVC: ::c_int = AF_ATMPVC;
-pub const PF_X25: ::c_int = AF_X25;
-pub const PF_INET6: ::c_int = AF_INET6;
-pub const PF_ROSE: ::c_int = AF_ROSE;
-pub const PF_DECnet: ::c_int = AF_DECnet;
-pub const PF_NETBEUI: ::c_int = AF_NETBEUI;
-pub const PF_SECURITY: ::c_int = AF_SECURITY;
-pub const PF_KEY: ::c_int = AF_KEY;
-pub const PF_NETLINK: ::c_int = AF_NETLINK;
-pub const PF_ROUTE: ::c_int = AF_ROUTE;
-pub const PF_PACKET: ::c_int = AF_PACKET;
-pub const PF_ASH: ::c_int = AF_ASH;
-pub const PF_ECONET: ::c_int = AF_ECONET;
-pub const PF_ATMSVC: ::c_int = AF_ATMSVC;
-pub const PF_RDS: ::c_int = AF_RDS;
-pub const PF_SNA: ::c_int = AF_SNA;
-pub const PF_IRDA: ::c_int = AF_IRDA;
-pub const PF_PPPOX: ::c_int = AF_PPPOX;
-pub const PF_WANPIPE: ::c_int = AF_WANPIPE;
-pub const PF_LLC: ::c_int = AF_LLC;
-pub const PF_CAN: ::c_int = AF_CAN;
-pub const PF_TIPC: ::c_int = AF_TIPC;
-pub const PF_BLUETOOTH: ::c_int = AF_BLUETOOTH;
-pub const PF_IUCV: ::c_int = AF_IUCV;
-pub const PF_RXRPC: ::c_int = AF_RXRPC;
-pub const PF_ISDN: ::c_int = AF_ISDN;
-pub const PF_PHONET: ::c_int = AF_PHONET;
-pub const PF_IEEE802154: ::c_int = AF_IEEE802154;
-pub const PF_CAIF: ::c_int = AF_CAIF;
-pub const PF_ALG: ::c_int = AF_ALG;
-
-pub const SOMAXCONN: ::c_int = 128;
-
-pub const MSG_OOB: ::c_int = 1;
-pub const MSG_PEEK: ::c_int = 2;
-pub const MSG_DONTROUTE: ::c_int = 4;
-pub const MSG_CTRUNC: ::c_int = 8;
-pub const MSG_TRUNC: ::c_int = 0x20;
-pub const MSG_DONTWAIT: ::c_int = 0x40;
-pub const MSG_EOR: ::c_int = 0x80;
-pub const MSG_WAITALL: ::c_int = 0x100;
-pub const MSG_FIN: ::c_int = 0x200;
-pub const MSG_SYN: ::c_int = 0x400;
-pub const MSG_CONFIRM: ::c_int = 0x800;
-pub const MSG_RST: ::c_int = 0x1000;
-pub const MSG_ERRQUEUE: ::c_int = 0x2000;
-pub const MSG_NOSIGNAL: ::c_int = 0x4000;
-pub const MSG_MORE: ::c_int = 0x8000;
-pub const MSG_WAITFORONE: ::c_int = 0x10000;
-pub const MSG_FASTOPEN: ::c_int = 0x20000000;
-pub const MSG_CMSG_CLOEXEC: ::c_int = 0x40000000;
-
-pub const SCM_TIMESTAMP: ::c_int = SO_TIMESTAMP;
-
-pub const SOCK_RAW: ::c_int = 3;
-pub const SOCK_RDM: ::c_int = 4;
-pub const IP_MULTICAST_IF: ::c_int = 32;
-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_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;
-pub const TCP_CORK: ::c_int = 3;
-pub const TCP_KEEPIDLE: ::c_int = 4;
-pub const TCP_KEEPINTVL: ::c_int = 5;
-pub const TCP_KEEPCNT: ::c_int = 6;
-pub const TCP_SYNCNT: ::c_int = 7;
-pub const TCP_LINGER2: ::c_int = 8;
-pub const TCP_DEFER_ACCEPT: ::c_int = 9;
-pub const TCP_WINDOW_CLAMP: ::c_int = 10;
-pub const TCP_INFO: ::c_int = 11;
-pub const TCP_QUICKACK: ::c_int = 12;
-pub const TCP_CONGESTION: ::c_int = 13;
-
-pub const SO_DEBUG: ::c_int = 1;
-
-pub const SHUT_RD: ::c_int = 0;
-pub const SHUT_WR: ::c_int = 1;
-pub const SHUT_RDWR: ::c_int = 2;
-
-pub const LOCK_SH: ::c_int = 1;
-pub const LOCK_EX: ::c_int = 2;
-pub const LOCK_NB: ::c_int = 4;
-pub const LOCK_UN: ::c_int = 8;
-
-pub const SS_ONSTACK: ::c_int = 1;
-pub const SS_DISABLE: ::c_int = 2;
-
-pub const PATH_MAX: ::c_int = 4096;
-
-pub const FD_SETSIZE: usize = 1024;
-
-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 EPOLL_CTL_ADD: ::c_int = 1;
-pub const EPOLL_CTL_MOD: ::c_int = 3;
-pub const EPOLL_CTL_DEL: ::c_int = 2;
-
-pub const MNT_DETACH: ::c_int = 0x2;
-pub const MNT_EXPIRE: ::c_int = 0x4;
-
-pub const Q_GETFMT: ::c_int = 0x800004;
-pub const Q_GETINFO: ::c_int = 0x800005;
-pub const Q_SETINFO: ::c_int = 0x800006;
-pub const QIF_BLIMITS: u32 = 1;
-pub const QIF_SPACE: u32 = 2;
-pub const QIF_ILIMITS: u32 = 4;
-pub const QIF_INODES: u32 = 8;
-pub const QIF_BTIME: u32 = 16;
-pub const QIF_ITIME: u32 = 32;
-pub const QIF_LIMITS: u32 = 5;
-pub const QIF_USAGE: u32 = 10;
-pub const QIF_TIMES: u32 = 48;
-pub const QIF_ALL: u32 = 63;
-
-pub const MNT_FORCE: ::c_int = 0x1;
-
-pub const Q_SYNC: ::c_int = 0x800001;
-pub const Q_QUOTAON: ::c_int = 0x800002;
-pub const Q_QUOTAOFF: ::c_int = 0x800003;
-pub const Q_GETQUOTA: ::c_int = 0x800007;
-pub const Q_SETQUOTA: ::c_int = 0x800008;
-
-pub const TCIOFF: ::c_int = 2;
-pub const TCION: ::c_int = 3;
-pub const TCOOFF: ::c_int = 0;
-pub const TCOON: ::c_int = 1;
-pub const TCIFLUSH: ::c_int = 0;
-pub const TCOFLUSH: ::c_int = 1;
-pub const TCIOFLUSH: ::c_int = 2;
-pub const NL0: ::c_int = 0x00000000;
-pub const NL1: ::c_int = 0x00000100;
-pub const TAB0: ::c_int = 0x00000000;
-pub const CR0: ::c_int = 0x00000000;
-pub const FF0: ::c_int = 0x00000000;
-pub const BS0: ::c_int = 0x00000000;
-pub const VT0: ::c_int = 0x00000000;
-pub const VERASE: usize = 2;
-pub const VKILL: usize = 3;
-pub const VINTR: usize = 0;
-pub const VQUIT: usize = 1;
-pub const VLNEXT: usize = 15;
-pub const IGNBRK: ::tcflag_t = 0x00000001;
-pub const BRKINT: ::tcflag_t = 0x00000002;
-pub const IGNPAR: ::tcflag_t = 0x00000004;
-pub const PARMRK: ::tcflag_t = 0x00000008;
-pub const INPCK: ::tcflag_t = 0x00000010;
-pub const ISTRIP: ::tcflag_t = 0x00000020;
-pub const INLCR: ::tcflag_t = 0x00000040;
-pub const IGNCR: ::tcflag_t = 0x00000080;
-pub const ICRNL: ::tcflag_t = 0x00000100;
-pub const IXANY: ::tcflag_t = 0x00000800;
-pub const IMAXBEL: ::tcflag_t = 0x00002000;
-pub const OPOST: ::tcflag_t = 0x1;
-pub const CS5: ::tcflag_t = 0x00000000;
-pub const CRTSCTS: ::tcflag_t = 0x80000000;
-pub const ECHO: ::tcflag_t = 0x00000008;
-pub const OCRNL: ::tcflag_t = 0o000010;
-pub const ONOCR: ::tcflag_t = 0o000020;
-pub const ONLRET: ::tcflag_t = 0o000040;
-pub const OFILL: ::tcflag_t = 0o000100;
-pub const OFDEL: ::tcflag_t = 0o000200;
-
-pub const CLONE_VM: ::c_int = 0x100;
-pub const CLONE_FS: ::c_int = 0x200;
-pub const CLONE_FILES: ::c_int = 0x400;
-pub const CLONE_SIGHAND: ::c_int = 0x800;
-pub const CLONE_PTRACE: ::c_int = 0x2000;
-pub const CLONE_VFORK: ::c_int = 0x4000;
-pub const CLONE_PARENT: ::c_int = 0x8000;
-pub const CLONE_THREAD: ::c_int = 0x10000;
-pub const CLONE_NEWNS: ::c_int = 0x20000;
-pub const CLONE_SYSVSEM: ::c_int = 0x40000;
-pub const CLONE_SETTLS: ::c_int = 0x80000;
-pub const CLONE_PARENT_SETTID: ::c_int = 0x100000;
-pub const CLONE_CHILD_CLEARTID: ::c_int = 0x200000;
-pub const CLONE_DETACHED: ::c_int = 0x400000;
-pub const CLONE_UNTRACED: ::c_int = 0x800000;
-pub const CLONE_CHILD_SETTID: ::c_int = 0x01000000;
-pub const CLONE_NEWUTS: ::c_int = 0x04000000;
-pub const CLONE_NEWIPC: ::c_int = 0x08000000;
-pub const CLONE_NEWUSER: ::c_int = 0x10000000;
-pub const CLONE_NEWPID: ::c_int = 0x20000000;
-pub const CLONE_NEWNET: ::c_int = 0x40000000;
-pub const CLONE_IO: ::c_int = 0x80000000;
-pub const CLONE_NEWCGROUP: ::c_int = 0x02000000;
-
-pub const WNOHANG: ::c_int = 0x00000001;
-pub const WUNTRACED: ::c_int = 0x00000002;
-pub const WSTOPPED: ::c_int = WUNTRACED;
-pub const WEXITED: ::c_int = 0x00000004;
-pub const WCONTINUED: ::c_int = 0x00000008;
-pub const WNOWAIT: ::c_int = 0x01000000;
-
-// ::Options set using PTRACE_SETOPTIONS.
-pub const PTRACE_O_TRACESYSGOOD: ::c_int = 0x00000001;
-pub const PTRACE_O_TRACEFORK: ::c_int = 0x00000002;
-pub const PTRACE_O_TRACEVFORK: ::c_int = 0x00000004;
-pub const PTRACE_O_TRACECLONE: ::c_int = 0x00000008;
-pub const PTRACE_O_TRACEEXEC: ::c_int = 0x00000010;
-pub const PTRACE_O_TRACEVFORKDONE: ::c_int = 0x00000020;
-pub const PTRACE_O_TRACEEXIT: ::c_int = 0x00000040;
-pub const PTRACE_O_TRACESECCOMP: ::c_int = 0x00000080;
-pub const PTRACE_O_EXITKILL: ::c_int = 0x00100000;
-pub const PTRACE_O_SUSPEND_SECCOMP: ::c_int = 0x00200000;
-pub const PTRACE_O_MASK: ::c_int = 0x003000ff;
-
-// Wait extended result codes for the above trace options.
-pub const PTRACE_EVENT_FORK: ::c_int = 1;
-pub const PTRACE_EVENT_VFORK: ::c_int = 2;
-pub const PTRACE_EVENT_CLONE: ::c_int = 3;
-pub const PTRACE_EVENT_EXEC: ::c_int = 4;
-pub const PTRACE_EVENT_VFORK_DONE: ::c_int = 5;
-pub const PTRACE_EVENT_EXIT: ::c_int = 6;
-pub const PTRACE_EVENT_SECCOMP: ::c_int = 7;
-// PTRACE_EVENT_STOP was added to glibc in 2.26
-// pub const PTRACE_EVENT_STOP: ::c_int = 128;
-
-pub const __WNOTHREAD: ::c_int = 0x20000000;
-pub const __WALL: ::c_int = 0x40000000;
-pub const __WCLONE: ::c_int = 0x80000000;
-
-pub const SPLICE_F_MOVE: ::c_uint = 0x01;
-pub const SPLICE_F_NONBLOCK: ::c_uint = 0x02;
-pub const SPLICE_F_MORE: ::c_uint = 0x04;
-pub const SPLICE_F_GIFT: ::c_uint = 0x08;
-
-pub const RTLD_LOCAL: ::c_int = 0;
-pub const RTLD_LAZY: ::c_int = 1;
-
-pub const POSIX_FADV_NORMAL: ::c_int = 0;
-pub const POSIX_FADV_RANDOM: ::c_int = 1;
-pub const POSIX_FADV_SEQUENTIAL: ::c_int = 2;
-pub const POSIX_FADV_WILLNEED: ::c_int = 3;
-
-pub const AT_FDCWD: ::c_int = -100;
-pub const AT_SYMLINK_NOFOLLOW: ::c_int = 0x100;
-pub const AT_REMOVEDIR: ::c_int = 0x200;
-pub const AT_SYMLINK_FOLLOW: ::c_int = 0x400;
-pub const AT_NO_AUTOMOUNT: ::c_int = 0x800;
-pub const AT_EMPTY_PATH: ::c_int = 0x1000;
-
-pub const LOG_CRON: ::c_int = 9 << 3;
-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 PIPE_BUF: usize = 4096;
-
-pub const SI_LOAD_SHIFT: ::c_uint = 16;
-
-pub const SIGEV_SIGNAL: ::c_int = 0;
-pub const SIGEV_NONE: ::c_int = 1;
-pub const SIGEV_THREAD: ::c_int = 2;
-
-pub const P_ALL: idtype_t = 0;
-pub const P_PID: idtype_t = 1;
-pub const P_PGID: idtype_t = 2;
-
-pub const UTIME_OMIT: c_long = 1073741822;
-pub const UTIME_NOW: c_long = 1073741823;
-
-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 POLLRDNORM: ::c_short = 0x040;
-pub const POLLRDBAND: ::c_short = 0x080;
-
-pub const ABDAY_1: ::nl_item = 0x20000;
-pub const ABDAY_2: ::nl_item = 0x20001;
-pub const ABDAY_3: ::nl_item = 0x20002;
-pub const ABDAY_4: ::nl_item = 0x20003;
-pub const ABDAY_5: ::nl_item = 0x20004;
-pub const ABDAY_6: ::nl_item = 0x20005;
-pub const ABDAY_7: ::nl_item = 0x20006;
-
-pub const DAY_1: ::nl_item = 0x20007;
-pub const DAY_2: ::nl_item = 0x20008;
-pub const DAY_3: ::nl_item = 0x20009;
-pub const DAY_4: ::nl_item = 0x2000A;
-pub const DAY_5: ::nl_item = 0x2000B;
-pub const DAY_6: ::nl_item = 0x2000C;
-pub const DAY_7: ::nl_item = 0x2000D;
-
-pub const ABMON_1: ::nl_item = 0x2000E;
-pub const ABMON_2: ::nl_item = 0x2000F;
-pub const ABMON_3: ::nl_item = 0x20010;
-pub const ABMON_4: ::nl_item = 0x20011;
-pub const ABMON_5: ::nl_item = 0x20012;
-pub const ABMON_6: ::nl_item = 0x20013;
-pub const ABMON_7: ::nl_item = 0x20014;
-pub const ABMON_8: ::nl_item = 0x20015;
-pub const ABMON_9: ::nl_item = 0x20016;
-pub const ABMON_10: ::nl_item = 0x20017;
-pub const ABMON_11: ::nl_item = 0x20018;
-pub const ABMON_12: ::nl_item = 0x20019;
-
-pub const MON_1: ::nl_item = 0x2001A;
-pub const MON_2: ::nl_item = 0x2001B;
-pub const MON_3: ::nl_item = 0x2001C;
-pub const MON_4: ::nl_item = 0x2001D;
-pub const MON_5: ::nl_item = 0x2001E;
-pub const MON_6: ::nl_item = 0x2001F;
-pub const MON_7: ::nl_item = 0x20020;
-pub const MON_8: ::nl_item = 0x20021;
-pub const MON_9: ::nl_item = 0x20022;
-pub const MON_10: ::nl_item = 0x20023;
-pub const MON_11: ::nl_item = 0x20024;
-pub const MON_12: ::nl_item = 0x20025;
-
-pub const AM_STR: ::nl_item = 0x20026;
-pub const PM_STR: ::nl_item = 0x20027;
-
-pub const D_T_FMT: ::nl_item = 0x20028;
-pub const D_FMT: ::nl_item = 0x20029;
-pub const T_FMT: ::nl_item = 0x2002A;
-pub const T_FMT_AMPM: ::nl_item = 0x2002B;
-
-pub const ERA: ::nl_item = 0x2002C;
-pub const ERA_D_FMT: ::nl_item = 0x2002E;
-pub const ALT_DIGITS: ::nl_item = 0x2002F;
-pub const ERA_D_T_FMT: ::nl_item = 0x20030;
-pub const ERA_T_FMT: ::nl_item = 0x20031;
-
-pub const CODESET: ::nl_item = 14;
-
-pub const CRNCYSTR: ::nl_item = 0x4000F;
-
-pub const RUSAGE_THREAD: ::c_int = 1;
-pub const RUSAGE_CHILDREN: ::c_int = -1;
-
-pub const RADIXCHAR: ::nl_item = 0x10000;
-pub const THOUSEP: ::nl_item = 0x10001;
-
-pub const YESEXPR: ::nl_item = 0x50000;
-pub const NOEXPR: ::nl_item = 0x50001;
-pub const YESSTR: ::nl_item = 0x50002;
-pub const NOSTR: ::nl_item = 0x50003;
-
-pub const FILENAME_MAX: ::c_uint = 4096;
-pub const L_tmpnam: ::c_uint = 20;
-pub const _PC_LINK_MAX: ::c_int = 0;
-pub const _PC_MAX_CANON: ::c_int = 1;
-pub const _PC_MAX_INPUT: ::c_int = 2;
-pub const _PC_NAME_MAX: ::c_int = 3;
-pub const _PC_PATH_MAX: ::c_int = 4;
-pub const _PC_PIPE_BUF: ::c_int = 5;
-pub const _PC_CHOWN_RESTRICTED: ::c_int = 6;
-pub const _PC_NO_TRUNC: ::c_int = 7;
-pub const _PC_VDISABLE: ::c_int = 8;
-pub const _PC_SYNC_IO: ::c_int = 9;
-pub const _PC_ASYNC_IO: ::c_int = 10;
-pub const _PC_PRIO_IO: ::c_int = 11;
-pub const _PC_SOCK_MAXBUF: ::c_int = 12;
-pub const _PC_FILESIZEBITS: ::c_int = 13;
-pub const _PC_REC_INCR_XFER_SIZE: ::c_int = 14;
-pub const _PC_REC_MAX_XFER_SIZE: ::c_int = 15;
-pub const _PC_REC_MIN_XFER_SIZE: ::c_int = 16;
-pub const _PC_REC_XFER_ALIGN: ::c_int = 17;
-pub const _PC_ALLOC_SIZE_MIN: ::c_int = 18;
-pub const _PC_SYMLINK_MAX: ::c_int = 19;
-pub const _PC_2_SYMLINKS: ::c_int = 20;
-
-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_STREAM_MAX: ::c_int = 5;
-pub const _SC_TZNAME_MAX: ::c_int = 6;
-pub const _SC_JOB_CONTROL: ::c_int = 7;
-pub const _SC_SAVED_IDS: ::c_int = 8;
-pub const _SC_REALTIME_SIGNALS: ::c_int = 9;
-pub const _SC_PRIORITY_SCHEDULING: ::c_int = 10;
-pub const _SC_TIMERS: ::c_int = 11;
-pub const _SC_ASYNCHRONOUS_IO: ::c_int = 12;
-pub const _SC_PRIORITIZED_IO: ::c_int = 13;
-pub const _SC_SYNCHRONIZED_IO: ::c_int = 14;
-pub const _SC_FSYNC: ::c_int = 15;
-pub const _SC_MAPPED_FILES: ::c_int = 16;
-pub const _SC_MEMLOCK: ::c_int = 17;
-pub const _SC_MEMLOCK_RANGE: ::c_int = 18;
-pub const _SC_MEMORY_PROTECTION: ::c_int = 19;
-pub const _SC_MESSAGE_PASSING: ::c_int = 20;
-pub const _SC_SEMAPHORES: ::c_int = 21;
-pub const _SC_SHARED_MEMORY_OBJECTS: ::c_int = 22;
-pub const _SC_AIO_LISTIO_MAX: ::c_int = 23;
-pub const _SC_AIO_MAX: ::c_int = 24;
-pub const _SC_AIO_PRIO_DELTA_MAX: ::c_int = 25;
-pub const _SC_DELAYTIMER_MAX: ::c_int = 26;
-pub const _SC_MQ_OPEN_MAX: ::c_int = 27;
-pub const _SC_MQ_PRIO_MAX: ::c_int = 28;
-pub const _SC_VERSION: ::c_int = 29;
-pub const _SC_PAGESIZE: ::c_int = 30;
-pub const _SC_PAGE_SIZE: ::c_int = _SC_PAGESIZE;
-pub const _SC_RTSIG_MAX: ::c_int = 31;
-pub const _SC_SEM_NSEMS_MAX: ::c_int = 32;
-pub const _SC_SEM_VALUE_MAX: ::c_int = 33;
-pub const _SC_SIGQUEUE_MAX: ::c_int = 34;
-pub const _SC_TIMER_MAX: ::c_int = 35;
-pub const _SC_BC_BASE_MAX: ::c_int = 36;
-pub const _SC_BC_DIM_MAX: ::c_int = 37;
-pub const _SC_BC_SCALE_MAX: ::c_int = 38;
-pub const _SC_BC_STRING_MAX: ::c_int = 39;
-pub const _SC_COLL_WEIGHTS_MAX: ::c_int = 40;
-pub const _SC_EXPR_NEST_MAX: ::c_int = 42;
-pub const _SC_LINE_MAX: ::c_int = 43;
-pub const _SC_RE_DUP_MAX: ::c_int = 44;
-pub const _SC_2_VERSION: ::c_int = 46;
-pub const _SC_2_C_BIND: ::c_int = 47;
-pub const _SC_2_C_DEV: ::c_int = 48;
-pub const _SC_2_FORT_DEV: ::c_int = 49;
-pub const _SC_2_FORT_RUN: ::c_int = 50;
-pub const _SC_2_SW_DEV: ::c_int = 51;
-pub const _SC_2_LOCALEDEF: ::c_int = 52;
-pub const _SC_UIO_MAXIOV: ::c_int = 60;
-pub const _SC_IOV_MAX: ::c_int = 60;
-pub const _SC_THREADS: ::c_int = 67;
-pub const _SC_THREAD_SAFE_FUNCTIONS: ::c_int = 68;
-pub const _SC_GETGR_R_SIZE_MAX: ::c_int = 69;
-pub const _SC_GETPW_R_SIZE_MAX: ::c_int = 70;
-pub const _SC_LOGIN_NAME_MAX: ::c_int = 71;
-pub const _SC_TTY_NAME_MAX: ::c_int = 72;
-pub const _SC_THREAD_DESTRUCTOR_ITERATIONS: ::c_int = 73;
-pub const _SC_THREAD_KEYS_MAX: ::c_int = 74;
-pub const _SC_THREAD_STACK_MIN: ::c_int = 75;
-pub const _SC_THREAD_THREADS_MAX: ::c_int = 76;
-pub const _SC_THREAD_ATTR_STACKADDR: ::c_int = 77;
-pub const _SC_THREAD_ATTR_STACKSIZE: ::c_int = 78;
-pub const _SC_THREAD_PRIORITY_SCHEDULING: ::c_int = 79;
-pub const _SC_THREAD_PRIO_INHERIT: ::c_int = 80;
-pub const _SC_THREAD_PRIO_PROTECT: ::c_int = 81;
-pub const _SC_THREAD_PROCESS_SHARED: ::c_int = 82;
-pub const _SC_NPROCESSORS_CONF: ::c_int = 83;
-pub const _SC_NPROCESSORS_ONLN: ::c_int = 84;
-pub const _SC_PHYS_PAGES: ::c_int = 85;
-pub const _SC_AVPHYS_PAGES: ::c_int = 86;
-pub const _SC_ATEXIT_MAX: ::c_int = 87;
-pub const _SC_PASS_MAX: ::c_int = 88;
-pub const _SC_XOPEN_VERSION: ::c_int = 89;
-pub const _SC_XOPEN_XCU_VERSION: ::c_int = 90;
-pub const _SC_XOPEN_UNIX: ::c_int = 91;
-pub const _SC_XOPEN_CRYPT: ::c_int = 92;
-pub const _SC_XOPEN_ENH_I18N: ::c_int = 93;
-pub const _SC_XOPEN_SHM: ::c_int = 94;
-pub const _SC_2_CHAR_TERM: ::c_int = 95;
-pub const _SC_2_UPE: ::c_int = 97;
-pub const _SC_XOPEN_XPG2: ::c_int = 98;
-pub const _SC_XOPEN_XPG3: ::c_int = 99;
-pub const _SC_XOPEN_XPG4: ::c_int = 100;
-pub const _SC_NZERO: ::c_int = 109;
-pub const _SC_XBS5_ILP32_OFF32: ::c_int = 125;
-pub const _SC_XBS5_ILP32_OFFBIG: ::c_int = 126;
-pub const _SC_XBS5_LP64_OFF64: ::c_int = 127;
-pub const _SC_XBS5_LPBIG_OFFBIG: ::c_int = 128;
-pub const _SC_XOPEN_LEGACY: ::c_int = 129;
-pub const _SC_XOPEN_REALTIME: ::c_int = 130;
-pub const _SC_XOPEN_REALTIME_THREADS: ::c_int = 131;
-pub const _SC_ADVISORY_INFO: ::c_int = 132;
-pub const _SC_BARRIERS: ::c_int = 133;
-pub const _SC_CLOCK_SELECTION: ::c_int = 137;
-pub const _SC_CPUTIME: ::c_int = 138;
-pub const _SC_THREAD_CPUTIME: ::c_int = 139;
-pub const _SC_MONOTONIC_CLOCK: ::c_int = 149;
-pub const _SC_READER_WRITER_LOCKS: ::c_int = 153;
-pub const _SC_SPIN_LOCKS: ::c_int = 154;
-pub const _SC_REGEXP: ::c_int = 155;
-pub const _SC_SHELL: ::c_int = 157;
-pub const _SC_SPAWN: ::c_int = 159;
-pub const _SC_SPORADIC_SERVER: ::c_int = 160;
-pub const _SC_THREAD_SPORADIC_SERVER: ::c_int = 161;
-pub const _SC_TIMEOUTS: ::c_int = 164;
-pub const _SC_TYPED_MEMORY_OBJECTS: ::c_int = 165;
-pub const _SC_2_PBS: ::c_int = 168;
-pub const _SC_2_PBS_ACCOUNTING: ::c_int = 169;
-pub const _SC_2_PBS_LOCATE: ::c_int = 170;
-pub const _SC_2_PBS_MESSAGE: ::c_int = 171;
-pub const _SC_2_PBS_TRACK: ::c_int = 172;
-pub const _SC_SYMLOOP_MAX: ::c_int = 173;
-pub const _SC_STREAMS: ::c_int = 174;
-pub const _SC_2_PBS_CHECKPOINT: ::c_int = 175;
-pub const _SC_V6_ILP32_OFF32: ::c_int = 176;
-pub const _SC_V6_ILP32_OFFBIG: ::c_int = 177;
-pub const _SC_V6_LP64_OFF64: ::c_int = 178;
-pub const _SC_V6_LPBIG_OFFBIG: ::c_int = 179;
-pub const _SC_HOST_NAME_MAX: ::c_int = 180;
-pub const _SC_TRACE: ::c_int = 181;
-pub const _SC_TRACE_EVENT_FILTER: ::c_int = 182;
-pub const _SC_TRACE_INHERIT: ::c_int = 183;
-pub const _SC_TRACE_LOG: ::c_int = 184;
-pub const _SC_IPV6: ::c_int = 235;
-pub const _SC_RAW_SOCKETS: ::c_int = 236;
-pub const _SC_V7_ILP32_OFF32: ::c_int = 237;
-pub const _SC_V7_ILP32_OFFBIG: ::c_int = 238;
-pub const _SC_V7_LP64_OFF64: ::c_int = 239;
-pub const _SC_V7_LPBIG_OFFBIG: ::c_int = 240;
-pub const _SC_SS_REPL_MAX: ::c_int = 241;
-pub const _SC_TRACE_EVENT_NAME_MAX: ::c_int = 242;
-pub const _SC_TRACE_NAME_MAX: ::c_int = 243;
-pub const _SC_TRACE_SYS_MAX: ::c_int = 244;
-pub const _SC_TRACE_USER_EVENT_MAX: ::c_int = 245;
-pub const _SC_XOPEN_STREAMS: ::c_int = 246;
-pub const _SC_THREAD_ROBUST_PRIO_INHERIT: ::c_int = 247;
-pub const _SC_THREAD_ROBUST_PRIO_PROTECT: ::c_int = 248;
-
-pub const RLIM_SAVED_MAX: ::rlim_t = RLIM_INFINITY;
-pub const RLIM_SAVED_CUR: ::rlim_t = RLIM_INFINITY;
-
-pub const GLOB_ERR: ::c_int = 1 << 0;
-pub const GLOB_MARK: ::c_int = 1 << 1;
-pub const GLOB_NOSORT: ::c_int = 1 << 2;
-pub const GLOB_DOOFFS: ::c_int = 1 << 3;
-pub const GLOB_NOCHECK: ::c_int = 1 << 4;
-pub const GLOB_APPEND: ::c_int = 1 << 5;
-pub const GLOB_NOESCAPE: ::c_int = 1 << 6;
-
-pub const GLOB_NOSPACE: ::c_int = 1;
-pub const GLOB_ABORTED: ::c_int = 2;
-pub const GLOB_NOMATCH: ::c_int = 3;
-
-pub const POSIX_MADV_NORMAL: ::c_int = 0;
-pub const POSIX_MADV_RANDOM: ::c_int = 1;
-pub const POSIX_MADV_SEQUENTIAL: ::c_int = 2;
-pub const POSIX_MADV_WILLNEED: ::c_int = 3;
-
-pub const S_IEXEC: mode_t = 64;
-pub const S_IWRITE: mode_t = 128;
-pub const S_IREAD: mode_t = 256;
-
-pub const F_LOCK: ::c_int = 1;
-pub const F_TEST: ::c_int = 3;
-pub const F_TLOCK: ::c_int = 2;
-pub const F_ULOCK: ::c_int = 0;
-
-pub const IFF_LOWER_UP: ::c_int = 0x10000;
-pub const IFF_DORMANT: ::c_int = 0x20000;
-pub const IFF_ECHO: ::c_int = 0x40000;
-
-pub const ST_RDONLY: ::c_ulong = 1;
-pub const ST_NOSUID: ::c_ulong = 2;
-pub const ST_NODEV: ::c_ulong = 4;
-pub const ST_NOEXEC: ::c_ulong = 8;
-pub const ST_SYNCHRONOUS: ::c_ulong = 16;
-pub const ST_MANDLOCK: ::c_ulong = 64;
-pub const ST_WRITE: ::c_ulong = 128;
-pub const ST_APPEND: ::c_ulong = 256;
-pub const ST_IMMUTABLE: ::c_ulong = 512;
-pub const ST_NOATIME: ::c_ulong = 1024;
-pub const ST_NODIRATIME: ::c_ulong = 2048;
-
-pub const RTLD_NEXT: *mut ::c_void = -1i64 as *mut ::c_void;
-pub const RTLD_DEFAULT: *mut ::c_void = 0i64 as *mut ::c_void;
-pub const RTLD_NODELETE: ::c_int = 0x1000;
-pub const RTLD_NOW: ::c_int = 0x2;
-
-pub const TCP_MD5SIG: ::c_int = 14;
-
-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;
-pub const PTHREAD_MUTEX_DEFAULT: ::c_int = PTHREAD_MUTEX_NORMAL;
-pub const PTHREAD_PROCESS_PRIVATE: ::c_int = 0;
-pub const PTHREAD_PROCESS_SHARED: ::c_int = 1;
-pub const __SIZEOF_PTHREAD_COND_T: usize = 48;
-
-pub const RENAME_NOREPLACE: ::c_int = 1;
-pub const RENAME_EXCHANGE: ::c_int = 2;
-pub const RENAME_WHITEOUT: ::c_int = 4;
-
-pub const SCHED_OTHER: ::c_int = 0;
-pub const SCHED_FIFO: ::c_int = 1;
-pub const SCHED_RR: ::c_int = 2;
-pub const SCHED_BATCH: ::c_int = 3;
-pub const SCHED_IDLE: ::c_int = 5;
-
-// netinet/in.h
-// NOTE: These are in addition to the constants defined in src/unix/mod.rs
-
-// IPPROTO_IP defined in src/unix/mod.rs
-/// Hop-by-hop option header
-pub const IPPROTO_HOPOPTS: ::c_int = 0;
-// IPPROTO_ICMP defined in src/unix/mod.rs
-/// group mgmt protocol
-pub const IPPROTO_IGMP: ::c_int = 2;
-/// for compatibility
-pub const IPPROTO_IPIP: ::c_int = 4;
-// IPPROTO_TCP defined in src/unix/mod.rs
-/// exterior gateway protocol
-pub const IPPROTO_EGP: ::c_int = 8;
-/// pup
-pub const IPPROTO_PUP: ::c_int = 12;
-// IPPROTO_UDP defined in src/unix/mod.rs
-/// xns idp
-pub const IPPROTO_IDP: ::c_int = 22;
-/// tp-4 w/ class negotiation
-pub const IPPROTO_TP: ::c_int = 29;
-/// DCCP
-pub const IPPROTO_DCCP: ::c_int = 33;
-// IPPROTO_IPV6 defined in src/unix/mod.rs
-/// IP6 routing header
-pub const IPPROTO_ROUTING: ::c_int = 43;
-/// IP6 fragmentation header
-pub const IPPROTO_FRAGMENT: ::c_int = 44;
-/// resource reservation
-pub const IPPROTO_RSVP: ::c_int = 46;
-/// General Routing Encap.
-pub const IPPROTO_GRE: ::c_int = 47;
-/// IP6 Encap Sec. Payload
-pub const IPPROTO_ESP: ::c_int = 50;
-/// IP6 Auth Header
-pub const IPPROTO_AH: ::c_int = 51;
-// IPPROTO_ICMPV6 defined in src/unix/mod.rs
-/// IP6 no next header
-pub const IPPROTO_NONE: ::c_int = 59;
-/// IP6 destination option
-pub const IPPROTO_DSTOPTS: ::c_int = 60;
-pub const IPPROTO_MTP: ::c_int = 92;
-pub const IPPROTO_BEETPH: ::c_int = 94;
-/// encapsulation header
-pub const IPPROTO_ENCAP: ::c_int = 98;
-/// Protocol indep. multicast
-pub const IPPROTO_PIM: ::c_int = 103;
-/// IP Payload Comp. Protocol
-pub const IPPROTO_COMP: ::c_int = 108;
-/// SCTP
-pub const IPPROTO_SCTP: ::c_int = 132;
-pub const IPPROTO_MH: ::c_int = 135;
-pub const IPPROTO_UDPLITE: ::c_int = 136;
-pub const IPPROTO_MPLS: ::c_int = 137;
-/// raw IP packet
-pub const IPPROTO_RAW: ::c_int = 255;
-pub const IPPROTO_MAX: ::c_int = 256;
-
-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 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;
-
-// System V IPC
-pub const IPC_PRIVATE: ::key_t = 0;
-
-pub const IPC_CREAT: ::c_int = 0o1000;
-pub const IPC_EXCL: ::c_int = 0o2000;
-pub const IPC_NOWAIT: ::c_int = 0o4000;
-
-pub const IPC_RMID: ::c_int = 0;
-pub const IPC_SET: ::c_int = 1;
-pub const IPC_STAT: ::c_int = 2;
-pub const IPC_INFO: ::c_int = 3;
-pub const MSG_STAT: ::c_int = 11;
-pub const MSG_INFO: ::c_int = 12;
-
-pub const MSG_NOERROR: ::c_int = 0o10000;
-pub const MSG_EXCEPT: ::c_int = 0o20000;
-pub const MSG_COPY: ::c_int = 0o40000;
-
-pub const SHM_R: ::c_int = 0o400;
-pub const SHM_W: ::c_int = 0o200;
-
-pub const SHM_RDONLY: ::c_int = 0o10000;
-pub const SHM_RND: ::c_int = 0o20000;
-pub const SHM_REMAP: ::c_int = 0o40000;
-pub const SHM_EXEC: ::c_int = 0o100000;
-
-pub const SHM_LOCK: ::c_int = 11;
-pub const SHM_UNLOCK: ::c_int = 12;
-
-pub const SHM_HUGETLB: ::c_int = 0o4000;
-pub const SHM_NORESERVE: ::c_int = 0o10000;
-
-pub const EPOLLRDHUP: ::c_int = 0x2000;
-pub const EPOLLEXCLUSIVE: ::c_int = 0x10000000;
-pub const EPOLLONESHOT: ::c_int = 0x40000000;
-
-pub const QFMT_VFS_OLD: ::c_int = 1;
-pub const QFMT_VFS_V0: ::c_int = 2;
-pub const QFMT_VFS_V1: ::c_int = 4;
-
-pub const EFD_SEMAPHORE: ::c_int = 0x1;
-
-pub const LOG_NFACILITIES: ::c_int = 24;
-
-pub const SEM_FAILED: *mut ::sem_t = 0 as *mut sem_t;
-
-pub const RB_AUTOBOOT: ::c_int = 0x01234567u32 as i32;
-pub const RB_HALT_SYSTEM: ::c_int = 0xcdef0123u32 as i32;
-pub const RB_ENABLE_CAD: ::c_int = 0x89abcdefu32 as i32;
-pub const RB_DISABLE_CAD: ::c_int = 0x00000000u32 as i32;
-pub const RB_POWER_OFF: ::c_int = 0x4321fedcu32 as i32;
-pub const RB_SW_SUSPEND: ::c_int = 0xd000fce2u32 as i32;
-pub const RB_KEXEC: ::c_int = 0x45584543u32 as i32;
-
-pub const AI_PASSIVE: ::c_int = 0x0001;
-pub const AI_CANONNAME: ::c_int = 0x0002;
-pub const AI_NUMERICHOST: ::c_int = 0x0004;
-pub const AI_V4MAPPED: ::c_int = 0x0008;
-pub const AI_ALL: ::c_int = 0x0010;
-pub const AI_ADDRCONFIG: ::c_int = 0x0020;
-
-pub const AI_NUMERICSERV: ::c_int = 0x0400;
-
-pub const EAI_BADFLAGS: ::c_int = -1;
-pub const EAI_NONAME: ::c_int = -2;
-pub const EAI_AGAIN: ::c_int = -3;
-pub const EAI_FAIL: ::c_int = -4;
-pub const EAI_FAMILY: ::c_int = -6;
-pub const EAI_SOCKTYPE: ::c_int = -7;
-pub const EAI_SERVICE: ::c_int = -8;
-pub const EAI_MEMORY: ::c_int = -10;
-pub const EAI_OVERFLOW: ::c_int = -12;
-
-pub const NI_NUMERICHOST: ::c_int = 1;
-pub const NI_NUMERICSERV: ::c_int = 2;
-pub const NI_NOFQDN: ::c_int = 4;
-pub const NI_NAMEREQD: ::c_int = 8;
-pub const NI_DGRAM: ::c_int = 16;
-
-pub const SYNC_FILE_RANGE_WAIT_BEFORE: ::c_uint = 1;
-pub const SYNC_FILE_RANGE_WRITE: ::c_uint = 2;
-pub const SYNC_FILE_RANGE_WAIT_AFTER: ::c_uint = 4;
-
-pub const EAI_SYSTEM: ::c_int = -11;
-
-pub const AIO_CANCELED: ::c_int = 0;
-pub const AIO_NOTCANCELED: ::c_int = 1;
-pub const AIO_ALLDONE: ::c_int = 2;
-pub const LIO_READ: ::c_int = 0;
-pub const LIO_WRITE: ::c_int = 1;
-pub const LIO_NOP: ::c_int = 2;
-pub const LIO_WAIT: ::c_int = 0;
-pub const LIO_NOWAIT: ::c_int = 1;
-
-pub const MREMAP_MAYMOVE: ::c_int = 1;
-pub const MREMAP_FIXED: ::c_int = 2;
-
-pub const PR_SET_PDEATHSIG: ::c_int = 1;
-pub const PR_GET_PDEATHSIG: ::c_int = 2;
-
-pub const PR_GET_DUMPABLE: ::c_int = 3;
-pub const PR_SET_DUMPABLE: ::c_int = 4;
-
-pub const PR_GET_UNALIGN: ::c_int = 5;
-pub const PR_SET_UNALIGN: ::c_int = 6;
-pub const PR_UNALIGN_NOPRINT: ::c_int = 1;
-pub const PR_UNALIGN_SIGBUS: ::c_int = 2;
-
-pub const PR_GET_KEEPCAPS: ::c_int = 7;
-pub const PR_SET_KEEPCAPS: ::c_int = 8;
-
-pub const PR_GET_FPEMU: ::c_int = 9;
-pub const PR_SET_FPEMU: ::c_int = 10;
-pub const PR_FPEMU_NOPRINT: ::c_int = 1;
-pub const PR_FPEMU_SIGFPE: ::c_int = 2;
-
-pub const PR_GET_FPEXC: ::c_int = 11;
-pub const PR_SET_FPEXC: ::c_int = 12;
-pub const PR_FP_EXC_SW_ENABLE: ::c_int = 0x80;
-pub const PR_FP_EXC_DIV: ::c_int = 0x010000;
-pub const PR_FP_EXC_OVF: ::c_int = 0x020000;
-pub const PR_FP_EXC_UND: ::c_int = 0x040000;
-pub const PR_FP_EXC_RES: ::c_int = 0x080000;
-pub const PR_FP_EXC_INV: ::c_int = 0x100000;
-pub const PR_FP_EXC_DISABLED: ::c_int = 0;
-pub const PR_FP_EXC_NONRECOV: ::c_int = 1;
-pub const PR_FP_EXC_ASYNC: ::c_int = 2;
-pub const PR_FP_EXC_PRECISE: ::c_int = 3;
-
-pub const PR_GET_TIMING: ::c_int = 13;
-pub const PR_SET_TIMING: ::c_int = 14;
-pub const PR_TIMING_STATISTICAL: ::c_int = 0;
-pub const PR_TIMING_TIMESTAMP: ::c_int = 1;
-
-pub const PR_SET_NAME: ::c_int = 15;
-pub const PR_GET_NAME: ::c_int = 16;
-
-pub const PR_GET_ENDIAN: ::c_int = 19;
-pub const PR_SET_ENDIAN: ::c_int = 20;
-pub const PR_ENDIAN_BIG: ::c_int = 0;
-pub const PR_ENDIAN_LITTLE: ::c_int = 1;
-pub const PR_ENDIAN_PPC_LITTLE: ::c_int = 2;
-
-pub const PR_GET_SECCOMP: ::c_int = 21;
-pub const PR_SET_SECCOMP: ::c_int = 22;
-
-pub const PR_CAPBSET_READ: ::c_int = 23;
-pub const PR_CAPBSET_DROP: ::c_int = 24;
-
-pub const PR_GET_TSC: ::c_int = 25;
-pub const PR_SET_TSC: ::c_int = 26;
-pub const PR_TSC_ENABLE: ::c_int = 1;
-pub const PR_TSC_SIGSEGV: ::c_int = 2;
-
-pub const PR_GET_SECUREBITS: ::c_int = 27;
-pub const PR_SET_SECUREBITS: ::c_int = 28;
-
-pub const PR_SET_TIMERSLACK: ::c_int = 29;
-pub const PR_GET_TIMERSLACK: ::c_int = 30;
-
-pub const PR_TASK_PERF_EVENTS_DISABLE: ::c_int = 31;
-pub const PR_TASK_PERF_EVENTS_ENABLE: ::c_int = 32;
-
-pub const PR_MCE_KILL: ::c_int = 33;
-pub const PR_MCE_KILL_CLEAR: ::c_int = 0;
-pub const PR_MCE_KILL_SET: ::c_int = 1;
-
-pub const PR_MCE_KILL_LATE: ::c_int = 0;
-pub const PR_MCE_KILL_EARLY: ::c_int = 1;
-pub const PR_MCE_KILL_DEFAULT: ::c_int = 2;
-
-pub const PR_MCE_KILL_GET: ::c_int = 34;
-
-pub const PR_SET_MM: ::c_int = 35;
-pub const PR_SET_MM_START_CODE: ::c_int = 1;
-pub const PR_SET_MM_END_CODE: ::c_int = 2;
-pub const PR_SET_MM_START_DATA: ::c_int = 3;
-pub const PR_SET_MM_END_DATA: ::c_int = 4;
-pub const PR_SET_MM_START_STACK: ::c_int = 5;
-pub const PR_SET_MM_START_BRK: ::c_int = 6;
-pub const PR_SET_MM_BRK: ::c_int = 7;
-pub const PR_SET_MM_ARG_START: ::c_int = 8;
-pub const PR_SET_MM_ARG_END: ::c_int = 9;
-pub const PR_SET_MM_ENV_START: ::c_int = 10;
-pub const PR_SET_MM_ENV_END: ::c_int = 11;
-pub const PR_SET_MM_AUXV: ::c_int = 12;
-pub const PR_SET_MM_EXE_FILE: ::c_int = 13;
-pub const PR_SET_MM_MAP: ::c_int = 14;
-pub const PR_SET_MM_MAP_SIZE: ::c_int = 15;
-
-pub const PR_SET_PTRACER: ::c_int = 0x59616d61;
-
-pub const PR_SET_CHILD_SUBREAPER: ::c_int = 36;
-pub const PR_GET_CHILD_SUBREAPER: ::c_int = 37;
-
-pub const PR_SET_NO_NEW_PRIVS: ::c_int = 38;
-pub const PR_GET_NO_NEW_PRIVS: ::c_int = 39;
-
-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 PR_MPX_ENABLE_MANAGEMENT: ::c_int = 43;
-pub const PR_MPX_DISABLE_MANAGEMENT: ::c_int = 44;
-
-pub const PR_SET_FP_MODE: ::c_int = 45;
-pub const PR_GET_FP_MODE: ::c_int = 46;
-pub const PR_FP_MODE_FR: ::c_int = 1 << 0;
-pub const PR_FP_MODE_FRE: ::c_int = 1 << 1;
-
-pub const PR_CAP_AMBIENT: ::c_int = 47;
-pub const PR_CAP_AMBIENT_IS_SET: ::c_int = 1;
-pub const PR_CAP_AMBIENT_RAISE: ::c_int = 2;
-pub const PR_CAP_AMBIENT_LOWER: ::c_int = 3;
-pub const PR_CAP_AMBIENT_CLEAR_ALL: ::c_int = 4;
-
-pub const GRND_NONBLOCK: ::c_uint = 0x0001;
-pub const GRND_RANDOM: ::c_uint = 0x0002;
-
-pub const ITIMER_REAL: ::c_int = 0;
-pub const ITIMER_VIRTUAL: ::c_int = 1;
-pub const ITIMER_PROF: ::c_int = 2;
-
-pub const TFD_CLOEXEC: ::c_int = O_CLOEXEC;
-pub const TFD_NONBLOCK: ::c_int = O_NONBLOCK;
-pub const TFD_TIMER_ABSTIME: ::c_int = 1;
-
-pub const XATTR_CREATE: ::c_int = 0x1;
-pub const XATTR_REPLACE: ::c_int = 0x2;
-
-pub const _POSIX_VDISABLE: ::cc_t = 0;
-
-pub const FALLOC_FL_KEEP_SIZE: ::c_int = 0x01;
-pub const FALLOC_FL_PUNCH_HOLE: ::c_int = 0x02;
-pub const FALLOC_FL_COLLAPSE_RANGE: ::c_int = 0x08;
-pub const FALLOC_FL_ZERO_RANGE: ::c_int = 0x10;
-pub const FALLOC_FL_INSERT_RANGE: ::c_int = 0x20;
-pub const FALLOC_FL_UNSHARE_RANGE: ::c_int = 0x40;
-
-// On Linux, libc doesn't define this constant, libattr does instead.
-// We still define it for Linux as it's defined by libc on other platforms,
-// and it's mentioned in the man pages for getxattr and setxattr.
-pub const ENOATTR: ::c_int = ::ENODATA;
-
-pub const SO_ORIGINAL_DST: ::c_int = 80;
-pub const IUTF8: ::tcflag_t = 0x00004000;
-pub const CMSPAR: ::tcflag_t = 0o10000000000;
-
-pub const MFD_CLOEXEC: ::c_uint = 0x0001;
-pub const MFD_ALLOW_SEALING: ::c_uint = 0x0002;
-
-// these are used in the p_type field of Elf32_Phdr and Elf64_Phdr, which has
-// the type Elf32Word and Elf64Word respectively. Luckily, both of those are u32
-// so we can use that type here to avoid having to cast.
-pub const PT_NULL: u32 = 0;
-pub const PT_LOAD: u32 = 1;
-pub const PT_DYNAMIC: u32 = 2;
-pub const PT_INTERP: u32 = 3;
-pub const PT_NOTE: u32 = 4;
-pub const PT_SHLIB: u32 = 5;
-pub const PT_PHDR: u32 = 6;
-pub const PT_TLS: u32 = 7;
-pub const PT_NUM: u32 = 8;
-pub const PT_LOOS: u32 = 0x60000000;
-pub const PT_GNU_EH_FRAME: u32 = 0x6474e550;
-pub const PT_GNU_STACK: u32 = 0x6474e551;
-pub const PT_GNU_RELRO: u32 = 0x6474e552;
-
-pub const SFD_CLOEXEC: ::c_int = 0x080000;
-
-pub const NCCS: usize = 32;
-
-pub const O_TRUNC: ::c_int = 0x00040000;
-pub const O_NOATIME: ::c_int = 0x00002000;
-pub const O_CLOEXEC: ::c_int = 0x00000100;
-pub const O_TMPFILE: ::c_int = 0x00004000;
-
-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 EDOTDOT: ::c_int = 73;
-
-pub const SA_NODEFER: ::c_int = 0x40000000;
-pub const SA_RESETHAND: ::c_int = 0x80000000;
-pub const SA_RESTART: ::c_int = 0x10000000;
-pub const SA_NOCLDSTOP: ::c_int = 0x00000001;
-
-pub const EPOLL_CLOEXEC: ::c_int = 0x80000;
-
-pub const EFD_CLOEXEC: ::c_int = 0x80000;
-
-pub const BUFSIZ: ::c_uint = 1024;
-pub const TMP_MAX: ::c_uint = 10000;
-pub const FOPEN_MAX: ::c_uint = 1000;
-pub const O_PATH: ::c_int = 0x00400000;
-pub const O_EXEC: ::c_int = O_PATH;
-pub const O_SEARCH: ::c_int = O_PATH;
-pub const O_ACCMODE: ::c_int = (03 | O_SEARCH);
-pub const O_NDELAY: ::c_int = O_NONBLOCK;
-pub const NI_MAXHOST: ::socklen_t = 255;
-pub const PTHREAD_STACK_MIN: ::size_t = 2048;
-pub const POSIX_FADV_DONTNEED: ::c_int = 4;
-pub const POSIX_FADV_NOREUSE: ::c_int = 5;
-
-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;
-
-pub const SOCK_DCCP: ::c_int = 6;
-pub const SOCK_PACKET: ::c_int = 10;
-
-pub const TCP_COOKIE_TRANSACTIONS: ::c_int = 15;
-pub const TCP_THIN_LINEAR_TIMEOUTS: ::c_int = 16;
-pub const TCP_THIN_DUPACK: ::c_int = 17;
-pub const TCP_USER_TIMEOUT: ::c_int = 18;
-pub const TCP_REPAIR: ::c_int = 19;
-pub const TCP_REPAIR_QUEUE: ::c_int = 20;
-pub const TCP_QUEUE_SEQ: ::c_int = 21;
-pub const TCP_REPAIR_OPTIONS: ::c_int = 22;
-pub const TCP_FASTOPEN: ::c_int = 23;
-pub const TCP_TIMESTAMP: ::c_int = 24;
-
-pub const SIGUNUSED: ::c_int = ::SIGSYS;
-
-pub const __SIZEOF_PTHREAD_CONDATTR_T: usize = 4;
-pub const __SIZEOF_PTHREAD_MUTEXATTR_T: usize = 4;
-pub const __SIZEOF_PTHREAD_RWLOCKATTR_T: usize = 8;
-
-pub const CPU_SETSIZE: ::c_int = 128;
-
-pub const PTRACE_TRACEME: ::c_int = 0;
-pub const PTRACE_PEEKTEXT: ::c_int = 1;
-pub const PTRACE_PEEKDATA: ::c_int = 2;
-pub const PTRACE_PEEKUSER: ::c_int = 3;
-pub const PTRACE_POKETEXT: ::c_int = 4;
-pub const PTRACE_POKEDATA: ::c_int = 5;
-pub const PTRACE_POKEUSER: ::c_int = 6;
-pub const PTRACE_CONT: ::c_int = 7;
-pub const PTRACE_KILL: ::c_int = 8;
-pub const PTRACE_SINGLESTEP: ::c_int = 9;
-pub const PTRACE_GETREGS: ::c_int = 12;
-pub const PTRACE_SETREGS: ::c_int = 13;
-pub const PTRACE_GETFPREGS: ::c_int = 14;
-pub const PTRACE_SETFPREGS: ::c_int = 15;
-pub const PTRACE_ATTACH: ::c_int = 16;
-pub const PTRACE_DETACH: ::c_int = 17;
-pub const PTRACE_GETFPXREGS: ::c_int = 18;
-pub const PTRACE_SETFPXREGS: ::c_int = 19;
-pub const PTRACE_SYSCALL: ::c_int = 24;
-pub const PTRACE_SETOPTIONS: ::c_int = 0x4200;
-pub const PTRACE_GETEVENTMSG: ::c_int = 0x4201;
-pub const PTRACE_GETSIGINFO: ::c_int = 0x4202;
-pub const PTRACE_SETSIGINFO: ::c_int = 0x4203;
-pub const PTRACE_GETREGSET: ::c_int = 0x4204;
-pub const PTRACE_SETREGSET: ::c_int = 0x4205;
-pub const PTRACE_SEIZE: ::c_int = 0x4206;
-pub const PTRACE_INTERRUPT: ::c_int = 0x4207;
-pub const PTRACE_LISTEN: ::c_int = 0x4208;
-pub const PTRACE_PEEKSIGINFO: ::c_int = 0x4209;
-
-pub const EPOLLWAKEUP: ::c_int = 0x20000000;
-
-pub const EFD_NONBLOCK: ::c_int = ::O_NONBLOCK;
-
-pub const SFD_NONBLOCK: ::c_int = ::O_NONBLOCK;
-
-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;
-
-// TODO(#247) Temporarily musl-specific (available since musl 0.9.12 / Linux
-// kernel 3.10). See also notbsd/mod.rs
-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;
-pub const B110: ::speed_t = 0o000003;
-pub const B134: ::speed_t = 0o000004;
-pub const B150: ::speed_t = 0o000005;
-pub const B200: ::speed_t = 0o000006;
-pub const B300: ::speed_t = 0o000007;
-pub const B600: ::speed_t = 0o000010;
-pub const B1200: ::speed_t = 0o000011;
-pub const B1800: ::speed_t = 0o000012;
-pub const B2400: ::speed_t = 0o000013;
-pub const B4800: ::speed_t = 0o000014;
-pub const B9600: ::speed_t = 0o000015;
-pub const B19200: ::speed_t = 0o000016;
-pub const B38400: ::speed_t = 0o000017;
-pub const EXTA: ::speed_t = B19200;
-pub const EXTB: ::speed_t = B38400;
-pub const B57600: ::speed_t = 0o010001;
-pub const B115200: ::speed_t = 0o010002;
-pub const B230400: ::speed_t = 0o010003;
-pub const B460800: ::speed_t = 0o010004;
-pub const B500000: ::speed_t = 0o010005;
-pub const B576000: ::speed_t = 0o010006;
-pub const B921600: ::speed_t = 0o010007;
-pub const B1000000: ::speed_t = 0o010010;
-pub const B1152000: ::speed_t = 0o010011;
-pub const B1500000: ::speed_t = 0o010012;
-pub const B2000000: ::speed_t = 0o010013;
-pub const B2500000: ::speed_t = 0o010014;
-pub const B3000000: ::speed_t = 0o010015;
-pub const B3500000: ::speed_t = 0o010016;
-pub const B4000000: ::speed_t = 0o010017;
-
-pub const SO_BINDTODEVICE: ::c_int = 25;
-pub const SO_TIMESTAMP: ::c_int = 29;
-pub const SO_MARK: ::c_int = 36;
-pub const SO_RXQ_OVFL: ::c_int = 40;
-pub const SO_PEEK_OFF: ::c_int = 42;
-pub const SO_BUSY_POLL: ::c_int = 46;
-
-pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 56;
-pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 40;
-
-pub const O_ASYNC: ::c_int = 0x00000400;
-
-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;
-pub const RLIMIT_NPROC: ::c_int = 6;
-pub const RLIMIT_MEMLOCK: ::c_int = 8;
-
-pub const O_APPEND: ::c_int = 0x00100000;
-pub const O_CREAT: ::c_int = 0x00010000;
-pub const O_EXCL: ::c_int = 0x00020000;
-pub const O_NOCTTY: ::c_int = 0x00000200;
-pub const O_NONBLOCK: ::c_int = 0x00000010;
-pub const O_SYNC: ::c_int = (0x00000040 | O_DSYNC);
-pub const O_RSYNC: ::c_int = O_SYNC;
-pub const O_DSYNC: ::c_int = 0x00000020;
-
-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 = 0x02000;
-pub const MAP_NORESERVE: ::c_int = 0x04000;
-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 = EDEADLK;
-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_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;
-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 = 0x00010000;
-
-pub const MAP_HUGETLB: ::c_int = 0x040000;
-
-pub const F_GETLK: ::c_int = 5;
-pub const F_GETOWN: ::c_int = 9;
-pub const F_SETLK: ::c_int = 6;
-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;
-
-pub const O_DIRECTORY: ::c_int = 0x00080000;
-pub const O_DIRECT: ::c_int = 0x00000800;
-pub const O_LARGEFILE: ::c_int = 0x00001000;
-pub const O_NOFOLLOW: ::c_int = 0x00000080;
-
-// intentionally not public, only used for fd_set
-cfg_if! {
- if #[cfg(target_pointer_width = "32")] {
- const ULONG_SIZE: usize = 32;
- } else if #[cfg(target_pointer_width = "64")] {
- const ULONG_SIZE: usize = 64;
- } else {
- // Unknown target_pointer_width
- }
-}
-
-// END_PUB_CONST
-
-f! {
- 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;
- (*set).fds_bits[fd / size] &= !(1 << (fd % size));
- return
- }
-
- pub fn FD_ISSET(fd: ::c_int, set: *mut fd_set) -> bool {
- let fd = fd as usize;
- let size = ::mem::size_of_val(&(*set).fds_bits[0]) * 8;
- return ((*set).fds_bits[fd / size] & (1 << (fd % size))) != 0
- }
-
- pub fn FD_SET(fd: ::c_int, set: *mut fd_set) -> () {
- let fd = fd as usize;
- let size = ::mem::size_of_val(&(*set).fds_bits[0]) * 8;
- (*set).fds_bits[fd / size] |= 1 << (fd % size);
- return
- }
-
- pub fn FD_ZERO(set: *mut fd_set) -> () {
- for slot in (*set).fds_bits.iter_mut() {
- *slot = 0;
- }
- }
-
- pub fn WIFSTOPPED(status: ::c_int) -> bool {
- (status & 0xff) == 0x7f
- }
-
- pub fn WSTOPSIG(status: ::c_int) -> ::c_int {
- (status >> 8) & 0xff
- }
-
- pub fn WIFCONTINUED(status: ::c_int) -> bool {
- status == 0xffff
- }
-
- pub fn WIFSIGNALED(status: ::c_int) -> bool {
- ((status & 0x7f) + 1) as i8 >= 2
- }
-
- pub fn WTERMSIG(status: ::c_int) -> ::c_int {
- status & 0x7f
- }
-
- pub fn WIFEXITED(status: ::c_int) -> bool {
- (status & 0x7f) == 0
- }
-
- pub fn WEXITSTATUS(status: ::c_int) -> ::c_int {
- (status >> 8) & 0xff
- }
-
- pub fn WCOREDUMP(status: ::c_int) -> bool {
- (status & 0x80) != 0
- }
-
- pub fn QCMD(cmd: ::c_int, type_: ::c_int) -> ::c_int {
- (cmd << 8) | (type_ & 0x00ff)
- }
-
- pub fn CPU_ZERO(cpuset: &mut cpu_set_t) -> () {
- for slot in cpuset.bits.iter_mut() {
- *slot = 0;
- }
- }
-
- pub fn CPU_SET(cpu: usize, cpuset: &mut cpu_set_t) -> () {
- let size_in_bits
- = 8 * ::mem::size_of_val(&cpuset.bits[0]); // 32, 64 etc
- let (idx, offset) = (cpu / size_in_bits, cpu % size_in_bits);
- cpuset.bits[idx] |= 1 << offset;
- ()
- }
-
- pub fn CPU_CLR(cpu: usize, cpuset: &mut cpu_set_t) -> () {
- let size_in_bits
- = 8 * ::mem::size_of_val(&cpuset.bits[0]); // 32, 64 etc
- let (idx, offset) = (cpu / size_in_bits, cpu % size_in_bits);
- cpuset.bits[idx] &= !(1 << offset);
- ()
- }
-
- pub fn CPU_ISSET(cpu: usize, cpuset: &cpu_set_t) -> bool {
- let size_in_bits = 8 * ::mem::size_of_val(&cpuset.bits[0]);
- let (idx, offset) = (cpu / size_in_bits, cpu % size_in_bits);
- 0 != (cpuset.bits[idx] & (1 << offset))
- }
-
- pub fn CPU_EQUAL(set1: &cpu_set_t, set2: &cpu_set_t) -> bool {
- set1.bits == set2.bits
- }
-
- pub fn major(dev: ::dev_t) -> ::c_uint {
- let mut major = 0;
- major |= (dev & 0x00000000000fff00) >> 8;
- major |= (dev & 0xfffff00000000000) >> 32;
- major as ::c_uint
- }
-
- pub fn minor(dev: ::dev_t) -> ::c_uint {
- let mut minor = 0;
- minor |= (dev & 0x00000000000000ff) >> 0;
- minor |= (dev & 0x00000ffffff00000) >> 12;
- minor as ::c_uint
- }
-
- pub fn makedev(major: ::c_uint, minor: ::c_uint) -> ::dev_t {
- let major = major as ::dev_t;
- let minor = minor as ::dev_t;
- let mut dev = 0;
- dev |= (major & 0x00000fff) << 8;
- dev |= (major & 0xfffff000) << 32;
- dev |= (minor & 0x000000ff) << 0;
- dev |= (minor & 0xffffff00) << 12;
- dev
- }
-}
-
-// EXTERN_FN
-
-#[link(name = "c")]
-#[link(name = "fdio")]
-extern {}
-
-#[cfg_attr(feature = "extra_traits", derive(Debug))]
-pub enum FILE {}
-impl ::Copy for FILE {}
-impl ::Clone for FILE {
- fn clone(&self) -> FILE { *self }
-}
-#[cfg_attr(feature = "extra_traits", derive(Debug))]
-pub enum fpos_t {} // TODO: fill this out with a struct
-impl ::Copy for fpos_t {}
-impl ::Clone for fpos_t {
- fn clone(&self) -> fpos_t { *self }
-}
-
-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;
-
- pub fn fprintf(stream: *mut ::FILE,
- format: *const ::c_char, ...) -> ::c_int;
- pub fn printf(format: *const ::c_char, ...) -> ::c_int;
- pub fn snprintf(s: *mut ::c_char, n: ::size_t,
- format: *const ::c_char, ...) -> ::c_int;
- pub fn sprintf(s: *mut ::c_char, format: *const ::c_char, ...) -> ::c_int;
- pub fn fscanf(stream: *mut ::FILE, format: *const ::c_char, ...) -> ::c_int;
- pub fn scanf(format: *const ::c_char, ...) -> ::c_int;
- pub fn sscanf(s: *const ::c_char, format: *const ::c_char, ...) -> ::c_int;
- pub fn getchar_unlocked() -> ::c_int;
- pub fn putchar_unlocked(c: ::c_int) -> ::c_int;
-
- pub fn socket(domain: ::c_int, ty: ::c_int, protocol: ::c_int) -> ::c_int;
- pub fn connect(socket: ::c_int, address: *const sockaddr,
- len: socklen_t) -> ::c_int;
- pub fn listen(socket: ::c_int, backlog: ::c_int) -> ::c_int;
- pub fn accept(socket: ::c_int, address: *mut sockaddr,
- address_len: *mut socklen_t) -> ::c_int;
- pub fn getpeername(socket: ::c_int, address: *mut sockaddr,
- address_len: *mut socklen_t) -> ::c_int;
- pub fn getsockname(socket: ::c_int, address: *mut sockaddr,
- address_len: *mut socklen_t) -> ::c_int;
- pub fn setsockopt(socket: ::c_int, level: ::c_int, name: ::c_int,
- value: *const ::c_void,
- option_len: socklen_t) -> ::c_int;
- pub fn socketpair(domain: ::c_int, type_: ::c_int, protocol: ::c_int,
- socket_vector: *mut ::c_int) -> ::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 shutdown(socket: ::c_int, how: ::c_int) -> ::c_int;
-
- pub fn chmod(path: *const c_char, mode: mode_t) -> ::c_int;
- pub fn fchmod(fd: ::c_int, mode: mode_t) -> ::c_int;
-
- pub fn fstat(fildes: ::c_int, buf: *mut stat) -> ::c_int;
-
- pub fn mkdir(path: *const c_char, mode: mode_t) -> ::c_int;
-
- pub fn stat(path: *const c_char, buf: *mut stat) -> ::c_int;
-
- pub fn pclose(stream: *mut ::FILE) -> ::c_int;
- pub fn fdopen(fd: ::c_int, mode: *const c_char) -> *mut ::FILE;
- pub fn fileno(stream: *mut ::FILE) -> ::c_int;
-
- pub fn open(path: *const c_char, oflag: ::c_int, ...) -> ::c_int;
- pub fn creat(path: *const c_char, mode: mode_t) -> ::c_int;
- pub fn fcntl(fd: ::c_int, cmd: ::c_int, ...) -> ::c_int;
-
- pub fn opendir(dirname: *const c_char) -> *mut ::DIR;
- pub fn readdir(dirp: *mut ::DIR) -> *mut ::dirent;
- pub fn readdir_r(dirp: *mut ::DIR, entry: *mut ::dirent,
- result: *mut *mut ::dirent) -> ::c_int;
- pub fn closedir(dirp: *mut ::DIR) -> ::c_int;
- pub fn rewinddir(dirp: *mut ::DIR);
-
- pub fn openat(dirfd: ::c_int, pathname: *const ::c_char,
- flags: ::c_int, ...) -> ::c_int;
- pub fn fchmodat(dirfd: ::c_int, pathname: *const ::c_char,
- mode: ::mode_t, flags: ::c_int) -> ::c_int;
- pub fn fchown(fd: ::c_int,
- owner: ::uid_t,
- group: ::gid_t) -> ::c_int;
- pub fn fchownat(dirfd: ::c_int, pathname: *const ::c_char,
- owner: ::uid_t, group: ::gid_t,
- flags: ::c_int) -> ::c_int;
- 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,
- newdirfd: ::c_int, newpath: *const ::c_char,
- flags: ::c_int) -> ::c_int;
- pub fn mkdirat(dirfd: ::c_int, pathname: *const ::c_char,
- mode: ::mode_t) -> ::c_int;
- pub fn readlinkat(dirfd: ::c_int, pathname: *const ::c_char,
- buf: *mut ::c_char, bufsiz: ::size_t) -> ::ssize_t;
- pub fn renameat(olddirfd: ::c_int, oldpath: *const ::c_char,
- newdirfd: ::c_int, newpath: *const ::c_char)
- -> ::c_int;
- pub fn symlinkat(target: *const ::c_char, newdirfd: ::c_int,
- linkpath: *const ::c_char) -> ::c_int;
- pub fn unlinkat(dirfd: ::c_int, pathname: *const ::c_char,
- flags: ::c_int) -> ::c_int;
-
- pub fn access(path: *const c_char, amode: ::c_int) -> ::c_int;
- pub fn alarm(seconds: ::c_uint) -> ::c_uint;
- pub fn chdir(dir: *const c_char) -> ::c_int;
- pub fn fchdir(dirfd: ::c_int) -> ::c_int;
- pub fn chown(path: *const c_char, uid: uid_t,
- gid: gid_t) -> ::c_int;
- pub fn lchown(path: *const c_char, uid: uid_t,
- gid: gid_t) -> ::c_int;
- pub fn close(fd: ::c_int) -> ::c_int;
- pub fn dup(fd: ::c_int) -> ::c_int;
- pub fn dup2(src: ::c_int, dst: ::c_int) -> ::c_int;
- pub fn execl(path: *const c_char,
- arg0: *const c_char, ...) -> ::c_int;
- pub fn execle(path: *const ::c_char,
- arg0: *const ::c_char, ...) -> ::c_int;
- pub fn execlp(file: *const ::c_char,
- arg0: *const ::c_char, ...) -> ::c_int;
- pub fn execv(prog: *const c_char,
- argv: *const *const c_char) -> ::c_int;
- pub fn execve(prog: *const c_char, argv: *const *const c_char,
- envp: *const *const c_char)
- -> ::c_int;
- pub fn execvp(c: *const c_char,
- argv: *const *const c_char) -> ::c_int;
- pub fn fork() -> pid_t;
- pub fn fpathconf(filedes: ::c_int, name: ::c_int) -> c_long;
- pub fn getcwd(buf: *mut c_char, size: ::size_t) -> *mut c_char;
- pub fn getegid() -> gid_t;
- pub fn geteuid() -> uid_t;
- pub fn getgid() -> gid_t;
- pub fn getgroups(ngroups_max: ::c_int, groups: *mut gid_t)
- -> ::c_int;
- pub fn getlogin() -> *mut c_char;
- pub fn getopt(argc: ::c_int, argv: *const *mut c_char,
- optstr: *const c_char) -> ::c_int;
- pub fn getpgid(pid: pid_t) -> pid_t;
- pub fn getpgrp() -> pid_t;
- pub fn getpid() -> pid_t;
- pub fn getppid() -> pid_t;
- pub fn getuid() -> uid_t;
- pub fn isatty(fd: ::c_int) -> ::c_int;
- pub fn link(src: *const c_char, dst: *const c_char) -> ::c_int;
- pub fn lseek(fd: ::c_int, offset: off_t, whence: ::c_int) -> off_t;
- pub fn pathconf(path: *const c_char, name: ::c_int) -> c_long;
- pub fn pause() -> ::c_int;
- pub fn pipe(fds: *mut ::c_int) -> ::c_int;
- pub fn posix_memalign(memptr: *mut *mut ::c_void,
- align: ::size_t,
- size: ::size_t) -> ::c_int;
- pub fn read(fd: ::c_int, buf: *mut ::c_void, count: ::size_t)
- -> ::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;
- pub fn setuid(uid: uid_t) -> ::c_int;
- pub fn sleep(secs: ::c_uint) -> ::c_uint;
- pub fn nanosleep(rqtp: *const timespec,
- rmtp: *mut timespec) -> ::c_int;
- pub fn tcgetpgrp(fd: ::c_int) -> pid_t;
- pub fn tcsetpgrp(fd: ::c_int, pgrp: ::pid_t) -> ::c_int;
- pub fn ttyname(fd: ::c_int) -> *mut c_char;
- pub fn unlink(c: *const c_char) -> ::c_int;
- pub fn wait(status: *mut ::c_int) -> pid_t;
- pub fn waitpid(pid: pid_t, status: *mut ::c_int, options: ::c_int)
- -> pid_t;
- pub fn write(fd: ::c_int, buf: *const ::c_void, count: ::size_t)
- -> ::ssize_t;
- pub fn pread(fd: ::c_int, buf: *mut ::c_void, count: ::size_t,
- offset: off_t) -> ::ssize_t;
- pub fn pwrite(fd: ::c_int, buf: *const ::c_void, count: ::size_t,
- offset: off_t) -> ::ssize_t;
- pub fn umask(mask: mode_t) -> mode_t;
-
- pub fn utime(file: *const c_char, buf: *const utimbuf) -> ::c_int;
-
- pub fn kill(pid: 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;
- pub fn mlockall(flags: ::c_int) -> ::c_int;
- pub fn munlockall() -> ::c_int;
-
- pub fn mmap(addr: *mut ::c_void,
- len: ::size_t,
- prot: ::c_int,
- flags: ::c_int,
- fd: ::c_int,
- offset: off_t)
- -> *mut ::c_void;
- pub fn munmap(addr: *mut ::c_void, len: ::size_t) -> ::c_int;
-
- pub fn if_nametoindex(ifname: *const c_char) -> ::c_uint;
- pub fn if_indextoname(ifindex: ::c_uint,
- ifname: *mut ::c_char) -> *mut ::c_char;
-
- pub fn lstat(path: *const c_char, buf: *mut stat) -> ::c_int;
-
- pub fn fsync(fd: ::c_int) -> ::c_int;
-
- 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 symlink(path1: *const c_char,
- path2: *const c_char) -> ::c_int;
-
- pub fn ftruncate(fd: ::c_int, length: off_t) -> ::c_int;
-
- pub fn signal(signum: ::c_int, handler: sighandler_t) -> sighandler_t;
-
- pub fn getrlimit(resource: ::c_int, rlim: *mut rlimit) -> ::c_int;
- pub fn setrlimit(resource: ::c_int, rlim: *const rlimit) -> ::c_int;
- pub fn getrusage(resource: ::c_int, usage: *mut rusage) -> ::c_int;
-
- pub fn realpath(pathname: *const ::c_char, resolved: *mut ::c_char)
- -> *mut ::c_char;
-
- pub fn flock(fd: ::c_int, operation: ::c_int) -> ::c_int;
-
- pub fn gettimeofday(tp: *mut ::timeval,
- tz: *mut ::c_void) -> ::c_int;
- pub fn times(buf: *mut ::tms) -> ::clock_t;
-
- pub fn pthread_self() -> ::pthread_t;
- pub fn pthread_join(native: ::pthread_t,
- value: *mut *mut ::c_void) -> ::c_int;
- pub fn pthread_exit(value: *mut ::c_void);
- pub fn pthread_attr_init(attr: *mut ::pthread_attr_t) -> ::c_int;
- pub fn pthread_attr_destroy(attr: *mut ::pthread_attr_t) -> ::c_int;
- pub fn pthread_attr_setstacksize(attr: *mut ::pthread_attr_t,
- stack_size: ::size_t) -> ::c_int;
- pub fn pthread_attr_setdetachstate(attr: *mut ::pthread_attr_t,
- state: ::c_int) -> ::c_int;
- pub fn pthread_detach(thread: ::pthread_t) -> ::c_int;
- pub fn sched_yield() -> ::c_int;
- pub fn pthread_key_create(key: *mut pthread_key_t,
- dtor: ::Option<unsafe extern fn(*mut ::c_void)>)
- -> ::c_int;
- pub fn pthread_key_delete(key: pthread_key_t) -> ::c_int;
- pub fn pthread_getspecific(key: pthread_key_t) -> *mut ::c_void;
- pub fn pthread_setspecific(key: pthread_key_t, value: *const ::c_void)
- -> ::c_int;
- pub fn pthread_mutex_init(lock: *mut pthread_mutex_t,
- attr: *const pthread_mutexattr_t) -> ::c_int;
- pub fn pthread_mutex_destroy(lock: *mut pthread_mutex_t) -> ::c_int;
- pub fn pthread_mutex_lock(lock: *mut pthread_mutex_t) -> ::c_int;
- pub fn pthread_mutex_trylock(lock: *mut pthread_mutex_t) -> ::c_int;
- pub fn pthread_mutex_unlock(lock: *mut pthread_mutex_t) -> ::c_int;
-
- pub fn pthread_mutexattr_init(attr: *mut pthread_mutexattr_t) -> ::c_int;
- pub fn pthread_mutexattr_destroy(attr: *mut pthread_mutexattr_t) -> ::c_int;
- pub fn pthread_mutexattr_settype(attr: *mut pthread_mutexattr_t,
- _type: ::c_int) -> ::c_int;
-
- pub fn pthread_cond_init(cond: *mut pthread_cond_t,
- attr: *const pthread_condattr_t) -> ::c_int;
- pub fn pthread_cond_wait(cond: *mut pthread_cond_t,
- lock: *mut pthread_mutex_t) -> ::c_int;
- pub fn pthread_cond_timedwait(cond: *mut pthread_cond_t,
- lock: *mut pthread_mutex_t,
- abstime: *const ::timespec) -> ::c_int;
- pub fn pthread_cond_signal(cond: *mut pthread_cond_t) -> ::c_int;
- pub fn pthread_cond_broadcast(cond: *mut pthread_cond_t) -> ::c_int;
- pub fn pthread_cond_destroy(cond: *mut pthread_cond_t) -> ::c_int;
- pub fn pthread_condattr_init(attr: *mut pthread_condattr_t) -> ::c_int;
- pub fn pthread_condattr_destroy(attr: *mut pthread_condattr_t) -> ::c_int;
- pub fn pthread_rwlock_init(lock: *mut pthread_rwlock_t,
- attr: *const pthread_rwlockattr_t) -> ::c_int;
- pub fn pthread_rwlock_destroy(lock: *mut pthread_rwlock_t) -> ::c_int;
- pub fn pthread_rwlock_rdlock(lock: *mut pthread_rwlock_t) -> ::c_int;
- pub fn pthread_rwlock_tryrdlock(lock: *mut pthread_rwlock_t) -> ::c_int;
- pub fn pthread_rwlock_wrlock(lock: *mut pthread_rwlock_t) -> ::c_int;
- pub fn pthread_rwlock_trywrlock(lock: *mut pthread_rwlock_t) -> ::c_int;
- pub fn pthread_rwlock_unlock(lock: *mut pthread_rwlock_t) -> ::c_int;
- pub fn pthread_rwlockattr_init(attr: *mut pthread_rwlockattr_t) -> ::c_int;
- pub fn pthread_rwlockattr_destroy(attr: *mut pthread_rwlockattr_t)
- -> ::c_int;
- pub fn strerror_r(errnum: ::c_int, buf: *mut c_char,
- buflen: ::size_t) -> ::c_int;
-
- pub fn getsockopt(sockfd: ::c_int,
- level: ::c_int,
- optname: ::c_int,
- optval: *mut ::c_void,
- optlen: *mut ::socklen_t) -> ::c_int;
- pub fn raise(signum: ::c_int) -> ::c_int;
- pub fn sigaction(signum: ::c_int,
- act: *const sigaction,
- oldact: *mut sigaction) -> ::c_int;
-
- pub fn utimes(filename: *const ::c_char,
- times: *const ::timeval) -> ::c_int;
- pub fn dlopen(filename: *const ::c_char,
- flag: ::c_int) -> *mut ::c_void;
- pub fn dlerror() -> *mut ::c_char;
- pub fn dlsym(handle: *mut ::c_void,
- symbol: *const ::c_char) -> *mut ::c_void;
- pub fn dlclose(handle: *mut ::c_void) -> ::c_int;
- pub fn dladdr(addr: *const ::c_void, info: *mut Dl_info) -> ::c_int;
-
- pub fn getaddrinfo(node: *const c_char,
- service: *const c_char,
- hints: *const addrinfo,
- res: *mut *mut addrinfo) -> ::c_int;
- pub fn freeaddrinfo(res: *mut addrinfo);
- pub fn gai_strerror(errcode: ::c_int) -> *const ::c_char;
- pub fn res_init() -> ::c_int;
-
- pub fn gmtime_r(time_p: *const time_t, result: *mut tm) -> *mut tm;
- pub fn localtime_r(time_p: *const time_t, result: *mut tm) -> *mut tm;
- pub fn mktime(tm: *mut tm) -> time_t;
- pub fn time(time: *mut time_t) -> time_t;
- pub fn gmtime(time_p: *const time_t) -> *mut tm;
- pub fn localtime(time_p: *const time_t) -> *mut tm;
-
- pub fn mknod(pathname: *const ::c_char, mode: ::mode_t,
- dev: ::dev_t) -> ::c_int;
- pub fn uname(buf: *mut ::utsname) -> ::c_int;
- pub fn gethostname(name: *mut ::c_char, len: ::size_t) -> ::c_int;
- pub fn getservbyname(name: *const ::c_char,
- proto: *const ::c_char) -> *mut servent;
- pub fn getprotobyname(name: *const ::c_char) -> *mut protoent;
- pub fn getprotobynumber(proto: ::c_int) -> *mut protoent;
- pub fn chroot(name: *const ::c_char) -> ::c_int;
- pub fn usleep(secs: ::c_uint) -> ::c_int;
- pub fn send(socket: ::c_int, buf: *const ::c_void, len: ::size_t,
- flags: ::c_int) -> ::ssize_t;
- pub fn recv(socket: ::c_int, buf: *mut ::c_void, len: ::size_t,
- flags: ::c_int) -> ::ssize_t;
- pub fn putenv(string: *mut c_char) -> ::c_int;
- pub fn poll(fds: *mut pollfd, nfds: nfds_t, timeout: ::c_int) -> ::c_int;
- pub fn select(nfds: ::c_int,
- readfs: *mut fd_set,
- writefds: *mut fd_set,
- errorfds: *mut fd_set,
- timeout: *mut timeval) -> ::c_int;
- pub fn setlocale(category: ::c_int,
- locale: *const ::c_char) -> *mut ::c_char;
- pub fn localeconv() -> *mut lconv;
-
- pub fn sem_destroy(sem: *mut sem_t) -> ::c_int;
- pub fn sem_wait(sem: *mut sem_t) -> ::c_int;
- pub fn sem_trywait(sem: *mut sem_t) -> ::c_int;
- pub fn sem_post(sem: *mut sem_t) -> ::c_int;
- pub fn sem_init(sem: *mut sem_t,
- pshared: ::c_int,
- value: ::c_uint)
- -> ::c_int;
- pub fn statvfs(path: *const c_char, buf: *mut statvfs) -> ::c_int;
- pub fn fstatvfs(fd: ::c_int, buf: *mut statvfs) -> ::c_int;
-
- pub fn readlink(path: *const c_char,
- buf: *mut c_char,
- bufsz: ::size_t)
- -> ::ssize_t;
-
- pub fn sigemptyset(set: *mut sigset_t) -> ::c_int;
- pub fn sigaddset(set: *mut sigset_t, signum: ::c_int) -> ::c_int;
- pub fn sigfillset(set: *mut sigset_t) -> ::c_int;
- pub fn sigdelset(set: *mut sigset_t, signum: ::c_int) -> ::c_int;
- pub fn sigismember(set: *const sigset_t, signum: ::c_int) -> ::c_int;
-
- pub fn sigprocmask(how: ::c_int,
- set: *const sigset_t,
- oldset: *mut sigset_t)
- -> ::c_int;
- pub fn sigpending(set: *mut sigset_t) -> ::c_int;
-
- pub fn timegm(tm: *mut ::tm) -> time_t;
-
- pub fn getsid(pid: pid_t) -> pid_t;
-
- pub fn sysconf(name: ::c_int) -> ::c_long;
-
- pub fn mkfifo(path: *const c_char, mode: mode_t) -> ::c_int;
-
- pub fn pselect(nfds: ::c_int,
- readfs: *mut fd_set,
- writefds: *mut fd_set,
- errorfds: *mut fd_set,
- timeout: *const timespec,
- sigmask: *const sigset_t) -> ::c_int;
- pub fn fseeko(stream: *mut ::FILE,
- offset: ::off_t,
- whence: ::c_int) -> ::c_int;
- pub fn ftello(stream: *mut ::FILE) -> ::off_t;
- pub fn tcdrain(fd: ::c_int) -> ::c_int;
- pub fn cfgetispeed(termios: *const ::termios) -> ::speed_t;
- pub fn cfgetospeed(termios: *const ::termios) -> ::speed_t;
- pub fn cfmakeraw(termios: *mut ::termios);
- pub fn cfsetispeed(termios: *mut ::termios, speed: ::speed_t) -> ::c_int;
- pub fn cfsetospeed(termios: *mut ::termios, speed: ::speed_t) -> ::c_int;
- pub fn cfsetspeed(termios: *mut ::termios, speed: ::speed_t) -> ::c_int;
- pub fn tcgetattr(fd: ::c_int, termios: *mut ::termios) -> ::c_int;
- pub fn tcsetattr(fd: ::c_int,
- optional_actions: ::c_int,
- termios: *const ::termios) -> ::c_int;
- pub fn tcflow(fd: ::c_int, action: ::c_int) -> ::c_int;
- pub fn tcflush(fd: ::c_int, action: ::c_int) -> ::c_int;
- pub fn tcgetsid(fd: ::c_int) -> ::pid_t;
- pub fn tcsendbreak(fd: ::c_int, duration: ::c_int) -> ::c_int;
- pub fn mkstemp(template: *mut ::c_char) -> ::c_int;
- pub fn mkdtemp(template: *mut ::c_char) -> *mut ::c_char;
-
- pub fn tmpnam(ptr: *mut ::c_char) -> *mut ::c_char;
-
- pub fn openlog(ident: *const ::c_char, logopt: ::c_int, facility: ::c_int);
- pub fn closelog();
- pub fn setlogmask(maskpri: ::c_int) -> ::c_int;
- pub fn syslog(priority: ::c_int, message: *const ::c_char, ...);
- pub fn nice(incr: ::c_int) -> ::c_int;
-
- pub fn grantpt(fd: ::c_int) -> ::c_int;
- 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 fdatasync(fd: ::c_int) -> ::c_int;
- pub fn mincore(addr: *mut ::c_void, len: ::size_t,
- vec: *mut ::c_uchar) -> ::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_settime(clk_id: ::clockid_t, tp: *const ::timespec) -> ::c_int;
- pub fn dirfd(dirp: *mut ::DIR) -> ::c_int;
-
- pub fn pthread_getattr_np(native: ::pthread_t,
- attr: *mut ::pthread_attr_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 memalign(align: ::size_t, size: ::size_t) -> *mut ::c_void;
- pub fn setgroups(ngroups: ::size_t,
- ptr: *const ::gid_t) -> ::c_int;
- pub fn pipe2(fds: *mut ::c_int, flags: ::c_int) -> ::c_int;
- pub fn statfs(path: *const ::c_char, buf: *mut statfs) -> ::c_int;
- pub fn statfs64(path: *const ::c_char, buf: *mut statfs64) -> ::c_int;
- pub fn fstatfs(fd: ::c_int, buf: *mut statfs) -> ::c_int;
- pub fn fstatfs64(fd: ::c_int, buf: *mut statfs64) -> ::c_int;
- pub fn statvfs64(path: *const ::c_char, buf: *mut statvfs64) -> ::c_int;
- pub fn fstatvfs64(fd: ::c_int, buf: *mut statvfs64) -> ::c_int;
- pub fn memrchr(cx: *const ::c_void,
- c: ::c_int,
- n: ::size_t) -> *mut ::c_void;
-
- pub fn posix_fadvise(fd: ::c_int, offset: ::off_t, len: ::off_t,
- advise: ::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 duplocale(base: ::locale_t) -> ::locale_t;
- pub fn freelocale(loc: ::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 creat64(path: *const c_char, mode: mode_t) -> ::c_int;
- pub fn fstat64(fildes: ::c_int, buf: *mut stat64) -> ::c_int;
- pub fn fstatat64(dirfd: ::c_int, pathname: *const c_char,
- buf: *mut stat64, flags: ::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;
- pub fn lstat64(path: *const c_char, buf: *mut stat64) -> ::c_int;
- pub fn mmap64(addr: *mut ::c_void,
- len: ::size_t,
- prot: ::c_int,
- flags: ::c_int,
- fd: ::c_int,
- offset: off64_t)
- -> *mut ::c_void;
- pub fn open64(path: *const c_char, oflag: ::c_int, ...) -> ::c_int;
- pub fn openat64(fd: ::c_int,
- path: *const c_char,
- oflag: ::c_int, ...) -> ::c_int;
- pub fn pread64(fd: ::c_int, buf: *mut ::c_void, count: ::size_t,
- offset: off64_t) -> ::ssize_t;
- pub fn preadv64(fd: ::c_int,
- iov: *const ::iovec,
- iovcnt: ::c_int,
- offset: ::off64_t) -> ::ssize_t;
- pub fn pwrite64(fd: ::c_int, buf: *const ::c_void, count: ::size_t,
- offset: off64_t) -> ::ssize_t;
- pub fn pwritev64(fd: ::c_int,
- iov: *const ::iovec,
- iovcnt: ::c_int,
- offset: ::off64_t) -> ::ssize_t;
- pub fn readdir64(dirp: *mut ::DIR) -> *mut ::dirent64;
- pub fn readdir64_r(dirp: *mut ::DIR, entry: *mut ::dirent64,
- result: *mut *mut ::dirent64) -> ::c_int;
- pub fn setrlimit64(resource: ::c_int, rlim: *const rlimit64) -> ::c_int;
- 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,
- 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 pthread_condattr_setpshared(attr: *mut pthread_condattr_t,
- pshared: ::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_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 ptsname_r(fd: ::c_int,
- buf: *mut ::c_char,
- buflen: ::size_t) -> ::c_int;
- pub fn clearenv() -> ::c_int;
- pub fn waitid(idtype: idtype_t, id: id_t, infop: *mut ::siginfo_t,
- options: ::c_int) -> ::c_int;
- pub fn setreuid(ruid: ::uid_t, euid: ::uid_t) -> ::c_int;
- pub fn setregid(rgid: ::gid_t, egid: ::gid_t) -> ::c_int;
- pub fn getresuid(ruid: *mut ::uid_t, euid: *mut ::uid_t,
- suid: *mut ::uid_t) -> ::c_int;
- pub fn getresgid(rgid: *mut ::gid_t, egid: *mut ::gid_t,
- sgid: *mut ::gid_t) -> ::c_int;
- pub fn acct(filename: *const ::c_char) -> ::c_int;
- pub fn brk(addr: *mut ::c_void) -> ::c_int;
- pub fn sbrk(increment: ::intptr_t) -> *mut ::c_void;
- pub fn vfork() -> ::pid_t;
- 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 wait4(pid: ::pid_t, status: *mut ::c_int, options: ::c_int,
- rusage: *mut ::rusage) -> ::pid_t;
- pub fn openpty(amaster: *mut ::c_int,
- aslave: *mut ::c_int,
- name: *mut ::c_char,
- termp: *const termios,
- winp: *const ::winsize) -> ::c_int;
- pub fn execvpe(file: *const ::c_char, argv: *const *const ::c_char,
- envp: *const *const ::c_char) -> ::c_int;
- pub fn fexecve(fd: ::c_int, argv: *const *const ::c_char,
- envp: *const *const ::c_char)
- -> ::c_int;
-
- 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 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 lutimes(file: *const ::c_char, times: *const ::timeval) -> ::c_int;
-
- pub fn setpwent();
- pub fn endpwent();
- pub fn getpwent() -> *mut passwd;
- 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,
- mode: mode_t) -> ::c_int;
-
- // System V IPC
- pub fn shmget(key: ::key_t, size: ::size_t, shmflg: ::c_int) -> ::c_int;
- 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;
- pub fn shmctl(shmid: ::c_int,
- cmd: ::c_int,
- buf: *mut ::shmid_ds) -> ::c_int;
- pub fn ftok(pathname: *const ::c_char, proj_id: ::c_int) -> ::key_t;
- pub fn semget(key: ::key_t, nsems: ::c_int, semflag: ::c_int) -> ::c_int;
- pub fn semop(semid: ::c_int,
- sops: *mut ::sembuf, nsops: ::size_t) -> ::c_int;
- pub fn semctl(semid: ::c_int,
- semnum: ::c_int, cmd: ::c_int, ...) -> ::c_int;
- pub fn msgctl(msqid: ::c_int, cmd: ::c_int, buf: *mut msqid_ds) -> ::c_int;
- pub fn msgget(key: ::key_t, msgflg: ::c_int) -> ::c_int;
- pub fn msgrcv(msqid: ::c_int, msgp: *mut ::c_void, msgsz: ::size_t,
- msgtyp: ::c_long, msgflg: ::c_int) -> ::ssize_t;
- pub fn msgsnd(msqid: ::c_int, msgp: *const ::c_void, msgsz: ::size_t,
- msgflg: ::c_int) -> ::c_int;
-
- pub fn mprotect(addr: *mut ::c_void, len: ::size_t, prot: ::c_int)
- -> ::c_int;
- pub fn __errno_location() -> *mut ::c_int;
-
- pub fn fopen64(filename: *const c_char,
- mode: *const c_char) -> *mut ::FILE;
- pub fn freopen64(filename: *const c_char, mode: *const c_char,
- file: *mut ::FILE) -> *mut ::FILE;
- pub fn tmpfile64() -> *mut ::FILE;
- pub fn fgetpos64(stream: *mut ::FILE, ptr: *mut fpos64_t) -> ::c_int;
- pub fn fsetpos64(stream: *mut ::FILE, ptr: *const fpos64_t) -> ::c_int;
- pub fn fseeko64(stream: *mut ::FILE,
- offset: ::off64_t,
- whence: ::c_int) -> ::c_int;
- 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 posix_fallocate(fd: ::c_int, offset: ::off_t,
- len: ::off_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,
- value: *mut ::c_void, size: ::size_t) -> ::ssize_t;
- pub fn lgetxattr(path: *const c_char, name: *const c_char,
- value: *mut ::c_void, size: ::size_t) -> ::ssize_t;
- pub fn fgetxattr(filedes: ::c_int, name: *const c_char,
- value: *mut ::c_void, size: ::size_t) -> ::ssize_t;
- pub fn setxattr(path: *const c_char, name: *const c_char,
- value: *const ::c_void, size: ::size_t,
- flags: ::c_int) -> ::c_int;
- pub fn lsetxattr(path: *const c_char, name: *const c_char,
- value: *const ::c_void, size: ::size_t,
- flags: ::c_int) -> ::c_int;
- pub fn fsetxattr(filedes: ::c_int, name: *const c_char,
- value: *const ::c_void, size: ::size_t,
- flags: ::c_int) -> ::c_int;
- pub fn listxattr(path: *const c_char, list: *mut c_char,
- size: ::size_t) -> ::ssize_t;
- pub fn llistxattr(path: *const c_char, list: *mut c_char,
- size: ::size_t) -> ::ssize_t;
- pub fn flistxattr(filedes: ::c_int, list: *mut c_char,
- size: ::size_t) -> ::ssize_t;
- pub fn removexattr(path: *const c_char, name: *const c_char) -> ::c_int;
- pub fn lremovexattr(path: *const c_char, name: *const c_char) -> ::c_int;
- pub fn fremovexattr(filedes: ::c_int, name: *const c_char) -> ::c_int;
- pub fn signalfd(fd: ::c_int,
- mask: *const ::sigset_t,
- flags: ::c_int) -> ::c_int;
- pub fn timerfd_create(clockid: ::c_int, flags: ::c_int) -> ::c_int;
- pub fn timerfd_gettime(fd: ::c_int,
- curr_value: *mut itimerspec) -> ::c_int;
- pub fn timerfd_settime(fd: ::c_int,
- flags: ::c_int,
- new_value: *const itimerspec,
- old_value: *mut itimerspec) -> ::c_int;
- pub fn pwritev(fd: ::c_int,
- iov: *const ::iovec,
- iovcnt: ::c_int,
- offset: ::off_t) -> ::ssize_t;
- pub fn preadv(fd: ::c_int,
- iov: *const ::iovec,
- iovcnt: ::c_int,
- offset: ::off_t) -> ::ssize_t;
- pub fn quotactl(cmd: ::c_int,
- special: *const ::c_char,
- id: ::c_int,
- data: *mut ::c_char) -> ::c_int;
- pub fn mq_open(name: *const ::c_char, oflag: ::c_int, ...) -> ::mqd_t;
- pub fn mq_close(mqd: ::mqd_t) -> ::c_int;
- pub fn mq_unlink(name: *const ::c_char) -> ::c_int;
- pub fn mq_receive(mqd: ::mqd_t,
- msg_ptr: *mut ::c_char,
- msg_len: ::size_t,
- msq_prio: *mut ::c_uint) -> ::ssize_t;
- pub fn mq_send(mqd: ::mqd_t,
- msg_ptr: *const ::c_char,
- msg_len: ::size_t,
- msq_prio: ::c_uint) -> ::c_int;
- pub fn mq_getattr(mqd: ::mqd_t, attr: *mut ::mq_attr) -> ::c_int;
- pub fn mq_setattr(mqd: ::mqd_t,
- newattr: *const ::mq_attr,
- oldattr: *mut ::mq_attr) -> ::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 dup3(oldfd: ::c_int, newfd: ::c_int, flags: ::c_int) -> ::c_int;
- pub fn mkostemp(template: *mut ::c_char, flags: ::c_int) -> ::c_int;
- pub fn mkostemps(template: *mut ::c_char,
- suffixlen: ::c_int,
- flags: ::c_int) -> ::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 nl_langinfo_l(item: ::nl_item, locale: ::locale_t) -> *mut ::c_char;
- pub fn getnameinfo(sa: *const ::sockaddr,
- salen: ::socklen_t,
- host: *mut ::c_char,
- hostlen: ::socklen_t,
- serv: *mut ::c_char,
- sevlen: ::socklen_t,
- flags: ::c_int) -> ::c_int;
- pub fn pthread_setschedprio(native: ::pthread_t,
- priority: ::c_int) -> ::c_int;
- pub fn prlimit(pid: ::pid_t, resource: ::c_int, new_limit: *const ::rlimit,
- old_limit: *mut ::rlimit) -> ::c_int;
- pub fn prlimit64(pid: ::pid_t,
- resource: ::c_int,
- new_limit: *const ::rlimit64,
- old_limit: *mut ::rlimit64) -> ::c_int;
- pub fn getloadavg(loadavg: *mut ::c_double, nelem: ::c_int) -> ::c_int;
- pub fn process_vm_readv(pid: ::pid_t,
- local_iov: *const ::iovec,
- liovcnt: ::c_ulong,
- remote_iov: *const ::iovec,
- riovcnt: ::c_ulong,
- flags: ::c_ulong) -> isize;
- pub fn process_vm_writev(pid: ::pid_t,
- local_iov: *const ::iovec,
- liovcnt: ::c_ulong,
- remote_iov: *const ::iovec,
- riovcnt: ::c_ulong,
- flags: ::c_ulong) -> isize;
- pub fn reboot(how_to: ::c_int) -> ::c_int;
- pub fn setfsgid(gid: ::gid_t) -> ::c_int;
- pub fn setfsuid(uid: ::uid_t) -> ::c_int;
-
- // Not available now on Android
- pub fn mkfifoat(dirfd: ::c_int, pathname: *const ::c_char,
- mode: ::mode_t) -> ::c_int;
- pub fn if_nameindex() -> *mut if_nameindex;
- pub fn if_freenameindex(ptr: *mut if_nameindex);
- 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,
- flags: ::c_int,
- ...) -> *mut ::c_void;
-
- 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;
- pub fn globfree(pglob: *mut ::glob_t);
-
- pub fn posix_madvise(addr: *mut ::c_void, len: ::size_t, advice: ::c_int)
- -> ::c_int;
-
- pub fn shm_unlink(name: *const ::c_char) -> ::c_int;
-
- pub fn seekdir(dirp: *mut ::DIR, loc: ::c_long);
-
- pub fn telldir(dirp: *mut ::DIR) -> ::c_long;
- pub fn madvise(addr: *mut ::c_void, len: ::size_t, advice: ::c_int)
- -> ::c_int;
-
- pub fn msync(addr: *mut ::c_void, len: ::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;
- pub fn mkstemps(template: *mut ::c_char, suffixlen: ::c_int) -> ::c_int;
- 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;
- pub fn sendmmsg(sockfd: ::c_int, msgvec: *mut mmsghdr, vlen: ::c_uint,
- flags: ::c_int) -> ::c_int;
- pub fn recvmmsg(sockfd: ::c_int, msgvec: *mut mmsghdr, vlen: ::c_uint,
- flags: ::c_int, timeout: *mut ::timespec) -> ::c_int;
- pub fn sync();
- pub fn syscall(num: ::c_long, ...) -> ::c_long;
- pub fn sched_getaffinity(pid: ::pid_t,
- cpusetsize: ::size_t,
- cpuset: *mut cpu_set_t) -> ::c_int;
- pub fn sched_setaffinity(pid: ::pid_t,
- cpusetsize: ::size_t,
- cpuset: *const cpu_set_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;
- pub fn pthread_getschedparam(native: ::pthread_t,
- policy: *mut ::c_int,
- param: *mut ::sched_param) -> ::c_int;
- pub fn unshare(flags: ::c_int) -> ::c_int;
- pub fn umount(target: *const ::c_char) -> ::c_int;
- pub fn sched_get_priority_max(policy: ::c_int) -> ::c_int;
- pub fn tee(fd_in: ::c_int,
- fd_out: ::c_int,
- len: ::size_t,
- flags: ::c_uint) -> ::ssize_t;
- pub fn settimeofday(tv: *const ::timeval, tz: *const ::timezone) -> ::c_int;
- pub fn splice(fd_in: ::c_int,
- off_in: *mut ::loff_t,
- fd_out: ::c_int,
- off_out: *mut ::loff_t,
- len: ::size_t,
- flags: ::c_uint) -> ::ssize_t;
- pub fn eventfd(init: ::c_uint, flags: ::c_int) -> ::c_int;
- 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;
- pub fn vmsplice(fd: ::c_int,
- iov: *const ::iovec,
- nr_segs: ::size_t,
- flags: ::c_uint) -> ::ssize_t;
- pub fn mount(src: *const ::c_char,
- target: *const ::c_char,
- fstype: *const ::c_char,
- flags: ::c_ulong,
- data: *const ::c_void) -> ::c_int;
- pub fn personality(persona: ::c_ulong) -> ::c_int;
- pub fn prctl(option: ::c_int, ...) -> ::c_int;
- pub fn sched_getparam(pid: ::pid_t, param: *mut ::sched_param) -> ::c_int;
- pub fn ppoll(fds: *mut ::pollfd,
- nfds: nfds_t,
- timeout: *const ::timespec,
- sigmask: *const sigset_t) -> ::c_int;
- pub fn pthread_mutex_timedlock(lock: *mut pthread_mutex_t,
- abstime: *const ::timespec) -> ::c_int;
- pub fn clone(cb: extern fn(*mut ::c_void) -> ::c_int,
- child_stack: *mut ::c_void,
- flags: ::c_int,
- arg: *mut ::c_void, ...) -> ::c_int;
- pub fn sched_getscheduler(pid: ::pid_t) -> ::c_int;
- pub fn clock_nanosleep(clk_id: ::clockid_t,
- flags: ::c_int,
- rqtp: *const ::timespec,
- rmtp: *mut ::timespec) -> ::c_int;
- pub fn pthread_attr_getguardsize(attr: *const ::pthread_attr_t,
- guardsize: *mut ::size_t) -> ::c_int;
- pub fn sethostname(name: *const ::c_char, len: ::size_t) -> ::c_int;
- pub fn sched_get_priority_min(policy: ::c_int) -> ::c_int;
- pub fn pthread_condattr_getpshared(attr: *const pthread_condattr_t,
- pshared: *mut ::c_int) -> ::c_int;
- pub fn sysinfo(info: *mut ::sysinfo) -> ::c_int;
- pub fn umount2(target: *const ::c_char, flags: ::c_int) -> ::c_int;
- pub fn pthread_setschedparam(native: ::pthread_t,
- policy: ::c_int,
- param: *const ::sched_param) -> ::c_int;
- pub fn swapon(path: *const ::c_char, swapflags: ::c_int) -> ::c_int;
- pub fn sched_setscheduler(pid: ::pid_t,
- policy: ::c_int,
- param: *const ::sched_param) -> ::c_int;
- pub fn sendfile(out_fd: ::c_int,
- in_fd: ::c_int,
- offset: *mut off_t,
- count: ::size_t) -> ::ssize_t;
- pub fn sigsuspend(mask: *const ::sigset_t) -> ::c_int;
- pub fn getgrgid_r(gid: ::gid_t,
- grp: *mut ::group,
- buf: *mut ::c_char,
- buflen: ::size_t,
- result: *mut *mut ::group) -> ::c_int;
- pub fn sigaltstack(ss: *const stack_t,
- oss: *mut stack_t) -> ::c_int;
- pub fn sem_close(sem: *mut sem_t) -> ::c_int;
- pub fn getdtablesize() -> ::c_int;
- pub fn getgrnam_r(name: *const ::c_char,
- grp: *mut ::group,
- buf: *mut ::c_char,
- buflen: ::size_t,
- result: *mut *mut ::group) -> ::c_int;
- pub fn initgroups(user: *const ::c_char, group: ::gid_t) -> ::c_int;
- pub fn pthread_sigmask(how: ::c_int, set: *const sigset_t,
- oldset: *mut sigset_t) -> ::c_int;
- pub fn sem_open(name: *const ::c_char, oflag: ::c_int, ...) -> *mut sem_t;
- pub fn getgrnam(name: *const ::c_char) -> *mut ::group;
- pub fn pthread_cancel(thread: ::pthread_t) -> ::c_int;
- pub fn pthread_kill(thread: ::pthread_t, sig: ::c_int) -> ::c_int;
- pub fn sem_unlink(name: *const ::c_char) -> ::c_int;
- pub fn daemon(nochdir: ::c_int, noclose: ::c_int) -> ::c_int;
- pub fn getpwnam_r(name: *const ::c_char,
- pwd: *mut passwd,
- buf: *mut ::c_char,
- buflen: ::size_t,
- result: *mut *mut passwd) -> ::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;
- pub fn sigwait(set: *const sigset_t,
- sig: *mut ::c_int) -> ::c_int;
- pub fn pthread_atfork(prepare: ::Option<unsafe extern fn()>,
- parent: ::Option<unsafe extern fn()>,
- child: ::Option<unsafe extern fn()>) -> ::c_int;
- pub fn getgrgid(gid: ::gid_t) -> *mut ::group;
- pub fn getgrouplist(user: *const ::c_char,
- group: ::gid_t,
- groups: *mut ::gid_t,
- ngroups: *mut ::c_int) -> ::c_int;
- pub fn pthread_mutexattr_getpshared(attr: *const pthread_mutexattr_t,
- pshared: *mut ::c_int) -> ::c_int;
- pub fn popen(command: *const c_char,
- mode: *const c_char) -> *mut ::FILE;
- pub fn faccessat(dirfd: ::c_int, pathname: *const ::c_char,
- mode: ::c_int, flags: ::c_int) -> ::c_int;
- pub fn pthread_create(native: *mut ::pthread_t,
- attr: *const ::pthread_attr_t,
- f: extern fn(*mut ::c_void) -> *mut ::c_void,
- value: *mut ::c_void) -> ::c_int;
- pub fn dl_iterate_phdr(
- callback: ::Option<unsafe extern fn(
- info: *mut ::dl_phdr_info,
- size: ::size_t,
- data: *mut ::c_void
- ) -> ::c_int>,
- data: *mut ::c_void
- ) -> ::c_int;
-}
-
-cfg_if! {
- if #[cfg(target_arch = "aarch64")] {
- mod aarch64;
- pub use self::aarch64::*;
- } else if #[cfg(any(target_arch = "x86_64"))] {
- mod x86_64;
- pub use self::x86_64::*;
- } else {
- // Unknown target_arch
- }
-}
-
-cfg_if! {
- if #[cfg(libc_align)] {
- #[macro_use]
- mod align;
- } else {
- #[macro_use]
- mod no_align;
- }
-}
-expand_align!();
-
-cfg_if! {
- if #[cfg(libc_core_cvoid)] {
- pub use ::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)]
- #[allow(missing_copy_implementations)]
- #[allow(missing_debug_implementations)]
- 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/no_align.rs b/libc/src/fuchsia/no_align.rs
deleted file mode 100644
index 437da97..0000000
--- a/libc/src/fuchsia/no_align.rs
+++ /dev/null
@@ -1,129 +0,0 @@
-macro_rules! expand_align {
- () => {
- s! {
- pub struct pthread_mutexattr_t {
- #[cfg(target_arch = "x86_64")]
- __align: [::c_int; 0],
- #[cfg(not(target_arch = "x86_64"))]
- __align: [::c_long; 0],
- size: [u8; ::__SIZEOF_PTHREAD_MUTEXATTR_T],
- }
-
- pub struct pthread_rwlockattr_t {
- __align: [::c_long; 0],
- size: [u8; ::__SIZEOF_PTHREAD_RWLOCKATTR_T],
- }
-
- pub struct pthread_condattr_t {
- __align: [::c_int; 0],
- size: [u8; ::__SIZEOF_PTHREAD_CONDATTR_T],
- }
- }
-
- s_no_extra_traits! {
- pub struct pthread_mutex_t {
- #[cfg(any(target_arch = "arm",
- all(target_arch = "x86_64",
- target_pointer_width = "32")))]
- __align: [::c_long; 0],
- #[cfg(not(any(target_arch = "arm",
- all(target_arch = "x86_64",
- target_pointer_width = "32"))))]
- __align: [::c_longlong; 0],
- size: [u8; ::__SIZEOF_PTHREAD_MUTEX_T],
- }
-
- pub struct pthread_rwlock_t {
- __align: [::c_long; 0],
- __align: [::c_longlong; 0],
- size: [u8; ::__SIZEOF_PTHREAD_RWLOCK_T],
- }
-
- pub struct pthread_cond_t {
- __align: [*const ::c_void; 0],
- #[cfg(not(target_env = "musl"))]
- __align: [::c_longlong; 0],
- size: [u8; ::__SIZEOF_PTHREAD_COND_T],
- }
- }
-
- cfg_if! {
- if #[cfg(feature = "extra_traits")] {
- impl PartialEq for pthread_cond_t {
- fn eq(&self, other: &pthread_cond_t) -> bool {
- // Ignore __align field
- self.size
- .iter()
- .zip(other.size.iter())
- .all(|(a,b)| a == b)
- }
- }
- impl Eq for pthread_cond_t {}
- impl ::fmt::Debug for pthread_cond_t {
- fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
- f.debug_struct("pthread_cond_t")
- // Ignore __align field
- // FIXME: .field("size", &self.size)
- .finish()
- }
- }
- impl ::hash::Hash for pthread_cond_t {
- fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
- // Ignore __align field
- self.size.hash(state);
- }
- }
-
- impl PartialEq for pthread_mutex_t {
- fn eq(&self, other: &pthread_mutex_t) -> bool {
- // Ignore __align field
- self.size
- .iter()
- .zip(other.size.iter())
- .all(|(a,b)| a == b)
- }
- }
- impl Eq for pthread_mutex_t {}
- impl ::fmt::Debug for pthread_mutex_t {
- fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
- f.debug_struct("pthread_mutex_t")
- // Ignore __align field
- // FIXME: .field("size", &self.size)
- .finish()
- }
- }
- impl ::hash::Hash for pthread_mutex_t {
- fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
- // Ignore __align field
- self.size.hash(state);
- }
- }
-
- impl PartialEq for pthread_rwlock_t {
- fn eq(&self, other: &pthread_rwlock_t) -> bool {
- // Ignore __align field
- self.size
- .iter()
- .zip(other.size.iter())
- .all(|(a,b)| a == b)
- }
- }
- impl Eq for pthread_rwlock_t {}
- impl ::fmt::Debug for pthread_rwlock_t {
- fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
- f.debug_struct("pthread_rwlock_t")
- // Ignore __align field
- // FIXME: .field("size", &self.size)
- .finish()
- }
- }
- impl ::hash::Hash for pthread_rwlock_t {
- fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
- // Ignore __align field
- self.size.hash(state);
- }
- }
- }
- }
- }
-}
diff --git a/libc/src/fuchsia/x86_64.rs b/libc/src/fuchsia/x86_64.rs
deleted file mode 100644
index e01f16d..0000000
--- a/libc/src/fuchsia/x86_64.rs
+++ /dev/null
@@ -1,502 +0,0 @@
-pub type c_char = i8;
-pub type wchar_t = i32;
-pub type nlink_t = u64;
-pub type blksize_t = ::c_long;
-pub type __u64 = ::c_ulonglong;
-
-s! {
- pub struct stat {
- pub st_dev: ::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 mcontext_t {
- __private: [u64; 32],
- }
-
- 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
- }
-}
-
-s_no_extra_traits! {
- pub struct ucontext_t {
- pub uc_flags: ::c_ulong,
- pub uc_link: *mut ucontext_t,
- pub uc_stack: ::stack_t,
- pub uc_mcontext: mcontext_t,
- pub uc_sigmask: ::sigset_t,
- __private: [u8; 512],
- }
-}
-
-cfg_if! {
- if #[cfg(feature = "extra_traits")] {
- impl PartialEq for ucontext_t {
- fn eq(&self, other: &ucontext_t) -> bool {
- self.uc_flags == other.uc_flags
- && self.uc_link == other.uc_link
- && self.uc_stack == other.uc_stack
- && self.uc_mcontext == other.uc_mcontext
- && self.uc_sigmask == other.uc_sigmask
- && self
- .__private
- .iter()
- .zip(other.__private.iter())
- .all(|(a,b)| a == b)
- }
- }
- impl Eq for ucontext_t {}
- impl ::fmt::Debug for ucontext_t {
- fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
- f.debug_struct("ucontext_t")
- .field("uc_flags", &self.uc_flags)
- .field("uc_link", &self.uc_link)
- .field("uc_stack", &self.uc_stack)
- .field("uc_mcontext", &self.uc_mcontext)
- .field("uc_sigmask", &self.uc_sigmask)
- // FIXME: .field("__private", &self.__private)
- .finish()
- }
- }
- impl ::hash::Hash for ucontext_t {
- fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
- self.uc_flags.hash(state);
- self.uc_link.hash(state);
- self.uc_stack.hash(state);
- self.uc_mcontext.hash(state);
- self.uc_sigmask.hash(state);
- self.__private.hash(state);
- }
- }
- }
-}
-
-// Syscall table
-
-pub const SYS_read: ::c_long = 0;
-pub const SYS_write: ::c_long = 1;
-pub const SYS_open: ::c_long = 2;
-pub const SYS_close: ::c_long = 3;
-pub const SYS_stat: ::c_long = 4;
-pub const SYS_fstat: ::c_long = 5;
-pub const SYS_lstat: ::c_long = 6;
-pub const SYS_poll: ::c_long = 7;
-pub const SYS_lseek: ::c_long = 8;
-pub const SYS_mmap: ::c_long = 9;
-pub const SYS_mprotect: ::c_long = 10;
-pub const SYS_munmap: ::c_long = 11;
-pub const SYS_brk: ::c_long = 12;
-pub const SYS_rt_sigaction: ::c_long = 13;
-pub const SYS_rt_sigprocmask: ::c_long = 14;
-pub const SYS_rt_sigreturn: ::c_long = 15;
-pub const SYS_ioctl: ::c_long = 16;
-pub const SYS_pread64: ::c_long = 17;
-pub const SYS_pwrite64: ::c_long = 18;
-pub const SYS_readv: ::c_long = 19;
-pub const SYS_writev: ::c_long = 20;
-pub const SYS_access: ::c_long = 21;
-pub const SYS_pipe: ::c_long = 22;
-pub const SYS_select: ::c_long = 23;
-pub const SYS_sched_yield: ::c_long = 24;
-pub const SYS_mremap: ::c_long = 25;
-pub const SYS_msync: ::c_long = 26;
-pub const SYS_mincore: ::c_long = 27;
-pub const SYS_madvise: ::c_long = 28;
-pub const SYS_shmget: ::c_long = 29;
-pub const SYS_shmat: ::c_long = 30;
-pub const SYS_shmctl: ::c_long = 31;
-pub const SYS_dup: ::c_long = 32;
-pub const SYS_dup2: ::c_long = 33;
-pub const SYS_pause: ::c_long = 34;
-pub const SYS_nanosleep: ::c_long = 35;
-pub const SYS_getitimer: ::c_long = 36;
-pub const SYS_alarm: ::c_long = 37;
-pub const SYS_setitimer: ::c_long = 38;
-pub const SYS_getpid: ::c_long = 39;
-pub const SYS_sendfile: ::c_long = 40;
-pub const SYS_socket: ::c_long = 41;
-pub const SYS_connect: ::c_long = 42;
-pub const SYS_accept: ::c_long = 43;
-pub const SYS_sendto: ::c_long = 44;
-pub const SYS_recvfrom: ::c_long = 45;
-pub const SYS_sendmsg: ::c_long = 46;
-pub const SYS_recvmsg: ::c_long = 47;
-pub const SYS_shutdown: ::c_long = 48;
-pub const SYS_bind: ::c_long = 49;
-pub const SYS_listen: ::c_long = 50;
-pub const SYS_getsockname: ::c_long = 51;
-pub const SYS_getpeername: ::c_long = 52;
-pub const SYS_socketpair: ::c_long = 53;
-pub const SYS_setsockopt: ::c_long = 54;
-pub const SYS_getsockopt: ::c_long = 55;
-pub const SYS_clone: ::c_long = 56;
-pub const SYS_fork: ::c_long = 57;
-pub const SYS_vfork: ::c_long = 58;
-pub const SYS_execve: ::c_long = 59;
-pub const SYS_exit: ::c_long = 60;
-pub const SYS_wait4: ::c_long = 61;
-pub const SYS_kill: ::c_long = 62;
-pub const SYS_uname: ::c_long = 63;
-pub const SYS_semget: ::c_long = 64;
-pub const SYS_semop: ::c_long = 65;
-pub const SYS_semctl: ::c_long = 66;
-pub const SYS_shmdt: ::c_long = 67;
-pub const SYS_msgget: ::c_long = 68;
-pub const SYS_msgsnd: ::c_long = 69;
-pub const SYS_msgrcv: ::c_long = 70;
-pub const SYS_msgctl: ::c_long = 71;
-pub const SYS_fcntl: ::c_long = 72;
-pub const SYS_flock: ::c_long = 73;
-pub const SYS_fsync: ::c_long = 74;
-pub const SYS_fdatasync: ::c_long = 75;
-pub const SYS_truncate: ::c_long = 76;
-pub const SYS_ftruncate: ::c_long = 77;
-pub const SYS_getdents: ::c_long = 78;
-pub const SYS_getcwd: ::c_long = 79;
-pub const SYS_chdir: ::c_long = 80;
-pub const SYS_fchdir: ::c_long = 81;
-pub const SYS_rename: ::c_long = 82;
-pub const SYS_mkdir: ::c_long = 83;
-pub const SYS_rmdir: ::c_long = 84;
-pub const SYS_creat: ::c_long = 85;
-pub const SYS_link: ::c_long = 86;
-pub const SYS_unlink: ::c_long = 87;
-pub const SYS_symlink: ::c_long = 88;
-pub const SYS_readlink: ::c_long = 89;
-pub const SYS_chmod: ::c_long = 90;
-pub const SYS_fchmod: ::c_long = 91;
-pub const SYS_chown: ::c_long = 92;
-pub const SYS_fchown: ::c_long = 93;
-pub const SYS_lchown: ::c_long = 94;
-pub const SYS_umask: ::c_long = 95;
-pub const SYS_gettimeofday: ::c_long = 96;
-pub const SYS_getrlimit: ::c_long = 97;
-pub const SYS_getrusage: ::c_long = 98;
-pub const SYS_sysinfo: ::c_long = 99;
-pub const SYS_times: ::c_long = 100;
-pub const SYS_ptrace: ::c_long = 101;
-pub const SYS_getuid: ::c_long = 102;
-pub const SYS_syslog: ::c_long = 103;
-pub const SYS_getgid: ::c_long = 104;
-pub const SYS_setuid: ::c_long = 105;
-pub const SYS_setgid: ::c_long = 106;
-pub const SYS_geteuid: ::c_long = 107;
-pub const SYS_getegid: ::c_long = 108;
-pub const SYS_setpgid: ::c_long = 109;
-pub const SYS_getppid: ::c_long = 110;
-pub const SYS_getpgrp: ::c_long = 111;
-pub const SYS_setsid: ::c_long = 112;
-pub const SYS_setreuid: ::c_long = 113;
-pub const SYS_setregid: ::c_long = 114;
-pub const SYS_getgroups: ::c_long = 115;
-pub const SYS_setgroups: ::c_long = 116;
-pub const SYS_setresuid: ::c_long = 117;
-pub const SYS_getresuid: ::c_long = 118;
-pub const SYS_setresgid: ::c_long = 119;
-pub const SYS_getresgid: ::c_long = 120;
-pub const SYS_getpgid: ::c_long = 121;
-pub const SYS_setfsuid: ::c_long = 122;
-pub const SYS_setfsgid: ::c_long = 123;
-pub const SYS_getsid: ::c_long = 124;
-pub const SYS_capget: ::c_long = 125;
-pub const SYS_capset: ::c_long = 126;
-pub const SYS_rt_sigpending: ::c_long = 127;
-pub const SYS_rt_sigtimedwait: ::c_long = 128;
-pub const SYS_rt_sigqueueinfo: ::c_long = 129;
-pub const SYS_rt_sigsuspend: ::c_long = 130;
-pub const SYS_sigaltstack: ::c_long = 131;
-pub const SYS_utime: ::c_long = 132;
-pub const SYS_mknod: ::c_long = 133;
-pub const SYS_uselib: ::c_long = 134;
-pub const SYS_personality: ::c_long = 135;
-pub const SYS_ustat: ::c_long = 136;
-pub const SYS_statfs: ::c_long = 137;
-pub const SYS_fstatfs: ::c_long = 138;
-pub const SYS_sysfs: ::c_long = 139;
-pub const SYS_getpriority: ::c_long = 140;
-pub const SYS_setpriority: ::c_long = 141;
-pub const SYS_sched_setparam: ::c_long = 142;
-pub const SYS_sched_getparam: ::c_long = 143;
-pub const SYS_sched_setscheduler: ::c_long = 144;
-pub const SYS_sched_getscheduler: ::c_long = 145;
-pub const SYS_sched_get_priority_max: ::c_long = 146;
-pub const SYS_sched_get_priority_min: ::c_long = 147;
-pub const SYS_sched_rr_get_interval: ::c_long = 148;
-pub const SYS_mlock: ::c_long = 149;
-pub const SYS_munlock: ::c_long = 150;
-pub const SYS_mlockall: ::c_long = 151;
-pub const SYS_munlockall: ::c_long = 152;
-pub const SYS_vhangup: ::c_long = 153;
-pub const SYS_modify_ldt: ::c_long = 154;
-pub const SYS_pivot_root: ::c_long = 155;
-pub const SYS__sysctl: ::c_long = 156;
-pub const SYS_prctl: ::c_long = 157;
-pub const SYS_arch_prctl: ::c_long = 158;
-pub const SYS_adjtimex: ::c_long = 159;
-pub const SYS_setrlimit: ::c_long = 160;
-pub const SYS_chroot: ::c_long = 161;
-pub const SYS_sync: ::c_long = 162;
-pub const SYS_acct: ::c_long = 163;
-pub const SYS_settimeofday: ::c_long = 164;
-pub const SYS_mount: ::c_long = 165;
-pub const SYS_umount2: ::c_long = 166;
-pub const SYS_swapon: ::c_long = 167;
-pub const SYS_swapoff: ::c_long = 168;
-pub const SYS_reboot: ::c_long = 169;
-pub const SYS_sethostname: ::c_long = 170;
-pub const SYS_setdomainname: ::c_long = 171;
-pub const SYS_iopl: ::c_long = 172;
-pub const SYS_ioperm: ::c_long = 173;
-pub const SYS_create_module: ::c_long = 174;
-pub const SYS_init_module: ::c_long = 175;
-pub const SYS_delete_module: ::c_long = 176;
-pub const SYS_get_kernel_syms: ::c_long = 177;
-pub const SYS_query_module: ::c_long = 178;
-pub const SYS_quotactl: ::c_long = 179;
-pub const SYS_nfsservctl: ::c_long = 180;
-pub const SYS_getpmsg: ::c_long = 181;
-pub const SYS_putpmsg: ::c_long = 182;
-pub const SYS_afs_syscall: ::c_long = 183;
-pub const SYS_tuxcall: ::c_long = 184;
-pub const SYS_security: ::c_long = 185;
-pub const SYS_gettid: ::c_long = 186;
-pub const SYS_readahead: ::c_long = 187;
-pub const SYS_setxattr: ::c_long = 188;
-pub const SYS_lsetxattr: ::c_long = 189;
-pub const SYS_fsetxattr: ::c_long = 190;
-pub const SYS_getxattr: ::c_long = 191;
-pub const SYS_lgetxattr: ::c_long = 192;
-pub const SYS_fgetxattr: ::c_long = 193;
-pub const SYS_listxattr: ::c_long = 194;
-pub const SYS_llistxattr: ::c_long = 195;
-pub const SYS_flistxattr: ::c_long = 196;
-pub const SYS_removexattr: ::c_long = 197;
-pub const SYS_lremovexattr: ::c_long = 198;
-pub const SYS_fremovexattr: ::c_long = 199;
-pub const SYS_tkill: ::c_long = 200;
-pub const SYS_time: ::c_long = 201;
-pub const SYS_futex: ::c_long = 202;
-pub const SYS_sched_setaffinity: ::c_long = 203;
-pub const SYS_sched_getaffinity: ::c_long = 204;
-pub const SYS_set_thread_area: ::c_long = 205;
-pub const SYS_io_setup: ::c_long = 206;
-pub const SYS_io_destroy: ::c_long = 207;
-pub const SYS_io_getevents: ::c_long = 208;
-pub const SYS_io_submit: ::c_long = 209;
-pub const SYS_io_cancel: ::c_long = 210;
-pub const SYS_get_thread_area: ::c_long = 211;
-pub const SYS_lookup_dcookie: ::c_long = 212;
-pub const SYS_epoll_create: ::c_long = 213;
-pub const SYS_epoll_ctl_old: ::c_long = 214;
-pub const SYS_epoll_wait_old: ::c_long = 215;
-pub const SYS_remap_file_pages: ::c_long = 216;
-pub const SYS_getdents64: ::c_long = 217;
-pub const SYS_set_tid_address: ::c_long = 218;
-pub const SYS_restart_syscall: ::c_long = 219;
-pub const SYS_semtimedop: ::c_long = 220;
-pub const SYS_fadvise64: ::c_long = 221;
-pub const SYS_timer_create: ::c_long = 222;
-pub const SYS_timer_settime: ::c_long = 223;
-pub const SYS_timer_gettime: ::c_long = 224;
-pub const SYS_timer_getoverrun: ::c_long = 225;
-pub const SYS_timer_delete: ::c_long = 226;
-pub const SYS_clock_settime: ::c_long = 227;
-pub const SYS_clock_gettime: ::c_long = 228;
-pub const SYS_clock_getres: ::c_long = 229;
-pub const SYS_clock_nanosleep: ::c_long = 230;
-pub const SYS_exit_group: ::c_long = 231;
-pub const SYS_epoll_wait: ::c_long = 232;
-pub const SYS_epoll_ctl: ::c_long = 233;
-pub const SYS_tgkill: ::c_long = 234;
-pub const SYS_utimes: ::c_long = 235;
-pub const SYS_vserver: ::c_long = 236;
-pub const SYS_mbind: ::c_long = 237;
-pub const SYS_set_mempolicy: ::c_long = 238;
-pub const SYS_get_mempolicy: ::c_long = 239;
-pub const SYS_mq_open: ::c_long = 240;
-pub const SYS_mq_unlink: ::c_long = 241;
-pub const SYS_mq_timedsend: ::c_long = 242;
-pub const SYS_mq_timedreceive: ::c_long = 243;
-pub const SYS_mq_notify: ::c_long = 244;
-pub const SYS_mq_getsetattr: ::c_long = 245;
-pub const SYS_kexec_load: ::c_long = 246;
-pub const SYS_waitid: ::c_long = 247;
-pub const SYS_add_key: ::c_long = 248;
-pub const SYS_request_key: ::c_long = 249;
-pub const SYS_keyctl: ::c_long = 250;
-pub const SYS_ioprio_set: ::c_long = 251;
-pub const SYS_ioprio_get: ::c_long = 252;
-pub const SYS_inotify_init: ::c_long = 253;
-pub const SYS_inotify_add_watch: ::c_long = 254;
-pub const SYS_inotify_rm_watch: ::c_long = 255;
-pub const SYS_migrate_pages: ::c_long = 256;
-pub const SYS_openat: ::c_long = 257;
-pub const SYS_mkdirat: ::c_long = 258;
-pub const SYS_mknodat: ::c_long = 259;
-pub const SYS_fchownat: ::c_long = 260;
-pub const SYS_futimesat: ::c_long = 261;
-pub const SYS_newfstatat: ::c_long = 262;
-pub const SYS_unlinkat: ::c_long = 263;
-pub const SYS_renameat: ::c_long = 264;
-pub const SYS_linkat: ::c_long = 265;
-pub const SYS_symlinkat: ::c_long = 266;
-pub const SYS_readlinkat: ::c_long = 267;
-pub const SYS_fchmodat: ::c_long = 268;
-pub const SYS_faccessat: ::c_long = 269;
-pub const SYS_pselect6: ::c_long = 270;
-pub const SYS_ppoll: ::c_long = 271;
-pub const SYS_unshare: ::c_long = 272;
-pub const SYS_set_robust_list: ::c_long = 273;
-pub const SYS_get_robust_list: ::c_long = 274;
-pub const SYS_splice: ::c_long = 275;
-pub const SYS_tee: ::c_long = 276;
-pub const SYS_sync_file_range: ::c_long = 277;
-pub const SYS_vmsplice: ::c_long = 278;
-pub const SYS_move_pages: ::c_long = 279;
-pub const SYS_utimensat: ::c_long = 280;
-pub const SYS_epoll_pwait: ::c_long = 281;
-pub const SYS_signalfd: ::c_long = 282;
-pub const SYS_timerfd_create: ::c_long = 283;
-pub const SYS_eventfd: ::c_long = 284;
-pub const SYS_fallocate: ::c_long = 285;
-pub const SYS_timerfd_settime: ::c_long = 286;
-pub const SYS_timerfd_gettime: ::c_long = 287;
-pub const SYS_accept4: ::c_long = 288;
-pub const SYS_signalfd4: ::c_long = 289;
-pub const SYS_eventfd2: ::c_long = 290;
-pub const SYS_epoll_create1: ::c_long = 291;
-pub const SYS_dup3: ::c_long = 292;
-pub const SYS_pipe2: ::c_long = 293;
-pub const SYS_inotify_init1: ::c_long = 294;
-pub const SYS_preadv: ::c_long = 295;
-pub const SYS_pwritev: ::c_long = 296;
-pub const SYS_rt_tgsigqueueinfo: ::c_long = 297;
-pub const SYS_perf_event_open: ::c_long = 298;
-pub const SYS_recvmmsg: ::c_long = 299;
-pub const SYS_fanotify_init: ::c_long = 300;
-pub const SYS_fanotify_mark: ::c_long = 301;
-pub const SYS_prlimit64: ::c_long = 302;
-pub const SYS_name_to_handle_at: ::c_long = 303;
-pub const SYS_open_by_handle_at: ::c_long = 304;
-pub const SYS_clock_adjtime: ::c_long = 305;
-pub const SYS_syncfs: ::c_long = 306;
-pub const SYS_sendmmsg: ::c_long = 307;
-pub const SYS_setns: ::c_long = 308;
-pub const SYS_getcpu: ::c_long = 309;
-pub const SYS_process_vm_readv: ::c_long = 310;
-pub const SYS_process_vm_writev: ::c_long = 311;
-pub const SYS_kcmp: ::c_long = 312;
-pub const SYS_finit_module: ::c_long = 313;
-pub const SYS_sched_setattr: ::c_long = 314;
-pub const SYS_sched_getattr: ::c_long = 315;
-pub const SYS_renameat2: ::c_long = 316;
-pub const SYS_seccomp: ::c_long = 317;
-pub const SYS_getrandom: ::c_long = 318;
-pub const SYS_memfd_create: ::c_long = 319;
-pub const SYS_kexec_file_load: ::c_long = 320;
-pub const SYS_bpf: ::c_long = 321;
-pub const SYS_execveat: ::c_long = 322;
-pub const SYS_userfaultfd: ::c_long = 323;
-pub const SYS_membarrier: ::c_long = 324;
-pub const SYS_mlock2: ::c_long = 325;
-pub const SYS_copy_file_range: ::c_long = 326;
-pub const SYS_preadv2: ::c_long = 327;
-pub const SYS_pwritev2: ::c_long = 328;
-// FIXME syscalls 329-331 have been added in musl 1.16
-// See discussion https://github.com/rust-lang/libc/pull/699
-
-// offsets in user_regs_structs, from sys/reg.h
-pub const R15: ::c_int = 0;
-pub const R14: ::c_int = 1;
-pub const R13: ::c_int = 2;
-pub const R12: ::c_int = 3;
-pub const RBP: ::c_int = 4;
-pub const RBX: ::c_int = 5;
-pub const R11: ::c_int = 6;
-pub const R10: ::c_int = 7;
-pub const R9: ::c_int = 8;
-pub const R8: ::c_int = 9;
-pub const RAX: ::c_int = 10;
-pub const RCX: ::c_int = 11;
-pub const RDX: ::c_int = 12;
-pub const RSI: ::c_int = 13;
-pub const RDI: ::c_int = 14;
-pub const ORIG_RAX: ::c_int = 15;
-pub const RIP: ::c_int = 16;
-pub const CS: ::c_int = 17;
-pub const EFLAGS: ::c_int = 18;
-pub const RSP: ::c_int = 19;
-pub const SS: ::c_int = 20;
-pub const FS_BASE: ::c_int = 21;
-pub const GS_BASE: ::c_int = 22;
-pub const DS: ::c_int = 23;
-pub const ES: ::c_int = 24;
-pub const FS: ::c_int = 25;
-pub const GS: ::c_int = 26;
-
-pub const MAP_32BIT: ::c_int = 0x0040;
-
-pub const SIGSTKSZ: ::size_t = 8192;
-pub const MINSIGSTKSZ: ::size_t = 2048;
-
-#[doc(hidden)]
-#[deprecated(
- since = "0.2.55",
- note = "If you are using this report to: \
- https://github.com/rust-lang/libc/issues/665"
-)]
-pub const AF_MAX: ::c_int = 42;
-#[doc(hidden)]
-#[deprecated(
- since = "0.2.55",
- note = "If you are using this report to: \
- https://github.com/rust-lang/libc/issues/665"
-)]
-#[allow(deprecated)]
-pub const PF_MAX: ::c_int = AF_MAX;
diff --git a/libc/src/hermit/aarch64.rs b/libc/src/hermit/aarch64.rs
deleted file mode 100644
index 1a92e3b..0000000
--- a/libc/src/hermit/aarch64.rs
+++ /dev/null
@@ -1,2 +0,0 @@
-pub type c_char = u8;
-pub type wchar_t = u32;
diff --git a/libc/src/hermit/mod.rs b/libc/src/hermit/mod.rs
deleted file mode 100644
index 9880b50..0000000
--- a/libc/src/hermit/mod.rs
+++ /dev/null
@@ -1,74 +0,0 @@
-// 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.
-
-// libc port for HermitCore (https://hermitcore.org)
-//
-// Ported by Colin Fink <colin.finck@rwth-aachen.de>
-// and Stefan Lankes <slankes@eonerc.rwth-aachen.de>
-
-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_long = i64;
-pub type c_ulong = u64;
-
-pub type wint_t = u32;
-pub type wctype_t = i64;
-
-pub type regoff_t = size_t;
-pub type off_t = c_long;
-
-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
- }
-}
-
-cfg_if! {
- if #[cfg(libc_core_cvoid)] {
- pub use ::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)]
- #[allow(missing_copy_implementations)]
- #[allow(missing_debug_implementations)]
- 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/hermit/x86_64.rs b/libc/src/hermit/x86_64.rs
deleted file mode 100644
index 76ec3ce..0000000
--- a/libc/src/hermit/x86_64.rs
+++ /dev/null
@@ -1,2 +0,0 @@
-pub type c_char = i8;
-pub type wchar_t = i32;
diff --git a/libc/src/lib.rs b/libc/src/lib.rs
deleted file mode 100644
index 2dc4270..0000000
--- a/libc/src/lib.rs
+++ /dev/null
@@ -1,143 +0,0 @@
-// Copyright 2012-2015 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-//! libc - Raw FFI bindings to platforms' system libraries
-//!
-//! [Documentation for other platforms][pd].
-//!
-//! [pd]: https://rust-lang.github.io/libc/#platform-specific-documentation
-#![crate_name = "libc"]
-#![crate_type = "rlib"]
-#![cfg_attr(not(feature = "rustc-dep-of-std"), deny(warnings))]
-#![allow(bad_style, overflowing_literals, improper_ctypes, unknown_lints)]
-// Attributes needed when building as part of the standard library
-#![cfg_attr(
- feature = "rustc-dep-of-std",
- feature(cfg_target_vendor, link_cfg, no_core)
-)]
-// Enable extra lints:
-#![cfg_attr(feature = "extra_traits", deny(missing_debug_implementations))]
-#![deny(missing_copy_implementations, safe_packed_borrows)]
-#![no_std]
-#![cfg_attr(feature = "rustc-dep-of-std", no_core)]
-#![cfg_attr(target_os = "redox", feature(static_nobundle))]
-
-#[macro_use]
-mod macros;
-
-cfg_if! {
- if #[cfg(feature = "rustc-dep-of-std")] {
- extern crate rustc_std_workspace_core as core;
- #[allow(unused_imports)]
- use core::iter;
- #[allow(unused_imports)]
- use core::option;
- }
-}
-
-cfg_if! {
- if #[cfg(libc_priv_mod_use)] {
- #[cfg(libc_core_cvoid)]
- #[allow(unused_imports)]
- use core::ffi;
- #[allow(unused_imports)]
- use core::fmt;
- #[allow(unused_imports)]
- use core::hash;
- #[allow(unused_imports)]
- use core::num;
- #[allow(unused_imports)]
- use core::mem;
- #[doc(hidden)]
- #[allow(unused_imports)]
- use core::clone::Clone;
- #[doc(hidden)]
- #[allow(unused_imports)]
- use core::marker::Copy;
- #[doc(hidden)]
- #[allow(unused_imports)]
- use core::option::Option;
- } else {
- #[doc(hidden)]
- #[allow(unused_imports)]
- pub use core::fmt;
- #[doc(hidden)]
- #[allow(unused_imports)]
- pub use core::hash;
- #[doc(hidden)]
- #[allow(unused_imports)]
- pub use core::num;
- #[doc(hidden)]
- #[allow(unused_imports)]
- pub use core::mem;
- #[doc(hidden)]
- #[allow(unused_imports)]
- pub use core::clone::Clone;
- #[doc(hidden)]
- #[allow(unused_imports)]
- pub use core::marker::Copy;
- #[doc(hidden)]
- #[allow(unused_imports)]
- pub use core::option::Option;
- }
-}
-
-cfg_if! {
- if #[cfg(windows)] {
- mod fixed_width_ints;
- pub use fixed_width_ints::*;
-
- mod windows;
- pub use windows::*;
- } else if #[cfg(target_os = "cloudabi")] {
- mod fixed_width_ints;
- pub use fixed_width_ints::*;
-
- mod cloudabi;
- pub use cloudabi::*;
- } else if #[cfg(target_os = "fuchsia")] {
- mod fixed_width_ints;
- pub use fixed_width_ints::*;
-
- mod fuchsia;
- pub use fuchsia::*;
- } else if #[cfg(target_os = "switch")] {
- mod fixed_width_ints;
- pub use fixed_width_ints::*;
-
- mod switch;
- pub use switch::*;
- } else if #[cfg(unix)] {
- mod fixed_width_ints;
- pub use fixed_width_ints::*;
-
- mod unix;
- pub use unix::*;
- } else if #[cfg(target_os = "hermit")] {
- mod fixed_width_ints;
- pub use fixed_width_ints::*;
-
- mod hermit;
- pub use hermit::*;
- } else if #[cfg(all(target_env = "sgx", target_vendor = "fortanix"))] {
- mod fixed_width_ints;
- pub use fixed_width_ints::*;
-
- mod sgx;
- pub use sgx::*;
- } else if #[cfg(any(target_env = "wasi", target_os = "wasi"))] {
- mod fixed_width_ints;
- pub use fixed_width_ints::*;
-
- mod wasi;
- pub use wasi::*;
- } else {
- // non-supported targets: empty...
- }
-}
diff --git a/libc/src/macros.rs b/libc/src/macros.rs
deleted file mode 100644
index 14a2804..0000000
--- a/libc/src/macros.rs
+++ /dev/null
@@ -1,195 +0,0 @@
-/// A macro for defining #[cfg] if-else statements.
-///
-/// This is similar to the `if/elif` C preprocessor macro by allowing definition
-/// of a cascade of `#[cfg]` cases, emitting the implementation which matches
-/// first.
-///
-/// This allows you to conveniently provide a long list #[cfg]'d blocks of code
-/// without having to rewrite each clause multiple times.
-#[allow(unused_macros)]
-macro_rules! cfg_if {
- // match if/else chains with a final `else`
- ($(
- if #[cfg($($meta:meta),*)] { $($it:item)* }
- ) else * else {
- $($it2:item)*
- }) => {
- cfg_if! {
- @__items
- () ;
- $( ( ($($meta),*) ($($it)*) ), )*
- ( () ($($it2)*) ),
- }
- };
-
- // match if/else chains lacking a final `else`
- (
- if #[cfg($($i_met:meta),*)] { $($i_it:item)* }
- $(
- else if #[cfg($($e_met:meta),*)] { $($e_it:item)* }
- )*
- ) => {
- cfg_if! {
- @__items
- () ;
- ( ($($i_met),*) ($($i_it)*) ),
- $( ( ($($e_met),*) ($($e_it)*) ), )*
- ( () () ),
- }
- };
-
- // Internal and recursive macro to emit all the items
- //
- // Collects all the negated cfgs in a list at the beginning and after the
- // semicolon is all the remaining items
- (@__items ($($not:meta,)*) ; ) => {};
- (@__items ($($not:meta,)*) ; ( ($($m:meta),*) ($($it:item)*) ),
- $($rest:tt)*) => {
- // Emit all items within one block, applying an approprate #[cfg]. The
- // #[cfg] will require all `$m` matchers specified and must also negate
- // all previous matchers.
- cfg_if! { @__apply cfg(all($($m,)* not(any($($not),*)))), $($it)* }
-
- // Recurse to emit all other items in `$rest`, and when we do so add all
- // our `$m` matchers to the list of `$not` matchers as future emissions
- // will have to negate everything we just matched as well.
- cfg_if! { @__items ($($not,)* $($m,)*) ; $($rest)* }
- };
-
- // Internal macro to Apply a cfg attribute to a list of items
- (@__apply $m:meta, $($it:item)*) => {
- $(#[$m] $it)*
- };
-}
-
-#[allow(unused_macros)]
-macro_rules! s {
- ($($(#[$attr:meta])* pub $t:ident $i:ident { $($field:tt)* })*) => ($(
- s!(it: $(#[$attr])* pub $t $i { $($field)* });
- )*);
- (it: $(#[$attr:meta])* pub union $i:ident { $($field:tt)* }) => (
- compile_error!("unions cannot derive extra traits, use s_no_extra_traits instead");
- );
- (it: $(#[$attr:meta])* pub struct $i:ident { $($field:tt)* }) => (
- __item! {
- #[repr(C)]
- #[cfg_attr(feature = "extra_traits", derive(Debug, Eq, Hash, PartialEq))]
- #[allow(deprecated)]
- $(#[$attr])*
- pub struct $i { $($field)* }
- }
- #[allow(deprecated)]
- impl ::Copy for $i {}
- #[allow(deprecated)]
- impl ::Clone for $i {
- fn clone(&self) -> $i { *self }
- }
- );
-}
-
-#[allow(unused_macros)]
-macro_rules! s_no_extra_traits {
- ($($(#[$attr:meta])* pub $t:ident $i:ident { $($field:tt)* })*) => ($(
- s_no_extra_traits!(it: $(#[$attr])* pub $t $i { $($field)* });
- )*);
- (it: $(#[$attr:meta])* pub union $i:ident { $($field:tt)* }) => (
- cfg_if! {
- if #[cfg(libc_union)] {
- __item! {
- #[repr(C)]
- $(#[$attr])*
- pub union $i { $($field)* }
- }
-
- impl ::Copy for $i {}
- impl ::Clone for $i {
- fn clone(&self) -> $i { *self }
- }
- }
- }
- );
- (it: $(#[$attr:meta])* pub struct $i:ident { $($field:tt)* }) => (
- __item! {
- #[repr(C)]
- $(#[$attr])*
- pub struct $i { $($field)* }
- }
- impl ::Copy for $i {}
- impl ::Clone for $i {
- fn clone(&self) -> $i { *self }
- }
- );
-}
-
-#[allow(unused_macros)]
-macro_rules! f {
- ($(pub fn $i:ident($($arg:ident: $argty:ty),*) -> $ret:ty {
- $($body:stmt);*
- })*) => ($(
- #[inline]
- pub unsafe extern fn $i($($arg: $argty),*) -> $ret {
- $($body);*
- }
- )*)
-}
-
-#[allow(unused_macros)]
-macro_rules! __item {
- ($i:item) => {
- $i
- };
-}
-
-#[allow(unused_macros)]
-macro_rules! align_const {
- ($($(#[$attr:meta])*
- pub const $name:ident : $t1:ty
- = $t2:ident { $($field:tt)* };)*) => ($(
- #[cfg(libc_align)]
- $(#[$attr])*
- pub const $name : $t1 = $t2 {
- $($field)*
- };
- #[cfg(not(libc_align))]
- $(#[$attr])*
- pub const $name : $t1 = $t2 {
- $($field)*
- __align: [],
- };
- )*)
-}
-
-// This macro is used to deprecate items that should be accessed via the mach crate
-#[allow(unused_macros)]
-macro_rules! deprecated_mach {
- (pub const $id:ident: $ty:ty = $expr:expr;) => {
- #[deprecated(
- since = "0.2.55",
- note = "Use the `mach` crate instead",
- )]
- #[allow(deprecated)]
- pub const $id: $ty = $expr;
- };
- ($(pub const $id:ident: $ty:ty = $expr:expr;)*) => {
- $(
- deprecated_mach!(
- pub const $id: $ty = $expr;
- );
- )*
- };
- (pub type $id:ident = $ty:ty;) => {
- #[deprecated(
- since = "0.2.55",
- note = "Use the `mach` crate instead",
- )]
- #[allow(deprecated)]
- pub type $id = $ty;
- };
- ($(pub type $id:ident = $ty:ty;)*) => {
- $(
- deprecated_mach!(
- pub type $id = $ty;
- );
- )*
- }
-}
diff --git a/libc/src/sgx.rs b/libc/src/sgx.rs
deleted file mode 100644
index 7da6269..0000000
--- a/libc/src/sgx.rs
+++ /dev/null
@@ -1,47 +0,0 @@
-//! SGX C types definition
-
-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(libc_core_cvoid)] {
- pub use ::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)]
- #[allow(missing_copy_implementations)]
- #[allow(missing_debug_implementations)]
- 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
deleted file mode 100644
index 801b8ed..0000000
--- a/libc/src/switch.rs
+++ /dev/null
@@ -1,50 +0,0 @@
-//! Switch C type definitions
-
-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(libc_core_cvoid)] {
- pub use ::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)]
- #[allow(missing_copy_implementations)]
- #[allow(missing_debug_implementations)]
- 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/align.rs b/libc/src/unix/align.rs
deleted file mode 100644
index 4fdba9a..0000000
--- a/libc/src/unix/align.rs
+++ /dev/null
@@ -1,6 +0,0 @@
-s! {
- #[repr(align(4))]
- pub struct in6_addr {
- pub s6_addr: [u8; 16],
- }
-}
diff --git a/libc/src/unix/bsd/apple/b32.rs b/libc/src/unix/bsd/apple/b32.rs
deleted file mode 100644
index 859809d..0000000
--- a/libc/src/unix/bsd/apple/b32.rs
+++ /dev/null
@@ -1,97 +0,0 @@
-//! 32-bit specific Apple (ios/darwin) definitions
-
-pub type c_long = i32;
-pub type c_ulong = u32;
-pub type boolean_t = ::c_int;
-
-s! {
- pub struct if_data {
- pub ifi_type: ::c_uchar,
- pub ifi_typelen: ::c_uchar,
- pub ifi_physical: ::c_uchar,
- pub ifi_addrlen: ::c_uchar,
- pub ifi_hdrlen: ::c_uchar,
- pub ifi_recvquota: ::c_uchar,
- pub ifi_xmitquota: ::c_uchar,
- pub ifi_unused1: ::c_uchar,
- pub ifi_mtu: u32,
- pub ifi_metric: u32,
- pub ifi_baudrate: u32,
- pub ifi_ipackets: u32,
- pub ifi_ierrors: u32,
- pub ifi_opackets: u32,
- pub ifi_oerrors: u32,
- pub ifi_collisions: u32,
- pub ifi_ibytes: u32,
- pub ifi_obytes: u32,
- pub ifi_imcasts: u32,
- pub ifi_omcasts: u32,
- pub ifi_iqdrops: u32,
- pub ifi_noproto: u32,
- pub ifi_recvtiming: u32,
- pub ifi_xmittiming: u32,
- pub ifi_lastchange: ::timeval,
- pub ifi_unused2: u32,
- pub ifi_hwassist: u32,
- pub ifi_reserved1: u32,
- pub ifi_reserved2: u32,
- }
-
- pub struct bpf_hdr {
- pub bh_tstamp: ::timeval,
- pub bh_caplen: u32,
- pub bh_datalen: u32,
- pub bh_hdrlen: ::c_ushort,
- }
-}
-
-s_no_extra_traits!{
- pub struct pthread_attr_t {
- __sig: c_long,
- __opaque: [::c_char; 36]
- }
-}
-
-cfg_if! {
- if #[cfg(feature = "extra_traits")] {
- impl PartialEq for pthread_attr_t {
- fn eq(&self, other: &pthread_attr_t) -> bool {
- self.__sig == other.__sig
- && self.__opaque
- .iter()
- .zip(other.__opaque.iter())
- .all(|(a,b)| a == b)
- }
- }
- impl Eq for pthread_attr_t {}
- impl ::fmt::Debug for pthread_attr_t {
- fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
- f.debug_struct("pthread_attr_t")
- .field("__sig", &self.__sig)
- // FIXME: .field("__opaque", &self.__opaque)
- .finish()
- }
- }
- impl ::hash::Hash for pthread_attr_t {
- fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
- self.__sig.hash(state);
- self.__opaque.hash(state);
- }
- }
- }
-}
-
-pub const __PTHREAD_MUTEX_SIZE__: usize = 40;
-pub const __PTHREAD_COND_SIZE__: usize = 24;
-pub const __PTHREAD_CONDATTR_SIZE__: usize = 4;
-pub const __PTHREAD_RWLOCK_SIZE__: usize = 124;
-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
deleted file mode 100644
index 7b89fc6..0000000
--- a/libc/src/unix/bsd/apple/b64.rs
+++ /dev/null
@@ -1,102 +0,0 @@
-//! 64-bit specific Apple (ios/darwin) definitions
-
-pub type c_long = i64;
-pub type c_ulong = u64;
-pub type boolean_t = ::c_uint;
-
-s! {
- pub struct timeval32 {
- pub tv_sec: i32,
- pub tv_usec: i32,
- }
-
- pub struct if_data {
- pub ifi_type: ::c_uchar,
- pub ifi_typelen: ::c_uchar,
- pub ifi_physical: ::c_uchar,
- pub ifi_addrlen: ::c_uchar,
- pub ifi_hdrlen: ::c_uchar,
- pub ifi_recvquota: ::c_uchar,
- pub ifi_xmitquota: ::c_uchar,
- pub ifi_unused1: ::c_uchar,
- pub ifi_mtu: u32,
- pub ifi_metric: u32,
- pub ifi_baudrate: u32,
- pub ifi_ipackets: u32,
- pub ifi_ierrors: u32,
- pub ifi_opackets: u32,
- pub ifi_oerrors: u32,
- pub ifi_collisions: u32,
- pub ifi_ibytes: u32,
- pub ifi_obytes: u32,
- pub ifi_imcasts: u32,
- pub ifi_omcasts: u32,
- pub ifi_iqdrops: u32,
- pub ifi_noproto: u32,
- pub ifi_recvtiming: u32,
- pub ifi_xmittiming: u32,
- pub ifi_lastchange: timeval32,
- pub ifi_unused2: u32,
- pub ifi_hwassist: u32,
- pub ifi_reserved1: u32,
- pub ifi_reserved2: u32,
- }
-
- pub struct bpf_hdr {
- pub bh_tstamp: ::timeval32,
- pub bh_caplen: u32,
- pub bh_datalen: u32,
- pub bh_hdrlen: ::c_ushort,
- }
-}
-
-s_no_extra_traits!{
- pub struct pthread_attr_t {
- __sig: c_long,
- __opaque: [::c_char; 56]
- }
-}
-
-cfg_if! {
- if #[cfg(feature = "extra_traits")] {
- impl PartialEq for pthread_attr_t {
- fn eq(&self, other: &pthread_attr_t) -> bool {
- self.__sig == other.__sig
- && self.__opaque
- .iter()
- .zip(other.__opaque.iter())
- .all(|(a,b)| a == b)
- }
- }
- impl Eq for pthread_attr_t {}
- impl ::fmt::Debug for pthread_attr_t {
- fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
- f.debug_struct("pthread_attr_t")
- .field("__sig", &self.__sig)
- // FIXME: .field("__opaque", &self.__opaque)
- .finish()
- }
- }
- impl ::hash::Hash for pthread_attr_t {
- fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
- self.__sig.hash(state);
- self.__opaque.hash(state);
- }
- }
- }
-}
-
-pub const __PTHREAD_MUTEX_SIZE__: usize = 56;
-pub const __PTHREAD_COND_SIZE__: usize = 40;
-pub const __PTHREAD_CONDATTR_SIZE__: usize = 8;
-pub const __PTHREAD_RWLOCK_SIZE__: usize = 192;
-pub const __PTHREAD_RWLOCKATTR_SIZE__: usize = 16;
-
-pub const TIOCTIMESTAMP: ::c_ulong = 0x40107459;
-pub const TIOCDCDTIMESTAMP: ::c_ulong = 0x40107458;
-
-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
deleted file mode 100644
index af28dba..0000000
--- a/libc/src/unix/bsd/apple/mod.rs
+++ /dev/null
@@ -1,3349 +0,0 @@
-//! Apple (ios/darwin)-specific definitions
-//!
-//! This covers *-apple-* triples currently
-pub type c_char = i8;
-pub type clock_t = c_ulong;
-pub type time_t = c_long;
-pub type suseconds_t = i32;
-pub type dev_t = i32;
-pub type ino_t = u64;
-pub type mode_t = u16;
-pub type nlink_t = u16;
-pub type blksize_t = i32;
-pub type rlim_t = u64;
-pub type pthread_key_t = c_ulong;
-pub type sigset_t = u32;
-pub type clockid_t = ::c_uint;
-pub type fsblkcnt_t = ::c_uint;
-pub type fsfilcnt_t = ::c_uint;
-pub type speed_t = ::c_ulong;
-pub type tcflag_t = ::c_ulong;
-pub type nl_item = ::c_int;
-pub type id_t = ::c_uint;
-pub type sem_t = ::c_int;
-pub type idtype_t = ::c_uint;
-pub type integer_t = ::c_int;
-pub type cpu_type_t = integer_t;
-pub type cpu_subtype_t = integer_t;
-
-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;
-
-deprecated_mach! {
- pub type vm_prot_t = ::c_int;
- pub type vm_size_t = ::uintptr_t;
- pub type mach_timebase_info_data_t = mach_timebase_info;
-}
-
-#[cfg_attr(feature = "extra_traits", derive(Debug))]
-pub enum timezone {}
-impl ::Copy for timezone {}
-impl ::Clone for timezone {
- fn clone(&self) -> timezone { *self }
-}
-
-s! {
- pub struct ip_mreq {
- pub imr_multiaddr: in_addr,
- pub imr_interface: in_addr,
- }
-
- pub struct aiocb {
- pub aio_fildes: ::c_int,
- pub aio_offset: ::off_t,
- pub aio_buf: *mut ::c_void,
- pub aio_nbytes: ::size_t,
- pub aio_reqprio: ::c_int,
- pub aio_sigevent: sigevent,
- pub aio_lio_opcode: ::c_int
- }
-
- pub struct glob_t {
- pub gl_pathc: ::size_t,
- __unused1: ::c_int,
- pub gl_offs: ::size_t,
- __unused2: ::c_int,
- pub gl_pathv: *mut *mut ::c_char,
-
- __unused3: *mut ::c_void,
-
- __unused4: *mut ::c_void,
- __unused5: *mut ::c_void,
- __unused6: *mut ::c_void,
- __unused7: *mut ::c_void,
- __unused8: *mut ::c_void,
- }
-
- 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_canonname: *mut ::c_char,
- pub ai_addr: *mut ::sockaddr,
- pub ai_next: *mut addrinfo,
- }
-
- #[deprecated(
- since = "0.2.55",
- note = "Use the `mach` crate instead",
- )]
- pub struct mach_timebase_info {
- pub numer: u32,
- pub denom: u32,
- }
-
- pub struct stat {
- pub st_dev: dev_t,
- pub st_mode: mode_t,
- pub st_nlink: nlink_t,
- pub st_ino: ino_t,
- pub st_uid: ::uid_t,
- pub st_gid: ::gid_t,
- pub st_rdev: dev_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_birthtime: time_t,
- pub st_birthtime_nsec: c_long,
- pub st_size: ::off_t,
- pub st_blocks: ::blkcnt_t,
- pub st_blksize: blksize_t,
- pub st_flags: u32,
- pub st_gen: u32,
- pub st_lspare: i32,
- pub st_qspare: [i64; 2],
- }
-
- pub struct pthread_mutexattr_t {
- __sig: ::c_long,
- __opaque: [u8; 8],
- }
-
- pub struct pthread_condattr_t {
- __sig: ::c_long,
- __opaque: [u8; __PTHREAD_CONDATTR_SIZE__],
- }
-
- pub struct pthread_rwlockattr_t {
- __sig: ::c_long,
- __opaque: [u8; __PTHREAD_RWLOCKATTR_SIZE__],
- }
-
- pub struct siginfo_t {
- pub si_signo: ::c_int,
- pub si_errno: ::c_int,
- pub si_code: ::c_int,
- pub si_pid: ::pid_t,
- pub si_uid: ::uid_t,
- pub si_status: ::c_int,
- pub si_addr: *mut ::c_void,
- _pad: [usize; 9],
- }
-
- pub struct sigaction {
- // FIXME: this field is actually a union
- pub sa_sigaction: ::sighandler_t,
- pub sa_mask: sigset_t,
- pub sa_flags: ::c_int,
- }
-
- pub struct stack_t {
- pub ss_sp: *mut ::c_void,
- pub ss_size: ::size_t,
- pub ss_flags: ::c_int,
- }
-
- pub struct fstore_t {
- pub fst_flags: ::c_uint,
- pub fst_posmode: ::c_int,
- pub fst_offset: ::off_t,
- pub fst_length: ::off_t,
- pub fst_bytesalloc: ::off_t,
- }
-
- pub struct radvisory {
- pub ra_offset: ::off_t,
- pub ra_count: ::c_int,
- }
-
- 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,
- }
-
- pub struct Dl_info {
- pub dli_fname: *const ::c_char,
- pub dli_fbase: *mut ::c_void,
- pub dli_sname: *const ::c_char,
- pub dli_saddr: *mut ::c_void,
- }
-
- 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 kevent64_s {
- pub ident: u64,
- pub filter: i16,
- pub flags: u16,
- pub fflags: u32,
- pub data: i64,
- pub udata: u64,
- pub ext: [u64; 2],
- }
-
- pub struct dqblk {
- pub dqb_bhardlimit: u64,
- pub dqb_bsoftlimit: u64,
- pub dqb_curbytes: u64,
- pub dqb_ihardlimit: u32,
- pub dqb_isoftlimit: u32,
- pub dqb_curinodes: u32,
- pub dqb_btime: u32,
- pub dqb_itime: u32,
- pub dqb_id: u32,
- pub dqb_spare: [u32; 4],
- }
-
- pub struct if_msghdr {
- pub ifm_msglen: ::c_ushort,
- pub ifm_version: ::c_uchar,
- pub ifm_type: ::c_uchar,
- pub ifm_addrs: ::c_int,
- pub ifm_flags: ::c_int,
- pub ifm_index: ::c_ushort,
- pub ifm_data: if_data,
- }
-
- pub struct termios {
- 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; ::NCCS],
- pub c_ispeed: ::speed_t,
- pub c_ospeed: ::speed_t,
- }
-
- pub struct flock {
- pub l_start: ::off_t,
- pub l_len: ::off_t,
- pub l_pid: ::pid_t,
- pub l_type: ::c_short,
- pub l_whence: ::c_short,
- }
-
- pub struct sf_hdtr {
- pub headers: *mut ::iovec,
- pub hdr_cnt: ::c_int,
- pub trailers: *mut ::iovec,
- pub trl_cnt: ::c_int,
- }
-
- 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_n_cs_precedes: ::c_char,
- pub int_p_sep_by_space: ::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 sigevent {
- pub sigev_notify: ::c_int,
- pub sigev_signo: ::c_int,
- pub sigev_value: ::sigval,
- __unused1: *mut ::c_void, //actually a function pointer
- pub sigev_notify_attributes: *mut ::pthread_attr_t
- }
-
- pub struct proc_taskinfo {
- pub pti_virtual_size: u64,
- pub pti_resident_size: u64,
- pub pti_total_user: u64,
- pub pti_total_system: u64,
- pub pti_threads_user: u64,
- pub pti_threads_system: u64,
- pub pti_policy: i32,
- pub pti_faults: i32,
- pub pti_pageins: i32,
- pub pti_cow_faults: i32,
- pub pti_messages_sent: i32,
- pub pti_messages_received: i32,
- pub pti_syscalls_mach: i32,
- pub pti_syscalls_unix: i32,
- pub pti_csw: i32,
- pub pti_threadnum: i32,
- pub pti_numrunning: i32,
- pub pti_priority: i32,
- }
-
- pub struct proc_bsdinfo {
- pub pbi_flags: u32,
- pub pbi_status: u32,
- pub pbi_xstatus: u32,
- pub pbi_pid: u32,
- pub pbi_ppid: u32,
- pub pbi_uid: ::uid_t,
- pub pbi_gid: ::gid_t,
- pub pbi_ruid: ::uid_t,
- pub pbi_rgid: ::gid_t,
- pub pbi_svuid: ::uid_t,
- pub pbi_svgid: ::gid_t,
- pub rfu_1: u32,
- pub pbi_comm: [::c_char; MAXCOMLEN],
- pub pbi_name: [::c_char; 32], // MAXCOMLEN * 2, but macro isn't happy...
- pub pbi_nfiles: u32,
- pub pbi_pgid: u32,
- pub pbi_pjobc: u32,
- pub e_tdev: u32,
- pub e_tpgid: u32,
- pub pbi_nice: i32,
- pub pbi_start_tvsec: u64,
- pub pbi_start_tvusec: u64,
- }
-
- pub struct proc_taskallinfo {
- pub pbsd: proc_bsdinfo,
- pub ptinfo: proc_taskinfo,
- }
-
- pub struct xsw_usage {
- pub xsu_total: u64,
- pub xsu_avail: u64,
- pub xsu_used: u64,
- pub xsu_pagesize: u32,
- pub xsu_encrypted: ::boolean_t,
- }
-
- pub struct xucred {
- pub cr_version: ::c_uint,
- pub cr_uid: ::uid_t,
- pub cr_ngroups: ::c_short,
- pub cr_groups: [::gid_t;16]
- }
-
- #[deprecated(
- since = "0.2.55",
- note = "Use the `mach` crate instead",
- )]
- pub struct mach_header {
- pub magic: u32,
- pub cputype: cpu_type_t,
- pub cpusubtype: cpu_subtype_t,
- pub filetype: u32,
- pub ncmds: u32,
- pub sizeofcmds: u32,
- pub flags: u32,
- }
-
- #[deprecated(
- since = "0.2.55",
- note = "Use the `mach` crate instead",
- )]
- pub struct mach_header_64 {
- pub magic: u32,
- pub cputype: cpu_type_t,
- pub cpusubtype: cpu_subtype_t,
- pub filetype: u32,
- pub ncmds: u32,
- pub sizeofcmds: u32,
- pub flags: u32,
- pub reserved: u32,
- }
-
- pub struct segment_command {
- pub cmd: u32,
- pub cmdsize: u32,
- pub segname: [::c_char; 16],
- pub vmaddr: u32,
- pub vmsize: u32,
- pub fileoff: u32,
- pub filesize: u32,
- pub maxprot: vm_prot_t,
- pub initprot: vm_prot_t,
- pub nsects: u32,
- pub flags: u32,
- }
-
- pub struct segment_command_64 {
- pub cmd: u32,
- pub cmdsize: u32,
- pub segname: [::c_char; 16],
- pub vmaddr: u64,
- pub vmsize: u64,
- pub fileoff: u64,
- pub filesize: u64,
- pub maxprot: vm_prot_t,
- pub initprot: vm_prot_t,
- pub nsects: u32,
- pub flags: u32,
- }
-
- pub struct load_command {
- pub cmd: u32,
- pub cmdsize: u32,
- }
-
- pub struct sockaddr_dl {
- pub sdl_len: ::c_uchar,
- pub sdl_family: ::c_uchar,
- pub sdl_index: ::c_ushort,
- pub sdl_type: ::c_uchar,
- pub sdl_nlen: ::c_uchar,
- pub sdl_alen: ::c_uchar,
- pub sdl_slen: ::c_uchar,
- pub sdl_data: [::c_char; 12],
- }
-
- pub struct sockaddr_inarp {
- pub sin_len: ::c_uchar,
- pub sin_family: ::c_uchar,
- pub sin_port: ::c_ushort,
- pub sin_addr: ::in_addr,
- pub sin_srcaddr: ::in_addr,
- 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: u16,
- pub sc_id: u32,
- pub sc_unit: u32,
- pub sc_reserved: [u32; 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,
- }
-
- // sys/shm.h
-
- pub struct arphdr {
- pub ar_hrd: u16,
- pub ar_pro: u16,
- pub ar_hln: u8,
- pub ar_pln: u8,
- pub ar_op: u16,
- }
-
- pub struct in_addr {
- pub s_addr: ::in_addr_t,
- }
-}
-
-s_no_extra_traits!{
- #[cfg_attr(libc_packedN, repr(packed(4)))]
- pub struct kevent {
- pub ident: ::uintptr_t,
- pub filter: i16,
- pub flags: u16,
- pub fflags: u32,
- pub data: ::intptr_t,
- pub udata: *mut ::c_void,
- }
-
- #[cfg_attr(libc_packedN, 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: i32,
- pub sem_nsems: ::c_ushort,
- pub sem_otime: ::time_t,
- pub sem_pad1: i32,
- pub sem_ctime: ::time_t,
- pub sem_pad2: i32,
- pub sem_pad3: [i32; 4],
- }
-
- #[cfg_attr(libc_packedN, 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 proc_threadinfo {
- pub pth_user_time: u64,
- pub pth_system_time: u64,
- pub pth_cpu_usage: i32,
- pub pth_policy: i32,
- pub pth_run_state: i32,
- pub pth_flags: i32,
- pub pth_sleep_time: i32,
- pub pth_curpri: i32,
- pub pth_priority: i32,
- pub pth_maxpriority: i32,
- pub pth_name: [::c_char; MAXTHREADNAMESIZE],
- }
-
- pub struct statfs {
- pub f_bsize: u32,
- pub f_iosize: i32,
- pub f_blocks: u64,
- pub f_bfree: u64,
- pub f_bavail: u64,
- pub f_files: u64,
- pub f_ffree: u64,
- pub f_fsid: ::fsid_t,
- pub f_owner: ::uid_t,
- pub f_type: u32,
- pub f_flags: u32,
- pub f_fssubtype: u32,
- pub f_fstypename: [::c_char; 16],
- pub f_mntonname: [::c_char; 1024],
- pub f_mntfromname: [::c_char; 1024],
- pub f_reserved: [u32; 8],
- }
-
- pub struct dirent {
- pub d_ino: u64,
- pub d_seekoff: u64,
- pub d_reclen: u16,
- pub d_namlen: u16,
- pub d_type: u8,
- pub d_name: [::c_char; 1024],
- }
-
- pub struct pthread_rwlock_t {
- __sig: ::c_long,
- __opaque: [u8; __PTHREAD_RWLOCK_SIZE__],
- }
-
- pub struct pthread_mutex_t {
- __sig: ::c_long,
- __opaque: [u8; __PTHREAD_MUTEX_SIZE__],
- }
-
- pub struct pthread_cond_t {
- __sig: ::c_long,
- __opaque: [u8; __PTHREAD_COND_SIZE__],
- }
-
- pub struct sockaddr_storage {
- pub ss_len: u8,
- pub ss_family: ::sa_family_t,
- __ss_pad1: [u8; 6],
- __ss_align: i64,
- __ss_pad2: [u8; 112],
- }
-
- pub struct utmpx {
- pub ut_user: [::c_char; _UTX_USERSIZE],
- pub ut_id: [::c_char; _UTX_IDSIZE],
- pub ut_line: [::c_char; _UTX_LINESIZE],
- pub ut_pid: ::pid_t,
- pub ut_type: ::c_short,
- pub ut_tv: ::timeval,
- pub ut_host: [::c_char; _UTX_HOSTSIZE],
- ut_pad: [u32; 16],
- }
-}
-
-cfg_if! {
- if #[cfg(libc_union)] {
- s_no_extra_traits! {
- pub union semun {
- pub val: ::c_int,
- pub buf: *mut semid_ds,
- pub array: *mut ::c_ushort,
- }
- }
-
- cfg_if! {
- if #[cfg(feature = "extra_traits")] {
- impl PartialEq for semun {
- fn eq(&self, other: &semun) -> bool {
- unsafe { self.val == other.val }
- }
- }
- impl Eq for semun {}
- impl ::fmt::Debug for semun {
- fn fmt(&self, f: &mut ::fmt::Formatter)
- -> ::fmt::Result {
- f.debug_struct("semun")
- .field("val", unsafe { &self.val })
- .finish()
- }
- }
- impl ::hash::Hash for semun {
- fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
- unsafe { self.val.hash(state) };
- }
- }
- }
- }
- }
-}
-
-cfg_if! {
- if #[cfg(feature = "extra_traits")] {
- impl PartialEq for kevent {
- fn eq(&self, other: &kevent) -> bool {
- self.ident == other.ident
- && self.filter == other.filter
- && self.flags == other.flags
- && self.fflags == other.fflags
- && self.data == other.data
- && self.udata == other.udata
- }
- }
- impl Eq for kevent {}
- impl ::fmt::Debug for kevent {
- fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
- let ident = self.ident;
- let filter = self.filter;
- let flags = self.flags;
- let fflags = self.fflags;
- let data = self.data;
- let udata = self.udata;
- f.debug_struct("kevent")
- .field("ident", &ident)
- .field("filter", &filter)
- .field("flags", &flags)
- .field("fflags", &fflags)
- .field("data", &data)
- .field("udata", &udata)
- .finish()
- }
- }
- impl ::hash::Hash for kevent {
- fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
- let ident = self.ident;
- let filter = self.filter;
- let flags = self.flags;
- let fflags = self.fflags;
- let data = self.data;
- let udata = self.udata;
- ident.hash(state);
- filter.hash(state);
- flags.hash(state);
- fflags.hash(state);
- data.hash(state);
- udata.hash(state);
- }
- }
-
- impl PartialEq for semid_ds {
- fn eq(&self, other: &semid_ds) -> bool {
- let sem_perm = self.sem_perm;
- let sem_pad3 = self.sem_pad3;
- let other_sem_perm = other.sem_perm;
- let other_sem_pad3 = other.sem_pad3;
- sem_perm == other_sem_perm
- && self.sem_base == other.sem_base
- && self.sem_nsems == other.sem_nsems
- && self.sem_otime == other.sem_otime
- && self.sem_pad1 == other.sem_pad1
- && self.sem_ctime == other.sem_ctime
- && self.sem_pad2 == other.sem_pad2
- && sem_pad3 == other_sem_pad3
- }
- }
- impl Eq for semid_ds {}
- impl ::fmt::Debug for semid_ds {
- fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
- let sem_perm = self.sem_perm;
- let sem_base = self.sem_base;
- let sem_nsems = self.sem_nsems;
- let sem_otime = self.sem_otime;
- let sem_pad1 = self.sem_pad1;
- let sem_ctime = self.sem_ctime;
- let sem_pad2 = self.sem_pad2;
- let sem_pad3 = self.sem_pad3;
- f.debug_struct("semid_ds")
- .field("sem_perm", &sem_perm)
- .field("sem_base", &sem_base)
- .field("sem_nsems", &sem_nsems)
- .field("sem_otime", &sem_otime)
- .field("sem_pad1", &sem_pad1)
- .field("sem_ctime", &sem_ctime)
- .field("sem_pad2", &sem_pad2)
- .field("sem_pad3", &sem_pad3)
- .finish()
- }
- }
- impl ::hash::Hash for semid_ds {
- fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
- let sem_perm = self.sem_perm;
- let sem_base = self.sem_base;
- let sem_nsems = self.sem_nsems;
- let sem_otime = self.sem_otime;
- let sem_pad1 = self.sem_pad1;
- let sem_ctime = self.sem_ctime;
- let sem_pad2 = self.sem_pad2;
- let sem_pad3 = self.sem_pad3;
- sem_perm.hash(state);
- sem_base.hash(state);
- sem_nsems.hash(state);
- sem_otime.hash(state);
- sem_pad1.hash(state);
- sem_ctime.hash(state);
- sem_pad2.hash(state);
- sem_pad3.hash(state);
- }
- }
-
- impl PartialEq for shmid_ds {
- fn eq(&self, other: &shmid_ds) -> bool {
- let shm_perm = self.shm_perm;
- let other_shm_perm = other.shm_perm;
- shm_perm == other_shm_perm
- && self.shm_segsz == other.shm_segsz
- && self.shm_lpid == other.shm_lpid
- && self.shm_cpid == other.shm_cpid
- && self.shm_nattch == other.shm_nattch
- && self.shm_atime == other.shm_atime
- && self.shm_dtime == other.shm_dtime
- && self.shm_ctime == other.shm_ctime
- && self.shm_internal == other.shm_internal
- }
- }
- impl Eq for shmid_ds {}
- impl ::fmt::Debug for shmid_ds {
- fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
- let shm_perm = self.shm_perm;
- let shm_segsz = self.shm_segsz;
- let shm_lpid = self.shm_lpid;
- let shm_cpid = self.shm_cpid;
- let shm_nattch = self.shm_nattch;
- let shm_atime = self.shm_atime;
- let shm_dtime = self.shm_dtime;
- let shm_ctime = self.shm_ctime;
- let shm_internal = self.shm_internal;
- f.debug_struct("shmid_ds")
- .field("shm_perm", &shm_perm)
- .field("shm_segsz", &shm_segsz)
- .field("shm_lpid", &shm_lpid)
- .field("shm_cpid", &shm_cpid)
- .field("shm_nattch", &shm_nattch)
- .field("shm_atime", &shm_atime)
- .field("shm_dtime", &shm_dtime)
- .field("shm_ctime", &shm_ctime)
- .field("shm_internal", &shm_internal)
- .finish()
- }
- }
- impl ::hash::Hash for shmid_ds {
- fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
- let shm_perm = self.shm_perm;
- let shm_segsz = self.shm_segsz;
- let shm_lpid = self.shm_lpid;
- let shm_cpid = self.shm_cpid;
- let shm_nattch = self.shm_nattch;
- let shm_atime = self.shm_atime;
- let shm_dtime = self.shm_dtime;
- let shm_ctime = self.shm_ctime;
- let shm_internal = self.shm_internal;
- shm_perm.hash(state);
- shm_segsz.hash(state);
- shm_lpid.hash(state);
- shm_cpid.hash(state);
- shm_nattch.hash(state);
- shm_atime.hash(state);
- shm_dtime.hash(state);
- shm_ctime.hash(state);
- shm_internal.hash(state);
- }
- }
-
- impl PartialEq for proc_threadinfo {
- fn eq(&self, other: &proc_threadinfo) -> bool {
- self.pth_user_time == other.pth_user_time
- && self.pth_system_time == other.pth_system_time
- && self.pth_cpu_usage == other.pth_cpu_usage
- && self.pth_policy == other.pth_policy
- && self.pth_run_state == other.pth_run_state
- && self.pth_flags == other.pth_flags
- && self.pth_sleep_time == other.pth_sleep_time
- && self.pth_curpri == other.pth_curpri
- && self.pth_priority == other.pth_priority
- && self.pth_maxpriority == other.pth_maxpriority
- && self.pth_name
- .iter()
- .zip(other.pth_name.iter())
- .all(|(a,b)| a == b)
- }
- }
- impl Eq for proc_threadinfo {}
- impl ::fmt::Debug for proc_threadinfo {
- fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
- f.debug_struct("proc_threadinfo")
- .field("pth_user_time", &self.pth_user_time)
- .field("pth_system_time", &self.pth_system_time)
- .field("pth_cpu_usage", &self.pth_cpu_usage)
- .field("pth_policy", &self.pth_policy)
- .field("pth_run_state", &self.pth_run_state)
- .field("pth_flags", &self.pth_flags)
- .field("pth_sleep_time", &self.pth_sleep_time)
- .field("pth_curpri", &self.pth_curpri)
- .field("pth_priority", &self.pth_priority)
- .field("pth_maxpriority", &self.pth_maxpriority)
- // FIXME: .field("pth_name", &self.pth_name)
- .finish()
- }
- }
- impl ::hash::Hash for proc_threadinfo {
- fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
- self.pth_user_time.hash(state);
- self.pth_system_time.hash(state);
- self.pth_cpu_usage.hash(state);
- self.pth_policy.hash(state);
- self.pth_run_state.hash(state);
- self.pth_flags.hash(state);
- self.pth_sleep_time.hash(state);
- self.pth_curpri.hash(state);
- self.pth_priority.hash(state);
- self.pth_maxpriority.hash(state);
- self.pth_name.hash(state);
- }
- }
-
- impl PartialEq for statfs {
- fn eq(&self, other: &statfs) -> bool {
- self.f_bsize == other.f_bsize
- && self.f_iosize == other.f_iosize
- && self.f_blocks == other.f_blocks
- && self.f_bfree == other.f_bfree
- && self.f_bavail == other.f_bavail
- && self.f_files == other.f_files
- && self.f_ffree == other.f_ffree
- && self.f_fsid == other.f_fsid
- && self.f_owner == other.f_owner
- && self.f_flags == other.f_flags
- && self.f_fssubtype == other.f_fssubtype
- && self.f_fstypename == other.f_fstypename
- && self.f_type == other.f_type
- && self
- .f_mntonname
- .iter()
- .zip(other.f_mntonname.iter())
- .all(|(a,b)| a == b)
- && self
- .f_mntfromname
- .iter()
- .zip(other.f_mntfromname.iter())
- .all(|(a,b)| a == b)
- && self.f_reserved == other.f_reserved
- }
- }
-
- impl Eq for statfs {}
- impl ::fmt::Debug for statfs {
- fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
- f.debug_struct("statfs")
- .field("f_bsize", &self.f_bsize)
- .field("f_iosize", &self.f_iosize)
- .field("f_blocks", &self.f_blocks)
- .field("f_bfree", &self.f_bfree)
- .field("f_bavail", &self.f_bavail)
- .field("f_files", &self.f_files)
- .field("f_ffree", &self.f_ffree)
- .field("f_fsid", &self.f_fsid)
- .field("f_owner", &self.f_owner)
- .field("f_flags", &self.f_flags)
- .field("f_fssubtype", &self.f_fssubtype)
- .field("f_fstypename", &self.f_fstypename)
- .field("f_type", &self.f_type)
- // FIXME: .field("f_mntonname", &self.f_mntonname)
- // FIXME: .field("f_mntfromname", &self.f_mntfromname)
- .field("f_reserved", &self.f_reserved)
- .finish()
- }
- }
-
- impl ::hash::Hash for statfs {
- fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
- self.f_bsize.hash(state);
- self.f_iosize.hash(state);
- self.f_blocks.hash(state);
- self.f_bfree.hash(state);
- self.f_bavail.hash(state);
- self.f_files.hash(state);
- self.f_ffree.hash(state);
- self.f_fsid.hash(state);
- self.f_owner.hash(state);
- self.f_flags.hash(state);
- self.f_fssubtype.hash(state);
- self.f_fstypename.hash(state);
- self.f_type.hash(state);
- self.f_mntonname.hash(state);
- self.f_mntfromname.hash(state);
- self.f_reserved.hash(state);
- }
- }
-
- impl PartialEq for dirent {
- fn eq(&self, other: &dirent) -> bool {
- self.d_ino == other.d_ino
- && self.d_seekoff == other.d_seekoff
- && self.d_reclen == other.d_reclen
- && self.d_namlen == other.d_namlen
- && self.d_type == other.d_type
- && self
- .d_name
- .iter()
- .zip(other.d_name.iter())
- .all(|(a,b)| a == b)
- }
- }
- impl Eq for dirent {}
- impl ::fmt::Debug for dirent {
- fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
- f.debug_struct("dirent")
- .field("d_ino", &self.d_ino)
- .field("d_seekoff", &self.d_seekoff)
- .field("d_reclen", &self.d_reclen)
- .field("d_namlen", &self.d_namlen)
- .field("d_type", &self.d_type)
- // FIXME: .field("d_name", &self.d_name)
- .finish()
- }
- }
- impl ::hash::Hash for dirent {
- fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
- self.d_ino.hash(state);
- self.d_seekoff.hash(state);
- self.d_reclen.hash(state);
- self.d_namlen.hash(state);
- self.d_type.hash(state);
- self.d_name.hash(state);
- }
- }
- impl PartialEq for pthread_rwlock_t {
- fn eq(&self, other: &pthread_rwlock_t) -> bool {
- self.__sig == other.__sig
- && self.
- __opaque
- .iter()
- .zip(other.__opaque.iter())
- .all(|(a,b)| a == b)
- }
- }
- impl Eq for pthread_rwlock_t {}
- impl ::fmt::Debug for pthread_rwlock_t {
- fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
- f.debug_struct("pthread_rwlock_t")
- .field("__sig", &self.__sig)
- // FIXME: .field("__opaque", &self.__opaque)
- .finish()
- }
- }
- impl ::hash::Hash for pthread_rwlock_t {
- fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
- self.__sig.hash(state);
- self.__opaque.hash(state);
- }
- }
-
- impl PartialEq for pthread_mutex_t {
- fn eq(&self, other: &pthread_mutex_t) -> bool {
- self.__sig == other.__sig
- && self.
- __opaque
- .iter()
- .zip(other.__opaque.iter())
- .all(|(a,b)| a == b)
- }
- }
-
- impl Eq for pthread_mutex_t {}
-
- impl ::fmt::Debug for pthread_mutex_t {
- fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
- f.debug_struct("pthread_mutex_t")
- .field("__sig", &self.__sig)
- // FIXME: .field("__opaque", &self.__opaque)
- .finish()
- }
- }
-
- impl ::hash::Hash for pthread_mutex_t {
- fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
- self.__sig.hash(state);
- self.__opaque.hash(state);
- }
- }
-
- impl PartialEq for pthread_cond_t {
- fn eq(&self, other: &pthread_cond_t) -> bool {
- self.__sig == other.__sig
- && self.
- __opaque
- .iter()
- .zip(other.__opaque.iter())
- .all(|(a,b)| a == b)
- }
- }
-
- impl Eq for pthread_cond_t {}
-
- impl ::fmt::Debug for pthread_cond_t {
- fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
- f.debug_struct("pthread_cond_t")
- .field("__sig", &self.__sig)
- // FIXME: .field("__opaque", &self.__opaque)
- .finish()
- }
- }
-
- impl ::hash::Hash for pthread_cond_t {
- fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
- self.__sig.hash(state);
- self.__opaque.hash(state);
- }
- }
-
- impl PartialEq for sockaddr_storage {
- fn eq(&self, other: &sockaddr_storage) -> bool {
- self.ss_len == other.ss_len
- && self.ss_family == other.ss_family
- && self
- .__ss_pad1
- .iter()
- .zip(other.__ss_pad1.iter())
- .all(|(a, b)| a == b)
- && self.__ss_align == other.__ss_align
- && self
- .__ss_pad2
- .iter()
- .zip(other.__ss_pad2.iter())
- .all(|(a, b)| a == b)
- }
- }
-
- impl Eq for sockaddr_storage {}
-
- impl ::fmt::Debug for sockaddr_storage {
- fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
- f.debug_struct("sockaddr_storage")
- .field("ss_len", &self.ss_len)
- .field("ss_family", &self.ss_family)
- .field("__ss_pad1", &self.__ss_pad1)
- .field("__ss_align", &self.__ss_align)
- // FIXME: .field("__ss_pad2", &self.__ss_pad2)
- .finish()
- }
- }
-
- impl ::hash::Hash for sockaddr_storage {
- fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
- self.ss_len.hash(state);
- self.ss_family.hash(state);
- self.__ss_pad1.hash(state);
- self.__ss_align.hash(state);
- self.__ss_pad2.hash(state);
- }
- }
-
- impl PartialEq for utmpx {
- fn eq(&self, other: &utmpx) -> bool {
- self.ut_user
- .iter()
- .zip(other.ut_user.iter())
- .all(|(a,b)| a == b)
- && self.ut_id == other.ut_id
- && self.ut_line == other.ut_line
- && self.ut_pid == other.ut_pid
- && self.ut_type == other.ut_type
- && self.ut_tv == other.ut_tv
- && self
- .ut_host
- .iter()
- .zip(other.ut_host.iter())
- .all(|(a,b)| a == b)
- && self.ut_pad == other.ut_pad
- }
- }
-
- impl Eq for utmpx {}
-
- impl ::fmt::Debug for utmpx {
- fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
- f.debug_struct("utmpx")
- // FIXME: .field("ut_user", &self.ut_user)
- .field("ut_id", &self.ut_id)
- .field("ut_line", &self.ut_line)
- .field("ut_pid", &self.ut_pid)
- .field("ut_type", &self.ut_type)
- .field("ut_tv", &self.ut_tv)
- // FIXME: .field("ut_host", &self.ut_host)
- .field("ut_pad", &self.ut_pad)
- .finish()
- }
- }
-
- impl ::hash::Hash for utmpx {
- fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
- self.ut_user.hash(state);
- self.ut_id.hash(state);
- self.ut_line.hash(state);
- self.ut_pid.hash(state);
- self.ut_type.hash(state);
- self.ut_tv.hash(state);
- self.ut_host.hash(state);
- self.ut_pad.hash(state);
- }
- }
- }
-}
-
-pub const _UTX_USERSIZE: usize = 256;
-pub const _UTX_LINESIZE: usize = 32;
-pub const _UTX_IDSIZE: usize = 4;
-pub const _UTX_HOSTSIZE: usize = 256;
-
-pub const EMPTY: ::c_short = 0;
-pub const RUN_LVL: ::c_short = 1;
-pub const BOOT_TIME: ::c_short = 2;
-pub const OLD_TIME: ::c_short = 3;
-pub const NEW_TIME: ::c_short = 4;
-pub const INIT_PROCESS: ::c_short = 5;
-pub const LOGIN_PROCESS: ::c_short = 6;
-pub const USER_PROCESS: ::c_short = 7;
-pub const DEAD_PROCESS: ::c_short = 8;
-pub const ACCOUNTING: ::c_short = 9;
-pub const SIGNATURE: ::c_short = 10;
-pub const SHUTDOWN_TIME: ::c_short = 11;
-
-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_ALL_MASK: ::c_int = LC_COLLATE_MASK
- | LC_CTYPE_MASK
- | LC_MESSAGES_MASK
- | LC_MONETARY_MASK
- | LC_NUMERIC_MASK
- | LC_TIME_MASK;
-
-pub const CODESET: ::nl_item = 0;
-pub const D_T_FMT: ::nl_item = 1;
-pub const D_FMT: ::nl_item = 2;
-pub const T_FMT: ::nl_item = 3;
-pub const T_FMT_AMPM: ::nl_item = 4;
-pub const AM_STR: ::nl_item = 5;
-pub const PM_STR: ::nl_item = 6;
-
-pub const DAY_1: ::nl_item = 7;
-pub const DAY_2: ::nl_item = 8;
-pub const DAY_3: ::nl_item = 9;
-pub const DAY_4: ::nl_item = 10;
-pub const DAY_5: ::nl_item = 11;
-pub const DAY_6: ::nl_item = 12;
-pub const DAY_7: ::nl_item = 13;
-
-pub const ABDAY_1: ::nl_item = 14;
-pub const ABDAY_2: ::nl_item = 15;
-pub const ABDAY_3: ::nl_item = 16;
-pub const ABDAY_4: ::nl_item = 17;
-pub const ABDAY_5: ::nl_item = 18;
-pub const ABDAY_6: ::nl_item = 19;
-pub const ABDAY_7: ::nl_item = 20;
-
-pub const MON_1: ::nl_item = 21;
-pub const MON_2: ::nl_item = 22;
-pub const MON_3: ::nl_item = 23;
-pub const MON_4: ::nl_item = 24;
-pub const MON_5: ::nl_item = 25;
-pub const MON_6: ::nl_item = 26;
-pub const MON_7: ::nl_item = 27;
-pub const MON_8: ::nl_item = 28;
-pub const MON_9: ::nl_item = 29;
-pub const MON_10: ::nl_item = 30;
-pub const MON_11: ::nl_item = 31;
-pub const MON_12: ::nl_item = 32;
-
-pub const ABMON_1: ::nl_item = 33;
-pub const ABMON_2: ::nl_item = 34;
-pub const ABMON_3: ::nl_item = 35;
-pub const ABMON_4: ::nl_item = 36;
-pub const ABMON_5: ::nl_item = 37;
-pub const ABMON_6: ::nl_item = 38;
-pub const ABMON_7: ::nl_item = 39;
-pub const ABMON_8: ::nl_item = 40;
-pub const ABMON_9: ::nl_item = 41;
-pub const ABMON_10: ::nl_item = 42;
-pub const ABMON_11: ::nl_item = 43;
-pub const ABMON_12: ::nl_item = 44;
-
-pub const CLOCK_REALTIME: ::clockid_t = 0;
-pub const CLOCK_MONOTONIC: ::clockid_t = 6;
-pub const CLOCK_PROCESS_CPUTIME_ID: ::clockid_t = 12;
-pub const CLOCK_THREAD_CPUTIME_ID: ::clockid_t = 16;
-
-pub const ERA: ::nl_item = 45;
-pub const ERA_D_FMT: ::nl_item = 46;
-pub const ERA_D_T_FMT: ::nl_item = 47;
-pub const ERA_T_FMT: ::nl_item = 48;
-pub const ALT_DIGITS: ::nl_item = 49;
-
-pub const RADIXCHAR: ::nl_item = 50;
-pub const THOUSEP: ::nl_item = 51;
-
-pub const YESEXPR: ::nl_item = 52;
-pub const NOEXPR: ::nl_item = 53;
-
-pub const YESSTR: ::nl_item = 54;
-pub const NOSTR: ::nl_item = 55;
-
-pub const CRNCYSTR: ::nl_item = 56;
-
-pub const D_MD_ORDER: ::nl_item = 57;
-
-pub const EXIT_FAILURE: ::c_int = 1;
-pub const EXIT_SUCCESS: ::c_int = 0;
-pub const RAND_MAX: ::c_int = 2147483647;
-pub const EOF: ::c_int = -1;
-pub const SEEK_SET: ::c_int = 0;
-pub const SEEK_CUR: ::c_int = 1;
-pub const SEEK_END: ::c_int = 2;
-pub const _IOFBF: ::c_int = 0;
-pub const _IONBF: ::c_int = 2;
-pub const _IOLBF: ::c_int = 1;
-pub const BUFSIZ: ::c_uint = 1024;
-pub const FOPEN_MAX: ::c_uint = 20;
-pub const FILENAME_MAX: ::c_uint = 1024;
-pub const L_tmpnam: ::c_uint = 1024;
-pub const TMP_MAX: ::c_uint = 308915776;
-pub const _PC_LINK_MAX: ::c_int = 1;
-pub const _PC_MAX_CANON: ::c_int = 2;
-pub const _PC_MAX_INPUT: ::c_int = 3;
-pub const _PC_NAME_MAX: ::c_int = 4;
-pub const _PC_PATH_MAX: ::c_int = 5;
-pub const _PC_PIPE_BUF: ::c_int = 6;
-pub const _PC_CHOWN_RESTRICTED: ::c_int = 7;
-pub const _PC_NO_TRUNC: ::c_int = 8;
-pub const _PC_VDISABLE: ::c_int = 9;
-pub const O_DSYNC: ::c_int = 0x400000;
-pub const O_NOCTTY: ::c_int = 0x20000;
-pub const O_CLOEXEC: ::c_int = 0x1000000;
-pub const O_DIRECTORY: ::c_int = 0x100000;
-pub const S_IFIFO: mode_t = 4096;
-pub const S_IFCHR: mode_t = 8192;
-pub const S_IFBLK: mode_t = 24576;
-pub const S_IFDIR: mode_t = 16384;
-pub const S_IFREG: mode_t = 32768;
-pub const S_IFLNK: mode_t = 40960;
-pub const S_IFSOCK: mode_t = 49152;
-pub const S_IFMT: mode_t = 61440;
-pub const S_IEXEC: mode_t = 64;
-pub const S_IWRITE: mode_t = 128;
-pub const S_IREAD: mode_t = 256;
-pub const S_IRWXU: mode_t = 448;
-pub const S_IXUSR: mode_t = 64;
-pub const S_IWUSR: mode_t = 128;
-pub const S_IRUSR: mode_t = 256;
-pub const S_IRWXG: mode_t = 56;
-pub const S_IXGRP: mode_t = 8;
-pub const S_IWGRP: mode_t = 16;
-pub const S_IRGRP: mode_t = 32;
-pub const S_IRWXO: mode_t = 7;
-pub const S_IXOTH: mode_t = 1;
-pub const S_IWOTH: mode_t = 2;
-pub const S_IROTH: mode_t = 4;
-pub const F_OK: ::c_int = 0;
-pub const R_OK: ::c_int = 4;
-pub const W_OK: ::c_int = 2;
-pub const X_OK: ::c_int = 1;
-pub const STDIN_FILENO: ::c_int = 0;
-pub const STDOUT_FILENO: ::c_int = 1;
-pub const STDERR_FILENO: ::c_int = 2;
-pub const F_LOCK: ::c_int = 1;
-pub const F_TEST: ::c_int = 3;
-pub const F_TLOCK: ::c_int = 2;
-pub const F_ULOCK: ::c_int = 0;
-pub const F_GETLK: ::c_int = 7;
-pub const F_SETLK: ::c_int = 8;
-pub const F_SETLKW: ::c_int = 9;
-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 PROT_NONE: ::c_int = 0;
-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;
-
-deprecated_mach! {
- pub const VM_FLAGS_FIXED: ::c_int = 0x0000;
- pub const VM_FLAGS_ANYWHERE: ::c_int = 0x0001;
- pub const VM_FLAGS_PURGABLE: ::c_int = 0x0002;
- pub const VM_FLAGS_RANDOM_ADDR: ::c_int = 0x0008;
- pub const VM_FLAGS_NO_CACHE: ::c_int = 0x0010;
- pub const VM_FLAGS_RESILIENT_CODESIGN: ::c_int = 0x0020;
- pub const VM_FLAGS_RESILIENT_MEDIA: ::c_int = 0x0040;
- pub const VM_FLAGS_OVERWRITE: ::c_int = 0x4000;
- 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 = 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 |
- VM_FLAGS_RETURN_DATA_ADDR |
- VM_FLAGS_RESILIENT_CODESIGN;
-
- pub const VM_FLAGS_SUPERPAGE_SHIFT: ::c_int = 16;
- pub const SUPERPAGE_NONE: ::c_int = 0;
- pub const SUPERPAGE_SIZE_ANY: ::c_int = 1;
- pub const VM_FLAGS_SUPERPAGE_NONE: ::c_int = SUPERPAGE_NONE <<
- VM_FLAGS_SUPERPAGE_SHIFT;
- pub const VM_FLAGS_SUPERPAGE_SIZE_ANY: ::c_int = SUPERPAGE_SIZE_ANY <<
- VM_FLAGS_SUPERPAGE_SHIFT;
- pub const SUPERPAGE_SIZE_2MB: ::c_int = 2;
- pub const VM_FLAGS_SUPERPAGE_SIZE_2MB: ::c_int = SUPERPAGE_SIZE_2MB <<
- VM_FLAGS_SUPERPAGE_SHIFT;
-
- pub const VM_MEMORY_MALLOC: ::c_int = 1;
- pub const VM_MEMORY_MALLOC_SMALL: ::c_int = 2;
- pub const VM_MEMORY_MALLOC_LARGE: ::c_int = 3;
- pub const VM_MEMORY_MALLOC_HUGE: ::c_int = 4;
- pub const VM_MEMORY_SBRK: ::c_int = 5;
- pub const VM_MEMORY_REALLOC: ::c_int = 6;
- pub const VM_MEMORY_MALLOC_TINY: ::c_int = 7;
- pub const VM_MEMORY_MALLOC_LARGE_REUSABLE: ::c_int = 8;
- pub const VM_MEMORY_MALLOC_LARGE_REUSED: ::c_int = 9;
- pub const VM_MEMORY_ANALYSIS_TOOL: ::c_int = 10;
- pub const VM_MEMORY_MALLOC_NANO: ::c_int = 11;
- pub const VM_MEMORY_MACH_MSG: ::c_int = 20;
- pub const VM_MEMORY_IOKIT: ::c_int = 21;
- pub const VM_MEMORY_STACK: ::c_int = 30;
- pub const VM_MEMORY_GUARD: ::c_int = 31;
- pub const VM_MEMORY_SHARED_PMAP: ::c_int = 32;
- pub const VM_MEMORY_DYLIB: ::c_int = 33;
- pub const VM_MEMORY_OBJC_DISPATCHERS: ::c_int = 34;
- pub const VM_MEMORY_UNSHARED_PMAP: ::c_int = 35;
- pub const VM_MEMORY_APPKIT: ::c_int = 40;
- pub const VM_MEMORY_FOUNDATION: ::c_int = 41;
- pub const VM_MEMORY_COREGRAPHICS: ::c_int = 42;
- pub const VM_MEMORY_CORESERVICES: ::c_int = 43;
- pub const VM_MEMORY_CARBON: ::c_int = VM_MEMORY_CORESERVICES;
- pub const VM_MEMORY_JAVA: ::c_int = 44;
- pub const VM_MEMORY_COREDATA: ::c_int = 45;
- pub const VM_MEMORY_COREDATA_OBJECTIDS: ::c_int = 46;
- pub const VM_MEMORY_ATS: ::c_int = 50;
- pub const VM_MEMORY_LAYERKIT: ::c_int = 51;
- pub const VM_MEMORY_CGIMAGE: ::c_int = 52;
- pub const VM_MEMORY_TCMALLOC: ::c_int = 53;
- pub const VM_MEMORY_COREGRAPHICS_DATA: ::c_int = 54;
- pub const VM_MEMORY_COREGRAPHICS_SHARED: ::c_int = 55;
- pub const VM_MEMORY_COREGRAPHICS_FRAMEBUFFERS: ::c_int = 56;
- pub const VM_MEMORY_COREGRAPHICS_BACKINGSTORES: ::c_int = 57;
- pub const VM_MEMORY_COREGRAPHICS_XALLOC: ::c_int = 58;
- pub const VM_MEMORY_COREGRAPHICS_MISC: ::c_int = VM_MEMORY_COREGRAPHICS;
- pub const VM_MEMORY_DYLD: ::c_int = 60;
- pub const VM_MEMORY_DYLD_MALLOC: ::c_int = 61;
- pub const VM_MEMORY_SQLITE: ::c_int = 62;
- pub const VM_MEMORY_JAVASCRIPT_CORE: ::c_int = 63;
- pub const VM_MEMORY_JAVASCRIPT_JIT_EXECUTABLE_ALLOCATOR: ::c_int = 64;
- pub const VM_MEMORY_JAVASCRIPT_JIT_REGISTER_FILE: ::c_int = 65;
- pub const VM_MEMORY_GLSL: ::c_int = 66;
- pub const VM_MEMORY_OPENCL: ::c_int = 67;
- pub const VM_MEMORY_COREIMAGE: ::c_int = 68;
- pub const VM_MEMORY_WEBCORE_PURGEABLE_BUFFERS: ::c_int = 69;
- pub const VM_MEMORY_IMAGEIO: ::c_int = 70;
- pub const VM_MEMORY_COREPROFILE: ::c_int = 71;
- pub const VM_MEMORY_ASSETSD: ::c_int = 72;
- pub const VM_MEMORY_OS_ALLOC_ONCE: ::c_int = 73;
- pub const VM_MEMORY_LIBDISPATCH: ::c_int = 74;
- pub const VM_MEMORY_ACCELERATE: ::c_int = 75;
- pub const VM_MEMORY_COREUI: ::c_int = 76;
- pub const VM_MEMORY_COREUIFILE: ::c_int = 77;
- pub const VM_MEMORY_GENEALOGY: ::c_int = 78;
- pub const VM_MEMORY_RAWCAMERA: ::c_int = 79;
- pub const VM_MEMORY_CORPSEINFO: ::c_int = 80;
- pub const VM_MEMORY_ASL: ::c_int = 81;
- pub const VM_MEMORY_SWIFT_RUNTIME: ::c_int = 82;
- pub const VM_MEMORY_SWIFT_METADATA: ::c_int = 83;
- pub const VM_MEMORY_DHMM: ::c_int = 84;
- pub const VM_MEMORY_SCENEKIT: ::c_int = 86;
- pub const VM_MEMORY_SKYWALK: ::c_int = 87;
- pub const VM_MEMORY_APPLICATION_SPECIFIC_1: ::c_int = 240;
- pub const VM_MEMORY_APPLICATION_SPECIFIC_16: ::c_int = 255;
-}
-
-pub const MAP_FAILED: *mut ::c_void = !0 as *mut ::c_void;
-
-pub const MCL_CURRENT: ::c_int = 0x0001;
-pub const MCL_FUTURE: ::c_int = 0x0002;
-
-pub const MS_ASYNC: ::c_int = 0x0001;
-pub const MS_INVALIDATE: ::c_int = 0x0002;
-pub const MS_SYNC: ::c_int = 0x0010;
-
-pub const MS_KILLPAGES: ::c_int = 0x0004;
-pub const MS_DEACTIVATE: ::c_int = 0x0008;
-
-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 EDEADLK: ::c_int = 11;
-pub const ENOMEM: ::c_int = 12;
-pub const EACCES: ::c_int = 13;
-pub const EFAULT: ::c_int = 14;
-pub const ENOTBLK: ::c_int = 15;
-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 EAGAIN: ::c_int = 35;
-pub const EWOULDBLOCK: ::c_int = EAGAIN;
-pub const EINPROGRESS: ::c_int = 36;
-pub const EALREADY: ::c_int = 37;
-pub const ENOTSOCK: ::c_int = 38;
-pub const EDESTADDRREQ: ::c_int = 39;
-pub const EMSGSIZE: ::c_int = 40;
-pub const EPROTOTYPE: ::c_int = 41;
-pub const ENOPROTOOPT: ::c_int = 42;
-pub const EPROTONOSUPPORT: ::c_int = 43;
-pub const ESOCKTNOSUPPORT: ::c_int = 44;
-pub const ENOTSUP: ::c_int = 45;
-pub const EPFNOSUPPORT: ::c_int = 46;
-pub const EAFNOSUPPORT: ::c_int = 47;
-pub const EADDRINUSE: ::c_int = 48;
-pub const EADDRNOTAVAIL: ::c_int = 49;
-pub const ENETDOWN: ::c_int = 50;
-pub const ENETUNREACH: ::c_int = 51;
-pub const ENETRESET: ::c_int = 52;
-pub const ECONNABORTED: ::c_int = 53;
-pub const ECONNRESET: ::c_int = 54;
-pub const ENOBUFS: ::c_int = 55;
-pub const EISCONN: ::c_int = 56;
-pub const ENOTCONN: ::c_int = 57;
-pub const ESHUTDOWN: ::c_int = 58;
-pub const ETOOMANYREFS: ::c_int = 59;
-pub const ETIMEDOUT: ::c_int = 60;
-pub const ECONNREFUSED: ::c_int = 61;
-pub const ELOOP: ::c_int = 62;
-pub const ENAMETOOLONG: ::c_int = 63;
-pub const EHOSTDOWN: ::c_int = 64;
-pub const EHOSTUNREACH: ::c_int = 65;
-pub const ENOTEMPTY: ::c_int = 66;
-pub const EPROCLIM: ::c_int = 67;
-pub const EUSERS: ::c_int = 68;
-pub const EDQUOT: ::c_int = 69;
-pub const ESTALE: ::c_int = 70;
-pub const EREMOTE: ::c_int = 71;
-pub const EBADRPC: ::c_int = 72;
-pub const ERPCMISMATCH: ::c_int = 73;
-pub const EPROGUNAVAIL: ::c_int = 74;
-pub const EPROGMISMATCH: ::c_int = 75;
-pub const EPROCUNAVAIL: ::c_int = 76;
-pub const ENOLCK: ::c_int = 77;
-pub const ENOSYS: ::c_int = 78;
-pub const EFTYPE: ::c_int = 79;
-pub const EAUTH: ::c_int = 80;
-pub const ENEEDAUTH: ::c_int = 81;
-pub const EPWROFF: ::c_int = 82;
-pub const EDEVERR: ::c_int = 83;
-pub const EOVERFLOW: ::c_int = 84;
-pub const EBADEXEC: ::c_int = 85;
-pub const EBADARCH: ::c_int = 86;
-pub const ESHLIBVERS: ::c_int = 87;
-pub const EBADMACHO: ::c_int = 88;
-pub const ECANCELED: ::c_int = 89;
-pub const EIDRM: ::c_int = 90;
-pub const ENOMSG: ::c_int = 91;
-pub const EILSEQ: ::c_int = 92;
-pub const ENOATTR: ::c_int = 93;
-pub const EBADMSG: ::c_int = 94;
-pub const EMULTIHOP: ::c_int = 95;
-pub const ENODATA: ::c_int = 96;
-pub const ENOLINK: ::c_int = 97;
-pub const ENOSR: ::c_int = 98;
-pub const ENOSTR: ::c_int = 99;
-pub const EPROTO: ::c_int = 100;
-pub const ETIME: ::c_int = 101;
-pub const EOPNOTSUPP: ::c_int = 102;
-pub const ENOPOLICY: ::c_int = 103;
-pub const ENOTRECOVERABLE: ::c_int = 104;
-pub const EOWNERDEAD: ::c_int = 105;
-pub const EQFULL: ::c_int = 106;
-pub const ELAST: ::c_int = 106;
-
-pub const EAI_AGAIN: ::c_int = 2;
-pub const EAI_BADFLAGS: ::c_int = 3;
-pub const EAI_FAIL: ::c_int = 4;
-pub const EAI_FAMILY: ::c_int = 5;
-pub const EAI_MEMORY: ::c_int = 6;
-pub const EAI_NODATA: ::c_int = 7;
-pub const EAI_NONAME: ::c_int = 8;
-pub const EAI_SERVICE: ::c_int = 9;
-pub const EAI_SOCKTYPE: ::c_int = 10;
-pub const EAI_SYSTEM: ::c_int = 11;
-pub const EAI_OVERFLOW: ::c_int = 14;
-
-pub const F_DUPFD: ::c_int = 0;
-pub const F_DUPFD_CLOEXEC: ::c_int = 67;
-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_PREALLOCATE: ::c_int = 42;
-pub const F_RDADVISE: ::c_int = 44;
-pub const F_RDAHEAD: ::c_int = 45;
-pub const F_NOCACHE: ::c_int = 48;
-pub const F_GETPATH: ::c_int = 50;
-pub const F_FULLFSYNC: ::c_int = 51;
-pub const F_FREEZE_FS: ::c_int = 53;
-pub const F_THAW_FS: ::c_int = 54;
-pub const F_GLOBAL_NOCACHE: ::c_int = 55;
-pub const F_NODIRECT: ::c_int = 62;
-
-pub const F_ALLOCATECONTIG: ::c_uint = 0x02;
-pub const F_ALLOCATEALL: ::c_uint = 0x04;
-
-pub const F_PEOFPOSMODE: ::c_int = 3;
-pub const F_VOLPOSMODE: ::c_int = 4;
-
-pub const AT_FDCWD: ::c_int = -2;
-pub const AT_EACCESS: ::c_int = 0x0010;
-pub const AT_SYMLINK_NOFOLLOW: ::c_int = 0x0020;
-pub const AT_SYMLINK_FOLLOW: ::c_int = 0x0040;
-pub const AT_REMOVEDIR: ::c_int = 0x0080;
-
-pub const TIOCMODG: ::c_ulong = 0x40047403;
-pub const TIOCMODS: ::c_ulong = 0x80047404;
-pub const TIOCM_LE: ::c_int = 0x1;
-pub const TIOCM_DTR: ::c_int = 0x2;
-pub const TIOCM_RTS: ::c_int = 0x4;
-pub const TIOCM_ST: ::c_int = 0x8;
-pub const TIOCM_SR: ::c_int = 0x10;
-pub const TIOCM_CTS: ::c_int = 0x20;
-pub const TIOCM_CAR: ::c_int = 0x40;
-pub const TIOCM_CD: ::c_int = 0x40;
-pub const TIOCM_RNG: ::c_int = 0x80;
-pub const TIOCM_RI: ::c_int = 0x80;
-pub const TIOCM_DSR: ::c_int = 0x100;
-pub const TIOCEXCL: ::c_int = 0x2000740d;
-pub const TIOCNXCL: ::c_int = 0x2000740e;
-pub const TIOCFLUSH: ::c_ulong = 0x80047410;
-pub const TIOCGETD: ::c_ulong = 0x4004741a;
-pub const TIOCSETD: ::c_ulong = 0x8004741b;
-pub const TIOCIXON: ::c_uint = 0x20007481;
-pub const TIOCIXOFF: ::c_uint = 0x20007480;
-pub const TIOCSBRK: ::c_uint = 0x2000747b;
-pub const TIOCCBRK: ::c_uint = 0x2000747a;
-pub const TIOCSDTR: ::c_uint = 0x20007479;
-pub const TIOCCDTR: ::c_uint = 0x20007478;
-pub const TIOCGPGRP: ::c_ulong = 0x40047477;
-pub const TIOCSPGRP: ::c_ulong = 0x80047476;
-pub const TIOCOUTQ: ::c_ulong = 0x40047473;
-pub const TIOCSTI: ::c_ulong = 0x80017472;
-pub const TIOCNOTTY: ::c_uint = 0x20007471;
-pub const TIOCPKT: ::c_ulong = 0x80047470;
-pub const TIOCPKT_DATA: ::c_int = 0x0;
-pub const TIOCPKT_FLUSHREAD: ::c_int = 0x1;
-pub const TIOCPKT_FLUSHWRITE: ::c_int = 0x2;
-pub const TIOCPKT_STOP: ::c_int = 0x4;
-pub const TIOCPKT_START: ::c_int = 0x8;
-pub const TIOCPKT_NOSTOP: ::c_int = 0x10;
-pub const TIOCPKT_DOSTOP: ::c_int = 0x20;
-pub const TIOCPKT_IOCTL: ::c_int = 0x40;
-pub const TIOCSTOP: ::c_uint = 0x2000746f;
-pub const TIOCSTART: ::c_uint = 0x2000746e;
-pub const TIOCMSET: ::c_ulong = 0x8004746d;
-pub const TIOCMBIS: ::c_ulong = 0x8004746c;
-pub const TIOCMBIC: ::c_ulong = 0x8004746b;
-pub const TIOCMGET: ::c_ulong = 0x4004746a;
-pub const TIOCREMOTE: ::c_ulong = 0x80047469;
-pub const TIOCGWINSZ: ::c_ulong = 0x40087468;
-pub const TIOCSWINSZ: ::c_ulong = 0x80087467;
-pub const TIOCUCNTL: ::c_ulong = 0x80047466;
-pub const TIOCSTAT: ::c_uint = 0x20007465;
-pub const TIOCSCONS: ::c_uint = 0x20007463;
-pub const TIOCCONS: ::c_ulong = 0x80047462;
-pub const TIOCSCTTY: ::c_uint = 0x20007461;
-pub const TIOCEXT: ::c_ulong = 0x80047460;
-pub const TIOCSIG: ::c_uint = 0x2000745f;
-pub const TIOCDRAIN: ::c_uint = 0x2000745e;
-pub const TIOCMSDTRWAIT: ::c_ulong = 0x8004745b;
-pub const TIOCMGDTRWAIT: ::c_ulong = 0x4004745a;
-pub const TIOCSDRAINWAIT: ::c_ulong = 0x80047457;
-pub const TIOCGDRAINWAIT: ::c_ulong = 0x40047456;
-pub const TIOCDSIMICROCODE: ::c_uint = 0x20007455;
-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;
-pub const B110: speed_t = 110;
-pub const B134: speed_t = 134;
-pub const B150: speed_t = 150;
-pub const B200: speed_t = 200;
-pub const B300: speed_t = 300;
-pub const B600: speed_t = 600;
-pub const B1200: speed_t = 1200;
-pub const B1800: speed_t = 1800;
-pub const B2400: speed_t = 2400;
-pub const B4800: speed_t = 4800;
-pub const B9600: speed_t = 9600;
-pub const B19200: speed_t = 19200;
-pub const B38400: speed_t = 38400;
-pub const B7200: speed_t = 7200;
-pub const B14400: speed_t = 14400;
-pub const B28800: speed_t = 28800;
-pub const B57600: speed_t = 57600;
-pub const B76800: speed_t = 76800;
-pub const B115200: speed_t = 115200;
-pub const B230400: speed_t = 230400;
-pub const EXTA: speed_t = 19200;
-pub const EXTB: speed_t = 38400;
-
-pub const SIGTRAP: ::c_int = 5;
-
-pub const GLOB_APPEND : ::c_int = 0x0001;
-pub const GLOB_DOOFFS : ::c_int = 0x0002;
-pub const GLOB_ERR : ::c_int = 0x0004;
-pub const GLOB_MARK : ::c_int = 0x0008;
-pub const GLOB_NOCHECK : ::c_int = 0x0010;
-pub const GLOB_NOSORT : ::c_int = 0x0020;
-pub const GLOB_NOESCAPE: ::c_int = 0x2000;
-
-pub const GLOB_NOSPACE : ::c_int = -1;
-pub const GLOB_ABORTED : ::c_int = -2;
-pub const GLOB_NOMATCH : ::c_int = -3;
-
-pub const POSIX_MADV_NORMAL: ::c_int = 0;
-pub const POSIX_MADV_RANDOM: ::c_int = 1;
-pub const POSIX_MADV_SEQUENTIAL: ::c_int = 2;
-pub const POSIX_MADV_WILLNEED: ::c_int = 3;
-pub const POSIX_MADV_DONTNEED: ::c_int = 4;
-
-pub const _SC_IOV_MAX: ::c_int = 56;
-pub const _SC_GETGR_R_SIZE_MAX: ::c_int = 70;
-pub const _SC_GETPW_R_SIZE_MAX: ::c_int = 71;
-pub const _SC_LOGIN_NAME_MAX: ::c_int = 73;
-pub const _SC_MQ_PRIO_MAX: ::c_int = 75;
-pub const _SC_THREAD_ATTR_STACKADDR: ::c_int = 82;
-pub const _SC_THREAD_ATTR_STACKSIZE: ::c_int = 83;
-pub const _SC_THREAD_DESTRUCTOR_ITERATIONS: ::c_int = 85;
-pub const _SC_THREAD_KEYS_MAX: ::c_int = 86;
-pub const _SC_THREAD_PRIO_INHERIT: ::c_int = 87;
-pub const _SC_THREAD_PRIO_PROTECT: ::c_int = 88;
-pub const _SC_THREAD_PRIORITY_SCHEDULING: ::c_int = 89;
-pub const _SC_THREAD_PROCESS_SHARED: ::c_int = 90;
-pub const _SC_THREAD_SAFE_FUNCTIONS: ::c_int = 91;
-pub const _SC_THREAD_STACK_MIN: ::c_int = 93;
-pub const _SC_THREAD_THREADS_MAX: ::c_int = 94;
-pub const _SC_THREADS: ::c_int = 96;
-pub const _SC_TTY_NAME_MAX: ::c_int = 101;
-pub const _SC_ATEXIT_MAX: ::c_int = 107;
-pub const _SC_XOPEN_CRYPT: ::c_int = 108;
-pub const _SC_XOPEN_ENH_I18N: ::c_int = 109;
-pub const _SC_XOPEN_LEGACY: ::c_int = 110;
-pub const _SC_XOPEN_REALTIME: ::c_int = 111;
-pub const _SC_XOPEN_REALTIME_THREADS: ::c_int = 112;
-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;
-pub const PTHREAD_CREATE_JOINABLE: ::c_int = 1;
-pub const PTHREAD_CREATE_DETACHED: ::c_int = 2;
-pub const PTHREAD_STACK_MIN: ::size_t = 8192;
-
-pub const RLIMIT_CPU: ::c_int = 0;
-pub const RLIMIT_FSIZE: ::c_int = 1;
-pub const RLIMIT_DATA: ::c_int = 2;
-pub const RLIMIT_STACK: ::c_int = 3;
-pub const RLIMIT_CORE: ::c_int = 4;
-pub const RLIMIT_AS: ::c_int = 5;
-pub const RLIMIT_RSS: ::c_int = RLIMIT_AS;
-pub const RLIMIT_MEMLOCK: ::c_int = 6;
-pub const RLIMIT_NPROC: ::c_int = 7;
-pub const RLIMIT_NOFILE: ::c_int = 8;
-pub const RLIM_NLIMITS: ::c_int = 9;
-pub const _RLIMIT_POSIX_FLAG: ::c_int = 0x1000;
-
-pub const RLIM_INFINITY: rlim_t = 0x7fff_ffff_ffff_ffff;
-
-pub const RUSAGE_SELF: ::c_int = 0;
-pub const RUSAGE_CHILDREN: ::c_int = -1;
-
-pub const MADV_NORMAL: ::c_int = 0;
-pub const MADV_RANDOM: ::c_int = 1;
-pub const MADV_SEQUENTIAL: ::c_int = 2;
-pub const MADV_WILLNEED: ::c_int = 3;
-pub const MADV_DONTNEED: ::c_int = 4;
-pub const MADV_FREE: ::c_int = 5;
-pub const MADV_ZERO_WIRED_PAGES: ::c_int = 6;
-pub const MADV_FREE_REUSABLE: ::c_int = 7;
-pub const MADV_FREE_REUSE: ::c_int = 8;
-pub const MADV_CAN_REUSE: ::c_int = 9;
-
-pub const MINCORE_INCORE: ::c_int = 0x1;
-pub const MINCORE_REFERENCED: ::c_int = 0x2;
-pub const MINCORE_MODIFIED: ::c_int = 0x4;
-pub const MINCORE_REFERENCED_OTHER: ::c_int = 0x8;
-pub const MINCORE_MODIFIED_OTHER: ::c_int = 0x10;
-
-//
-// sys/netinet/in.h
-// Protocols (RFC 1700)
-// NOTE: These are in addition to the constants defined in src/unix/mod.rs
-
-// IPPROTO_IP defined in src/unix/mod.rs
-/// IP6 hop-by-hop options
-pub const IPPROTO_HOPOPTS: ::c_int = 0;
-// IPPROTO_ICMP defined in src/unix/mod.rs
-/// group mgmt protocol
-pub const IPPROTO_IGMP: ::c_int = 2;
-/// gateway<sup>2</sup> (deprecated)
-pub const IPPROTO_GGP: ::c_int = 3;
-/// for compatibility
-pub const IPPROTO_IPIP: ::c_int = 4;
-// IPPROTO_TCP defined in src/unix/mod.rs
-/// Stream protocol II.
-pub const IPPROTO_ST: ::c_int = 7;
-/// exterior gateway protocol
-pub const IPPROTO_EGP: ::c_int = 8;
-/// private interior gateway
-pub const IPPROTO_PIGP: ::c_int = 9;
-/// BBN RCC Monitoring
-pub const IPPROTO_RCCMON: ::c_int = 10;
-/// network voice protocol
-pub const IPPROTO_NVPII: ::c_int = 11;
-/// pup
-pub const IPPROTO_PUP: ::c_int = 12;
-/// Argus
-pub const IPPROTO_ARGUS: ::c_int = 13;
-/// EMCON
-pub const IPPROTO_EMCON: ::c_int = 14;
-/// Cross Net Debugger
-pub const IPPROTO_XNET: ::c_int = 15;
-/// Chaos
-pub const IPPROTO_CHAOS: ::c_int = 16;
-// IPPROTO_UDP defined in src/unix/mod.rs
-/// Multiplexing
-pub const IPPROTO_MUX: ::c_int = 18;
-/// DCN Measurement Subsystems
-pub const IPPROTO_MEAS: ::c_int = 19;
-/// Host Monitoring
-pub const IPPROTO_HMP: ::c_int = 20;
-/// Packet Radio Measurement
-pub const IPPROTO_PRM: ::c_int = 21;
-/// xns idp
-pub const IPPROTO_IDP: ::c_int = 22;
-/// Trunk-1
-pub const IPPROTO_TRUNK1: ::c_int = 23;
-/// Trunk-2
-pub const IPPROTO_TRUNK2: ::c_int = 24;
-/// Leaf-1
-pub const IPPROTO_LEAF1: ::c_int = 25;
-/// Leaf-2
-pub const IPPROTO_LEAF2: ::c_int = 26;
-/// Reliable Data
-pub const IPPROTO_RDP: ::c_int = 27;
-/// Reliable Transaction
-pub const IPPROTO_IRTP: ::c_int = 28;
-/// tp-4 w/ class negotiation
-pub const IPPROTO_TP: ::c_int = 29;
-/// Bulk Data Transfer
-pub const IPPROTO_BLT: ::c_int = 30;
-/// Network Services
-pub const IPPROTO_NSP: ::c_int = 31;
-/// Merit Internodal
-pub const IPPROTO_INP: ::c_int = 32;
-/// Sequential Exchange
-pub const IPPROTO_SEP: ::c_int = 33;
-/// Third Party Connect
-pub const IPPROTO_3PC: ::c_int = 34;
-/// InterDomain Policy Routing
-pub const IPPROTO_IDPR: ::c_int = 35;
-/// XTP
-pub const IPPROTO_XTP: ::c_int = 36;
-/// Datagram Delivery
-pub const IPPROTO_DDP: ::c_int = 37;
-/// Control Message Transport
-pub const IPPROTO_CMTP: ::c_int = 38;
-/// TP++ Transport
-pub const IPPROTO_TPXX: ::c_int = 39;
-/// IL transport protocol
-pub const IPPROTO_IL: ::c_int = 40;
-// IPPROTO_IPV6 defined in src/unix/mod.rs
-/// Source Demand Routing
-pub const IPPROTO_SDRP: ::c_int = 42;
-/// IP6 routing header
-pub const IPPROTO_ROUTING: ::c_int = 43;
-/// IP6 fragmentation header
-pub const IPPROTO_FRAGMENT: ::c_int = 44;
-/// InterDomain Routing
-pub const IPPROTO_IDRP: ::c_int = 45;
-/// resource reservation
-pub const IPPROTO_RSVP: ::c_int = 46;
-/// General Routing Encap.
-pub const IPPROTO_GRE: ::c_int = 47;
-/// Mobile Host Routing
-pub const IPPROTO_MHRP: ::c_int = 48;
-/// BHA
-pub const IPPROTO_BHA: ::c_int = 49;
-/// IP6 Encap Sec. Payload
-pub const IPPROTO_ESP: ::c_int = 50;
-/// IP6 Auth Header
-pub const IPPROTO_AH: ::c_int = 51;
-/// Integ. Net Layer Security
-pub const IPPROTO_INLSP: ::c_int = 52;
-/// IP with encryption
-pub const IPPROTO_SWIPE: ::c_int = 53;
-/// Next Hop Resolution
-pub const IPPROTO_NHRP: ::c_int = 54;
-/* 55-57: Unassigned */
-// IPPROTO_ICMPV6 defined in src/unix/mod.rs
-/// IP6 no next header
-pub const IPPROTO_NONE: ::c_int = 59;
-/// IP6 destination option
-pub const IPPROTO_DSTOPTS: ::c_int = 60;
-/// any host internal protocol
-pub const IPPROTO_AHIP: ::c_int = 61;
-/// CFTP
-pub const IPPROTO_CFTP: ::c_int = 62;
-/// "hello" routing protocol
-pub const IPPROTO_HELLO: ::c_int = 63;
-/// SATNET/Backroom EXPAK
-pub const IPPROTO_SATEXPAK: ::c_int = 64;
-/// Kryptolan
-pub const IPPROTO_KRYPTOLAN: ::c_int = 65;
-/// Remote Virtual Disk
-pub const IPPROTO_RVD: ::c_int = 66;
-/// Pluribus Packet Core
-pub const IPPROTO_IPPC: ::c_int = 67;
-/// Any distributed FS
-pub const IPPROTO_ADFS: ::c_int = 68;
-/// Satnet Monitoring
-pub const IPPROTO_SATMON: ::c_int = 69;
-/// VISA Protocol
-pub const IPPROTO_VISA: ::c_int = 70;
-/// Packet Core Utility
-pub const IPPROTO_IPCV: ::c_int = 71;
-/// Comp. Prot. Net. Executive
-pub const IPPROTO_CPNX: ::c_int = 72;
-/// Comp. Prot. HeartBeat
-pub const IPPROTO_CPHB: ::c_int = 73;
-/// Wang Span Network
-pub const IPPROTO_WSN: ::c_int = 74;
-/// Packet Video Protocol
-pub const IPPROTO_PVP: ::c_int = 75;
-/// BackRoom SATNET Monitoring
-pub const IPPROTO_BRSATMON: ::c_int = 76;
-/// Sun net disk proto (temp.)
-pub const IPPROTO_ND: ::c_int = 77;
-/// WIDEBAND Monitoring
-pub const IPPROTO_WBMON: ::c_int = 78;
-/// WIDEBAND EXPAK
-pub const IPPROTO_WBEXPAK: ::c_int = 79;
-/// ISO cnlp
-pub const IPPROTO_EON: ::c_int = 80;
-/// VMTP
-pub const IPPROTO_VMTP: ::c_int = 81;
-/// Secure VMTP
-pub const IPPROTO_SVMTP: ::c_int = 82;
-/// Banyon VINES
-pub const IPPROTO_VINES: ::c_int = 83;
-/// TTP
-pub const IPPROTO_TTP: ::c_int = 84;
-/// NSFNET-IGP
-pub const IPPROTO_IGP: ::c_int = 85;
-/// dissimilar gateway prot.
-pub const IPPROTO_DGP: ::c_int = 86;
-/// TCF
-pub const IPPROTO_TCF: ::c_int = 87;
-/// Cisco/GXS IGRP
-pub const IPPROTO_IGRP: ::c_int = 88;
-/// OSPFIGP
-pub const IPPROTO_OSPFIGP: ::c_int = 89;
-/// Strite RPC protocol
-pub const IPPROTO_SRPC: ::c_int = 90;
-/// Locus Address Resoloution
-pub const IPPROTO_LARP: ::c_int = 91;
-/// Multicast Transport
-pub const IPPROTO_MTP: ::c_int = 92;
-/// AX.25 Frames
-pub const IPPROTO_AX25: ::c_int = 93;
-/// IP encapsulated in IP
-pub const IPPROTO_IPEIP: ::c_int = 94;
-/// Mobile Int.ing control
-pub const IPPROTO_MICP: ::c_int = 95;
-/// Semaphore Comm. security
-pub const IPPROTO_SCCSP: ::c_int = 96;
-/// Ethernet IP encapsulation
-pub const IPPROTO_ETHERIP: ::c_int = 97;
-/// encapsulation header
-pub const IPPROTO_ENCAP: ::c_int = 98;
-/// any private encr. scheme
-pub const IPPROTO_APES: ::c_int = 99;
-/// GMTP
-pub const IPPROTO_GMTP: ::c_int = 100;
-
-/* 101-254: Partly Unassigned */
-/// Protocol Independent Mcast
-pub const IPPROTO_PIM: ::c_int = 103;
-/// payload compression (IPComp)
-pub const IPPROTO_IPCOMP: ::c_int = 108;
-/// PGM
-pub const IPPROTO_PGM: ::c_int = 113;
-/// SCTP
-pub const IPPROTO_SCTP: ::c_int = 132;
-
-/* 255: Reserved */
-/* BSD Private, local use, namespace incursion */
-/// divert pseudo-protocol
-pub const IPPROTO_DIVERT: ::c_int = 254;
-/// raw IP packet
-pub const IPPROTO_RAW: ::c_int = 255;
-pub const IPPROTO_MAX: ::c_int = 256;
-/// last return value of *_input(), meaning "all job for this pkt is done".
-pub const IPPROTO_DONE: ::c_int = 257;
-
-pub const AF_UNSPEC: ::c_int = 0;
-pub const AF_LOCAL: ::c_int = 1;
-pub const AF_UNIX: ::c_int = AF_LOCAL;
-pub const AF_INET: ::c_int = 2;
-pub const AF_IMPLINK: ::c_int = 3;
-pub const AF_PUP: ::c_int = 4;
-pub const AF_CHAOS: ::c_int = 5;
-pub const AF_NS: ::c_int = 6;
-pub const AF_ISO: ::c_int = 7;
-pub const AF_OSI: ::c_int = AF_ISO;
-pub const AF_ECMA: ::c_int = 8;
-pub const AF_DATAKIT: ::c_int = 9;
-pub const AF_CCITT: ::c_int = 10;
-pub const AF_SNA: ::c_int = 11;
-pub const AF_DECnet: ::c_int = 12;
-pub const AF_DLI: ::c_int = 13;
-pub const AF_LAT: ::c_int = 14;
-pub const AF_HYLINK: ::c_int = 15;
-pub const AF_APPLETALK: ::c_int = 16;
-pub const AF_ROUTE: ::c_int = 17;
-pub const AF_LINK: ::c_int = 18;
-pub const pseudo_AF_XTP: ::c_int = 19;
-pub const AF_COIP: ::c_int = 20;
-pub const AF_CNT: ::c_int = 21;
-pub const pseudo_AF_RTIP: ::c_int = 22;
-pub const AF_IPX: ::c_int = 23;
-pub const AF_SIP: ::c_int = 24;
-pub const pseudo_AF_PIP: ::c_int = 25;
-pub const AF_ISDN: ::c_int = 28;
-pub const AF_E164: ::c_int = AF_ISDN;
-pub const pseudo_AF_KEY: ::c_int = 29;
-pub const AF_INET6: ::c_int = 30;
-pub const AF_NATM: ::c_int = 31;
-pub const AF_SYSTEM: ::c_int = 32;
-pub const AF_NETBIOS: ::c_int = 33;
-pub const AF_PPP: ::c_int = 34;
-pub const pseudo_AF_HDRCMPLT: ::c_int = 35;
-#[doc(hidden)]
-#[deprecated(
- since = "0.2.55",
- note = "If you are using this report to: \
- https://github.com/rust-lang/libc/issues/665"
-)]
-pub const AF_MAX: ::c_int = 40;
-pub const AF_SYS_CONTROL: ::c_int = 2;
-
-pub const SYSPROTO_EVENT: ::c_int = 1;
-pub const SYSPROTO_CONTROL: ::c_int = 2;
-
-pub const PF_UNSPEC: ::c_int = AF_UNSPEC;
-pub const PF_LOCAL: ::c_int = AF_LOCAL;
-pub const PF_UNIX: ::c_int = PF_LOCAL;
-pub const PF_INET: ::c_int = AF_INET;
-pub const PF_IMPLINK: ::c_int = AF_IMPLINK;
-pub const PF_PUP: ::c_int = AF_PUP;
-pub const PF_CHAOS: ::c_int = AF_CHAOS;
-pub const PF_NS: ::c_int = AF_NS;
-pub const PF_ISO: ::c_int = AF_ISO;
-pub const PF_OSI: ::c_int = AF_ISO;
-pub const PF_ECMA: ::c_int = AF_ECMA;
-pub const PF_DATAKIT: ::c_int = AF_DATAKIT;
-pub const PF_CCITT: ::c_int = AF_CCITT;
-pub const PF_SNA: ::c_int = AF_SNA;
-pub const PF_DECnet: ::c_int = AF_DECnet;
-pub const PF_DLI: ::c_int = AF_DLI;
-pub const PF_LAT: ::c_int = AF_LAT;
-pub const PF_HYLINK: ::c_int = AF_HYLINK;
-pub const PF_APPLETALK: ::c_int = AF_APPLETALK;
-pub const PF_ROUTE: ::c_int = AF_ROUTE;
-pub const PF_LINK: ::c_int = AF_LINK;
-pub const PF_XTP: ::c_int = pseudo_AF_XTP;
-pub const PF_COIP: ::c_int = AF_COIP;
-pub const PF_CNT: ::c_int = AF_CNT;
-pub const PF_SIP: ::c_int = AF_SIP;
-pub const PF_IPX: ::c_int = AF_IPX;
-pub const PF_RTIP: ::c_int = pseudo_AF_RTIP;
-pub const PF_PIP: ::c_int = pseudo_AF_PIP;
-pub const PF_ISDN: ::c_int = AF_ISDN;
-pub const PF_KEY: ::c_int = pseudo_AF_KEY;
-pub const PF_INET6: ::c_int = AF_INET6;
-pub const PF_NATM: ::c_int = AF_NATM;
-pub const PF_SYSTEM: ::c_int = AF_SYSTEM;
-pub const PF_NETBIOS: ::c_int = AF_NETBIOS;
-pub const PF_PPP: ::c_int = AF_PPP;
-#[doc(hidden)]
-#[deprecated(
- since = "0.2.55",
- note = "If you are using this report to: \
- https://github.com/rust-lang/libc/issues/665"
-)]
-#[allow(deprecated)]
-pub const PF_MAX: ::c_int = AF_MAX;
-
-#[doc(hidden)]
-#[deprecated(
- since = "0.2.55",
- note = "If you are using this report to: \
- https://github.com/rust-lang/libc/issues/665"
-)]
-#[allow(deprecated)]
-pub const NET_MAXID: ::c_int = AF_MAX;
-
-pub const NET_RT_DUMP: ::c_int = 1;
-pub const NET_RT_FLAGS: ::c_int = 2;
-pub const NET_RT_IFLIST: ::c_int = 3;
-#[doc(hidden)]
-#[deprecated(since = "0.2.55")]
-pub const NET_RT_MAXID: ::c_int = 10;
-
-pub const SOMAXCONN: ::c_int = 128;
-
-pub const SOCK_MAXADDRLEN: ::c_int = 255;
-
-pub const SOCK_STREAM: ::c_int = 1;
-pub const SOCK_DGRAM: ::c_int = 2;
-pub const SOCK_RAW: ::c_int = 3;
-pub const SOCK_RDM: ::c_int = 4;
-pub const SOCK_SEQPACKET: ::c_int = 5;
-pub const IP_TTL: ::c_int = 4;
-pub const IP_HDRINCL: ::c_int = 2;
-pub const IP_RECVDSTADDR: ::c_int = 7;
-pub const IP_ADD_MEMBERSHIP: ::c_int = 12;
-pub const IP_DROP_MEMBERSHIP: ::c_int = 13;
-pub const IP_RECVIF: ::c_int = 20;
-pub const IP_PKTINFO: ::c_int = 26;
-pub const IP_RECVTOS: ::c_int = 27;
-pub const IPV6_JOIN_GROUP: ::c_int = 12;
-pub const IPV6_LEAVE_GROUP: ::c_int = 13;
-pub const IPV6_RECVTCLASS: ::c_int = 35;
-pub const IPV6_TCLASS: ::c_int = 36;
-pub const IPV6_PKTINFO: ::c_int = 46;
-pub const IPV6_RECVPKTINFO: ::c_int = 61;
-
-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;
-
-pub const LOCAL_PEERCRED: ::c_int = 0x001;
-pub const LOCAL_PEERPID: ::c_int = 0x002;
-pub const LOCAL_PEEREPID: ::c_int = 0x003;
-pub const LOCAL_PEERUUID: ::c_int = 0x004;
-pub const LOCAL_PEEREUUID: ::c_int = 0x005;
-
-pub const SOL_SOCKET: ::c_int = 0xffff;
-
-pub const SO_DEBUG: ::c_int = 0x01;
-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_TIMESTAMP: ::c_int = 0x0400;
-pub const SO_TIMESTAMP_MONOTONIC: ::c_int = 0x0800;
-pub const SO_DONTTRUNC: ::c_int = 0x2000;
-pub const SO_WANTMORE: ::c_int = 0x4000;
-pub const SO_WANTOOBFLAG: ::c_int = 0x8000;
-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_LABEL: ::c_int = 0x1010;
-pub const SO_PEERLABEL: ::c_int = 0x1011;
-pub const SO_NREAD: ::c_int = 0x1020;
-pub const SO_NKE: ::c_int = 0x1021;
-pub const SO_NOSIGPIPE: ::c_int = 0x1022;
-pub const SO_NOADDRERR: ::c_int = 0x1023;
-pub const SO_NWRITE: ::c_int = 0x1024;
-pub const SO_REUSESHAREUID: ::c_int = 0x1025;
-pub const SO_NOTIFYCONFLICT: ::c_int = 0x1026;
-pub const SO_RANDOMPORT: ::c_int = 0x1082;
-pub const SO_NP_EXTENSIONS: ::c_int = 0x1083;
-
-pub const MSG_OOB: ::c_int = 0x1;
-pub const MSG_PEEK: ::c_int = 0x2;
-pub const MSG_DONTROUTE: ::c_int = 0x4;
-pub const MSG_EOR: ::c_int = 0x8;
-pub const MSG_TRUNC: ::c_int = 0x10;
-pub const MSG_CTRUNC: ::c_int = 0x20;
-pub const MSG_WAITALL: ::c_int = 0x40;
-pub const MSG_DONTWAIT: ::c_int = 0x80;
-pub const MSG_EOF: ::c_int = 0x100;
-pub const MSG_FLUSH: ::c_int = 0x400;
-pub const MSG_HOLD: ::c_int = 0x800;
-pub const MSG_SEND: ::c_int = 0x1000;
-pub const MSG_HAVEMORE: ::c_int = 0x2000;
-pub const MSG_RCVMORE: ::c_int = 0x4000;
-// pub const MSG_COMPAT: ::c_int = 0x8000;
-
-pub const SCM_TIMESTAMP: ::c_int = 0x02;
-pub const SCM_CREDS: ::c_int = 0x03;
-
-// https://github.com/aosm/xnu/blob/master/bsd/net/if.h#L140-L156
-pub const IFF_UP: ::c_int = 0x1; // interface is up
-pub const IFF_BROADCAST: ::c_int = 0x2; // broadcast address valid
-pub const IFF_DEBUG: ::c_int = 0x4; // turn on debugging
-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; // obsolete: 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_ALTPHYS: ::c_int = IFF_LINK2;// use alternate physical connection
-pub const IFF_MULTICAST: ::c_int = 0x8000;// supports multicast
-
-pub const SHUT_RD: ::c_int = 0;
-pub const SHUT_WR: ::c_int = 1;
-pub const SHUT_RDWR: ::c_int = 2;
-
-pub const LOCK_SH: ::c_int = 1;
-pub const LOCK_EX: ::c_int = 2;
-pub const LOCK_NB: ::c_int = 4;
-pub const LOCK_UN: ::c_int = 8;
-
-pub const MAP_COPY: ::c_int = 0x0002;
-pub const MAP_RENAME: ::c_int = 0x0020;
-pub const MAP_NORESERVE: ::c_int = 0x0040;
-pub const MAP_NOEXTEND: ::c_int = 0x0100;
-pub const MAP_HASSEMAPHORE: ::c_int = 0x0200;
-pub const MAP_NOCACHE: ::c_int = 0x0400;
-pub const MAP_JIT: ::c_int = 0x0800;
-
-pub const _SC_ARG_MAX: ::c_int = 1;
-pub const _SC_CHILD_MAX: ::c_int = 2;
-pub const _SC_CLK_TCK: ::c_int = 3;
-pub const _SC_NGROUPS_MAX: ::c_int = 4;
-pub const _SC_OPEN_MAX: ::c_int = 5;
-pub const _SC_JOB_CONTROL: ::c_int = 6;
-pub const _SC_SAVED_IDS: ::c_int = 7;
-pub const _SC_VERSION: ::c_int = 8;
-pub const _SC_BC_BASE_MAX: ::c_int = 9;
-pub const _SC_BC_DIM_MAX: ::c_int = 10;
-pub const _SC_BC_SCALE_MAX: ::c_int = 11;
-pub const _SC_BC_STRING_MAX: ::c_int = 12;
-pub const _SC_COLL_WEIGHTS_MAX: ::c_int = 13;
-pub const _SC_EXPR_NEST_MAX: ::c_int = 14;
-pub const _SC_LINE_MAX: ::c_int = 15;
-pub const _SC_RE_DUP_MAX: ::c_int = 16;
-pub const _SC_2_VERSION: ::c_int = 17;
-pub const _SC_2_C_BIND: ::c_int = 18;
-pub const _SC_2_C_DEV: ::c_int = 19;
-pub const _SC_2_CHAR_TERM: ::c_int = 20;
-pub const _SC_2_FORT_DEV: ::c_int = 21;
-pub const _SC_2_FORT_RUN: ::c_int = 22;
-pub const _SC_2_LOCALEDEF: ::c_int = 23;
-pub const _SC_2_SW_DEV: ::c_int = 24;
-pub const _SC_2_UPE: ::c_int = 25;
-pub const _SC_STREAM_MAX: ::c_int = 26;
-pub const _SC_TZNAME_MAX: ::c_int = 27;
-pub const _SC_ASYNCHRONOUS_IO: ::c_int = 28;
-pub const _SC_PAGESIZE: ::c_int = 29;
-pub const _SC_MEMLOCK: ::c_int = 30;
-pub const _SC_MEMLOCK_RANGE: ::c_int = 31;
-pub const _SC_MEMORY_PROTECTION: ::c_int = 32;
-pub const _SC_MESSAGE_PASSING: ::c_int = 33;
-pub const _SC_PRIORITIZED_IO: ::c_int = 34;
-pub const _SC_PRIORITY_SCHEDULING: ::c_int = 35;
-pub const _SC_REALTIME_SIGNALS: ::c_int = 36;
-pub const _SC_SEMAPHORES: ::c_int = 37;
-pub const _SC_FSYNC: ::c_int = 38;
-pub const _SC_SHARED_MEMORY_OBJECTS: ::c_int = 39;
-pub const _SC_SYNCHRONIZED_IO: ::c_int = 40;
-pub const _SC_TIMERS: ::c_int = 41;
-pub const _SC_AIO_LISTIO_MAX: ::c_int = 42;
-pub const _SC_AIO_MAX: ::c_int = 43;
-pub const _SC_AIO_PRIO_DELTA_MAX: ::c_int = 44;
-pub const _SC_DELAYTIMER_MAX: ::c_int = 45;
-pub const _SC_MQ_OPEN_MAX: ::c_int = 46;
-pub const _SC_MAPPED_FILES: ::c_int = 47;
-pub const _SC_RTSIG_MAX: ::c_int = 48;
-pub const _SC_SEM_NSEMS_MAX: ::c_int = 49;
-pub const _SC_SEM_VALUE_MAX: ::c_int = 50;
-pub const _SC_SIGQUEUE_MAX: ::c_int = 51;
-pub const _SC_TIMER_MAX: ::c_int = 52;
-pub const _SC_NPROCESSORS_CONF: ::c_int = 57;
-pub const _SC_NPROCESSORS_ONLN: ::c_int = 58;
-pub const _SC_2_PBS: ::c_int = 59;
-pub const _SC_2_PBS_ACCOUNTING: ::c_int = 60;
-pub const _SC_2_PBS_CHECKPOINT: ::c_int = 61;
-pub const _SC_2_PBS_LOCATE: ::c_int = 62;
-pub const _SC_2_PBS_MESSAGE: ::c_int = 63;
-pub const _SC_2_PBS_TRACK: ::c_int = 64;
-pub const _SC_ADVISORY_INFO: ::c_int = 65;
-pub const _SC_BARRIERS: ::c_int = 66;
-pub const _SC_CLOCK_SELECTION: ::c_int = 67;
-pub const _SC_CPUTIME: ::c_int = 68;
-pub const _SC_FILE_LOCKING: ::c_int = 69;
-pub const _SC_HOST_NAME_MAX: ::c_int = 72;
-pub const _SC_MONOTONIC_CLOCK: ::c_int = 74;
-pub const _SC_READER_WRITER_LOCKS: ::c_int = 76;
-pub const _SC_REGEXP: ::c_int = 77;
-pub const _SC_SHELL: ::c_int = 78;
-pub const _SC_SPAWN: ::c_int = 79;
-pub const _SC_SPIN_LOCKS: ::c_int = 80;
-pub const _SC_SPORADIC_SERVER: ::c_int = 81;
-pub const _SC_THREAD_CPUTIME: ::c_int = 84;
-pub const _SC_THREAD_SPORADIC_SERVER: ::c_int = 92;
-pub const _SC_TIMEOUTS: ::c_int = 95;
-pub const _SC_TRACE: ::c_int = 97;
-pub const _SC_TRACE_EVENT_FILTER: ::c_int = 98;
-pub const _SC_TRACE_INHERIT: ::c_int = 99;
-pub const _SC_TRACE_LOG: ::c_int = 100;
-pub const _SC_TYPED_MEMORY_OBJECTS: ::c_int = 102;
-pub const _SC_V6_ILP32_OFF32: ::c_int = 103;
-pub const _SC_V6_ILP32_OFFBIG: ::c_int = 104;
-pub const _SC_V6_LP64_OFF64: ::c_int = 105;
-pub const _SC_V6_LPBIG_OFFBIG: ::c_int = 106;
-pub const _SC_IPV6: ::c_int = 118;
-pub const _SC_RAW_SOCKETS: ::c_int = 119;
-pub const _SC_SYMLOOP_MAX: ::c_int = 120;
-pub const _SC_PAGE_SIZE: ::c_int = _SC_PAGESIZE;
-pub const _SC_XOPEN_STREAMS: ::c_int = 114;
-pub const _SC_XBS5_ILP32_OFF32: ::c_int = 122;
-pub const _SC_XBS5_ILP32_OFFBIG: ::c_int = 123;
-pub const _SC_XBS5_LP64_OFF64: ::c_int = 124;
-pub const _SC_XBS5_LPBIG_OFFBIG: ::c_int = 125;
-pub const _SC_SS_REPL_MAX: ::c_int = 126;
-pub const _SC_TRACE_EVENT_NAME_MAX: ::c_int = 127;
-pub const _SC_TRACE_NAME_MAX: ::c_int = 128;
-pub const _SC_TRACE_SYS_MAX: ::c_int = 129;
-pub const _SC_TRACE_USER_EVENT_MAX: ::c_int = 130;
-pub const _SC_PASS_MAX: ::c_int = 131;
-
-pub const PTHREAD_MUTEX_NORMAL: ::c_int = 0;
-pub const PTHREAD_MUTEX_ERRORCHECK: ::c_int = 1;
-pub const PTHREAD_MUTEX_RECURSIVE: ::c_int = 2;
-pub const PTHREAD_MUTEX_DEFAULT: ::c_int = PTHREAD_MUTEX_NORMAL;
-pub const _PTHREAD_MUTEX_SIG_init: ::c_long = 0x32AAABA7;
-pub const _PTHREAD_COND_SIG_init: ::c_long = 0x3CB0B1BB;
-pub const _PTHREAD_RWLOCK_SIG_init: ::c_long = 0x2DA8B3B4;
-pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t {
- __sig: _PTHREAD_MUTEX_SIG_init,
- __opaque: [0; __PTHREAD_MUTEX_SIZE__],
-};
-pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = pthread_cond_t {
- __sig: _PTHREAD_COND_SIG_init,
- __opaque: [0; __PTHREAD_COND_SIZE__],
-};
-pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = pthread_rwlock_t {
- __sig: _PTHREAD_RWLOCK_SIG_init,
- __opaque: [0; __PTHREAD_RWLOCK_SIZE__],
-};
-
-pub const SIGSTKSZ: ::size_t = 131072;
-
-pub const FD_SETSIZE: usize = 1024;
-
-pub const ST_NOSUID: ::c_ulong = 2;
-
-pub const EVFILT_READ: i16 = -1;
-pub const EVFILT_WRITE: i16 = -2;
-pub const EVFILT_AIO: i16 = -3;
-pub const EVFILT_VNODE: i16 = -4;
-pub const EVFILT_PROC: i16 = -5;
-pub const EVFILT_SIGNAL: i16 = -6;
-pub const EVFILT_TIMER: i16 = -7;
-pub const EVFILT_MACHPORT: i16 = -8;
-pub const EVFILT_FS: i16 = -9;
-pub const EVFILT_USER: i16 = -10;
-pub const EVFILT_VM: i16 = -12;
-
-pub const EV_ADD: u16 = 0x1;
-pub const EV_DELETE: u16 = 0x2;
-pub const EV_ENABLE: u16 = 0x4;
-pub const EV_DISABLE: u16 = 0x8;
-pub const EV_ONESHOT: u16 = 0x10;
-pub const EV_CLEAR: u16 = 0x20;
-pub const EV_RECEIPT: u16 = 0x40;
-pub const EV_DISPATCH: u16 = 0x80;
-pub const EV_FLAG0: u16 = 0x1000;
-pub const EV_POLL: u16 = 0x1000;
-pub const EV_FLAG1: u16 = 0x2000;
-pub const EV_OOBAND: u16 = 0x2000;
-pub const EV_ERROR: u16 = 0x4000;
-pub const EV_EOF: u16 = 0x8000;
-pub const EV_SYSFLAGS: u16 = 0xf000;
-
-pub const NOTE_TRIGGER: u32 = 0x01000000;
-pub const NOTE_FFNOP: u32 = 0x00000000;
-pub const NOTE_FFAND: u32 = 0x40000000;
-pub const NOTE_FFOR: u32 = 0x80000000;
-pub const NOTE_FFCOPY: u32 = 0xc0000000;
-pub const NOTE_FFCTRLMASK: u32 = 0xc0000000;
-pub const NOTE_FFLAGSMASK: u32 = 0x00ffffff;
-pub const NOTE_LOWAT: u32 = 0x00000001;
-pub const NOTE_DELETE: u32 = 0x00000001;
-pub const NOTE_WRITE: u32 = 0x00000002;
-pub const NOTE_EXTEND: u32 = 0x00000004;
-pub const NOTE_ATTRIB: u32 = 0x00000008;
-pub const NOTE_LINK: u32 = 0x00000010;
-pub const NOTE_RENAME: u32 = 0x00000020;
-pub const NOTE_REVOKE: u32 = 0x00000040;
-pub const NOTE_NONE: u32 = 0x00000080;
-pub const NOTE_EXIT: u32 = 0x80000000;
-pub const NOTE_FORK: u32 = 0x40000000;
-pub const NOTE_EXEC: u32 = 0x20000000;
-#[doc(hidden)]
-#[deprecated(since="0.2.49", note="Deprecated since MacOSX 10.9")]
-pub const NOTE_REAP: u32 = 0x10000000;
-pub const NOTE_SIGNAL: u32 = 0x08000000;
-pub const NOTE_EXITSTATUS: u32 = 0x04000000;
-pub const NOTE_EXIT_DETAIL: u32 = 0x02000000;
-pub const NOTE_PDATAMASK: u32 = 0x000fffff;
-pub const NOTE_PCTRLMASK: u32 = 0xfff00000;
-#[doc(hidden)]
-#[deprecated(since="0.2.49", note="Deprecated since MacOSX 10.9")]
-pub const NOTE_EXIT_REPARENTED: u32 = 0x00080000;
-pub const NOTE_EXIT_DETAIL_MASK: u32 = 0x00070000;
-pub const NOTE_EXIT_DECRYPTFAIL: u32 = 0x00010000;
-pub const NOTE_EXIT_MEMORY: u32 = 0x00020000;
-pub const NOTE_EXIT_CSERROR: u32 = 0x00040000;
-pub const NOTE_VM_PRESSURE: u32 = 0x80000000;
-pub const NOTE_VM_PRESSURE_TERMINATE: u32 = 0x40000000;
-pub const NOTE_VM_PRESSURE_SUDDEN_TERMINATE: u32 = 0x20000000;
-pub const NOTE_VM_ERROR: u32 = 0x10000000;
-pub const NOTE_SECONDS: u32 = 0x00000001;
-pub const NOTE_USECONDS: u32 = 0x00000002;
-pub const NOTE_NSECONDS: u32 = 0x00000004;
-pub const NOTE_ABSOLUTE: u32 = 0x00000008;
-pub const NOTE_LEEWAY: u32 = 0x00000010;
-pub const NOTE_CRITICAL: u32 = 0x00000020;
-pub const NOTE_BACKGROUND: u32 = 0x00000040;
-pub const NOTE_TRACK: u32 = 0x00000001;
-pub const NOTE_TRACKERR: u32 = 0x00000002;
-pub const NOTE_CHILD: u32 = 0x00000004;
-
-pub const OCRNL: ::tcflag_t = 0x00000010;
-pub const ONOCR: ::tcflag_t = 0x00000020;
-pub const ONLRET: ::tcflag_t = 0x00000040;
-pub const OFILL: ::tcflag_t = 0x00000080;
-pub const NLDLY: ::tcflag_t = 0x00000300;
-pub const TABDLY: ::tcflag_t = 0x00000c04;
-pub const CRDLY: ::tcflag_t = 0x00003000;
-pub const FFDLY: ::tcflag_t = 0x00004000;
-pub const BSDLY: ::tcflag_t = 0x00008000;
-pub const VTDLY: ::tcflag_t = 0x00010000;
-pub const OFDEL: ::tcflag_t = 0x00020000;
-
-pub const NL0: ::tcflag_t = 0x00000000;
-pub const NL1: ::tcflag_t = 0x00000100;
-pub const TAB0: ::tcflag_t = 0x00000000;
-pub const TAB1: ::tcflag_t = 0x00000400;
-pub const TAB2: ::tcflag_t = 0x00000800;
-pub const CR0: ::tcflag_t = 0x00000000;
-pub const CR1: ::tcflag_t = 0x00001000;
-pub const CR2: ::tcflag_t = 0x00002000;
-pub const CR3: ::tcflag_t = 0x00003000;
-pub const FF0: ::tcflag_t = 0x00000000;
-pub const FF1: ::tcflag_t = 0x00004000;
-pub const BS0: ::tcflag_t = 0x00000000;
-pub const BS1: ::tcflag_t = 0x00008000;
-pub const TAB3: ::tcflag_t = 0x00000004;
-pub const VT0: ::tcflag_t = 0x00000000;
-pub const VT1: ::tcflag_t = 0x00010000;
-pub const IUTF8: ::tcflag_t = 0x00004000;
-pub const CRTSCTS: ::tcflag_t = 0x00030000;
-
-pub const NI_MAXHOST: ::socklen_t = 1025;
-pub const NI_MAXSERV: ::socklen_t = 32;
-pub const NI_NOFQDN: ::c_int = 0x00000001;
-pub const NI_NUMERICHOST: ::c_int = 0x00000002;
-pub const NI_NAMEREQD: ::c_int = 0x00000004;
-pub const NI_NUMERICSERV: ::c_int = 0x00000008;
-pub const NI_NUMERICSCOPE: ::c_int = 0x00000100;
-pub const NI_DGRAM: ::c_int = 0x00000010;
-
-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;
-pub const RTLD_NOLOAD: ::c_int = 0x10;
-pub const RTLD_GLOBAL: ::c_int = 0x8;
-
-pub const _WSTOPPED: ::c_int = 0o177;
-
-pub const LOG_NETINFO: ::c_int = 12 << 3;
-pub const LOG_REMOTEAUTH: ::c_int = 13 << 3;
-pub const LOG_INSTALL: ::c_int = 14 << 3;
-pub const LOG_RAS: ::c_int = 15 << 3;
-pub const LOG_LAUNCHD: ::c_int = 24 << 3;
-pub const LOG_NFACILITIES: ::c_int = 25;
-
-pub const CTLTYPE: ::c_int = 0xf;
-pub const CTLTYPE_NODE: ::c_int = 1;
-pub const CTLTYPE_INT: ::c_int = 2;
-pub const CTLTYPE_STRING: ::c_int = 3;
-pub const CTLTYPE_QUAD: ::c_int = 4;
-pub const CTLTYPE_OPAQUE: ::c_int = 5;
-pub const CTLTYPE_STRUCT: ::c_int = CTLTYPE_OPAQUE;
-pub const CTLFLAG_RD: ::c_int = 0x80000000;
-pub const CTLFLAG_WR: ::c_int = 0x40000000;
-pub const CTLFLAG_RW: ::c_int = CTLFLAG_RD | CTLFLAG_WR;
-pub const CTLFLAG_NOLOCK: ::c_int = 0x20000000;
-pub const CTLFLAG_ANYBODY: ::c_int = 0x10000000;
-pub const CTLFLAG_SECURE: ::c_int = 0x08000000;
-pub const CTLFLAG_MASKED: ::c_int = 0x04000000;
-pub const CTLFLAG_NOAUTO: ::c_int = 0x02000000;
-pub const CTLFLAG_KERN: ::c_int = 0x01000000;
-pub const CTLFLAG_LOCKED: ::c_int = 0x00800000;
-pub const CTLFLAG_OID2: ::c_int = 0x00400000;
-pub const CTL_UNSPEC: ::c_int = 0;
-pub const CTL_KERN: ::c_int = 1;
-pub const CTL_VM: ::c_int = 2;
-pub const CTL_VFS: ::c_int = 3;
-pub const CTL_NET: ::c_int = 4;
-pub const CTL_DEBUG: ::c_int = 5;
-pub const CTL_HW: ::c_int = 6;
-pub const CTL_MACHDEP: ::c_int = 7;
-pub const CTL_USER: ::c_int = 8;
-pub const CTL_MAXID: ::c_int = 9;
-pub const KERN_OSTYPE: ::c_int = 1;
-pub const KERN_OSRELEASE: ::c_int = 2;
-pub const KERN_OSREV: ::c_int = 3;
-pub const KERN_VERSION: ::c_int = 4;
-pub const KERN_MAXVNODES: ::c_int = 5;
-pub const KERN_MAXPROC: ::c_int = 6;
-pub const KERN_MAXFILES: ::c_int = 7;
-pub const KERN_ARGMAX: ::c_int = 8;
-pub const KERN_SECURELVL: ::c_int = 9;
-pub const KERN_HOSTNAME: ::c_int = 10;
-pub const KERN_HOSTID: ::c_int = 11;
-pub const KERN_CLOCKRATE: ::c_int = 12;
-pub const KERN_VNODE: ::c_int = 13;
-pub const KERN_PROC: ::c_int = 14;
-pub const KERN_FILE: ::c_int = 15;
-pub const KERN_PROF: ::c_int = 16;
-pub const KERN_POSIX1: ::c_int = 17;
-pub const KERN_NGROUPS: ::c_int = 18;
-pub const KERN_JOB_CONTROL: ::c_int = 19;
-pub const KERN_SAVED_IDS: ::c_int = 20;
-pub const KERN_BOOTTIME: ::c_int = 21;
-pub const KERN_NISDOMAINNAME: ::c_int = 22;
-pub const KERN_DOMAINNAME: ::c_int = KERN_NISDOMAINNAME;
-pub const KERN_MAXPARTITIONS: ::c_int = 23;
-pub const KERN_KDEBUG: ::c_int = 24;
-pub const KERN_UPDATEINTERVAL: ::c_int = 25;
-pub const KERN_OSRELDATE: ::c_int = 26;
-pub const KERN_NTP_PLL: ::c_int = 27;
-pub const KERN_BOOTFILE: ::c_int = 28;
-pub const KERN_MAXFILESPERPROC: ::c_int = 29;
-pub const KERN_MAXPROCPERUID: ::c_int = 30;
-pub const KERN_DUMPDEV: ::c_int = 31;
-pub const KERN_IPC: ::c_int = 32;
-pub const KERN_DUMMY: ::c_int = 33;
-pub const KERN_PS_STRINGS: ::c_int = 34;
-pub const KERN_USRSTACK32: ::c_int = 35;
-pub const KERN_LOGSIGEXIT: ::c_int = 36;
-pub const KERN_SYMFILE: ::c_int = 37;
-pub const KERN_PROCARGS: ::c_int = 38;
-pub const KERN_NETBOOT: ::c_int = 40;
-pub const KERN_SYSV: ::c_int = 42;
-pub const KERN_AFFINITY: ::c_int = 43;
-pub const KERN_TRANSLATE: ::c_int = 44;
-pub const KERN_CLASSIC: ::c_int = KERN_TRANSLATE;
-pub const KERN_EXEC: ::c_int = 45;
-pub const KERN_CLASSICHANDLER: ::c_int = KERN_EXEC;
-pub const KERN_AIOMAX: ::c_int = 46;
-pub const KERN_AIOPROCMAX: ::c_int = 47;
-pub const KERN_AIOTHREADS: ::c_int = 48;
-pub const KERN_COREFILE: ::c_int = 50;
-pub const KERN_COREDUMP: ::c_int = 51;
-pub const KERN_SUGID_COREDUMP: ::c_int = 52;
-pub const KERN_PROCDELAYTERM: ::c_int = 53;
-pub const KERN_SHREG_PRIVATIZABLE: ::c_int = 54;
-pub const KERN_LOW_PRI_WINDOW: ::c_int = 56;
-pub const KERN_LOW_PRI_DELAY: ::c_int = 57;
-pub const KERN_POSIX: ::c_int = 58;
-pub const KERN_USRSTACK64: ::c_int = 59;
-pub const KERN_NX_PROTECTION: ::c_int = 60;
-pub const KERN_TFP: ::c_int = 61;
-pub const KERN_PROCNAME: ::c_int = 62;
-pub const KERN_THALTSTACK: ::c_int = 63;
-pub const KERN_SPECULATIVE_READS: ::c_int = 64;
-pub const KERN_OSVERSION: ::c_int = 65;
-pub const KERN_SAFEBOOT: ::c_int = 66;
-pub const KERN_RAGEVNODE: ::c_int = 68;
-pub const KERN_TTY: ::c_int = 69;
-pub const KERN_CHECKOPENEVT: ::c_int = 70;
-pub const KERN_THREADNAME: ::c_int = 71;
-pub const KERN_MAXID: ::c_int = 72;
-pub const KERN_RAGE_PROC: ::c_int = 1;
-pub const KERN_RAGE_THREAD: ::c_int = 2;
-pub const KERN_UNRAGE_PROC: ::c_int = 3;
-pub const KERN_UNRAGE_THREAD: ::c_int = 4;
-pub const KERN_OPENEVT_PROC: ::c_int = 1;
-pub const KERN_UNOPENEVT_PROC: ::c_int = 2;
-pub const KERN_TFP_POLICY: ::c_int = 1;
-pub const KERN_TFP_POLICY_DENY: ::c_int = 0;
-pub const KERN_TFP_POLICY_DEFAULT: ::c_int = 2;
-pub const KERN_KDEFLAGS: ::c_int = 1;
-pub const KERN_KDDFLAGS: ::c_int = 2;
-pub const KERN_KDENABLE: ::c_int = 3;
-pub const KERN_KDSETBUF: ::c_int = 4;
-pub const KERN_KDGETBUF: ::c_int = 5;
-pub const KERN_KDSETUP: ::c_int = 6;
-pub const KERN_KDREMOVE: ::c_int = 7;
-pub const KERN_KDSETREG: ::c_int = 8;
-pub const KERN_KDGETREG: ::c_int = 9;
-pub const KERN_KDREADTR: ::c_int = 10;
-pub const KERN_KDPIDTR: ::c_int = 11;
-pub const KERN_KDTHRMAP: ::c_int = 12;
-pub const KERN_KDPIDEX: ::c_int = 14;
-pub const KERN_KDSETRTCDEC: ::c_int = 15;
-pub const KERN_KDGETENTROPY: ::c_int = 16;
-pub const KERN_KDWRITETR: ::c_int = 17;
-pub const KERN_KDWRITEMAP: ::c_int = 18;
-#[doc(hidden)]
-#[deprecated(since = "0.2.49", note ="Removed in MacOSX 10.12")]
-pub const KERN_KDENABLE_BG_TRACE: ::c_int = 19;
-#[doc(hidden)]
-#[deprecated(since = "0.2.49", note ="Removed in MacOSX 10.12")]
-pub const KERN_KDDISABLE_BG_TRACE: ::c_int = 20;
-pub const KERN_KDREADCURTHRMAP: ::c_int = 21;
-pub const KERN_KDSET_TYPEFILTER: ::c_int = 22;
-pub const KERN_KDBUFWAIT: ::c_int = 23;
-pub const KERN_KDCPUMAP: ::c_int = 24;
-pub const KERN_PROC_ALL: ::c_int = 0;
-pub const KERN_PROC_PID: ::c_int = 1;
-pub const KERN_PROC_PGRP: ::c_int = 2;
-pub const KERN_PROC_SESSION: ::c_int = 3;
-pub const KERN_PROC_TTY: ::c_int = 4;
-pub const KERN_PROC_UID: ::c_int = 5;
-pub const KERN_PROC_RUID: ::c_int = 6;
-pub const KERN_PROC_LCID: ::c_int = 7;
-pub const KIPC_MAXSOCKBUF: ::c_int = 1;
-pub const KIPC_SOCKBUF_WASTE: ::c_int = 2;
-pub const KIPC_SOMAXCONN: ::c_int = 3;
-pub const KIPC_MAX_LINKHDR: ::c_int = 4;
-pub const KIPC_MAX_PROTOHDR: ::c_int = 5;
-pub const KIPC_MAX_HDR: ::c_int = 6;
-pub const KIPC_MAX_DATALEN: ::c_int = 7;
-pub const KIPC_MBSTAT: ::c_int = 8;
-pub const KIPC_NMBCLUSTERS: ::c_int = 9;
-pub const KIPC_SOQLIMITCOMPAT: ::c_int = 10;
-pub const VM_METER: ::c_int = 1;
-pub const VM_LOADAVG: ::c_int = 2;
-pub const VM_MACHFACTOR: ::c_int = 4;
-pub const VM_SWAPUSAGE: ::c_int = 5;
-pub const VM_MAXID: ::c_int = 6;
-pub const HW_MACHINE: ::c_int = 1;
-pub const HW_MODEL: ::c_int = 2;
-pub const HW_NCPU: ::c_int = 3;
-pub const HW_BYTEORDER: ::c_int = 4;
-pub const HW_PHYSMEM: ::c_int = 5;
-pub const HW_USERMEM: ::c_int = 6;
-pub const HW_PAGESIZE: ::c_int = 7;
-pub const HW_DISKNAMES: ::c_int = 8;
-pub const HW_DISKSTATS: ::c_int = 9;
-pub const HW_EPOCH: ::c_int = 10;
-pub const HW_FLOATINGPT: ::c_int = 11;
-pub const HW_MACHINE_ARCH: ::c_int = 12;
-pub const HW_VECTORUNIT: ::c_int = 13;
-pub const HW_BUS_FREQ: ::c_int = 14;
-pub const HW_CPU_FREQ: ::c_int = 15;
-pub const HW_CACHELINE: ::c_int = 16;
-pub const HW_L1ICACHESIZE: ::c_int = 17;
-pub const HW_L1DCACHESIZE: ::c_int = 18;
-pub const HW_L2SETTINGS: ::c_int = 19;
-pub const HW_L2CACHESIZE: ::c_int = 20;
-pub const HW_L3SETTINGS: ::c_int = 21;
-pub const HW_L3CACHESIZE: ::c_int = 22;
-pub const HW_TB_FREQ: ::c_int = 23;
-pub const HW_MEMSIZE: ::c_int = 24;
-pub const HW_AVAILCPU: ::c_int = 25;
-pub const HW_MAXID: ::c_int = 26;
-pub const USER_CS_PATH: ::c_int = 1;
-pub const USER_BC_BASE_MAX: ::c_int = 2;
-pub const USER_BC_DIM_MAX: ::c_int = 3;
-pub const USER_BC_SCALE_MAX: ::c_int = 4;
-pub const USER_BC_STRING_MAX: ::c_int = 5;
-pub const USER_COLL_WEIGHTS_MAX: ::c_int = 6;
-pub const USER_EXPR_NEST_MAX: ::c_int = 7;
-pub const USER_LINE_MAX: ::c_int = 8;
-pub const USER_RE_DUP_MAX: ::c_int = 9;
-pub const USER_POSIX2_VERSION: ::c_int = 10;
-pub const USER_POSIX2_C_BIND: ::c_int = 11;
-pub const USER_POSIX2_C_DEV: ::c_int = 12;
-pub const USER_POSIX2_CHAR_TERM: ::c_int = 13;
-pub const USER_POSIX2_FORT_DEV: ::c_int = 14;
-pub const USER_POSIX2_FORT_RUN: ::c_int = 15;
-pub const USER_POSIX2_LOCALEDEF: ::c_int = 16;
-pub const USER_POSIX2_SW_DEV: ::c_int = 17;
-pub const USER_POSIX2_UPE: ::c_int = 18;
-pub const USER_STREAM_MAX: ::c_int = 19;
-pub const USER_TZNAME_MAX: ::c_int = 20;
-pub const USER_MAXID: ::c_int = 21;
-pub const CTL_DEBUG_NAME: ::c_int = 0;
-pub const CTL_DEBUG_VALUE: ::c_int = 1;
-pub const CTL_DEBUG_MAXID: ::c_int = 20;
-
-pub const PRIO_DARWIN_THREAD: ::c_int = 3;
-pub const PRIO_DARWIN_PROCESS: ::c_int = 4;
-pub const PRIO_DARWIN_BG: ::c_int = 0x1000;
-pub const PRIO_DARWIN_NONUI: ::c_int = 0x1001;
-
-pub const SEM_FAILED: *mut sem_t = -1isize as *mut ::sem_t;
-
-pub const AI_PASSIVE: ::c_int = 0x00000001;
-pub const AI_CANONNAME: ::c_int = 0x00000002;
-pub const AI_NUMERICHOST: ::c_int = 0x00000004;
-pub const AI_NUMERICSERV: ::c_int = 0x00001000;
-pub const AI_MASK: ::c_int = AI_PASSIVE | AI_CANONNAME | AI_NUMERICHOST |
- AI_NUMERICSERV | AI_ADDRCONFIG;
-pub const AI_ALL: ::c_int = 0x00000100;
-pub const AI_V4MAPPED_CFG: ::c_int = 0x00000200;
-pub const AI_ADDRCONFIG: ::c_int = 0x00000400;
-pub const AI_V4MAPPED: ::c_int = 0x00000800;
-pub const AI_DEFAULT: ::c_int = AI_V4MAPPED_CFG | AI_ADDRCONFIG;
-pub const AI_UNUSABLE: ::c_int = 0x10000000;
-
-pub const SIGEV_NONE: ::c_int = 0;
-pub const SIGEV_SIGNAL: ::c_int = 1;
-pub const SIGEV_THREAD: ::c_int = 3;
-
-pub const AIO_CANCELED: ::c_int = 2;
-pub const AIO_NOTCANCELED: ::c_int = 4;
-pub const AIO_ALLDONE: ::c_int = 1;
-pub const AIO_LISTIO_MAX: ::c_int = 16;
-pub const LIO_NOP: ::c_int = 0;
-pub const LIO_WRITE: ::c_int = 2;
-pub const LIO_READ: ::c_int = 1;
-pub const LIO_WAIT: ::c_int = 2;
-pub const LIO_NOWAIT: ::c_int = 1;
-
-pub const WEXITED: ::c_int = 0x00000004;
-pub const WSTOPPED: ::c_int = 0x00000008;
-pub const WCONTINUED: ::c_int = 0x00000010;
-pub const WNOWAIT: ::c_int = 0x00000020;
-
-pub const P_ALL: idtype_t = 0;
-pub const P_PID: idtype_t = 1;
-pub const P_PGID: idtype_t = 2;
-
-pub const XATTR_NOFOLLOW: ::c_int = 0x0001;
-pub const XATTR_CREATE: ::c_int = 0x0002;
-pub const XATTR_REPLACE: ::c_int = 0x0004;
-pub const XATTR_NOSECURITY: ::c_int = 0x0008;
-pub const XATTR_NODEFAULT: ::c_int = 0x0010;
-pub const XATTR_SHOWCOMPRESSION: ::c_int = 0x0020;
-
-pub const NET_RT_IFLIST2: ::c_int = 0x0006;
-
-// net/route.h
-pub const RTF_UP: ::c_int = 0x1;
-pub const RTF_GATEWAY: ::c_int = 0x2;
-pub const RTF_HOST: ::c_int = 0x4;
-pub const RTF_REJECT: ::c_int = 0x8;
-pub const RTF_DYNAMIC: ::c_int = 0x10;
-pub const RTF_MODIFIED: ::c_int = 0x20;
-pub const RTF_DONE: ::c_int = 0x40;
-pub const RTF_DELCLONE: ::c_int = 0x80;
-pub const RTF_CLONING: ::c_int = 0x100;
-pub const RTF_XRESOLVE: ::c_int = 0x200;
-pub const RTF_LLINFO: ::c_int = 0x400;
-pub const RTF_STATIC: ::c_int = 0x800;
-pub const RTF_BLACKHOLE: ::c_int = 0x1000;
-pub const RTF_NOIFREF: ::c_int = 0x2000;
-pub const RTF_PROTO2: ::c_int = 0x4000;
-pub const RTF_PROTO1: ::c_int = 0x8000;
-pub const RTF_PRCLONING: ::c_int = 0x10000;
-pub const RTF_WASCLONED: ::c_int = 0x20000;
-pub const RTF_PROTO3: ::c_int = 0x40000;
-pub const RTF_PINNED: ::c_int = 0x100000;
-pub const RTF_LOCAL: ::c_int = 0x200000;
-pub const RTF_BROADCAST: ::c_int = 0x400000;
-pub const RTF_MULTICAST: ::c_int = 0x800000;
-pub const RTF_IFSCOPE: ::c_int = 0x1000000;
-pub const RTF_CONDEMNED: ::c_int = 0x2000000;
-pub const RTF_IFREF: ::c_int = 0x4000000;
-pub const RTF_PROXY: ::c_int = 0x8000000;
-pub const RTF_ROUTER: ::c_int = 0x10000000;
-
-pub const RTM_VERSION: ::c_int = 5;
-
-// Message types
-pub const RTM_ADD: ::c_int = 0x1;
-pub const RTM_DELETE: ::c_int = 0x2;
-pub const RTM_CHANGE: ::c_int = 0x3;
-pub const RTM_GET: ::c_int = 0x4;
-pub const RTM_LOSING: ::c_int = 0x5;
-pub const RTM_REDIRECT: ::c_int = 0x6;
-pub const RTM_MISS: ::c_int = 0x7;
-pub const RTM_LOCK: ::c_int = 0x8;
-pub const RTM_OLDADD: ::c_int = 0x9;
-pub const RTM_OLDDEL: ::c_int = 0xa;
-pub const RTM_RESOLVE: ::c_int = 0xb;
-pub const RTM_NEWADDR: ::c_int = 0xc;
-pub const RTM_DELADDR: ::c_int = 0xd;
-pub const RTM_IFINFO: ::c_int = 0xe;
-pub const RTM_NEWMADDR: ::c_int = 0xf;
-pub const RTM_DELMADDR: ::c_int = 0x10;
-pub const RTM_IFINFO2: ::c_int = 0x12;
-pub const RTM_NEWMADDR2: ::c_int = 0x13;
-pub const RTM_GET2: ::c_int = 0x14;
-
-// Bitmask values for rtm_inits and rmx_locks.
-pub const RTV_MTU: ::c_int = 0x1;
-pub const RTV_HOPCOUNT: ::c_int = 0x2;
-pub const RTV_EXPIRE: ::c_int = 0x4;
-pub const RTV_RPIPE: ::c_int = 0x8;
-pub const RTV_SPIPE: ::c_int = 0x10;
-pub const RTV_SSTHRESH: ::c_int = 0x20;
-pub const RTV_RTT: ::c_int = 0x40;
-pub const RTV_RTTVAR: ::c_int = 0x80;
-
-// Bitmask values for rtm_addrs.
-pub const RTA_DST: ::c_int = 0x1;
-pub const RTA_GATEWAY: ::c_int = 0x2;
-pub const RTA_NETMASK: ::c_int = 0x4;
-pub const RTA_GENMASK: ::c_int = 0x8;
-pub const RTA_IFP: ::c_int = 0x10;
-pub const RTA_IFA: ::c_int = 0x20;
-pub const RTA_AUTHOR: ::c_int = 0x40;
-pub const RTA_BRD: ::c_int = 0x80;
-
-// Index offsets for sockaddr array for alternate internal encoding.
-pub const RTAX_DST: ::c_int = 0;
-pub const RTAX_GATEWAY: ::c_int = 1;
-pub const RTAX_NETMASK: ::c_int = 2;
-pub const RTAX_GENMASK: ::c_int = 3;
-pub const RTAX_IFP: ::c_int = 4;
-pub const RTAX_IFA: ::c_int = 5;
-pub const RTAX_AUTHOR: ::c_int = 6;
-pub const RTAX_BRD: ::c_int = 7;
-pub const RTAX_MAX: ::c_int = 8;
-
-pub const KERN_PROCARGS2: ::c_int = 49;
-
-pub const PROC_PIDTASKALLINFO: ::c_int = 2;
-pub const PROC_PIDTASKINFO: ::c_int = 4;
-pub const PROC_PIDTHREADINFO: ::c_int = 5;
-pub const MAXCOMLEN: usize = 16;
-pub const MAXTHREADNAMESIZE: usize = 64;
-
-pub const XUCRED_VERSION: ::c_uint = 0;
-
-pub const LC_SEGMENT: u32 = 0x1;
-pub const LC_SEGMENT_64: u32 = 0x19;
-
-pub const MH_MAGIC: u32 = 0xfeedface;
-pub const MH_MAGIC_64: u32 = 0xfeedfacf;
-
-// net/if_utun.h
-pub const UTUN_OPT_FLAGS: ::c_int = 1;
-pub const UTUN_OPT_IFNAME: ::c_int = 2;
-
-// net/bpf.h
-pub const DLT_NULL: ::c_uint = 0; // no link-layer encapsulation
-pub const DLT_EN10MB: ::c_uint = 1; // Ethernet (10Mb)
-pub const DLT_EN3MB: ::c_uint = 2; // Experimental Ethernet (3Mb)
-pub const DLT_AX25: ::c_uint = 3; // Amateur Radio AX.25
-pub const DLT_PRONET: ::c_uint = 4; // Proteon ProNET Token Ring
-pub const DLT_CHAOS: ::c_uint = 5; // Chaos
-pub const DLT_IEEE802: ::c_uint = 6; // IEEE 802 Networks
-pub const DLT_ARCNET: ::c_uint = 7; // ARCNET
-pub const DLT_SLIP: ::c_uint = 8; // Serial Line IP
-pub const DLT_PPP: ::c_uint = 9; // Point-to-point Protocol
-pub const DLT_FDDI: ::c_uint = 10; // FDDI
-pub const DLT_ATM_RFC1483: ::c_uint = 11; // LLC/SNAP encapsulated atm
-pub const DLT_RAW: ::c_uint = 12; // raw IP
-pub const DLT_LOOP: ::c_uint = 108;
-
-// https://github.com/apple/darwin-xnu/blob/master/bsd/net/bpf.h#L100
-// sizeof(i32)
-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;
-
-cfg_if! {
- if #[cfg(libc_const_size_of)] {
- fn __DARWIN_ALIGN32(p: usize) -> usize {
- const __DARWIN_ALIGNBYTES32: usize = ::mem::size_of::<u32>() - 1;
- p + __DARWIN_ALIGNBYTES32 & !__DARWIN_ALIGNBYTES32
- }
- } else {
- fn __DARWIN_ALIGN32(p: usize) -> usize {
- let __DARWIN_ALIGNBYTES32: usize = ::mem::size_of::<u32>() - 1;
- p + __DARWIN_ALIGNBYTES32 & !__DARWIN_ALIGNBYTES32
- }
- }
-}
-
-f! {
- pub fn CMSG_NXTHDR(mhdr: *const ::msghdr,
- cmsg: *const ::cmsghdr) -> *mut ::cmsghdr {
- if cmsg.is_null() {
- return ::CMSG_FIRSTHDR(mhdr);
- };
- let cmsg_len = (*cmsg).cmsg_len as usize;
- let next = cmsg as usize + __DARWIN_ALIGN32(cmsg_len as usize);
- let max = (*mhdr).msg_control as usize
- + (*mhdr).msg_controllen as usize;
- if next + __DARWIN_ALIGN32(::mem::size_of::<::cmsghdr>()) > max {
- 0 as *mut ::cmsghdr
- } else {
- next as *mut ::cmsghdr
- }
- }
-
- pub fn CMSG_DATA(cmsg: *const ::cmsghdr) -> *mut ::c_uchar {
- (cmsg as *mut ::c_uchar)
- .offset(__DARWIN_ALIGN32(::mem::size_of::<::cmsghdr>()) as isize)
- }
-
- pub fn CMSG_SPACE(length: ::c_uint) -> ::c_uint {
- (__DARWIN_ALIGN32(::mem::size_of::<::cmsghdr>())
- + __DARWIN_ALIGN32(length as usize))
- as ::c_uint
- }
-
- pub fn CMSG_LEN(length: ::c_uint) -> ::c_uint {
- (__DARWIN_ALIGN32(::mem::size_of::<::cmsghdr>()) + length as usize)
- as ::c_uint
- }
-
- pub fn WSTOPSIG(status: ::c_int) -> ::c_int {
- status >> 8
- }
-
- pub fn _WSTATUS(status: ::c_int) -> ::c_int {
- status & 0x7f
- }
-
- pub fn WIFCONTINUED(status: ::c_int) -> bool {
- _WSTATUS(status) == _WSTOPPED && WSTOPSIG(status) == 0x13
- }
-
- pub fn WIFSIGNALED(status: ::c_int) -> bool {
- _WSTATUS(status) != _WSTOPPED && _WSTATUS(status) != 0
- }
-
- pub fn WIFSTOPPED(status: ::c_int) -> bool {
- _WSTATUS(status) == _WSTOPPED && WSTOPSIG(status) != 0x13
- }
-}
-
-extern {
- pub fn setgrent();
- #[doc(hidden)]
- #[deprecated(since="0.2.49", note="Deprecated in MacOSX 10.5")]
- #[link_name = "daemon$1050"]
- pub fn daemon(nochdir: ::c_int, noclose: ::c_int) -> ::c_int;
- #[doc(hidden)]
- #[deprecated(since="0.2.49", note="Deprecated in MacOSX 10.10")]
- pub fn sem_destroy(sem: *mut sem_t) -> ::c_int;
- #[doc(hidden)]
- #[deprecated(since="0.2.49", note="Deprecated in MacOSX 10.10")]
- pub fn sem_init(sem: *mut sem_t,
- pshared: ::c_int,
- value: ::c_uint)
- -> ::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;
- #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
- link_name = "aio_suspend$UNIX2003")]
- 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,
- nitems: ::c_int, sevp: *mut sigevent) -> ::c_int;
-
- pub fn dirfd(dirp: *mut ::DIR) -> ::c_int;
-
- pub fn lutimes(file: *const ::c_char, times: *const ::timeval) -> ::c_int;
-
- pub fn gettimeofday(tp: *mut ::timeval,
- tz: *mut ::c_void) -> ::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 pututxline(ut: *const utmpx) -> *mut utmpx;
- pub fn setutxent();
- pub fn endutxent();
- pub fn utmpxname(file: *const ::c_char) -> ::c_int;
-
- pub fn getnameinfo(sa: *const ::sockaddr,
- salen: ::socklen_t,
- host: *mut ::c_char,
- hostlen: ::socklen_t,
- serv: *mut ::c_char,
- sevlen: ::socklen_t,
- flags: ::c_int) -> ::c_int;
- pub fn mincore(addr: *const ::c_void, len: ::size_t,
- vec: *mut ::c_char) -> ::c_int;
- pub fn sysctlnametomib(name: *const ::c_char,
- mibp: *mut ::c_int,
- sizep: *mut ::size_t)
- -> ::c_int;
- #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
- 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,
- oldlenp: *mut ::size_t,
- newp: *mut ::c_void,
- newlen: ::size_t)
- -> ::c_int;
- pub fn sysctlbyname(name: *const ::c_char,
- oldp: *mut ::c_void,
- oldlenp: *mut ::size_t,
- newp: *mut ::c_void,
- newlen: ::size_t)
- -> ::c_int;
- #[deprecated(since = "0.2.55", note = "Use the mach crate")]
- pub fn mach_absolute_time() -> u64;
- #[deprecated(since = "0.2.55", note = "Use the mach crate")]
- #[allow(deprecated)]
- pub fn mach_timebase_info(info: *mut ::mach_timebase_info) -> ::c_int;
- pub fn pthread_setname_np(name: *const ::c_char) -> ::c_int;
- pub fn pthread_get_stackaddr_np(thread: ::pthread_t) -> *mut ::c_void;
- pub fn pthread_get_stacksize_np(thread: ::pthread_t) -> ::size_t;
- pub fn pthread_condattr_setpshared(attr: *mut pthread_condattr_t,
- pshared: ::c_int) -> ::c_int;
- 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 __error() -> *mut ::c_int;
- pub fn backtrace(buf: *mut *mut ::c_void,
- sz: ::c_int) -> ::c_int;
- #[cfg_attr(target_os = "macos", link_name = "statfs$INODE64")]
- pub fn statfs(path: *const ::c_char, buf: *mut statfs) -> ::c_int;
- #[cfg_attr(target_os = "macos", link_name = "fstatfs$INODE64")]
- pub fn fstatfs(fd: ::c_int, buf: *mut statfs) -> ::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 kevent64(kq: ::c_int,
- changelist: *const ::kevent64_s,
- nchanges: ::c_int,
- eventlist: *mut ::kevent64_s,
- nevents: ::c_int,
- flags: ::c_uint,
- timeout: *const ::timespec) -> ::c_int;
- pub fn mount(src: *const ::c_char,
- target: *const ::c_char,
- flags: ::c_int,
- data: *mut ::c_void) -> ::c_int;
- pub fn ptrace(request: ::c_int,
- pid: ::pid_t,
- addr: *mut ::c_char,
- data: ::c_int) -> ::c_int;
- pub fn quotactl(special: *const ::c_char,
- cmd: ::c_int,
- id: ::c_int,
- data: *mut ::c_char) -> ::c_int;
- pub fn sethostname(name: *const ::c_char, len: ::c_int) -> ::c_int;
- pub fn sendfile(fd: ::c_int,
- s: ::c_int,
- offset: ::off_t,
- 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,
- termp: *mut termios,
- winp: *mut ::winsize) -> ::c_int;
- pub fn forkpty(amaster: *mut ::c_int,
- name: *mut ::c_char,
- termp: *mut termios,
- winp: *mut ::winsize) -> ::pid_t;
- pub fn login_tty(fd: ::c_int) -> ::c_int;
- pub fn duplocale(base: ::locale_t) -> ::locale_t;
- pub fn freelocale(loc: ::locale_t) -> ::c_int;
- pub fn localeconv_l(loc: ::locale_t) -> *mut lconv;
- 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 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;
- pub fn fgetxattr(filedes: ::c_int, name: *const ::c_char,
- value: *mut ::c_void, size: ::size_t, position: u32,
- flags: ::c_int) -> ::ssize_t;
- pub fn setxattr(path: *const ::c_char, name: *const ::c_char,
- value: *const ::c_void, size: ::size_t, position: u32,
- flags: ::c_int) -> ::c_int;
- pub fn fsetxattr(filedes: ::c_int, name: *const ::c_char,
- value: *const ::c_void, size: ::size_t, position: u32,
- flags: ::c_int) -> ::c_int;
- pub fn listxattr(path: *const ::c_char, list: *mut ::c_char,
- size: ::size_t, flags: ::c_int) -> ::ssize_t;
- pub fn flistxattr(filedes: ::c_int, list: *mut ::c_char,
- 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;
-
- pub fn getgrouplist(name: *const ::c_char,
- basegid: ::c_int,
- groups: *mut ::c_int,
- ngroups: *mut ::c_int) -> ::c_int;
- pub fn initgroups(user: *const ::c_char, basegroup: ::c_int) -> ::c_int;
-
- #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
- link_name = "waitid$UNIX2003")]
- pub fn waitid(idtype: idtype_t, id: id_t, infop: *mut ::siginfo_t,
- options: ::c_int) -> ::c_int;
- pub fn brk(addr: *const ::c_void) -> *mut ::c_void;
- pub fn sbrk(increment: ::c_int) -> *mut ::c_void;
- pub fn settimeofday(tv: *const ::timeval, tz: *const ::timezone) -> ::c_int;
- #[deprecated(since = "0.2.55", note = "Use the mach crate")]
- pub fn _dyld_image_count() -> u32;
- #[deprecated(since = "0.2.55", note = "Use the mach crate")]
- #[allow(deprecated)]
- pub fn _dyld_get_image_header(image_index: u32) -> *const mach_header;
- #[deprecated(since = "0.2.55", note = "Use the mach crate")]
- pub fn _dyld_get_image_vmaddr_slide(image_index: u32) -> ::intptr_t;
- #[deprecated(since = "0.2.55", note = "Use the mach crate")]
- 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;
- pub fn uname(buf: *mut ::utsname) -> ::c_int;
-}
-
-cfg_if! {
- if #[cfg(any(target_arch = "arm", target_arch = "x86"))] {
- mod b32;
- pub use self::b32::*;
- } else if #[cfg(any(target_arch = "x86_64", target_arch = "aarch64"))] {
- mod b64;
- pub use self::b64::*;
- } else {
- // Unknown target_arch
- }
-}
diff --git a/libc/src/unix/bsd/freebsdlike/dragonfly/mod.rs b/libc/src/unix/bsd/freebsdlike/dragonfly/mod.rs
deleted file mode 100644
index 26faffe..0000000
--- a/libc/src/unix/bsd/freebsdlike/dragonfly/mod.rs
+++ /dev/null
@@ -1,1060 +0,0 @@
-pub type dev_t = u32;
-pub type c_char = i8;
-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;
-
-pub type c_long = i64;
-pub type c_ulong = u64;
-pub type time_t = i64;
-pub type suseconds_t = i64;
-
-pub type uuid_t = ::uuid;
-
-pub type fsblkcnt_t = u64;
-pub type fsfilcnt_t = u64;
-
-pub type mqd_t = ::c_int;
-pub type sem_t = *mut sem;
-
-#[cfg_attr(feature = "extra_traits", derive(Debug))]
-pub enum sem {}
-impl ::Copy for sem {}
-impl ::Clone for sem {
- fn clone(&self) -> sem { *self }
-}
-
-s! {
- pub struct kevent {
- pub ident: ::uintptr_t,
- pub filter: ::c_short,
- pub flags: ::c_ushort,
- pub fflags: ::c_uint,
- pub data: ::intptr_t,
- pub udata: *mut ::c_void,
- }
-
- pub struct exit_status {
- pub e_termination: u16,
- pub e_exit: u16
- }
-
- pub struct aiocb {
- pub aio_fildes: ::c_int,
- pub aio_offset: ::off_t,
- pub aio_buf: *mut ::c_void,
- pub aio_nbytes: ::size_t,
- pub aio_sigevent: sigevent,
- pub aio_lio_opcode: ::c_int,
- pub aio_reqprio: ::c_int,
- _aio_val: ::c_int,
- _aio_err: ::c_int
- }
-
- pub struct uuid {
- pub time_low: u32,
- pub time_mid: u16,
- pub time_hi_and_version: u16,
- pub clock_seq_hi_and_reserved: u8,
- pub clock_seq_low: u8,
- pub node: [u8; 6],
- }
-
- pub struct mq_attr {
- pub mq_flags: ::c_long,
- pub mq_maxmsg: ::c_long,
- pub mq_msgsize: ::c_long,
- pub mq_curmsgs: ::c_long,
- }
-
- pub struct sigevent {
- pub sigev_notify: ::c_int,
- // The union is 8-byte in size, so it is aligned at a 8-byte offset.
- #[cfg(target_pointer_width = "64")]
- __unused1: ::c_int,
- pub sigev_signo: ::c_int, //actually a union
- // pad the union
- #[cfg(target_pointer_width = "64")]
- __unused2: ::c_int,
- pub sigev_value: ::sigval,
- __unused3: *mut ::c_void //actually a function pointer
- }
-
- 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,
- pub f_owner: ::uid_t,
- pub f_type: ::c_uint,
- pub f_syncreads: u64,
- pub f_syncwrites: u64,
- pub f_asyncreads: u64,
- pub f_asyncwrites: u64,
- pub f_fsid_uuid: ::uuid_t,
- pub f_uid_uuid: ::uuid_t,
- }
-
- pub struct stat {
- pub st_ino: ::ino_t,
- pub st_nlink: ::nlink_t,
- pub st_dev: ::dev_t,
- pub st_mode: ::mode_t,
- pub st_padding1: u16,
- pub st_uid: ::uid_t,
- pub st_gid: ::gid_t,
- pub st_rdev: ::dev_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_size: ::off_t,
- pub st_blocks: i64,
- pub st_blksize: u32,
- pub st_flags: u32,
- pub st_gen: u32,
- pub st_lspare: i32,
- pub st_qspare1: i64,
- pub st_qspare2: i64,
- }
-
- pub struct if_data {
- pub ifi_type: ::c_uchar,
- pub ifi_physical: ::c_uchar,
- pub ifi_addrlen: ::c_uchar,
- pub ifi_hdrlen: ::c_uchar,
- pub ifi_recvquota: ::c_uchar,
- pub ifi_xmitquota: ::c_uchar,
- pub ifi_mtu: ::c_ulong,
- pub ifi_metric: ::c_ulong,
- pub ifi_link_state: ::c_ulong,
- pub ifi_baudrate: u64,
- pub ifi_ipackets: ::c_ulong,
- pub ifi_ierrors: ::c_ulong,
- pub ifi_opackets: ::c_ulong,
- pub ifi_oerrors: ::c_ulong,
- pub ifi_collisions: ::c_ulong,
- pub ifi_ibytes: ::c_ulong,
- pub ifi_obytes: ::c_ulong,
- pub ifi_imcasts: ::c_ulong,
- pub ifi_omcasts: ::c_ulong,
- pub ifi_iqdrops: ::c_ulong,
- pub ifi_noproto: ::c_ulong,
- pub ifi_hwassist: ::c_ulong,
- pub ifi_oqdrops: ::c_ulong,
- pub ifi_lastchange: ::timeval,
- }
-
- pub struct if_msghdr {
- pub ifm_msglen: ::c_ushort,
- pub ifm_version: ::c_uchar,
- pub ifm_type: ::c_uchar,
- pub ifm_addrs: ::c_int,
- pub ifm_flags: ::c_int,
- pub ifm_index: ::c_ushort,
- pub ifm_data: if_data,
- }
-
- pub struct sockaddr_dl {
- pub sdl_len: ::c_uchar,
- pub sdl_family: ::c_uchar,
- pub sdl_index: ::c_ushort,
- pub sdl_type: ::c_uchar,
- pub sdl_nlen: ::c_uchar,
- pub sdl_alen: ::c_uchar,
- pub sdl_slen: ::c_uchar,
- pub sdl_data: [::c_char; 12],
- pub sdl_rcf: ::c_ushort,
- pub sdl_route: [::c_ushort; 16],
- }
-
- pub struct stack_t {
- pub ss_sp: *mut ::c_char,
- pub ss_size: ::size_t,
- pub ss_flags: ::c_int,
- }
-}
-
-s_no_extra_traits! {
- pub struct utmpx {
- pub ut_name: [::c_char; 32],
- pub ut_id: [::c_char; 4],
-
- pub ut_line: [::c_char; 32],
- pub ut_host: [::c_char; 256],
-
- pub ut_unused: [u8; 16],
- pub ut_session: u16,
- pub ut_type: u16,
- pub ut_pid: ::pid_t,
- ut_exit: exit_status,
- ut_ss: ::sockaddr_storage,
- pub ut_tv: ::timeval,
- pub ut_unused2: [u8; 16],
- }
-
- pub struct dirent {
- pub d_fileno: ::ino_t,
- pub d_namlen: u16,
- pub d_type: u8,
- __unused1: u8,
- __unused2: u32,
- pub d_name: [::c_char; 256],
- }
-
- 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: i32,
- pub f_flags: i32,
- 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],
- }
-}
-
-cfg_if! {
- if #[cfg(feature = "extra_traits")] {
- impl PartialEq for utmpx {
- fn eq(&self, other: &utmpx) -> bool {
- self.ut_name == other.ut_name
- && self.ut_id == other.ut_id
- && self.ut_line == other.ut_line
- && self
- .ut_host
- .iter()
- .zip(other.ut_host.iter())
- .all(|(a,b)| a == b)
- && self.ut_unused == other.ut_unused
- && self.ut_session == other.ut_session
- && self.ut_type == other.ut_type
- && self.ut_pid == other.ut_pid
- && self.ut_exit == other.ut_exit
- && self.ut_ss == other.ut_ss
- && self.ut_tv == other.ut_tv
- && self.ut_unused2 == other.ut_unused2
- }
- }
- impl Eq for utmpx {}
- impl ::fmt::Debug for utmpx {
- fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
- f.debug_struct("utmpx")
- .field("ut_name", &self.ut_name)
- .field("ut_id", &self.ut_id)
- .field("ut_line", &self.ut_line)
- // FIXME: .field("ut_host", &self.ut_host)
- .field("ut_unused", &self.ut_unused)
- .field("ut_session", &self.ut_session)
- .field("ut_type", &self.ut_type)
- .field("ut_pid", &self.ut_pid)
- .field("ut_exit", &self.ut_exit)
- .field("ut_ss", &self.ut_ss)
- .field("ut_tv", &self.ut_tv)
- .field("ut_unused2", &self.ut_unused2)
- .finish()
- }
- }
- impl ::hash::Hash for utmpx {
- fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
- self.ut_name.hash(state);
- self.ut_id.hash(state);
- self.ut_line.hash(state);
- self.ut_host.hash(state);
- self.ut_unused.hash(state);
- self.ut_session.hash(state);
- self.ut_type.hash(state);
- self.ut_pid.hash(state);
- self.ut_exit.hash(state);
- self.ut_ss.hash(state);
- self.ut_tv.hash(state);
- self.ut_unused2.hash(state);
- }
- }
-
- impl PartialEq for dirent {
- fn eq(&self, other: &dirent) -> bool {
- self.d_fileno == other.d_fileno
- && self.d_namlen == other.d_namlen
- && self.d_type == other.d_type
- // Ignore __unused1
- // Ignore __unused2
- && self
- .d_name
- .iter()
- .zip(other.d_name.iter())
- .all(|(a,b)| a == b)
- }
- }
- impl Eq for dirent {}
- impl ::fmt::Debug for dirent {
- fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
- f.debug_struct("dirent")
- .field("d_fileno", &self.d_fileno)
- .field("d_namlen", &self.d_namlen)
- .field("d_type", &self.d_type)
- // Ignore __unused1
- // Ignore __unused2
- // FIXME: .field("d_name", &self.d_name)
- .finish()
- }
- }
- impl ::hash::Hash for dirent {
- fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
- self.d_fileno.hash(state);
- self.d_namlen.hash(state);
- self.d_type.hash(state);
- // Ignore __unused1
- // Ignore __unused2
- self.d_name.hash(state);
- }
- }
-
- impl PartialEq for statfs {
- fn eq(&self, other: &statfs) -> bool {
- self.f_bsize == other.f_bsize
- && self.f_iosize == other.f_iosize
- && self.f_blocks == other.f_blocks
- && self.f_bfree == other.f_bfree
- && self.f_bavail == other.f_bavail
- && self.f_files == other.f_files
- && self.f_ffree == other.f_ffree
- && self.f_fsid == other.f_fsid
- && self.f_owner == other.f_owner
- && self.f_type == other.f_type
- && self.f_flags == other.f_flags
- && self.f_syncwrites == other.f_syncwrites
- && self.f_asyncwrites == other.f_asyncwrites
- && self.f_fstypename == other.f_fstypename
- && self
- .f_mntonname
- .iter()
- .zip(other.f_mntonname.iter())
- .all(|(a,b)| a == b)
- && self.f_syncreads == other.f_syncreads
- && self.f_asyncreads == other.f_asyncreads
- && self
- .f_mntfromname
- .iter()
- .zip(other.f_mntfromname.iter())
- .all(|(a,b)| a == b)
- }
- }
- impl Eq for statfs {}
- impl ::fmt::Debug for statfs {
- fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
- f.debug_struct("statfs")
- .field("f_bsize", &self.f_bsize)
- .field("f_iosize", &self.f_iosize)
- .field("f_blocks", &self.f_blocks)
- .field("f_bfree", &self.f_bfree)
- .field("f_bavail", &self.f_bavail)
- .field("f_files", &self.f_files)
- .field("f_ffree", &self.f_ffree)
- .field("f_fsid", &self.f_fsid)
- .field("f_owner", &self.f_owner)
- .field("f_type", &self.f_type)
- .field("f_flags", &self.f_flags)
- .field("f_syncwrites", &self.f_syncwrites)
- .field("f_asyncwrites", &self.f_asyncwrites)
- // FIXME: .field("f_mntonname", &self.f_mntonname)
- .field("f_syncreads", &self.f_syncreads)
- .field("f_asyncreads", &self.f_asyncreads)
- // FIXME: .field("f_mntfromname", &self.f_mntfromname)
- .finish()
- }
- }
- impl ::hash::Hash for statfs {
- fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
- self.f_bsize.hash(state);
- self.f_iosize.hash(state);
- self.f_blocks.hash(state);
- self.f_bfree.hash(state);
- self.f_bavail.hash(state);
- self.f_files.hash(state);
- self.f_ffree.hash(state);
- self.f_fsid.hash(state);
- self.f_owner.hash(state);
- self.f_type.hash(state);
- self.f_flags.hash(state);
- self.f_syncwrites.hash(state);
- self.f_asyncwrites.hash(state);
- self.f_fstypename.hash(state);
- self.f_mntonname.hash(state);
- self.f_syncreads.hash(state);
- self.f_asyncreads.hash(state);
- self.f_mntfromname.hash(state);
- }
- }
- }
-}
-
-pub const RAND_MAX: ::c_int = 0x7fff_ffff;
-pub const PTHREAD_STACK_MIN: ::size_t = 16384;
-pub const SIGSTKSZ: ::size_t = 40960;
-pub const MADV_INVAL: ::c_int = 10;
-pub const MADV_SETMAP: ::c_int = 11;
-pub const O_CLOEXEC: ::c_int = 0x00020000;
-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;
-
-pub const Q_GETQUOTA: ::c_int = 0x300;
-pub const Q_SETQUOTA: ::c_int = 0x400;
-
-pub const CLOCK_REALTIME: ::clockid_t = 0;
-pub const CLOCK_VIRTUAL: ::clockid_t = 1;
-pub const CLOCK_PROF: ::clockid_t = 2;
-pub const CLOCK_MONOTONIC: ::clockid_t = 4;
-pub const CLOCK_UPTIME: ::clockid_t = 5;
-pub const CLOCK_UPTIME_PRECISE: ::clockid_t = 7;
-pub const CLOCK_UPTIME_FAST: ::clockid_t = 8;
-pub const CLOCK_REALTIME_PRECISE: ::clockid_t = 9;
-pub const CLOCK_REALTIME_FAST: ::clockid_t = 10;
-pub const CLOCK_MONOTONIC_PRECISE: ::clockid_t = 11;
-pub const CLOCK_MONOTONIC_FAST: ::clockid_t = 12;
-pub const CLOCK_SECOND: ::clockid_t = 13;
-pub const CLOCK_THREAD_CPUTIME_ID: ::clockid_t = 14;
-pub const CLOCK_PROCESS_CPUTIME_ID: ::clockid_t = 15;
-
-pub const CTL_UNSPEC: ::c_int = 0;
-pub const CTL_KERN: ::c_int = 1;
-pub const CTL_VM: ::c_int = 2;
-pub const CTL_VFS: ::c_int = 3;
-pub const CTL_NET: ::c_int = 4;
-pub const CTL_DEBUG: ::c_int = 5;
-pub const CTL_HW: ::c_int = 6;
-pub const CTL_MACHDEP: ::c_int = 7;
-pub const CTL_USER: ::c_int = 8;
-pub const CTL_P1003_1B: ::c_int = 9;
-pub const CTL_LWKT: ::c_int = 10;
-pub const CTL_MAXID: ::c_int = 11;
-pub const KERN_OSTYPE: ::c_int = 1;
-pub const KERN_OSRELEASE: ::c_int = 2;
-pub const KERN_OSREV: ::c_int = 3;
-pub const KERN_VERSION: ::c_int = 4;
-pub const KERN_MAXVNODES: ::c_int = 5;
-pub const KERN_MAXPROC: ::c_int = 6;
-pub const KERN_MAXFILES: ::c_int = 7;
-pub const KERN_ARGMAX: ::c_int = 8;
-pub const KERN_SECURELVL: ::c_int = 9;
-pub const KERN_HOSTNAME: ::c_int = 10;
-pub const KERN_HOSTID: ::c_int = 11;
-pub const KERN_CLOCKRATE: ::c_int = 12;
-pub const KERN_VNODE: ::c_int = 13;
-pub const KERN_PROC: ::c_int = 14;
-pub const KERN_FILE: ::c_int = 15;
-pub const KERN_PROF: ::c_int = 16;
-pub const KERN_POSIX1: ::c_int = 17;
-pub const KERN_NGROUPS: ::c_int = 18;
-pub const KERN_JOB_CONTROL: ::c_int = 19;
-pub const KERN_SAVED_IDS: ::c_int = 20;
-pub const KERN_BOOTTIME: ::c_int = 21;
-pub const KERN_NISDOMAINNAME: ::c_int = 22;
-pub const KERN_UPDATEINTERVAL: ::c_int = 23;
-pub const KERN_OSRELDATE: ::c_int = 24;
-pub const KERN_NTP_PLL: ::c_int = 25;
-pub const KERN_BOOTFILE: ::c_int = 26;
-pub const KERN_MAXFILESPERPROC: ::c_int = 27;
-pub const KERN_MAXPROCPERUID: ::c_int = 28;
-pub const KERN_DUMPDEV: ::c_int = 29;
-pub const KERN_IPC: ::c_int = 30;
-pub const KERN_DUMMY: ::c_int = 31;
-pub const KERN_PS_STRINGS: ::c_int = 32;
-pub const KERN_USRSTACK: ::c_int = 33;
-pub const KERN_LOGSIGEXIT: ::c_int = 34;
-pub const KERN_IOV_MAX: ::c_int = 35;
-pub const KERN_MAXPOSIXLOCKSPERUID: ::c_int = 36;
-pub const KERN_MAXID: ::c_int = 37;
-pub const KERN_PROC_ALL: ::c_int = 0;
-pub const KERN_PROC_PID: ::c_int = 1;
-pub const KERN_PROC_PGRP: ::c_int = 2;
-pub const KERN_PROC_SESSION: ::c_int = 3;
-pub const KERN_PROC_TTY: ::c_int = 4;
-pub const KERN_PROC_UID: ::c_int = 5;
-pub const KERN_PROC_RUID: ::c_int = 6;
-pub const KERN_PROC_ARGS: ::c_int = 7;
-pub const KERN_PROC_CWD: ::c_int = 8;
-pub const KERN_PROC_PATHNAME: ::c_int = 9;
-pub const KERN_PROC_FLAGMASK: ::c_int = 0x10;
-pub const KERN_PROC_FLAG_LWP: ::c_int = 0x10;
-pub const KIPC_MAXSOCKBUF: ::c_int = 1;
-pub const KIPC_SOCKBUF_WASTE: ::c_int = 2;
-pub const KIPC_SOMAXCONN: ::c_int = 3;
-pub const KIPC_MAX_LINKHDR: ::c_int = 4;
-pub const KIPC_MAX_PROTOHDR: ::c_int = 5;
-pub const KIPC_MAX_HDR: ::c_int = 6;
-pub const KIPC_MAX_DATALEN: ::c_int = 7;
-pub const KIPC_MBSTAT: ::c_int = 8;
-pub const KIPC_NMBCLUSTERS: ::c_int = 9;
-pub const HW_MACHINE: ::c_int = 1;
-pub const HW_MODEL: ::c_int = 2;
-pub const HW_NCPU: ::c_int = 3;
-pub const HW_BYTEORDER: ::c_int = 4;
-pub const HW_PHYSMEM: ::c_int = 5;
-pub const HW_USERMEM: ::c_int = 6;
-pub const HW_PAGESIZE: ::c_int = 7;
-pub const HW_DISKNAMES: ::c_int = 8;
-pub const HW_DISKSTATS: ::c_int = 9;
-pub const HW_FLOATINGPT: ::c_int = 10;
-pub const HW_MACHINE_ARCH: ::c_int = 11;
-pub const HW_MACHINE_PLATFORM: ::c_int = 12;
-pub const HW_SENSORS: ::c_int = 13;
-pub const HW_MAXID: ::c_int = 14;
-pub const USER_CS_PATH: ::c_int = 1;
-pub const USER_BC_BASE_MAX: ::c_int = 2;
-pub const USER_BC_DIM_MAX: ::c_int = 3;
-pub const USER_BC_SCALE_MAX: ::c_int = 4;
-pub const USER_BC_STRING_MAX: ::c_int = 5;
-pub const USER_COLL_WEIGHTS_MAX: ::c_int = 6;
-pub const USER_EXPR_NEST_MAX: ::c_int = 7;
-pub const USER_LINE_MAX: ::c_int = 8;
-pub const USER_RE_DUP_MAX: ::c_int = 9;
-pub const USER_POSIX2_VERSION: ::c_int = 10;
-pub const USER_POSIX2_C_BIND: ::c_int = 11;
-pub const USER_POSIX2_C_DEV: ::c_int = 12;
-pub const USER_POSIX2_CHAR_TERM: ::c_int = 13;
-pub const USER_POSIX2_FORT_DEV: ::c_int = 14;
-pub const USER_POSIX2_FORT_RUN: ::c_int = 15;
-pub const USER_POSIX2_LOCALEDEF: ::c_int = 16;
-pub const USER_POSIX2_SW_DEV: ::c_int = 17;
-pub const USER_POSIX2_UPE: ::c_int = 18;
-pub const USER_STREAM_MAX: ::c_int = 19;
-pub const USER_TZNAME_MAX: ::c_int = 20;
-pub const USER_MAXID: ::c_int = 21;
-pub const CTL_P1003_1B_ASYNCHRONOUS_IO: ::c_int = 1;
-pub const CTL_P1003_1B_MAPPED_FILES: ::c_int = 2;
-pub const CTL_P1003_1B_MEMLOCK: ::c_int = 3;
-pub const CTL_P1003_1B_MEMLOCK_RANGE: ::c_int = 4;
-pub const CTL_P1003_1B_MEMORY_PROTECTION: ::c_int = 5;
-pub const CTL_P1003_1B_MESSAGE_PASSING: ::c_int = 6;
-pub const CTL_P1003_1B_PRIORITIZED_IO: ::c_int = 7;
-pub const CTL_P1003_1B_PRIORITY_SCHEDULING: ::c_int = 8;
-pub const CTL_P1003_1B_REALTIME_SIGNALS: ::c_int = 9;
-pub const CTL_P1003_1B_SEMAPHORES: ::c_int = 10;
-pub const CTL_P1003_1B_FSYNC: ::c_int = 11;
-pub const CTL_P1003_1B_SHARED_MEMORY_OBJECTS: ::c_int = 12;
-pub const CTL_P1003_1B_SYNCHRONIZED_IO: ::c_int = 13;
-pub const CTL_P1003_1B_TIMERS: ::c_int = 14;
-pub const CTL_P1003_1B_AIO_LISTIO_MAX: ::c_int = 15;
-pub const CTL_P1003_1B_AIO_MAX: ::c_int = 16;
-pub const CTL_P1003_1B_AIO_PRIO_DELTA_MAX: ::c_int = 17;
-pub const CTL_P1003_1B_DELAYTIMER_MAX: ::c_int = 18;
-pub const CTL_P1003_1B_UNUSED1: ::c_int = 19;
-pub const CTL_P1003_1B_PAGESIZE: ::c_int = 20;
-pub const CTL_P1003_1B_RTSIG_MAX: ::c_int = 21;
-pub const CTL_P1003_1B_SEM_NSEMS_MAX: ::c_int = 22;
-pub const CTL_P1003_1B_SEM_VALUE_MAX: ::c_int = 23;
-pub const CTL_P1003_1B_SIGQUEUE_MAX: ::c_int = 24;
-pub const CTL_P1003_1B_TIMER_MAX: ::c_int = 25;
-pub const CTL_P1003_1B_MAXID: ::c_int = 26;
-
-pub const EVFILT_READ: i16 = -1;
-pub const EVFILT_WRITE: i16 = -2;
-pub const EVFILT_AIO: i16 = -3;
-pub const EVFILT_VNODE: i16 = -4;
-pub const EVFILT_PROC: i16 = -5;
-pub const EVFILT_SIGNAL: i16 = -6;
-pub const EVFILT_TIMER: i16 = -7;
-pub const EVFILT_EXCEPT: i16 = -8;
-pub const EVFILT_USER: i16 = -9;
-pub const EVFILT_FS: i16 = -10;
-
-pub const EV_ADD: u16 = 0x1;
-pub const EV_DELETE: u16 = 0x2;
-pub const EV_ENABLE: u16 = 0x4;
-pub const EV_DISABLE: u16 = 0x8;
-pub const EV_ONESHOT: u16 = 0x10;
-pub const EV_CLEAR: u16 = 0x20;
-pub const EV_RECEIPT: u16 = 0x40;
-pub const EV_DISPATCH: u16 = 0x80;
-pub const EV_NODATA: u16 = 0x1000;
-pub const EV_FLAG1: u16 = 0x2000;
-pub const EV_ERROR: u16 = 0x4000;
-pub const EV_EOF: u16 = 0x8000;
-pub const EV_SYSFLAGS: u16 = 0xf000;
-
-pub const NOTE_TRIGGER: u32 = 0x01000000;
-pub const NOTE_FFNOP: u32 = 0x00000000;
-pub const NOTE_FFAND: u32 = 0x40000000;
-pub const NOTE_FFOR: u32 = 0x80000000;
-pub const NOTE_FFCOPY: u32 = 0xc0000000;
-pub const NOTE_FFCTRLMASK: u32 = 0xc0000000;
-pub const NOTE_FFLAGSMASK: u32 = 0x00ffffff;
-pub const NOTE_LOWAT: u32 = 0x00000001;
-pub const NOTE_OOB: u32 = 0x00000002;
-pub const NOTE_DELETE: u32 = 0x00000001;
-pub const NOTE_WRITE: u32 = 0x00000002;
-pub const NOTE_EXTEND: u32 = 0x00000004;
-pub const NOTE_ATTRIB: u32 = 0x00000008;
-pub const NOTE_LINK: u32 = 0x00000010;
-pub const NOTE_RENAME: u32 = 0x00000020;
-pub const NOTE_REVOKE: u32 = 0x00000040;
-pub const NOTE_EXIT: u32 = 0x80000000;
-pub const NOTE_FORK: u32 = 0x40000000;
-pub const NOTE_EXEC: u32 = 0x20000000;
-pub const NOTE_PDATAMASK: u32 = 0x000fffff;
-pub const NOTE_PCTRLMASK: u32 = 0xf0000000;
-pub const NOTE_TRACK: u32 = 0x00000001;
-pub const NOTE_TRACKERR: u32 = 0x00000002;
-pub const NOTE_CHILD: u32 = 0x00000004;
-
-pub const 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
-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_SMART: ::c_int = 0x20; // interface manages own routes
-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_COMPAT: ::c_int = 0x400; // was 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_ALTPHYS: ::c_int = IFF_LINK2; // use alternate physical connection
-pub const IFF_MULTICAST: ::c_int = 0x8000; // supports multicast
-// was interface is in polling mode
-pub const IFF_POLLING_COMPAT: ::c_int = 0x10000;
-pub const IFF_PPROMISC: ::c_int = 0x20000; // user-requested promisc mode
-pub const IFF_MONITOR: ::c_int = 0x40000; // user-requested monitor mode
-pub const IFF_STATICARP: ::c_int = 0x80000; // static ARP
-pub const IFF_NPOLLING: ::c_int = 0x100000; // interface is in polling mode
-pub const IFF_IDIRECT: ::c_int = 0x200000; // direct input
-
-//
-// sys/netinet/in.h
-// Protocols (RFC 1700)
-// NOTE: These are in addition to the constants defined in src/unix/mod.rs
-
-// IPPROTO_IP defined in src/unix/mod.rs
-/// IP6 hop-by-hop options
-pub const IPPROTO_HOPOPTS: ::c_int = 0;
-// IPPROTO_ICMP defined in src/unix/mod.rs
-/// group mgmt protocol
-pub const IPPROTO_IGMP: ::c_int = 2;
-/// gateway^2 (deprecated)
-pub const IPPROTO_GGP: ::c_int = 3;
-/// for compatibility
-pub const IPPROTO_IPIP: ::c_int = 4;
-// IPPROTO_TCP defined in src/unix/mod.rs
-/// Stream protocol II.
-pub const IPPROTO_ST: ::c_int = 7;
-/// exterior gateway protocol
-pub const IPPROTO_EGP: ::c_int = 8;
-/// private interior gateway
-pub const IPPROTO_PIGP: ::c_int = 9;
-/// BBN RCC Monitoring
-pub const IPPROTO_RCCMON: ::c_int = 10;
-/// network voice protocol
-pub const IPPROTO_NVPII: ::c_int = 11;
-/// pup
-pub const IPPROTO_PUP: ::c_int = 12;
-/// Argus
-pub const IPPROTO_ARGUS: ::c_int = 13;
-/// EMCON
-pub const IPPROTO_EMCON: ::c_int = 14;
-/// Cross Net Debugger
-pub const IPPROTO_XNET: ::c_int = 15;
-/// Chaos
-pub const IPPROTO_CHAOS: ::c_int = 16;
-// IPPROTO_UDP defined in src/unix/mod.rs
-/// Multiplexing
-pub const IPPROTO_MUX: ::c_int = 18;
-/// DCN Measurement Subsystems
-pub const IPPROTO_MEAS: ::c_int = 19;
-/// Host Monitoring
-pub const IPPROTO_HMP: ::c_int = 20;
-/// Packet Radio Measurement
-pub const IPPROTO_PRM: ::c_int = 21;
-/// xns idp
-pub const IPPROTO_IDP: ::c_int = 22;
-/// Trunk-1
-pub const IPPROTO_TRUNK1: ::c_int = 23;
-/// Trunk-2
-pub const IPPROTO_TRUNK2: ::c_int = 24;
-/// Leaf-1
-pub const IPPROTO_LEAF1: ::c_int = 25;
-/// Leaf-2
-pub const IPPROTO_LEAF2: ::c_int = 26;
-/// Reliable Data
-pub const IPPROTO_RDP: ::c_int = 27;
-/// Reliable Transaction
-pub const IPPROTO_IRTP: ::c_int = 28;
-/// tp-4 w/ class negotiation
-pub const IPPROTO_TP: ::c_int = 29;
-/// Bulk Data Transfer
-pub const IPPROTO_BLT: ::c_int = 30;
-/// Network Services
-pub const IPPROTO_NSP: ::c_int = 31;
-/// Merit Internodal
-pub const IPPROTO_INP: ::c_int = 32;
-/// Sequential Exchange
-pub const IPPROTO_SEP: ::c_int = 33;
-/// Third Party Connect
-pub const IPPROTO_3PC: ::c_int = 34;
-/// InterDomain Policy Routing
-pub const IPPROTO_IDPR: ::c_int = 35;
-/// XTP
-pub const IPPROTO_XTP: ::c_int = 36;
-/// Datagram Delivery
-pub const IPPROTO_DDP: ::c_int = 37;
-/// Control Message Transport
-pub const IPPROTO_CMTP: ::c_int = 38;
-/// TP++ Transport
-pub const IPPROTO_TPXX: ::c_int = 39;
-/// IL transport protocol
-pub const IPPROTO_IL: ::c_int = 40;
-// IPPROTO_IPV6 defined in src/unix/mod.rs
-/// Source Demand Routing
-pub const IPPROTO_SDRP: ::c_int = 42;
-/// IP6 routing header
-pub const IPPROTO_ROUTING: ::c_int = 43;
-/// IP6 fragmentation header
-pub const IPPROTO_FRAGMENT: ::c_int = 44;
-/// InterDomain Routing
-pub const IPPROTO_IDRP: ::c_int = 45;
-/// resource reservation
-pub const IPPROTO_RSVP: ::c_int = 46;
-/// General Routing Encap.
-pub const IPPROTO_GRE: ::c_int = 47;
-/// Mobile Host Routing
-pub const IPPROTO_MHRP: ::c_int = 48;
-/// BHA
-pub const IPPROTO_BHA: ::c_int = 49;
-/// IP6 Encap Sec. Payload
-pub const IPPROTO_ESP: ::c_int = 50;
-/// IP6 Auth Header
-pub const IPPROTO_AH: ::c_int = 51;
-/// Integ. Net Layer Security
-pub const IPPROTO_INLSP: ::c_int = 52;
-/// IP with encryption
-pub const IPPROTO_SWIPE: ::c_int = 53;
-/// Next Hop Resolution
-pub const IPPROTO_NHRP: ::c_int = 54;
-/// IP Mobility
-pub const IPPROTO_MOBILE: ::c_int = 55;
-/// Transport Layer Security
-pub const IPPROTO_TLSP: ::c_int = 56;
-/// SKIP
-pub const IPPROTO_SKIP: ::c_int = 57;
-// IPPROTO_ICMPV6 defined in src/unix/mod.rs
-/// IP6 no next header
-pub const IPPROTO_NONE: ::c_int = 59;
-/// IP6 destination option
-pub const IPPROTO_DSTOPTS: ::c_int = 60;
-/// any host internal protocol
-pub const IPPROTO_AHIP: ::c_int = 61;
-/// CFTP
-pub const IPPROTO_CFTP: ::c_int = 62;
-/// "hello" routing protocol
-pub const IPPROTO_HELLO: ::c_int = 63;
-/// SATNET/Backroom EXPAK
-pub const IPPROTO_SATEXPAK: ::c_int = 64;
-/// Kryptolan
-pub const IPPROTO_KRYPTOLAN: ::c_int = 65;
-/// Remote Virtual Disk
-pub const IPPROTO_RVD: ::c_int = 66;
-/// Pluribus Packet Core
-pub const IPPROTO_IPPC: ::c_int = 67;
-/// Any distributed FS
-pub const IPPROTO_ADFS: ::c_int = 68;
-/// Satnet Monitoring
-pub const IPPROTO_SATMON: ::c_int = 69;
-/// VISA Protocol
-pub const IPPROTO_VISA: ::c_int = 70;
-/// Packet Core Utility
-pub const IPPROTO_IPCV: ::c_int = 71;
-/// Comp. Prot. Net. Executive
-pub const IPPROTO_CPNX: ::c_int = 72;
-/// Comp. Prot. HeartBeat
-pub const IPPROTO_CPHB: ::c_int = 73;
-/// Wang Span Network
-pub const IPPROTO_WSN: ::c_int = 74;
-/// Packet Video Protocol
-pub const IPPROTO_PVP: ::c_int = 75;
-/// BackRoom SATNET Monitoring
-pub const IPPROTO_BRSATMON: ::c_int = 76;
-/// Sun net disk proto (temp.)
-pub const IPPROTO_ND: ::c_int = 77;
-/// WIDEBAND Monitoring
-pub const IPPROTO_WBMON: ::c_int = 78;
-/// WIDEBAND EXPAK
-pub const IPPROTO_WBEXPAK: ::c_int = 79;
-/// ISO cnlp
-pub const IPPROTO_EON: ::c_int = 80;
-/// VMTP
-pub const IPPROTO_VMTP: ::c_int = 81;
-/// Secure VMTP
-pub const IPPROTO_SVMTP: ::c_int = 82;
-/// Banyon VINES
-pub const IPPROTO_VINES: ::c_int = 83;
-/// TTP
-pub const IPPROTO_TTP: ::c_int = 84;
-/// NSFNET-IGP
-pub const IPPROTO_IGP: ::c_int = 85;
-/// dissimilar gateway prot.
-pub const IPPROTO_DGP: ::c_int = 86;
-/// TCF
-pub const IPPROTO_TCF: ::c_int = 87;
-/// Cisco/GXS IGRP
-pub const IPPROTO_IGRP: ::c_int = 88;
-/// OSPFIGP
-pub const IPPROTO_OSPFIGP: ::c_int = 89;
-/// Strite RPC protocol
-pub const IPPROTO_SRPC: ::c_int = 90;
-/// Locus Address Resoloution
-pub const IPPROTO_LARP: ::c_int = 91;
-/// Multicast Transport
-pub const IPPROTO_MTP: ::c_int = 92;
-/// AX.25 Frames
-pub const IPPROTO_AX25: ::c_int = 93;
-/// IP encapsulated in IP
-pub const IPPROTO_IPEIP: ::c_int = 94;
-/// Mobile Int.ing control
-pub const IPPROTO_MICP: ::c_int = 95;
-/// Semaphore Comm. security
-pub const IPPROTO_SCCSP: ::c_int = 96;
-/// Ethernet IP encapsulation
-pub const IPPROTO_ETHERIP: ::c_int = 97;
-/// encapsulation header
-pub const IPPROTO_ENCAP: ::c_int = 98;
-/// any private encr. scheme
-pub const IPPROTO_APES: ::c_int = 99;
-/// GMTP
-pub const IPPROTO_GMTP: ::c_int = 100;
-/// payload compression (IPComp)
-pub const IPPROTO_IPCOMP: ::c_int = 108;
-
-/* 101-254: Partly Unassigned */
-/// Protocol Independent Mcast
-pub const IPPROTO_PIM: ::c_int = 103;
-/// CARP
-pub const IPPROTO_CARP: ::c_int = 112;
-/// PGM
-pub const IPPROTO_PGM: ::c_int = 113;
-/// PFSYNC
-pub const IPPROTO_PFSYNC: ::c_int = 240;
-
-/* 255: Reserved */
-/* BSD Private, local use, namespace incursion, no longer used */
-/// divert pseudo-protocol
-pub const IPPROTO_DIVERT: ::c_int = 254;
-pub const IPPROTO_MAX: ::c_int = 256;
-/// last return value of *_input(), meaning "all job for this pkt is done".
-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;
-#[doc(hidden)]
-#[deprecated(
- since = "0.2.55",
- note = "If you are using this report to: \
- https://github.com/rust-lang/libc/issues/665"
-)]
-pub const AF_MAX: ::c_int = 36;
-
-pub const PF_BLUETOOTH: ::c_int = AF_BLUETOOTH;
-#[doc(hidden)]
-#[deprecated(
- since = "0.2.55",
- note = "If you are using this report to: \
- https://github.com/rust-lang/libc/issues/665"
-)]
-#[allow(deprecated)]
-pub const PF_MAX: ::c_int = AF_MAX;
-
-pub const NET_RT_DUMP: ::c_int = 1;
-pub const NET_RT_FLAGS: ::c_int = 2;
-pub const NET_RT_IFLIST: ::c_int = 3;
-pub const NET_RT_MAXID: ::c_int = 4;
-
-pub const SOMAXOPT_SIZE: ::c_int = 65536;
-
-#[doc(hidden)]
-#[deprecated(
- since = "0.2.55",
- note = "If you are using this report to: \
- https://github.com/rust-lang/libc/issues/665"
-)]
-#[allow(deprecated)]
-pub const NET_MAXID: ::c_int = AF_MAX;
-
-pub const MSG_UNUSED09: ::c_int = 0x00000200;
-pub const MSG_NOSIGNAL: ::c_int = 0x00000400;
-pub const MSG_SYNC: ::c_int = 0x00000800;
-pub const MSG_CMSG_CLOEXEC: ::c_int = 0x00001000;
-pub const MSG_FBLOCKING: ::c_int = 0x00010000;
-pub const MSG_FNONBLOCKING: ::c_int = 0x00020000;
-pub const MSG_FMASK: ::c_int = 0xFFFF0000;
-
-pub const EMPTY: ::c_short = 0;
-pub const RUN_LVL: ::c_short = 1;
-pub const BOOT_TIME: ::c_short = 2;
-pub const OLD_TIME: ::c_short = 3;
-pub const NEW_TIME: ::c_short = 4;
-pub const INIT_PROCESS: ::c_short = 5;
-pub const LOGIN_PROCESS: ::c_short = 6;
-pub const USER_PROCESS: ::c_short = 7;
-pub const DEAD_PROCESS: ::c_short = 8;
-
-pub const LC_COLLATE_MASK: ::c_int = (1 << 0);
-pub const LC_CTYPE_MASK: ::c_int = (1 << 1);
-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
- | LC_MONETARY_MASK
- | LC_NUMERIC_MASK
- | LC_TIME_MASK;
-
-pub const TIOCSIG: ::c_uint = 0x2000745f;
-pub const BTUARTDISC: ::c_int = 0x7;
-pub const TIOCDCDTIMESTAMP: ::c_uint = 0x40107458;
-pub const TIOCISPTMASTER: ::c_uint = 0x20007455;
-pub const TIOCMODG: ::c_uint = 0x40047403;
-pub const TIOCMODS: ::c_ulong = 0x80047404;
-pub const TIOCREMOTE: ::c_ulong = 0x80047469;
-
-// Constants used by "at" family of system calls.
-pub const AT_FDCWD: ::c_int = 0xFFFAFDCD; // invalid file descriptor
-pub const AT_SYMLINK_NOFOLLOW: ::c_int = 1;
-pub const AT_REMOVEDIR: ::c_int = 2;
-pub const AT_EACCESS: ::c_int = 4;
-pub const AT_SYMLINK_FOLLOW: ::c_int = 8;
-
-pub const VCHECKPT: usize = 19;
-
-pub const _PC_2_SYMLINKS: ::c_int = 22;
-pub const _PC_TIMESTAMP_RESOLUTION: ::c_int = 23;
-
-pub const _SC_V7_ILP32_OFF32: ::c_int = 122;
-pub const _SC_V7_ILP32_OFFBIG: ::c_int = 123;
-pub const _SC_V7_LP64_OFF64: ::c_int = 124;
-pub const _SC_V7_LPBIG_OFFBIG: ::c_int = 125;
-pub const _SC_THREAD_ROBUST_PRIO_INHERIT: ::c_int = 126;
-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;
-
-fn _CMSG_ALIGN(n: usize) -> usize {
- (n + 3) & !3
-}
-
-f! {
- pub fn CMSG_DATA(cmsg: *const ::cmsghdr) -> *mut ::c_uchar {
- (cmsg as *mut ::c_uchar)
- .offset(_CMSG_ALIGN(::mem::size_of::<::cmsghdr>()) as isize)
- }
-
- pub fn CMSG_LEN(length: ::c_uint) -> ::c_uint {
- (_CMSG_ALIGN(::mem::size_of::<::cmsghdr>()) + length as usize)
- as ::c_uint
- }
-
- pub fn CMSG_NXTHDR(mhdr: *const ::msghdr, cmsg: *const ::cmsghdr)
- -> *mut ::cmsghdr
- {
- let next = cmsg as usize + _CMSG_ALIGN((*cmsg).cmsg_len as usize)
- + _CMSG_ALIGN(::mem::size_of::<::cmsghdr>());
- let max = (*mhdr).msg_control as usize
- + (*mhdr).msg_controllen as usize;
- if next <= max {
- (cmsg as usize + _CMSG_ALIGN((*cmsg).cmsg_len as usize))
- as *mut ::cmsghdr
- } else {
- 0 as *mut ::cmsghdr
- }
- }
-
- pub fn CMSG_SPACE(length: ::c_uint) -> ::c_uint {
- (_CMSG_ALIGN(::mem::size_of::<::cmsghdr>()) +
- _CMSG_ALIGN(length as usize)) as ::c_uint
- }
-}
-
-extern {
- pub fn setgrent();
- pub fn mprotect(addr: *mut ::c_void, len: ::size_t, prot: ::c_int)
- -> ::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_settime(clk_id: ::clockid_t, tp: *const ::timespec) -> ::c_int;
-
- pub fn setutxdb(_type: ::c_uint, file: *mut ::c_char) -> ::c_int;
-
- pub fn aio_waitcomplete(iocbp: *mut *mut aiocb,
- 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;
- pub fn uname(buf: *mut ::utsname) -> ::c_int;
-}
diff --git a/libc/src/unix/bsd/freebsdlike/freebsd/aarch64.rs b/libc/src/unix/bsd/freebsdlike/freebsd/aarch64.rs
deleted file mode 100644
index 22fd2b8..0000000
--- a/libc/src/unix/bsd/freebsdlike/freebsd/aarch64.rs
+++ /dev/null
@@ -1,44 +0,0 @@
-pub type c_char = u8;
-pub type c_long = i64;
-pub type c_ulong = u64;
-pub type time_t = i64;
-pub type suseconds_t = i64;
-
-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,
- 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_size: ::off_t,
- pub st_blocks: ::blkcnt_t,
- pub st_blksize: ::blksize_t,
- pub st_flags: ::fflags_t,
- pub st_gen: u32,
- pub st_lspare: i32,
- pub st_birthtime: ::time_t,
- pub st_birthtime_nsec: ::c_long,
- }
-}
-
-// should be pub(crate), but that requires Rust 1.18.0
-cfg_if! {
- if #[cfg(libc_const_size_of)] {
- #[doc(hidden)]
- pub const _ALIGNBYTES: usize = ::mem::size_of::<::c_longlong>() - 1;
- } else {
- #[doc(hidden)]
- pub const _ALIGNBYTES: usize = 8 - 1;
- }
-}
-
-pub const MAP_32BIT: ::c_int = 0x00080000;
diff --git a/libc/src/unix/bsd/freebsdlike/freebsd/arm.rs b/libc/src/unix/bsd/freebsdlike/freebsd/arm.rs
deleted file mode 100644
index b7480aa..0000000
--- a/libc/src/unix/bsd/freebsdlike/freebsd/arm.rs
+++ /dev/null
@@ -1,47 +0,0 @@
-pub type c_char = u8;
-pub type c_long = i32;
-pub type c_ulong = u32;
-pub type time_t = i64;
-pub type suseconds_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,
- pub st_atime: ::time_t,
- pub st_atime_nsec: ::c_long,
- pub st_atime_pad: ::c_long,
- pub st_mtime: ::time_t,
- pub st_mtime_nsec: ::c_long,
- pub st_mtime_pad: ::c_long,
- pub st_ctime: ::time_t,
- pub st_ctime_nsec: ::c_long,
- pub st_ctime_pad: ::c_long,
- pub st_size: ::off_t,
- pub st_blocks: ::blkcnt_t,
- pub st_blksize: ::blksize_t,
- pub st_flags: ::fflags_t,
- pub st_gen: u32,
- pub st_lspare: i32,
- pub st_birthtime: ::time_t,
- pub st_birthtime_nsec: ::c_long,
- pub st_birthtime_pad: ::c_long,
- }
-}
-
-// should be pub(crate), but that requires Rust 1.18.0
-cfg_if! {
- if #[cfg(libc_const_size_of)] {
- #[doc(hidden)]
- pub const _ALIGNBYTES: usize = ::mem::size_of::<::c_int>() - 1;
- } else {
- #[doc(hidden)]
- pub const _ALIGNBYTES: usize = 4 - 1;
- }
-}
-pub const MAP_32BIT: ::c_int = 0x00080000;
diff --git a/libc/src/unix/bsd/freebsdlike/freebsd/freebsd11/mod.rs b/libc/src/unix/bsd/freebsdlike/freebsd/freebsd11/mod.rs
deleted file mode 100644
index 7d7dc2c..0000000
--- a/libc/src/unix/bsd/freebsdlike/freebsd/freebsd11/mod.rs
+++ /dev/null
@@ -1,214 +0,0 @@
-// APIs that had breaking changes after FreeBSD 11
-
-// The type of `nlink_t` changed from `u16` to `u64` in FreeBSD 12:
-pub type nlink_t = u16;
-// Type of `dev_t` changed from `u32` to `u64` in FreeBSD 12:
-pub type dev_t = u32;
-// Type of `ino_t` changed from `unsigned int` to `unsigned long` in FreeBSD 12:
-pub type ino_t = u32;
-
-s! {
- pub struct kevent {
- pub ident: ::uintptr_t,
- pub filter: ::c_short,
- pub flags: ::c_ushort,
- pub fflags: ::c_uint,
- pub data: ::intptr_t,
- pub udata: *mut ::c_void,
- }
-
- pub struct shmid_ds {
- pub shm_perm: ::ipc_perm,
- pub shm_segsz: ::size_t,
- pub shm_lpid: ::pid_t,
- pub shm_cpid: ::pid_t,
- // Type of shm_nattc changed from `int` to `shmatt_t` (aka `unsigned
- // int`) in FreeBSD 12:
- pub shm_nattch: ::c_int,
- pub shm_atime: ::time_t,
- pub shm_dtime: ::time_t,
- pub shm_ctime: ::time_t,
- }
-}
-
-s_no_extra_traits! {
- pub struct dirent {
- pub d_fileno: ::ino_t,
- pub d_reclen: u16,
- pub d_type: u8,
- // Type of `d_namlen` changed from `char` to `u16` in FreeBSD 12:
- pub d_namlen: u8,
- pub d_name: [::c_char; 256],
- }
-
- pub struct statfs {
- pub f_version: u32,
- pub f_type: u32,
- pub f_flags: u64,
- pub f_bsize: u64,
- pub f_iosize: u64,
- pub f_blocks: u64,
- pub f_bfree: u64,
- pub f_bavail: i64,
- pub f_files: u64,
- pub f_ffree: i64,
- pub f_syncwrites: u64,
- pub f_asyncwrites: u64,
- pub f_syncreads: u64,
- pub f_asyncreads: u64,
- f_spare: [u64; 10],
- pub f_namemax: u32,
- pub f_owner: ::uid_t,
- pub f_fsid: ::fsid_t,
- f_charspare: [::c_char; 80],
- pub f_fstypename: [::c_char; 16],
- // Array length changed from 88 to 1024 in FreeBSD 12:
- pub f_mntfromname: [::c_char; 88],
- // Array length changed from 88 to 1024 in FreeBSD 12:
- pub f_mntonname: [::c_char; 88],
- }
-}
-
-cfg_if! {
- if #[cfg(feature = "extra_traits")] {
- impl PartialEq for statfs {
- fn eq(&self, other: &statfs) -> bool {
- self.f_version == other.f_version
- && self.f_type == other.f_type
- && self.f_flags == other.f_flags
- && self.f_bsize == other.f_bsize
- && self.f_iosize == other.f_iosize
- && self.f_blocks == other.f_blocks
- && self.f_bfree == other.f_bfree
- && self.f_bavail == other.f_bavail
- && self.f_files == other.f_files
- && self.f_ffree == other.f_ffree
- && self.f_syncwrites == other.f_syncwrites
- && self.f_asyncwrites == other.f_asyncwrites
- && self.f_syncreads == other.f_syncreads
- && self.f_asyncreads == other.f_asyncreads
- && self.f_namemax == other.f_namemax
- && self.f_owner == other.f_owner
- && self.f_fsid == other.f_fsid
- && self.f_fstypename == other.f_fstypename
- && self
- .f_mntfromname
- .iter()
- .zip(other.f_mntfromname.iter())
- .all(|(a,b)| a == b)
- && self
- .f_mntonname
- .iter()
- .zip(other.f_mntonname.iter())
- .all(|(a,b)| a == b)
- }
- }
- impl Eq for statfs {}
- impl ::fmt::Debug for statfs {
- fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
- f.debug_struct("statfs")
- .field("f_bsize", &self.f_bsize)
- .field("f_iosize", &self.f_iosize)
- .field("f_blocks", &self.f_blocks)
- .field("f_bfree", &self.f_bfree)
- .field("f_bavail", &self.f_bavail)
- .field("f_files", &self.f_files)
- .field("f_ffree", &self.f_ffree)
- .field("f_syncwrites", &self.f_syncwrites)
- .field("f_asyncwrites", &self.f_asyncwrites)
- .field("f_syncreads", &self.f_syncreads)
- .field("f_asyncreads", &self.f_asyncreads)
- .field("f_namemax", &self.f_namemax)
- .field("f_owner", &self.f_owner)
- .field("f_fsid", &self.f_fsid)
- .field("f_fstypename", &self.f_fstypename)
- .field("f_mntfromname", &&self.f_mntfromname[..])
- .field("f_mntonname", &&self.f_mntonname[..])
- .finish()
- }
- }
- impl ::hash::Hash for statfs {
- fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
- self.f_version.hash(state);
- self.f_type.hash(state);
- self.f_flags.hash(state);
- self.f_bsize.hash(state);
- self.f_iosize.hash(state);
- self.f_blocks.hash(state);
- self.f_bfree.hash(state);
- self.f_bavail.hash(state);
- self.f_files.hash(state);
- self.f_ffree.hash(state);
- self.f_syncwrites.hash(state);
- self.f_asyncwrites.hash(state);
- self.f_syncreads.hash(state);
- self.f_asyncreads.hash(state);
- self.f_namemax.hash(state);
- self.f_owner.hash(state);
- self.f_fsid.hash(state);
- self.f_fstypename.hash(state);
- self.f_mntfromname.hash(state);
- self.f_mntonname.hash(state);
- }
- }
-
- impl PartialEq for dirent {
- fn eq(&self, other: &dirent) -> bool {
- self.d_fileno == other.d_fileno
- && self.d_reclen == other.d_reclen
- && self.d_type == other.d_type
- && self.d_namlen == other.d_namlen
- && self
- .d_name[..self.d_namlen as _]
- .iter()
- .zip(other.d_name.iter())
- .all(|(a,b)| a == b)
- }
- }
- impl Eq for dirent {}
- impl ::fmt::Debug for dirent {
- fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
- f.debug_struct("dirent")
- .field("d_fileno", &self.d_fileno)
- .field("d_reclen", &self.d_reclen)
- .field("d_type", &self.d_type)
- .field("d_namlen", &self.d_namlen)
- .field("d_name", &&self.d_name[..self.d_namlen as _])
- .finish()
- }
- }
- impl ::hash::Hash for dirent {
- fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
- self.d_fileno.hash(state);
- self.d_reclen.hash(state);
- self.d_type.hash(state);
- self.d_namlen.hash(state);
- self.d_name[..self.d_namlen as _].hash(state);
- }
- }
- }
-}
-
-extern {
- // Return type ::c_int was removed in FreeBSD 12
- pub fn setgrent() -> ::c_int;
-
- // Type of `addr` argument changed from `const void*` to `void*`
- // in FreeBSD 12
- pub fn mprotect(addr: *const ::c_void, len: ::size_t, prot: ::c_int)
- -> ::c_int;
-
- // Return type ::c_int was removed in FreeBSD 12
- pub fn freelocale(loc: ::locale_t) -> ::c_int;
-
- // Return type ::c_int changed to ::ssize_t in FreeBSD 12:
- pub fn msgrcv(msqid: ::c_int, msgp: *mut ::c_void, msgsz: ::size_t,
- msgtyp: ::c_long, msgflg: ::c_int) -> ::c_int;
-}
-
-cfg_if! {
- if #[cfg(target_arch = "x86_64")] {
- mod x86_64;
- pub use self::x86_64::*;
- }
-}
diff --git a/libc/src/unix/bsd/freebsdlike/freebsd/freebsd11/x86_64.rs b/libc/src/unix/bsd/freebsdlike/freebsd/freebsd11/x86_64.rs
deleted file mode 100644
index bba277e..0000000
--- a/libc/src/unix/bsd/freebsdlike/freebsd/freebsd11/x86_64.rs
+++ /dev/null
@@ -1,30 +0,0 @@
-#[repr(C)]
-#[cfg_attr(feature = "extra_traits", derive(Debug, Eq, Hash, PartialEq))]
-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_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_size: ::off_t,
- pub st_blocks: ::blkcnt_t,
- pub st_blksize: ::blksize_t,
- pub st_flags: ::fflags_t,
- pub st_gen: u32,
- pub st_lspare: i32,
- pub st_birthtime: ::time_t,
- pub st_birthtime_nsec: ::c_long,
-}
-
-impl ::Copy for ::stat {}
-impl ::Clone for ::stat {
- fn clone(&self) -> ::stat { *self }
-}
diff --git a/libc/src/unix/bsd/freebsdlike/freebsd/freebsd12/mod.rs b/libc/src/unix/bsd/freebsdlike/freebsd/freebsd12/mod.rs
deleted file mode 100644
index ab1b8d9..0000000
--- a/libc/src/unix/bsd/freebsdlike/freebsd/freebsd12/mod.rs
+++ /dev/null
@@ -1,207 +0,0 @@
-// APIs that changed in FreeBSD12
-
-pub type nlink_t = u64;
-pub type dev_t = u64;
-pub type ino_t = ::c_ulong;
-pub type shmatt_t = ::c_uint;
-
-s! {
- 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,
- pub shm_dtime: ::time_t,
- pub shm_ctime: ::time_t,
- }
-
- pub struct kevent {
- pub ident: ::uintptr_t,
- pub filter: ::c_short,
- pub flags: ::c_ushort,
- pub fflags: ::c_uint,
- pub data: ::intptr_t,
- pub udata: *mut ::c_void,
- pub ext: [u64; 4],
- }
-}
-
-s_no_extra_traits! {
- pub struct dirent {
- pub d_fileno: ::ino_t,
- pub d_off: ::off_t,
- pub d_reclen: u16,
- pub d_type: u8,
- d_pad0: u8,
- pub d_namlen: u16,
- d_pad1: u16,
- pub d_name: [::c_char; 256],
- }
-
- pub struct statfs {
- pub f_version: u32,
- pub f_type: u32,
- pub f_flags: u64,
- pub f_bsize: u64,
- pub f_iosize: u64,
- pub f_blocks: u64,
- pub f_bfree: u64,
- pub f_bavail: i64,
- pub f_files: u64,
- pub f_ffree: i64,
- pub f_syncwrites: u64,
- pub f_asyncwrites: u64,
- pub f_syncreads: u64,
- pub f_asyncreads: u64,
- f_spare: [u64; 10],
- pub f_namemax: u32,
- 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; 1024],
- pub f_mntonname: [::c_char; 1024],
- }
-}
-
-cfg_if! {
- if #[cfg(feature = "extra_traits")] {
- impl PartialEq for statfs {
- fn eq(&self, other: &statfs) -> bool {
- self.f_version == other.f_version
- && self.f_type == other.f_type
- && self.f_flags == other.f_flags
- && self.f_bsize == other.f_bsize
- && self.f_iosize == other.f_iosize
- && self.f_blocks == other.f_blocks
- && self.f_bfree == other.f_bfree
- && self.f_bavail == other.f_bavail
- && self.f_files == other.f_files
- && self.f_ffree == other.f_ffree
- && self.f_syncwrites == other.f_syncwrites
- && self.f_asyncwrites == other.f_asyncwrites
- && self.f_syncreads == other.f_syncreads
- && self.f_asyncreads == other.f_asyncreads
- && self.f_namemax == other.f_namemax
- && self.f_owner == other.f_owner
- && self.f_fsid == other.f_fsid
- && self.f_fstypename == other.f_fstypename
- && self
- .f_mntfromname
- .iter()
- .zip(other.f_mntfromname.iter())
- .all(|(a,b)| a == b)
- && self
- .f_mntonname
- .iter()
- .zip(other.f_mntonname.iter())
- .all(|(a,b)| a == b)
- }
- }
- impl Eq for statfs {}
- impl ::fmt::Debug for statfs {
- fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
- f.debug_struct("statfs")
- .field("f_bsize", &self.f_bsize)
- .field("f_iosize", &self.f_iosize)
- .field("f_blocks", &self.f_blocks)
- .field("f_bfree", &self.f_bfree)
- .field("f_bavail", &self.f_bavail)
- .field("f_files", &self.f_files)
- .field("f_ffree", &self.f_ffree)
- .field("f_syncwrites", &self.f_syncwrites)
- .field("f_asyncwrites", &self.f_asyncwrites)
- .field("f_syncreads", &self.f_syncreads)
- .field("f_asyncreads", &self.f_asyncreads)
- .field("f_namemax", &self.f_namemax)
- .field("f_owner", &self.f_owner)
- .field("f_fsid", &self.f_fsid)
- .field("f_fstypename", &self.f_fstypename)
- .field("f_mntfromname", &&self.f_mntfromname[..])
- .field("f_mntonname", &&self.f_mntonname[..])
- .finish()
- }
- }
- impl ::hash::Hash for statfs {
- fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
- self.f_version.hash(state);
- self.f_type.hash(state);
- self.f_flags.hash(state);
- self.f_bsize.hash(state);
- self.f_iosize.hash(state);
- self.f_blocks.hash(state);
- self.f_bfree.hash(state);
- self.f_bavail.hash(state);
- self.f_files.hash(state);
- self.f_ffree.hash(state);
- self.f_syncwrites.hash(state);
- self.f_asyncwrites.hash(state);
- self.f_syncreads.hash(state);
- self.f_asyncreads.hash(state);
- self.f_namemax.hash(state);
- self.f_owner.hash(state);
- self.f_fsid.hash(state);
- self.f_charspare.hash(state);
- self.f_fstypename.hash(state);
- self.f_mntfromname.hash(state);
- self.f_mntonname.hash(state);
- }
- }
-
- impl PartialEq for dirent {
- fn eq(&self, other: &dirent) -> bool {
- self.d_fileno == other.d_fileno
- && self.d_off == other.d_off
- && self.d_reclen == other.d_reclen
- && self.d_type == other.d_type
- && self.d_namlen == other.d_namlen
- && self
- .d_name[..self.d_namlen as _]
- .iter()
- .zip(other.d_name.iter())
- .all(|(a,b)| a == b)
- }
- }
- impl Eq for dirent {}
- impl ::fmt::Debug for dirent {
- fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
- f.debug_struct("dirent")
- .field("d_fileno", &self.d_fileno)
- .field("d_off", &self.d_off)
- .field("d_reclen", &self.d_reclen)
- .field("d_type", &self.d_type)
- .field("d_namlen", &self.d_namlen)
- .field("d_name", &&self.d_name[..self.d_namlen as _])
- .finish()
- }
- }
- impl ::hash::Hash for dirent {
- fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
- self.d_fileno.hash(state);
- self.d_off.hash(state);
- self.d_reclen.hash(state);
- self.d_type.hash(state);
- self.d_namlen.hash(state);
- self.d_name[..self.d_namlen as _].hash(state);
- }
- }
- }
-}
-
-extern {
- pub fn setgrent();
- pub fn mprotect(addr: *mut ::c_void, len: ::size_t, prot: ::c_int)
- -> ::c_int;
- pub fn freelocale(loc: ::locale_t);
- pub fn msgrcv(msqid: ::c_int, msgp: *mut ::c_void, msgsz: ::size_t,
- msgtyp: ::c_long, msgflg: ::c_int) -> ::ssize_t;
-}
-
-cfg_if! {
- if #[cfg(target_arch = "x86_64")] {
- mod x86_64;
- pub use self::x86_64::*;
- }
-}
diff --git a/libc/src/unix/bsd/freebsdlike/freebsd/freebsd12/x86_64.rs b/libc/src/unix/bsd/freebsdlike/freebsd/freebsd12/x86_64.rs
deleted file mode 100644
index dbaa4ae..0000000
--- a/libc/src/unix/bsd/freebsdlike/freebsd/freebsd12/x86_64.rs
+++ /dev/null
@@ -1,32 +0,0 @@
-#[repr(C)]
-#[cfg_attr(feature = "extra_traits", derive(Debug, Eq, Hash, PartialEq))]
-pub struct stat {
- pub st_dev: ::dev_t,
- pub st_ino: ::ino_t,
- pub st_nlink: ::nlink_t,
- pub st_mode: ::mode_t,
- st_padding0: i16,
- pub st_uid: ::uid_t,
- pub st_gid: ::gid_t,
- st_padding1: i32,
- pub st_rdev: ::dev_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_birthtime: ::time_t,
- pub st_birthtime_nsec: ::c_long,
- pub st_size: ::off_t,
- pub st_blocks: ::blkcnt_t,
- pub st_blksize: ::blksize_t,
- pub st_flags: ::fflags_t,
- pub st_gen: u64,
- pub st_spare: [u64; 10],
-}
-
-impl ::Copy for ::stat {}
-impl ::Clone for ::stat {
- fn clone(&self) -> ::stat { *self }
-}
diff --git a/libc/src/unix/bsd/freebsdlike/freebsd/mod.rs b/libc/src/unix/bsd/freebsdlike/freebsd/mod.rs
deleted file mode 100644
index e594551..0000000
--- a/libc/src/unix/bsd/freebsdlike/freebsd/mod.rs
+++ /dev/null
@@ -1,1357 +0,0 @@
-pub type fflags_t = u32;
-pub type clock_t = i32;
-
-pub type lwpid_t = i32;
-pub type blksize_t = i32;
-pub type clockid_t = ::c_int;
-pub type sem_t = _sem;
-
-pub type fsblkcnt_t = u64;
-pub type fsfilcnt_t = u64;
-pub type idtype_t = ::c_uint;
-
-pub type key_t = ::c_long;
-pub type msglen_t = ::c_ulong;
-pub type msgqnum_t = ::c_ulong;
-
-pub type mqd_t = *mut ::c_void;
-pub type posix_spawnattr_t = *mut ::c_void;
-pub type posix_spawn_file_actions_t = *mut ::c_void;
-
-s! {
- pub struct aiocb {
- pub aio_fildes: ::c_int,
- pub aio_offset: ::off_t,
- pub aio_buf: *mut ::c_void,
- pub aio_nbytes: ::size_t,
- __unused1: [::c_int; 2],
- __unused2: *mut ::c_void,
- pub aio_lio_opcode: ::c_int,
- pub aio_reqprio: ::c_int,
- // unused 3 through 5 are the __aiocb_private structure
- __unused3: ::c_long,
- __unused4: ::c_long,
- __unused5: *mut ::c_void,
- pub aio_sigevent: sigevent
- }
-
- pub struct jail {
- pub version: u32,
- pub path: *mut ::c_char,
- pub hostname: *mut ::c_char,
- pub jailname: *mut ::c_char,
- pub ip4s: ::c_uint,
- pub ip6s: ::c_uint,
- pub ip4: *mut ::in_addr,
- pub ip6: *mut ::in6_addr,
- }
-
- pub struct sigevent {
- pub sigev_notify: ::c_int,
- pub sigev_signo: ::c_int,
- pub sigev_value: ::sigval,
- //The rest of the structure is actually a union. We expose only
- //sigev_notify_thread_id because it's the most useful union member.
- pub sigev_notify_thread_id: ::lwpid_t,
- #[cfg(target_pointer_width = "64")]
- __unused1: ::c_int,
- __unused2: [::c_long; 7]
- }
-
- pub struct statvfs {
- pub f_bavail: ::fsblkcnt_t,
- pub f_bfree: ::fsblkcnt_t,
- pub f_blocks: ::fsblkcnt_t,
- pub f_favail: ::fsfilcnt_t,
- pub f_ffree: ::fsfilcnt_t,
- pub f_files: ::fsfilcnt_t,
- pub f_bsize: ::c_ulong,
- pub f_flag: ::c_ulong,
- pub f_frsize: ::c_ulong,
- pub f_fsid: ::c_ulong,
- pub f_namemax: ::c_ulong,
- }
-
- // internal structure has changed over time
- pub struct _sem {
- data: [u32; 4],
- }
-
- pub struct ipc_perm {
- pub cuid: ::uid_t,
- pub cgid: ::gid_t,
- pub uid: ::uid_t,
- pub gid: ::gid_t,
- pub mode: ::mode_t,
- pub seq: ::c_ushort,
- pub key: ::key_t,
- }
-
- pub struct msqid_ds {
- pub msg_perm: ::ipc_perm,
- __unused1: *mut ::c_void,
- __unused2: *mut ::c_void,
- pub msg_cbytes: ::msglen_t,
- pub msg_qnum: ::msgqnum_t,
- pub msg_qbytes: ::msglen_t,
- pub msg_lspid: ::pid_t,
- pub msg_lrpid: ::pid_t,
- pub msg_stime: ::time_t,
- pub msg_rtime: ::time_t,
- pub msg_ctime: ::time_t,
- }
-
- pub struct xucred {
- pub cr_version: ::c_uint,
- pub cr_uid: ::uid_t,
- pub cr_ngroups: ::c_short,
- pub cr_groups: [::gid_t;16],
- __cr_unused1: *mut ::c_void,
- }
-
- pub struct stack_t {
- pub ss_sp: *mut ::c_void,
- pub ss_size: ::size_t,
- pub ss_flags: ::c_int,
- }
-
- pub struct mmsghdr {
- pub msg_hdr: ::msghdr,
- pub msg_len: ::ssize_t,
- }
-}
-
-s_no_extra_traits! {
- pub struct utmpx {
- pub ut_type: ::c_short,
- pub ut_tv: ::timeval,
- pub ut_id: [::c_char; 8],
- pub ut_pid: ::pid_t,
- pub ut_user: [::c_char; 32],
- pub ut_line: [::c_char; 16],
- pub ut_host: [::c_char; 128],
- pub __ut_spare: [::c_char; 64],
- }
-
- pub struct sockaddr_dl {
- pub sdl_len: ::c_uchar,
- pub sdl_family: ::c_uchar,
- pub sdl_index: ::c_ushort,
- pub sdl_type: ::c_uchar,
- pub sdl_nlen: ::c_uchar,
- pub sdl_alen: ::c_uchar,
- pub sdl_slen: ::c_uchar,
- pub sdl_data: [::c_char; 46],
- }
-
- pub struct mq_attr {
- pub mq_flags: ::c_long,
- pub mq_maxmsg: ::c_long,
- pub mq_msgsize: ::c_long,
- pub mq_curmsgs: ::c_long,
- __reserved: [::c_long; 4]
- }
-}
-
-cfg_if! {
- if #[cfg(feature = "extra_traits")] {
- impl PartialEq for utmpx {
- fn eq(&self, other: &utmpx) -> bool {
- self.ut_type == other.ut_type
- && self.ut_tv == other.ut_tv
- && self.ut_id == other.ut_id
- && self.ut_pid == other.ut_pid
- && self.ut_user == other.ut_user
- && self.ut_line == other.ut_line
- && self
- .ut_host
- .iter()
- .zip(other.ut_host.iter())
- .all(|(a,b)| a == b)
- && self
- .__ut_spare
- .iter()
- .zip(other.__ut_spare.iter())
- .all(|(a,b)| a == b)
- }
- }
- impl Eq for utmpx {}
- impl ::fmt::Debug for utmpx {
- fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
- f.debug_struct("utmpx")
- .field("ut_type", &self.ut_type)
- .field("ut_tv", &self.ut_tv)
- .field("ut_id", &self.ut_id)
- .field("ut_pid", &self.ut_pid)
- .field("ut_user", &self.ut_user)
- .field("ut_line", &self.ut_line)
- // FIXME: .field("ut_host", &self.ut_host)
- // FIXME: .field("__ut_spare", &self.__ut_spare)
- .finish()
- }
- }
- impl ::hash::Hash for utmpx {
- fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
- self.ut_type.hash(state);
- self.ut_tv.hash(state);
- self.ut_id.hash(state);
- self.ut_pid.hash(state);
- self.ut_user.hash(state);
- self.ut_line.hash(state);
- self.ut_host.hash(state);
- self.__ut_spare.hash(state);
- }
- }
-
- impl PartialEq for sockaddr_dl {
- fn eq(&self, other: &sockaddr_dl) -> bool {
- self.sdl_len == other.sdl_len
- && self.sdl_family == other.sdl_family
- && self.sdl_index == other.sdl_index
- && self.sdl_type == other.sdl_type
- && self.sdl_nlen == other.sdl_nlen
- && self.sdl_alen == other.sdl_alen
- && self.sdl_slen == other.sdl_slen
- && self
- .sdl_data
- .iter()
- .zip(other.sdl_data.iter())
- .all(|(a,b)| a == b)
- }
- }
- impl Eq for sockaddr_dl {}
- impl ::fmt::Debug for sockaddr_dl {
- fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
- f.debug_struct("sockaddr_dl")
- .field("sdl_len", &self.sdl_len)
- .field("sdl_family", &self.sdl_family)
- .field("sdl_index", &self.sdl_index)
- .field("sdl_type", &self.sdl_type)
- .field("sdl_nlen", &self.sdl_nlen)
- .field("sdl_alen", &self.sdl_alen)
- .field("sdl_slen", &self.sdl_slen)
- // FIXME: .field("sdl_data", &self.sdl_data)
- .finish()
- }
- }
- impl ::hash::Hash for sockaddr_dl {
- fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
- self.sdl_len.hash(state);
- self.sdl_family.hash(state);
- self.sdl_index.hash(state);
- self.sdl_type.hash(state);
- self.sdl_nlen.hash(state);
- self.sdl_alen.hash(state);
- self.sdl_slen.hash(state);
- self.sdl_data.hash(state);
- }
- }
-
- impl PartialEq for mq_attr {
- fn eq(&self, other: &mq_attr) -> bool {
- self.mq_flags == other.mq_flags &&
- self.mq_maxmsg == other.mq_maxmsg &&
- self.mq_msgsize == other.mq_msgsize &&
- self.mq_curmsgs == other.mq_curmsgs
- }
- }
- impl Eq for mq_attr {}
- impl ::fmt::Debug for mq_attr {
- fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
- f.debug_struct("mq_attr")
- .field("mq_flags", &self.mq_flags)
- .field("mq_maxmsg", &self.mq_maxmsg)
- .field("mq_msgsize", &self.mq_msgsize)
- .field("mq_curmsgs", &self.mq_curmsgs)
- .finish()
- }
- }
- impl ::hash::Hash for mq_attr {
- fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
- self.mq_flags.hash(state);
- self.mq_maxmsg.hash(state);
- self.mq_msgsize.hash(state);
- self.mq_curmsgs.hash(state);
- }
- }
- }
-}
-
-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;
-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;
-pub const O_TTY_INIT: ::c_int = 0x00080000;
-pub const F_GETLK: ::c_int = 11;
-pub const F_SETLK: ::c_int = 12;
-pub const F_SETLKW: ::c_int = 13;
-pub const ENOTCAPABLE: ::c_int = 93;
-pub const ECAPMODE: ::c_int = 94;
-pub const ENOTRECOVERABLE: ::c_int = 95;
-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 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;
-
-pub const POSIX_FADV_NORMAL: ::c_int = 0;
-pub const POSIX_FADV_RANDOM: ::c_int = 1;
-pub const POSIX_FADV_SEQUENTIAL: ::c_int = 2;
-pub const POSIX_FADV_WILLNEED: ::c_int = 3;
-pub const POSIX_FADV_DONTNEED: ::c_int = 4;
-pub const POSIX_FADV_NOREUSE: ::c_int = 5;
-
-pub const POLLINIGNEOF: ::c_short = 0x2000;
-
-pub const EVFILT_READ: i16 = -1;
-pub const EVFILT_WRITE: i16 = -2;
-pub const EVFILT_AIO: i16 = -3;
-pub const EVFILT_VNODE: i16 = -4;
-pub const EVFILT_PROC: i16 = -5;
-pub const EVFILT_SIGNAL: i16 = -6;
-pub const EVFILT_TIMER: i16 = -7;
-pub const EVFILT_PROCDESC: i16 = -8;
-pub const EVFILT_FS: i16 = -9;
-pub const EVFILT_LIO: i16 = -10;
-pub const EVFILT_USER: i16 = -11;
-pub const EVFILT_SENDFILE: i16 = -12;
-pub const EVFILT_EMPTY: i16 = -13;
-
-pub const EV_ADD: u16 = 0x1;
-pub const EV_DELETE: u16 = 0x2;
-pub const EV_ENABLE: u16 = 0x4;
-pub const EV_DISABLE: u16 = 0x8;
-pub const EV_ONESHOT: u16 = 0x10;
-pub const EV_CLEAR: u16 = 0x20;
-pub const EV_RECEIPT: u16 = 0x40;
-pub const EV_DISPATCH: u16 = 0x80;
-pub const EV_DROP: u16 = 0x1000;
-pub const EV_FLAG1: u16 = 0x2000;
-pub const EV_ERROR: u16 = 0x4000;
-pub const EV_EOF: u16 = 0x8000;
-pub const EV_SYSFLAGS: u16 = 0xf000;
-
-pub const NOTE_TRIGGER: u32 = 0x01000000;
-pub const NOTE_FFNOP: u32 = 0x00000000;
-pub const NOTE_FFAND: u32 = 0x40000000;
-pub const NOTE_FFOR: u32 = 0x80000000;
-pub const NOTE_FFCOPY: u32 = 0xc0000000;
-pub const NOTE_FFCTRLMASK: u32 = 0xc0000000;
-pub const NOTE_FFLAGSMASK: u32 = 0x00ffffff;
-pub const NOTE_LOWAT: u32 = 0x00000001;
-pub const NOTE_DELETE: u32 = 0x00000001;
-pub const NOTE_WRITE: u32 = 0x00000002;
-pub const NOTE_EXTEND: u32 = 0x00000004;
-pub const NOTE_ATTRIB: u32 = 0x00000008;
-pub const NOTE_LINK: u32 = 0x00000010;
-pub const NOTE_RENAME: u32 = 0x00000020;
-pub const NOTE_REVOKE: u32 = 0x00000040;
-pub const NOTE_EXIT: u32 = 0x80000000;
-pub const NOTE_FORK: u32 = 0x40000000;
-pub const NOTE_EXEC: u32 = 0x20000000;
-pub const NOTE_PDATAMASK: u32 = 0x000fffff;
-pub const NOTE_PCTRLMASK: u32 = 0xf0000000;
-pub const NOTE_TRACK: u32 = 0x00000001;
-pub const NOTE_TRACKERR: u32 = 0x00000002;
-pub const NOTE_CHILD: u32 = 0x00000004;
-pub const NOTE_SECONDS: u32 = 0x00000001;
-pub const NOTE_MSECONDS: u32 = 0x00000002;
-pub const NOTE_USECONDS: u32 = 0x00000004;
-pub const NOTE_NSECONDS: u32 = 0x00000008;
-
-pub const MADV_PROTECT: ::c_int = 10;
-pub const RUSAGE_THREAD: ::c_int = 1;
-
-pub const CLOCK_REALTIME: ::clockid_t = 0;
-pub const CLOCK_VIRTUAL: ::clockid_t = 1;
-pub const CLOCK_PROF: ::clockid_t = 2;
-pub const CLOCK_MONOTONIC: ::clockid_t = 4;
-pub const CLOCK_UPTIME: ::clockid_t = 5;
-pub const CLOCK_UPTIME_PRECISE: ::clockid_t = 7;
-pub const CLOCK_UPTIME_FAST: ::clockid_t = 8;
-pub const CLOCK_REALTIME_PRECISE: ::clockid_t = 9;
-pub const CLOCK_REALTIME_FAST: ::clockid_t = 10;
-pub const CLOCK_MONOTONIC_PRECISE: ::clockid_t = 11;
-pub const CLOCK_MONOTONIC_FAST: ::clockid_t = 12;
-pub const CLOCK_SECOND: ::clockid_t = 13;
-pub const CLOCK_THREAD_CPUTIME_ID: ::clockid_t = 14;
-pub const CLOCK_PROCESS_CPUTIME_ID: ::clockid_t = 15;
-
-pub const CTL_UNSPEC: ::c_int = 0;
-pub const CTL_KERN: ::c_int = 1;
-pub const CTL_VM: ::c_int = 2;
-pub const CTL_VFS: ::c_int = 3;
-pub const CTL_NET: ::c_int = 4;
-pub const CTL_DEBUG: ::c_int = 5;
-pub const CTL_HW: ::c_int = 6;
-pub const CTL_MACHDEP: ::c_int = 7;
-pub const CTL_USER: ::c_int = 8;
-pub const CTL_P1003_1B: ::c_int = 9;
-pub const KERN_OSTYPE: ::c_int = 1;
-pub const KERN_OSRELEASE: ::c_int = 2;
-pub const KERN_OSREV: ::c_int = 3;
-pub const KERN_VERSION: ::c_int = 4;
-pub const KERN_MAXVNODES: ::c_int = 5;
-pub const KERN_MAXPROC: ::c_int = 6;
-pub const KERN_MAXFILES: ::c_int = 7;
-pub const KERN_ARGMAX: ::c_int = 8;
-pub const KERN_SECURELVL: ::c_int = 9;
-pub const KERN_HOSTNAME: ::c_int = 10;
-pub const KERN_HOSTID: ::c_int = 11;
-pub const KERN_CLOCKRATE: ::c_int = 12;
-pub const KERN_VNODE: ::c_int = 13;
-pub const KERN_PROC: ::c_int = 14;
-pub const KERN_FILE: ::c_int = 15;
-pub const KERN_PROF: ::c_int = 16;
-pub const KERN_POSIX1: ::c_int = 17;
-pub const KERN_NGROUPS: ::c_int = 18;
-pub const KERN_JOB_CONTROL: ::c_int = 19;
-pub const KERN_SAVED_IDS: ::c_int = 20;
-pub const KERN_BOOTTIME: ::c_int = 21;
-pub const KERN_NISDOMAINNAME: ::c_int = 22;
-pub const KERN_UPDATEINTERVAL: ::c_int = 23;
-pub const KERN_OSRELDATE: ::c_int = 24;
-pub const KERN_NTP_PLL: ::c_int = 25;
-pub const KERN_BOOTFILE: ::c_int = 26;
-pub const KERN_MAXFILESPERPROC: ::c_int = 27;
-pub const KERN_MAXPROCPERUID: ::c_int = 28;
-pub const KERN_DUMPDEV: ::c_int = 29;
-pub const KERN_IPC: ::c_int = 30;
-pub const KERN_DUMMY: ::c_int = 31;
-pub const KERN_PS_STRINGS: ::c_int = 32;
-pub const KERN_USRSTACK: ::c_int = 33;
-pub const KERN_LOGSIGEXIT: ::c_int = 34;
-pub const KERN_IOV_MAX: ::c_int = 35;
-pub const KERN_HOSTUUID: ::c_int = 36;
-pub const KERN_ARND: ::c_int = 37;
-pub const KERN_PROC_ALL: ::c_int = 0;
-pub const KERN_PROC_PID: ::c_int = 1;
-pub const KERN_PROC_PGRP: ::c_int = 2;
-pub const KERN_PROC_SESSION: ::c_int = 3;
-pub const KERN_PROC_TTY: ::c_int = 4;
-pub const KERN_PROC_UID: ::c_int = 5;
-pub const KERN_PROC_RUID: ::c_int = 6;
-pub const KERN_PROC_ARGS: ::c_int = 7;
-pub const KERN_PROC_PROC: ::c_int = 8;
-pub const KERN_PROC_SV_NAME: ::c_int = 9;
-pub const KERN_PROC_RGID: ::c_int = 10;
-pub const KERN_PROC_GID: ::c_int = 11;
-pub const KERN_PROC_PATHNAME: ::c_int = 12;
-pub const KERN_PROC_OVMMAP: ::c_int = 13;
-pub const KERN_PROC_OFILEDESC: ::c_int = 14;
-pub const KERN_PROC_KSTACK: ::c_int = 15;
-pub const KERN_PROC_INC_THREAD: ::c_int = 0x10;
-pub const KERN_PROC_VMMAP: ::c_int = 32;
-pub const KERN_PROC_FILEDESC: ::c_int = 33;
-pub const KERN_PROC_GROUPS: ::c_int = 34;
-pub const KERN_PROC_ENV: ::c_int = 35;
-pub const KERN_PROC_AUXV: ::c_int = 36;
-pub const KERN_PROC_RLIMIT: ::c_int = 37;
-pub const KERN_PROC_PS_STRINGS: ::c_int = 38;
-pub const KERN_PROC_UMASK: ::c_int = 39;
-pub const KERN_PROC_OSREL: ::c_int = 40;
-pub const KERN_PROC_SIGTRAMP: ::c_int = 41;
-pub const KIPC_MAXSOCKBUF: ::c_int = 1;
-pub const KIPC_SOCKBUF_WASTE: ::c_int = 2;
-pub const KIPC_SOMAXCONN: ::c_int = 3;
-pub const KIPC_MAX_LINKHDR: ::c_int = 4;
-pub const KIPC_MAX_PROTOHDR: ::c_int = 5;
-pub const KIPC_MAX_HDR: ::c_int = 6;
-pub const KIPC_MAX_DATALEN: ::c_int = 7;
-pub const HW_MACHINE: ::c_int = 1;
-pub const HW_MODEL: ::c_int = 2;
-pub const HW_NCPU: ::c_int = 3;
-pub const HW_BYTEORDER: ::c_int = 4;
-pub const HW_PHYSMEM: ::c_int = 5;
-pub const HW_USERMEM: ::c_int = 6;
-pub const HW_PAGESIZE: ::c_int = 7;
-pub const HW_DISKNAMES: ::c_int = 8;
-pub const HW_DISKSTATS: ::c_int = 9;
-pub const HW_FLOATINGPT: ::c_int = 10;
-pub const HW_MACHINE_ARCH: ::c_int = 11;
-pub const HW_REALMEM: ::c_int = 12;
-pub const USER_CS_PATH: ::c_int = 1;
-pub const USER_BC_BASE_MAX: ::c_int = 2;
-pub const USER_BC_DIM_MAX: ::c_int = 3;
-pub const USER_BC_SCALE_MAX: ::c_int = 4;
-pub const USER_BC_STRING_MAX: ::c_int = 5;
-pub const USER_COLL_WEIGHTS_MAX: ::c_int = 6;
-pub const USER_EXPR_NEST_MAX: ::c_int = 7;
-pub const USER_LINE_MAX: ::c_int = 8;
-pub const USER_RE_DUP_MAX: ::c_int = 9;
-pub const USER_POSIX2_VERSION: ::c_int = 10;
-pub const USER_POSIX2_C_BIND: ::c_int = 11;
-pub const USER_POSIX2_C_DEV: ::c_int = 12;
-pub const USER_POSIX2_CHAR_TERM: ::c_int = 13;
-pub const USER_POSIX2_FORT_DEV: ::c_int = 14;
-pub const USER_POSIX2_FORT_RUN: ::c_int = 15;
-pub const USER_POSIX2_LOCALEDEF: ::c_int = 16;
-pub const USER_POSIX2_SW_DEV: ::c_int = 17;
-pub const USER_POSIX2_UPE: ::c_int = 18;
-pub const USER_STREAM_MAX: ::c_int = 19;
-pub const USER_TZNAME_MAX: ::c_int = 20;
-pub const CTL_P1003_1B_ASYNCHRONOUS_IO: ::c_int = 1;
-pub const CTL_P1003_1B_MAPPED_FILES: ::c_int = 2;
-pub const CTL_P1003_1B_MEMLOCK: ::c_int = 3;
-pub const CTL_P1003_1B_MEMLOCK_RANGE: ::c_int = 4;
-pub const CTL_P1003_1B_MEMORY_PROTECTION: ::c_int = 5;
-pub const CTL_P1003_1B_MESSAGE_PASSING: ::c_int = 6;
-pub const CTL_P1003_1B_PRIORITIZED_IO: ::c_int = 7;
-pub const CTL_P1003_1B_PRIORITY_SCHEDULING: ::c_int = 8;
-pub const CTL_P1003_1B_REALTIME_SIGNALS: ::c_int = 9;
-pub const CTL_P1003_1B_SEMAPHORES: ::c_int = 10;
-pub const CTL_P1003_1B_FSYNC: ::c_int = 11;
-pub const CTL_P1003_1B_SHARED_MEMORY_OBJECTS: ::c_int = 12;
-pub const CTL_P1003_1B_SYNCHRONIZED_IO: ::c_int = 13;
-pub const CTL_P1003_1B_TIMERS: ::c_int = 14;
-pub const CTL_P1003_1B_AIO_LISTIO_MAX: ::c_int = 15;
-pub const CTL_P1003_1B_AIO_MAX: ::c_int = 16;
-pub const CTL_P1003_1B_AIO_PRIO_DELTA_MAX: ::c_int = 17;
-pub const CTL_P1003_1B_DELAYTIMER_MAX: ::c_int = 18;
-pub const CTL_P1003_1B_MQ_OPEN_MAX: ::c_int = 19;
-pub const CTL_P1003_1B_PAGESIZE: ::c_int = 20;
-pub const CTL_P1003_1B_RTSIG_MAX: ::c_int = 21;
-pub const CTL_P1003_1B_SEM_NSEMS_MAX: ::c_int = 22;
-pub const CTL_P1003_1B_SEM_VALUE_MAX: ::c_int = 23;
-pub const CTL_P1003_1B_SIGQUEUE_MAX: ::c_int = 24;
-pub const CTL_P1003_1B_TIMER_MAX: ::c_int = 25;
-pub const TIOCGPTN: ::c_uint = 0x4004740f;
-pub const TIOCPTMASTER: ::c_uint = 0x2000741c;
-pub const TIOCSIG: ::c_uint = 0x2004745f;
-pub const TIOCM_DCD: ::c_int = 0x40;
-pub const H4DISC: ::c_int = 0x7;
-
-pub const FIONCLEX: ::c_ulong = 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 FIOGETLBA: ::c_ulong = 0x40046679;
-pub const FIODGNAME: ::c_ulong = 0x80106678;
-pub const FIONWRITE: ::c_ulong = 0x40046677;
-pub const FIONSPACE: ::c_ulong = 0x40046676;
-pub const FIOSEEKDATA: ::c_ulong = 0xc0086661;
-pub const FIOSEEKHOLE: ::c_ulong = 0xc0086662;
-
-pub const JAIL_API_VERSION: u32 = 2;
-pub const JAIL_CREATE: ::c_int = 0x01;
-pub const JAIL_UPDATE: ::c_int = 0x02;
-pub const JAIL_ATTACH: ::c_int = 0x04;
-pub const JAIL_DYING: ::c_int = 0x08;
-pub const JAIL_SET_MASK: ::c_int = 0x0f;
-pub const JAIL_GET_MASK: ::c_int = 0x08;
-pub const JAIL_SYS_DISABLE: ::c_int = 0;
-pub const JAIL_SYS_NEW: ::c_int = 1;
-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;
-pub const SO_LISTENQLEN: ::c_int = 0x1012;
-pub const SO_LISTENINCQLEN: ::c_int = 0x1013;
-pub const SO_SETFIB: ::c_int = 0x1014;
-pub const SO_USER_COOKIE: ::c_int = 0x1015;
-pub const SO_PROTOCOL: ::c_int = 0x1016;
-pub const SO_PROTOTYPE: ::c_int = SO_PROTOCOL;
-pub const SO_VENDOR: ::c_int = 0x80000000;
-
-pub const LOCAL_PEERCRED: ::c_int = 1;
-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;
-pub const AF_BLUETOOTH: ::c_int = 36;
-pub const AF_IEEE80211: ::c_int = 37;
-pub const AF_INET_SDP: ::c_int = 40;
-pub const AF_INET6_SDP: ::c_int = 42;
-#[doc(hidden)]
-#[deprecated(
- since = "0.2.55",
- note = "If you are using this report to: \
- https://github.com/rust-lang/libc/issues/665"
-)]
-pub const AF_MAX: ::c_int = 42;
-
-// https://github.com/freebsd/freebsd/blob/master/sys/net/if.h#L140
-pub const IFF_UP: ::c_int = 0x1; // (n) interface is up
-pub const IFF_BROADCAST: ::c_int = 0x2; // (i) broadcast address valid
-pub const IFF_DEBUG: ::c_int = 0x4; // (n) turn on debugging
-pub const IFF_LOOPBACK: ::c_int = 0x8; // (i) is a loopback net
-pub const IFF_POINTOPOINT: ::c_int = 0x10; // (i) is a point-to-point link
-// 0x20 was IFF_SMART
-pub const IFF_RUNNING: ::c_int = 0x40; // (d) resources allocated
-#[doc(hidden)]
-#[deprecated(
- since="0.2.54",
- note="IFF_DRV_RUNNING is deprecated. Use the portable IFF_RUNNING instead"
-)]
-pub const IFF_DRV_RUNNING: ::c_int = 0x40;
-pub const IFF_NOARP: ::c_int = 0x80; // (n) no address resolution protocol
-pub const IFF_PROMISC: ::c_int = 0x100; // (n) receive all packets
-pub const IFF_ALLMULTI: ::c_int = 0x200; // (n) receive all multicast packets
-pub const IFF_OACTIVE: ::c_int = 0x400; // (d) tx hardware queue is full
-#[doc(hidden)]
-#[deprecated(
- since = "0.2.54",
- note = "Use the portable `IFF_OACTIVE` instead",
-)]
-pub const IFF_DRV_OACTIVE: ::c_int = 0x400;
-pub const IFF_SIMPLEX: ::c_int = 0x800; // (i) 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_ALTPHYS: ::c_int = IFF_LINK2; // use alternate physical connection
-pub const IFF_MULTICAST: ::c_int = 0x8000; // (i) supports multicast
-// (i) unconfigurable using ioctl(2)
-pub const IFF_CANTCONFIG: ::c_int = 0x10000;
-pub const IFF_PPROMISC: ::c_int = 0x20000; // (n) user-requested promisc mode
-pub const IFF_MONITOR: ::c_int = 0x40000; // (n) user-requested monitor mode
-pub const IFF_STATICARP: ::c_int = 0x80000; // (n) static ARP
-pub const IFF_DYING: ::c_int = 0x200000; // (n) interface is winding down
-pub const IFF_RENAMING: ::c_int = 0x400000; // (n) interface is being renamed
-
-// sys/netinet/in.h
-// Protocols (RFC 1700)
-// NOTE: These are in addition to the constants defined in src/unix/mod.rs
-
-// IPPROTO_IP defined in src/unix/mod.rs
-/// IP6 hop-by-hop options
-pub const IPPROTO_HOPOPTS: ::c_int = 0;
-// IPPROTO_ICMP defined in src/unix/mod.rs
-/// group mgmt protocol
-pub const IPPROTO_IGMP: ::c_int = 2;
-/// gateway^2 (deprecated)
-pub const IPPROTO_GGP: ::c_int = 3;
-/// for compatibility
-pub const IPPROTO_IPIP: ::c_int = 4;
-// IPPROTO_TCP defined in src/unix/mod.rs
-/// Stream protocol II.
-pub const IPPROTO_ST: ::c_int = 7;
-/// exterior gateway protocol
-pub const IPPROTO_EGP: ::c_int = 8;
-/// private interior gateway
-pub const IPPROTO_PIGP: ::c_int = 9;
-/// BBN RCC Monitoring
-pub const IPPROTO_RCCMON: ::c_int = 10;
-/// network voice protocol
-pub const IPPROTO_NVPII: ::c_int = 11;
-/// pup
-pub const IPPROTO_PUP: ::c_int = 12;
-/// Argus
-pub const IPPROTO_ARGUS: ::c_int = 13;
-/// EMCON
-pub const IPPROTO_EMCON: ::c_int = 14;
-/// Cross Net Debugger
-pub const IPPROTO_XNET: ::c_int = 15;
-/// Chaos
-pub const IPPROTO_CHAOS: ::c_int = 16;
-// IPPROTO_UDP defined in src/unix/mod.rs
-/// Multiplexing
-pub const IPPROTO_MUX: ::c_int = 18;
-/// DCN Measurement Subsystems
-pub const IPPROTO_MEAS: ::c_int = 19;
-/// Host Monitoring
-pub const IPPROTO_HMP: ::c_int = 20;
-/// Packet Radio Measurement
-pub const IPPROTO_PRM: ::c_int = 21;
-/// xns idp
-pub const IPPROTO_IDP: ::c_int = 22;
-/// Trunk-1
-pub const IPPROTO_TRUNK1: ::c_int = 23;
-/// Trunk-2
-pub const IPPROTO_TRUNK2: ::c_int = 24;
-/// Leaf-1
-pub const IPPROTO_LEAF1: ::c_int = 25;
-/// Leaf-2
-pub const IPPROTO_LEAF2: ::c_int = 26;
-/// Reliable Data
-pub const IPPROTO_RDP: ::c_int = 27;
-/// Reliable Transaction
-pub const IPPROTO_IRTP: ::c_int = 28;
-/// tp-4 w/ class negotiation
-pub const IPPROTO_TP: ::c_int = 29;
-/// Bulk Data Transfer
-pub const IPPROTO_BLT: ::c_int = 30;
-/// Network Services
-pub const IPPROTO_NSP: ::c_int = 31;
-/// Merit Internodal
-pub const IPPROTO_INP: ::c_int = 32;
-/// Sequential Exchange
-pub const IPPROTO_SEP: ::c_int = 33;
-/// Third Party Connect
-pub const IPPROTO_3PC: ::c_int = 34;
-/// InterDomain Policy Routing
-pub const IPPROTO_IDPR: ::c_int = 35;
-/// XTP
-pub const IPPROTO_XTP: ::c_int = 36;
-/// Datagram Delivery
-pub const IPPROTO_DDP: ::c_int = 37;
-/// Control Message Transport
-pub const IPPROTO_CMTP: ::c_int = 38;
-/// TP++ Transport
-pub const IPPROTO_TPXX: ::c_int = 39;
-/// IL transport protocol
-pub const IPPROTO_IL: ::c_int = 40;
-// IPPROTO_IPV6 defined in src/unix/mod.rs
-/// Source Demand Routing
-pub const IPPROTO_SDRP: ::c_int = 42;
-/// IP6 routing header
-pub const IPPROTO_ROUTING: ::c_int = 43;
-/// IP6 fragmentation header
-pub const IPPROTO_FRAGMENT: ::c_int = 44;
-/// InterDomain Routing
-pub const IPPROTO_IDRP: ::c_int = 45;
-/// resource reservation
-pub const IPPROTO_RSVP: ::c_int = 46;
-/// General Routing Encap.
-pub const IPPROTO_GRE: ::c_int = 47;
-/// Mobile Host Routing
-pub const IPPROTO_MHRP: ::c_int = 48;
-/// BHA
-pub const IPPROTO_BHA: ::c_int = 49;
-/// IP6 Encap Sec. Payload
-pub const IPPROTO_ESP: ::c_int = 50;
-/// IP6 Auth Header
-pub const IPPROTO_AH: ::c_int = 51;
-/// Integ. Net Layer Security
-pub const IPPROTO_INLSP: ::c_int = 52;
-/// IP with encryption
-pub const IPPROTO_SWIPE: ::c_int = 53;
-/// Next Hop Resolution
-pub const IPPROTO_NHRP: ::c_int = 54;
-/// IP Mobility
-pub const IPPROTO_MOBILE: ::c_int = 55;
-/// Transport Layer Security
-pub const IPPROTO_TLSP: ::c_int = 56;
-/// SKIP
-pub const IPPROTO_SKIP: ::c_int = 57;
-// IPPROTO_ICMPV6 defined in src/unix/mod.rs
-/// IP6 no next header
-pub const IPPROTO_NONE: ::c_int = 59;
-/// IP6 destination option
-pub const IPPROTO_DSTOPTS: ::c_int = 60;
-/// any host internal protocol
-pub const IPPROTO_AHIP: ::c_int = 61;
-/// CFTP
-pub const IPPROTO_CFTP: ::c_int = 62;
-/// "hello" routing protocol
-pub const IPPROTO_HELLO: ::c_int = 63;
-/// SATNET/Backroom EXPAK
-pub const IPPROTO_SATEXPAK: ::c_int = 64;
-/// Kryptolan
-pub const IPPROTO_KRYPTOLAN: ::c_int = 65;
-/// Remote Virtual Disk
-pub const IPPROTO_RVD: ::c_int = 66;
-/// Pluribus Packet Core
-pub const IPPROTO_IPPC: ::c_int = 67;
-/// Any distributed FS
-pub const IPPROTO_ADFS: ::c_int = 68;
-/// Satnet Monitoring
-pub const IPPROTO_SATMON: ::c_int = 69;
-/// VISA Protocol
-pub const IPPROTO_VISA: ::c_int = 70;
-/// Packet Core Utility
-pub const IPPROTO_IPCV: ::c_int = 71;
-/// Comp. Prot. Net. Executive
-pub const IPPROTO_CPNX: ::c_int = 72;
-/// Comp. Prot. HeartBeat
-pub const IPPROTO_CPHB: ::c_int = 73;
-/// Wang Span Network
-pub const IPPROTO_WSN: ::c_int = 74;
-/// Packet Video Protocol
-pub const IPPROTO_PVP: ::c_int = 75;
-/// BackRoom SATNET Monitoring
-pub const IPPROTO_BRSATMON: ::c_int = 76;
-/// Sun net disk proto (temp.)
-pub const IPPROTO_ND: ::c_int = 77;
-/// WIDEBAND Monitoring
-pub const IPPROTO_WBMON: ::c_int = 78;
-/// WIDEBAND EXPAK
-pub const IPPROTO_WBEXPAK: ::c_int = 79;
-/// ISO cnlp
-pub const IPPROTO_EON: ::c_int = 80;
-/// VMTP
-pub const IPPROTO_VMTP: ::c_int = 81;
-/// Secure VMTP
-pub const IPPROTO_SVMTP: ::c_int = 82;
-/// Banyon VINES
-pub const IPPROTO_VINES: ::c_int = 83;
-/// TTP
-pub const IPPROTO_TTP: ::c_int = 84;
-/// NSFNET-IGP
-pub const IPPROTO_IGP: ::c_int = 85;
-/// dissimilar gateway prot.
-pub const IPPROTO_DGP: ::c_int = 86;
-/// TCF
-pub const IPPROTO_TCF: ::c_int = 87;
-/// Cisco/GXS IGRP
-pub const IPPROTO_IGRP: ::c_int = 88;
-/// OSPFIGP
-pub const IPPROTO_OSPFIGP: ::c_int = 89;
-/// Strite RPC protocol
-pub const IPPROTO_SRPC: ::c_int = 90;
-/// Locus Address Resoloution
-pub const IPPROTO_LARP: ::c_int = 91;
-/// Multicast Transport
-pub const IPPROTO_MTP: ::c_int = 92;
-/// AX.25 Frames
-pub const IPPROTO_AX25: ::c_int = 93;
-/// IP encapsulated in IP
-pub const IPPROTO_IPEIP: ::c_int = 94;
-/// Mobile Int.ing control
-pub const IPPROTO_MICP: ::c_int = 95;
-/// Semaphore Comm. security
-pub const IPPROTO_SCCSP: ::c_int = 96;
-/// Ethernet IP encapsulation
-pub const IPPROTO_ETHERIP: ::c_int = 97;
-/// encapsulation header
-pub const IPPROTO_ENCAP: ::c_int = 98;
-/// any private encr. scheme
-pub const IPPROTO_APES: ::c_int = 99;
-/// GMTP
-pub const IPPROTO_GMTP: ::c_int = 100;
-/// payload compression (IPComp)
-pub const IPPROTO_IPCOMP: ::c_int = 108;
-/// SCTP
-pub const IPPROTO_SCTP: ::c_int = 132;
-/// IPv6 Mobility Header
-pub const IPPROTO_MH: ::c_int = 135;
-/// UDP-Lite
-pub const IPPROTO_UDPLITE: ::c_int = 136;
-/// IP6 Host Identity Protocol
-pub const IPPROTO_HIP: ::c_int = 139;
-/// IP6 Shim6 Protocol
-pub const IPPROTO_SHIM6: ::c_int = 140;
-
-/* 101-254: Partly Unassigned */
-/// Protocol Independent Mcast
-pub const IPPROTO_PIM: ::c_int = 103;
-/// CARP
-pub const IPPROTO_CARP: ::c_int = 112;
-/// PGM
-pub const IPPROTO_PGM: ::c_int = 113;
-/// MPLS-in-IP
-pub const IPPROTO_MPLS: ::c_int = 137;
-/// PFSYNC
-pub const IPPROTO_PFSYNC: ::c_int = 240;
-
-/* 255: Reserved */
-/* BSD Private, local use, namespace incursion, no longer used */
-/// OLD divert pseudo-proto
-pub const IPPROTO_OLD_DIVERT: ::c_int = 254;
-pub const IPPROTO_MAX: ::c_int = 256;
-/// last return value of *_input(), meaning "all job for this pkt is done".
-pub const IPPROTO_DONE: ::c_int = 257;
-
-/* Only used internally, so can be outside the range of valid IP protocols. */
-/// divert pseudo-protocol
-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 IP_BINDMULTI: ::c_int = 25;
-pub const IP_RSS_LISTEN_BUCKET: ::c_int = 26;
-pub const IP_ORIGDSTADDR : ::c_int = 27;
-pub const IP_RECVORIGDSTADDR : ::c_int = IP_ORIGDSTADDR;
-
-pub const IP_RECVTOS: ::c_int = 68;
-
-pub const IPV6_ORIGDSTADDR: ::c_int = 72;
-pub const IPV6_RECVORIGDSTADDR: ::c_int = IPV6_ORIGDSTADDR;
-
-pub const PF_SLOW: ::c_int = AF_SLOW;
-pub const PF_SCLUSTER: ::c_int = AF_SCLUSTER;
-pub const PF_ARP: ::c_int = AF_ARP;
-pub const PF_BLUETOOTH: ::c_int = AF_BLUETOOTH;
-pub const PF_IEEE80211: ::c_int = AF_IEEE80211;
-pub const PF_INET_SDP: ::c_int = AF_INET_SDP;
-pub const PF_INET6_SDP: ::c_int = AF_INET6_SDP;
-#[doc(hidden)]
-#[deprecated(
- since = "0.2.55",
- note = "If you are using this report to: \
- https://github.com/rust-lang/libc/issues/665"
-)]
-#[allow(deprecated)]
-pub const PF_MAX: ::c_int = AF_MAX;
-
-pub const NET_RT_DUMP: ::c_int = 1;
-pub const NET_RT_FLAGS: ::c_int = 2;
-pub const NET_RT_IFLIST: ::c_int = 3;
-pub const NET_RT_IFMALIST: ::c_int = 4;
-pub const NET_RT_IFLISTL: ::c_int = 5;
-
-// System V IPC
-pub const IPC_PRIVATE: ::key_t = 0;
-pub const IPC_CREAT: ::c_int = 0o1000;
-pub const IPC_EXCL: ::c_int = 0o2000;
-pub const IPC_NOWAIT: ::c_int = 0o4000;
-pub const IPC_RMID: ::c_int = 0;
-pub const IPC_SET: ::c_int = 1;
-pub const IPC_STAT: ::c_int = 2;
-pub const IPC_INFO: ::c_int = 3;
-pub const IPC_R : ::c_int = 0o400;
-pub const IPC_W : ::c_int = 0o200;
-pub const IPC_M : ::c_int = 0o10000;
-pub const MSG_NOERROR: ::c_int = 0o10000;
-pub const SHM_RDONLY: ::c_int = 0o10000;
-pub const SHM_RND: ::c_int = 0o20000;
-pub const SHM_R: ::c_int = 0o400;
-pub const SHM_W: ::c_int = 0o200;
-pub const SHM_LOCK: ::c_int = 11;
-pub const SHM_UNLOCK: ::c_int = 12;
-pub const SHM_STAT: ::c_int = 13;
-pub const SHM_INFO: ::c_int = 14;
-pub const SHM_ANON: *mut ::c_char = 1 as *mut ::c_char;
-
-// The *_MAXID constants never should've been used outside of the
-// FreeBSD base system. And with the exception of CTL_P1003_1B_MAXID,
-// they were all removed in svn r262489. They remain here for backwards
-// compatibility only, and are scheduled to be removed in libc 1.0.0.
-#[doc(hidden)]
-#[deprecated(since="0.2.54",note="Removed in FreeBSD 11")]
-#[allow(deprecated)]
-pub const NET_MAXID: ::c_int = AF_MAX;
-#[doc(hidden)]
-#[deprecated(since="0.2.54",note="Removed in FreeBSD 11")]
-pub const CTL_MAXID: ::c_int = 10;
-#[doc(hidden)]
-#[deprecated(since="0.2.54",note="Removed in FreeBSD 11")]
-pub const KERN_MAXID: ::c_int = 38;
-#[doc(hidden)]
-#[deprecated(since="0.2.54",note="Removed in FreeBSD 11")]
-pub const HW_MAXID: ::c_int = 13;
-#[doc(hidden)]
-#[deprecated(since="0.2.54",note="Removed in FreeBSD 11")]
-pub const USER_MAXID: ::c_int = 21;
-#[doc(hidden)]
-pub const CTL_P1003_1B_MAXID: ::c_int = 26;
-
-pub const MSG_NOTIFICATION: ::c_int = 0x00002000;
-pub const MSG_NBIO: ::c_int = 0x00004000;
-pub const MSG_COMPAT: ::c_int = 0x00008000;
-pub const MSG_CMSG_CLOEXEC: ::c_int = 0x00040000;
-pub const MSG_NOSIGNAL: ::c_int = 0x20000;
-
-pub const EMPTY: ::c_short = 0;
-pub const BOOT_TIME: ::c_short = 1;
-pub const OLD_TIME: ::c_short = 2;
-pub const NEW_TIME: ::c_short = 3;
-pub const USER_PROCESS: ::c_short = 4;
-pub const INIT_PROCESS: ::c_short = 5;
-pub const LOGIN_PROCESS: ::c_short = 6;
-pub const DEAD_PROCESS: ::c_short = 7;
-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_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
- | LC_MONETARY_MASK
- | LC_NUMERIC_MASK
- | LC_TIME_MASK;
-
-pub const WSTOPPED: ::c_int = 2; // same as WUNTRACED
-pub const WCONTINUED: ::c_int = 4;
-pub const WNOWAIT: ::c_int = 8;
-pub const WEXITED: ::c_int = 16;
-pub const WTRAPPED: ::c_int = 32;
-
-// FreeBSD defines a great many more of these, we only expose the
-// standardized ones.
-pub const P_PID: idtype_t = 0;
-pub const P_PGID: idtype_t = 2;
-pub const P_ALL: idtype_t = 7;
-
-pub const B460800: ::speed_t = 460800;
-pub const B921600: ::speed_t = 921600;
-
-pub const AT_FDCWD: ::c_int = -100;
-pub const AT_EACCESS: ::c_int = 0x100;
-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 TABDLY: ::tcflag_t = 0x00000004;
-pub const TAB0: ::tcflag_t = 0x00000000;
-pub const TAB3: ::tcflag_t = 0x00000004;
-
-pub const _PC_ACL_NFS4: ::c_int = 64;
-
-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;
-
-fn _ALIGN(p: usize) -> usize {
- (p + _ALIGNBYTES) & !_ALIGNBYTES
-}
-
-f! {
- pub fn CMSG_DATA(cmsg: *const ::cmsghdr) -> *mut ::c_uchar {
- (cmsg as *mut ::c_uchar)
- .offset(_ALIGN(::mem::size_of::<::cmsghdr>()) as isize)
- }
-
- pub fn CMSG_LEN(length: ::c_uint) -> ::c_uint {
- _ALIGN(::mem::size_of::<::cmsghdr>()) as ::c_uint + length
- }
-
- pub fn CMSG_NXTHDR(mhdr: *const ::msghdr, cmsg: *const ::cmsghdr)
- -> *mut ::cmsghdr
- {
- if cmsg.is_null() {
- return ::CMSG_FIRSTHDR(mhdr);
- };
- let next = cmsg as usize + _ALIGN((*cmsg).cmsg_len as usize)
- + _ALIGN(::mem::size_of::<::cmsghdr>());
- let max = (*mhdr).msg_control as usize
- + (*mhdr).msg_controllen as usize;
- if next > max {
- 0 as *mut ::cmsghdr
- } else {
- (cmsg as usize + _ALIGN((*cmsg).cmsg_len as usize))
- as *mut ::cmsghdr
- }
- }
-
- pub fn CMSG_SPACE(length: ::c_uint) -> ::c_uint {
- (_ALIGN(::mem::size_of::<::cmsghdr>()) + _ALIGN(length as usize))
- as ::c_uint
- }
-
- pub fn uname(buf: *mut ::utsname) -> ::c_int {
- __xuname(256, buf as *mut ::c_void)
- }
-}
-
-extern {
- pub fn __error() -> *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_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;
- pub fn jail_get(iov: *mut ::iovec, niov: ::c_uint, flags: ::c_int)
- -> ::c_int;
- 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,
- advise: ::c_int) -> ::c_int;
- pub fn mkostemp(template: *mut ::c_char, flags: ::c_int) -> ::c_int;
- pub fn mkostemps(template: *mut ::c_char,
- suffixlen: ::c_int,
- flags: ::c_int) -> ::c_int;
-
- pub fn getutxuser(user: *const ::c_char) -> *mut utmpx;
- pub fn setutxdb(_type: ::c_int, file: *const ::c_char) -> ::c_int;
-
- pub fn aio_waitcomplete(iocbp: *mut *mut aiocb,
- timeout: *mut ::timespec) -> ::ssize_t;
- pub fn mq_getfd_np(mqd: ::mqd_t) -> ::c_int;
-
- pub fn waitid(idtype: idtype_t, id: ::id_t, infop: *mut ::siginfo_t,
- options: ::c_int) -> ::c_int;
-
- pub fn ftok(pathname: *const ::c_char, proj_id: ::c_int) -> ::key_t;
- pub fn shmget(key: ::key_t, size: ::size_t, shmflg: ::c_int) -> ::c_int;
- 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;
- pub fn shmctl(shmid: ::c_int, cmd: ::c_int,
- buf: *mut ::shmid_ds) -> ::c_int;
- pub fn msgctl(msqid: ::c_int, cmd: ::c_int,
- buf: *mut ::msqid_ds) -> ::c_int;
- pub fn msgget(key: ::key_t, msgflg: ::c_int) -> ::c_int;
- pub fn msgsnd(msqid: ::c_int, msgp: *const ::c_void, msgsz: ::size_t,
- msgflg: ::c_int) -> ::c_int;
- pub fn cfmakesane(termios: *mut ::termios);
- 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;
- pub fn __xuname(nmln: ::c_int, buf: *mut ::c_void) -> ::c_int;
-
- pub fn sendmmsg(sockfd: ::c_int, msgvec: *mut ::mmsghdr, vlen: ::size_t,
- flags: ::c_int) -> ::ssize_t;
- pub fn recvmmsg(sockfd: ::c_int, msgvec: *mut ::mmsghdr, vlen: ::size_t,
- flags: ::c_int, timeout: *const ::timespec) -> ::ssize_t;
-}
-
-#[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! {
- if #[cfg(freebsd12)] {
- mod freebsd12;
- pub use self::freebsd12::*;
- } else {
- mod freebsd11;
- pub use self::freebsd11::*;
- }
-}
-
-cfg_if! {
- if #[cfg(target_arch = "x86")] {
- mod x86;
- pub use self::x86::*;
- } else if #[cfg(target_arch = "x86_64")] {
- mod x86_64;
- pub use self::x86_64::*;
- } else 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 = "powerpc64")] {
- mod powerpc64;
- pub use self::powerpc64::*;
- } else {
- // Unknown target_arch
- }
-}
diff --git a/libc/src/unix/bsd/freebsdlike/freebsd/powerpc64.rs b/libc/src/unix/bsd/freebsdlike/freebsd/powerpc64.rs
deleted file mode 100644
index 5c0c6e7..0000000
--- a/libc/src/unix/bsd/freebsdlike/freebsd/powerpc64.rs
+++ /dev/null
@@ -1,44 +0,0 @@
-pub type c_char = u8;
-pub type c_long = i64;
-pub type c_ulong = u64;
-pub type time_t = i64;
-pub type suseconds_t = i64;
-
-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,
- 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_size: ::off_t,
- pub st_blocks: ::blkcnt_t,
- pub st_blksize: ::blksize_t,
- pub st_flags: ::fflags_t,
- pub st_gen: u32,
- pub st_lspare: i32,
- pub st_birthtime: ::time_t,
- pub st_birthtime_nsec: ::c_long,
- }
-}
-
-// should be pub(crate), but that requires Rust 1.18.0
-cfg_if! {
- if #[cfg(libc_const_size_of)] {
- #[doc(hidden)]
- pub const _ALIGNBYTES: usize = ::mem::size_of::<::c_long>() - 1;
- } else {
- #[doc(hidden)]
- pub const _ALIGNBYTES: usize = 8 - 1;
- }
-}
-
-pub const MAP_32BIT: ::c_int = 0x00080000;
diff --git a/libc/src/unix/bsd/freebsdlike/freebsd/x86.rs b/libc/src/unix/bsd/freebsdlike/freebsd/x86.rs
deleted file mode 100644
index adec88c..0000000
--- a/libc/src/unix/bsd/freebsdlike/freebsd/x86.rs
+++ /dev/null
@@ -1,43 +0,0 @@
-pub type c_char = i8;
-pub type c_long = i32;
-pub type c_ulong = u32;
-pub type time_t = i32;
-pub type suseconds_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,
- 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_size: ::off_t,
- pub st_blocks: ::blkcnt_t,
- pub st_blksize: ::blksize_t,
- pub st_flags: ::fflags_t,
- pub st_gen: u32,
- pub st_lspare: i32,
- pub st_birthtime: ::time_t,
- pub st_birthtime_nsec: ::c_long,
- __unused: [u8; 8],
- }
-}
-
-// should be pub(crate), but that requires Rust 1.18.0
-cfg_if! {
- if #[cfg(libc_const_size_of)] {
- #[doc(hidden)]
- pub const _ALIGNBYTES: usize = ::mem::size_of::<::c_long>() - 1;
- } else {
- #[doc(hidden)]
- pub const _ALIGNBYTES: usize = 8 - 1;
- }
-}
diff --git a/libc/src/unix/bsd/freebsdlike/freebsd/x86_64.rs b/libc/src/unix/bsd/freebsdlike/freebsd/x86_64.rs
deleted file mode 100644
index 5220cde..0000000
--- a/libc/src/unix/bsd/freebsdlike/freebsd/x86_64.rs
+++ /dev/null
@@ -1,17 +0,0 @@
-pub type c_char = i8;
-pub type c_long = i64;
-pub type c_ulong = u64;
-pub type time_t = i64;
-pub type suseconds_t = i64;
-
-// should be pub(crate), but that requires Rust 1.18.0
-cfg_if! {
- if #[cfg(libc_const_size_of)] {
- #[doc(hidden)]
- pub const _ALIGNBYTES: usize = ::mem::size_of::<::c_long>() - 1;
- } else {
- #[doc(hidden)]
- pub const _ALIGNBYTES: usize = 8 - 1;
- }
-}
-pub const MAP_32BIT: ::c_int = 0x00080000;
diff --git a/libc/src/unix/bsd/freebsdlike/mod.rs b/libc/src/unix/bsd/freebsdlike/mod.rs
deleted file mode 100644
index 64168eb..0000000
--- a/libc/src/unix/bsd/freebsdlike/mod.rs
+++ /dev/null
@@ -1,1316 +0,0 @@
-pub type mode_t = u16;
-pub type pthread_attr_t = *mut ::c_void;
-pub type rlim_t = i64;
-pub type pthread_mutex_t = *mut ::c_void;
-pub type pthread_mutexattr_t = *mut ::c_void;
-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 pthread_key_t = ::c_int;
-pub type tcflag_t = ::c_uint;
-pub type speed_t = ::c_uint;
-pub type nl_item = ::c_int;
-pub type id_t = i64;
-pub type vm_size_t = ::uintptr_t;
-
-#[cfg_attr(feature = "extra_traits", derive(Debug))]
-pub enum timezone {}
-impl ::Copy for timezone {}
-impl ::Clone for timezone {
- fn clone(&self) -> timezone { *self }
-}
-
-s! {
- pub struct in_addr {
- pub s_addr: ::in_addr_t,
- }
-
- pub struct ip_mreq {
- pub imr_multiaddr: in_addr,
- pub imr_interface: in_addr,
- }
-
- pub struct glob_t {
- pub gl_pathc: ::size_t,
- pub gl_matchc: ::size_t,
- pub gl_offs: ::size_t,
- pub gl_flags: ::c_int,
- pub gl_pathv: *mut *mut ::c_char,
- __unused3: *mut ::c_void,
- __unused4: *mut ::c_void,
- __unused5: *mut ::c_void,
- __unused6: *mut ::c_void,
- __unused7: *mut ::c_void,
- __unused8: *mut ::c_void,
- }
-
- 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_canonname: *mut ::c_char,
- pub ai_addr: *mut ::sockaddr,
- pub ai_next: *mut addrinfo,
- }
-
- pub struct sigset_t {
- bits: [u32; 4],
- }
-
- pub struct siginfo_t {
- pub si_signo: ::c_int,
- pub si_errno: ::c_int,
- pub si_code: ::c_int,
- pub si_pid: ::pid_t,
- pub si_uid: ::uid_t,
- pub si_status: ::c_int,
- pub si_addr: *mut ::c_void,
- _pad: [::c_int; 12],
- }
-
- pub struct sigaction {
- pub sa_sigaction: ::sighandler_t,
- pub sa_flags: ::c_int,
- pub sa_mask: sigset_t,
- }
-
- pub struct sched_param {
- pub sched_priority: ::c_int,
- }
-
- pub struct Dl_info {
- pub dli_fname: *const ::c_char,
- pub dli_fbase: *mut ::c_void,
- pub dli_sname: *const ::c_char,
- pub dli_saddr: *mut ::c_void,
- }
-
- 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 termios {
- 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; ::NCCS],
- pub c_ispeed: ::speed_t,
- pub c_ospeed: ::speed_t,
- }
-
- pub struct flock {
- pub l_start: ::off_t,
- pub l_len: ::off_t,
- pub l_pid: ::pid_t,
- pub l_type: ::c_short,
- pub l_whence: ::c_short,
- #[cfg(not(target_os = "dragonfly"))]
- pub l_sysid: ::c_int,
- }
-
- pub struct sf_hdtr {
- pub headers: *mut ::iovec,
- pub hdr_cnt: ::c_int,
- pub trailers: *mut ::iovec,
- pub trl_cnt: ::c_int,
- }
-
- 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_n_cs_precedes: ::c_char,
- pub int_p_sep_by_space: ::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 cmsgcred {
- pub cmcred_pid: ::pid_t,
- pub cmcred_uid: ::uid_t,
- pub cmcred_euid: ::uid_t,
- pub cmcred_gid: ::gid_t,
- 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,
- }
-}
-
-s_no_extra_traits! {
- pub struct sockaddr_storage {
- pub ss_len: u8,
- pub ss_family: ::sa_family_t,
- __ss_pad1: [u8; 6],
- __ss_align: i64,
- __ss_pad2: [u8; 112],
- }
-}
-
-cfg_if! {
- if #[cfg(feature = "extra_traits")] {
- impl PartialEq for sockaddr_storage {
- fn eq(&self, other: &sockaddr_storage) -> bool {
- self.ss_len == other.ss_len
- && self.ss_family == other.ss_family
- && self.__ss_pad1 == other.__ss_pad1
- && self.__ss_align == other.__ss_align
- && self
- .__ss_pad2
- .iter()
- .zip(other.__ss_pad2.iter())
- .all(|(a, b)| a == b)
- }
- }
- impl Eq for sockaddr_storage {}
- impl ::fmt::Debug for sockaddr_storage {
- fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
- f.debug_struct("sockaddr_storage")
- .field("ss_len", &self.ss_len)
- .field("ss_family", &self.ss_family)
- .field("__ss_pad1", &self.__ss_pad1)
- .field("__ss_align", &self.__ss_align)
- // FIXME: .field("__ss_pad2", &self.__ss_pad2)
- .finish()
- }
- }
- impl ::hash::Hash for sockaddr_storage {
- fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
- self.ss_len.hash(state);
- self.ss_family.hash(state);
- self.__ss_pad1.hash(state);
- self.__ss_align.hash(state);
- self.__ss_pad2.hash(state);
- }
- }
- }
-}
-
-pub const AIO_LISTIO_MAX: ::c_int = 16;
-pub const AIO_CANCELED: ::c_int = 1;
-pub const AIO_NOTCANCELED: ::c_int = 2;
-pub const AIO_ALLDONE: ::c_int = 3;
-pub const LIO_NOP: ::c_int = 0;
-pub const LIO_WRITE: ::c_int = 1;
-pub const LIO_READ: ::c_int = 2;
-pub const LIO_WAIT: ::c_int = 1;
-pub const LIO_NOWAIT: ::c_int = 0;
-
-pub const SIGEV_NONE: ::c_int = 0;
-pub const SIGEV_SIGNAL: ::c_int = 1;
-pub const SIGEV_THREAD: ::c_int = 2;
-pub const SIGEV_KEVENT: ::c_int = 3;
-
-pub const CODESET: ::nl_item = 0;
-pub const D_T_FMT: ::nl_item = 1;
-pub const D_FMT: ::nl_item = 2;
-pub const T_FMT: ::nl_item = 3;
-pub const T_FMT_AMPM: ::nl_item = 4;
-pub const AM_STR: ::nl_item = 5;
-pub const PM_STR: ::nl_item = 6;
-
-pub const DAY_1: ::nl_item = 7;
-pub const DAY_2: ::nl_item = 8;
-pub const DAY_3: ::nl_item = 9;
-pub const DAY_4: ::nl_item = 10;
-pub const DAY_5: ::nl_item = 11;
-pub const DAY_6: ::nl_item = 12;
-pub const DAY_7: ::nl_item = 13;
-
-pub const ABDAY_1: ::nl_item = 14;
-pub const ABDAY_2: ::nl_item = 15;
-pub const ABDAY_3: ::nl_item = 16;
-pub const ABDAY_4: ::nl_item = 17;
-pub const ABDAY_5: ::nl_item = 18;
-pub const ABDAY_6: ::nl_item = 19;
-pub const ABDAY_7: ::nl_item = 20;
-
-pub const MON_1: ::nl_item = 21;
-pub const MON_2: ::nl_item = 22;
-pub const MON_3: ::nl_item = 23;
-pub const MON_4: ::nl_item = 24;
-pub const MON_5: ::nl_item = 25;
-pub const MON_6: ::nl_item = 26;
-pub const MON_7: ::nl_item = 27;
-pub const MON_8: ::nl_item = 28;
-pub const MON_9: ::nl_item = 29;
-pub const MON_10: ::nl_item = 30;
-pub const MON_11: ::nl_item = 31;
-pub const MON_12: ::nl_item = 32;
-
-pub const ABMON_1: ::nl_item = 33;
-pub const ABMON_2: ::nl_item = 34;
-pub const ABMON_3: ::nl_item = 35;
-pub const ABMON_4: ::nl_item = 36;
-pub const ABMON_5: ::nl_item = 37;
-pub const ABMON_6: ::nl_item = 38;
-pub const ABMON_7: ::nl_item = 39;
-pub const ABMON_8: ::nl_item = 40;
-pub const ABMON_9: ::nl_item = 41;
-pub const ABMON_10: ::nl_item = 42;
-pub const ABMON_11: ::nl_item = 43;
-pub const ABMON_12: ::nl_item = 44;
-
-pub const ERA: ::nl_item = 45;
-pub const ERA_D_FMT: ::nl_item = 46;
-pub const ERA_D_T_FMT: ::nl_item = 47;
-pub const ERA_T_FMT: ::nl_item = 48;
-pub const ALT_DIGITS: ::nl_item = 49;
-
-pub const RADIXCHAR: ::nl_item = 50;
-pub const THOUSEP: ::nl_item = 51;
-
-pub const YESEXPR: ::nl_item = 52;
-pub const NOEXPR: ::nl_item = 53;
-
-pub const YESSTR: ::nl_item = 54;
-pub const NOSTR: ::nl_item = 55;
-
-pub const CRNCYSTR: ::nl_item = 56;
-
-pub const D_MD_ORDER: ::nl_item = 57;
-
-pub const ALTMON_1: ::nl_item = 58;
-pub const ALTMON_2: ::nl_item = 59;
-pub const ALTMON_3: ::nl_item = 60;
-pub const ALTMON_4: ::nl_item = 61;
-pub const ALTMON_5: ::nl_item = 62;
-pub const ALTMON_6: ::nl_item = 63;
-pub const ALTMON_7: ::nl_item = 64;
-pub const ALTMON_8: ::nl_item = 65;
-pub const ALTMON_9: ::nl_item = 66;
-pub const ALTMON_10: ::nl_item = 67;
-pub const ALTMON_11: ::nl_item = 68;
-pub const ALTMON_12: ::nl_item = 69;
-
-pub const EXIT_FAILURE: ::c_int = 1;
-pub const EXIT_SUCCESS: ::c_int = 0;
-pub const EOF: ::c_int = -1;
-pub const SEEK_SET: ::c_int = 0;
-pub const SEEK_CUR: ::c_int = 1;
-pub const SEEK_END: ::c_int = 2;
-pub const SEEK_DATA: ::c_int = 3;
-pub const SEEK_HOLE: ::c_int = 4;
-pub const _IOFBF: ::c_int = 0;
-pub const _IONBF: ::c_int = 2;
-pub const _IOLBF: ::c_int = 1;
-pub const BUFSIZ: ::c_uint = 1024;
-pub const FOPEN_MAX: ::c_uint = 20;
-pub const FILENAME_MAX: ::c_uint = 1024;
-pub const L_tmpnam: ::c_uint = 1024;
-pub const TMP_MAX: ::c_uint = 308915776;
-
-pub const O_NOCTTY: ::c_int = 32768;
-pub const O_DIRECT: ::c_int = 0x00010000;
-
-pub const S_IFIFO: mode_t = 4096;
-pub const S_IFCHR: mode_t = 8192;
-pub const S_IFBLK: mode_t = 24576;
-pub const S_IFDIR: mode_t = 16384;
-pub const S_IFREG: mode_t = 32768;
-pub const S_IFLNK: mode_t = 40960;
-pub const S_IFSOCK: mode_t = 49152;
-pub const S_IFMT: mode_t = 61440;
-pub const S_IEXEC: mode_t = 64;
-pub const S_IWRITE: mode_t = 128;
-pub const S_IREAD: mode_t = 256;
-pub const S_IRWXU: mode_t = 448;
-pub const S_IXUSR: mode_t = 64;
-pub const S_IWUSR: mode_t = 128;
-pub const S_IRUSR: mode_t = 256;
-pub const S_IRWXG: mode_t = 56;
-pub const S_IXGRP: mode_t = 8;
-pub const S_IWGRP: mode_t = 16;
-pub const S_IRGRP: mode_t = 32;
-pub const S_IRWXO: mode_t = 7;
-pub const S_IXOTH: mode_t = 1;
-pub const S_IWOTH: mode_t = 2;
-pub const S_IROTH: mode_t = 4;
-pub const F_OK: ::c_int = 0;
-pub const R_OK: ::c_int = 4;
-pub const W_OK: ::c_int = 2;
-pub const X_OK: ::c_int = 1;
-pub const STDIN_FILENO: ::c_int = 0;
-pub const STDOUT_FILENO: ::c_int = 1;
-pub const STDERR_FILENO: ::c_int = 2;
-pub const F_LOCK: ::c_int = 1;
-pub const F_TEST: ::c_int = 3;
-pub const F_TLOCK: ::c_int = 2;
-pub const F_ULOCK: ::c_int = 0;
-pub const F_DUPFD_CLOEXEC: ::c_int = 17;
-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 PROT_NONE: ::c_int = 0;
-pub const PROT_READ: ::c_int = 1;
-pub const PROT_WRITE: ::c_int = 2;
-pub const PROT_EXEC: ::c_int = 4;
-
-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 MAP_FAILED: *mut ::c_void = !0 as *mut ::c_void;
-
-pub const MCL_CURRENT: ::c_int = 0x0001;
-pub const MCL_FUTURE: ::c_int = 0x0002;
-
-pub const MS_SYNC: ::c_int = 0x0000;
-pub const MS_ASYNC: ::c_int = 0x0001;
-pub const MS_INVALIDATE: ::c_int = 0x0002;
-
-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 EDEADLK: ::c_int = 11;
-pub const ENOMEM: ::c_int = 12;
-pub const EACCES: ::c_int = 13;
-pub const EFAULT: ::c_int = 14;
-pub const ENOTBLK: ::c_int = 15;
-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 EAGAIN: ::c_int = 35;
-pub const EWOULDBLOCK: ::c_int = 35;
-pub const EINPROGRESS: ::c_int = 36;
-pub const EALREADY: ::c_int = 37;
-pub const ENOTSOCK: ::c_int = 38;
-pub const EDESTADDRREQ: ::c_int = 39;
-pub const EMSGSIZE: ::c_int = 40;
-pub const EPROTOTYPE: ::c_int = 41;
-pub const ENOPROTOOPT: ::c_int = 42;
-pub const EPROTONOSUPPORT: ::c_int = 43;
-pub const ESOCKTNOSUPPORT: ::c_int = 44;
-pub const EOPNOTSUPP: ::c_int = 45;
-pub const ENOTSUP: ::c_int = EOPNOTSUPP;
-pub const EPFNOSUPPORT: ::c_int = 46;
-pub const EAFNOSUPPORT: ::c_int = 47;
-pub const EADDRINUSE: ::c_int = 48;
-pub const EADDRNOTAVAIL: ::c_int = 49;
-pub const ENETDOWN: ::c_int = 50;
-pub const ENETUNREACH: ::c_int = 51;
-pub const ENETRESET: ::c_int = 52;
-pub const ECONNABORTED: ::c_int = 53;
-pub const ECONNRESET: ::c_int = 54;
-pub const ENOBUFS: ::c_int = 55;
-pub const EISCONN: ::c_int = 56;
-pub const ENOTCONN: ::c_int = 57;
-pub const ESHUTDOWN: ::c_int = 58;
-pub const ETOOMANYREFS: ::c_int = 59;
-pub const ETIMEDOUT: ::c_int = 60;
-pub const ECONNREFUSED: ::c_int = 61;
-pub const ELOOP: ::c_int = 62;
-pub const ENAMETOOLONG: ::c_int = 63;
-pub const EHOSTDOWN: ::c_int = 64;
-pub const EHOSTUNREACH: ::c_int = 65;
-pub const ENOTEMPTY: ::c_int = 66;
-pub const EPROCLIM: ::c_int = 67;
-pub const EUSERS: ::c_int = 68;
-pub const EDQUOT: ::c_int = 69;
-pub const ESTALE: ::c_int = 70;
-pub const EREMOTE: ::c_int = 71;
-pub const EBADRPC: ::c_int = 72;
-pub const ERPCMISMATCH: ::c_int = 73;
-pub const EPROGUNAVAIL: ::c_int = 74;
-pub const EPROGMISMATCH: ::c_int = 75;
-pub const EPROCUNAVAIL: ::c_int = 76;
-pub const ENOLCK: ::c_int = 77;
-pub const ENOSYS: ::c_int = 78;
-pub const EFTYPE: ::c_int = 79;
-pub const EAUTH: ::c_int = 80;
-pub const ENEEDAUTH: ::c_int = 81;
-pub const EIDRM: ::c_int = 82;
-pub const ENOMSG: ::c_int = 83;
-pub const EOVERFLOW: ::c_int = 84;
-pub const ECANCELED: ::c_int = 85;
-pub const EILSEQ: ::c_int = 86;
-pub const ENOATTR: ::c_int = 87;
-pub const EDOOFUS: ::c_int = 88;
-pub const EBADMSG: ::c_int = 89;
-pub const EMULTIHOP: ::c_int = 90;
-pub const ENOLINK: ::c_int = 91;
-pub const EPROTO: ::c_int = 92;
-
-pub const POLLSTANDARD: ::c_short = ::POLLIN | ::POLLPRI | ::POLLOUT |
- ::POLLRDNORM | ::POLLRDBAND | ::POLLWRBAND | ::POLLERR |
- ::POLLHUP | ::POLLNVAL;
-
-pub const EAI_AGAIN: ::c_int = 2;
-pub const EAI_BADFLAGS: ::c_int = 3;
-pub const EAI_FAIL: ::c_int = 4;
-pub const EAI_FAMILY: ::c_int = 5;
-pub const EAI_MEMORY: ::c_int = 6;
-pub const EAI_NONAME: ::c_int = 8;
-pub const EAI_SERVICE: ::c_int = 9;
-pub const EAI_SOCKTYPE: ::c_int = 10;
-pub const EAI_SYSTEM: ::c_int = 11;
-pub const EAI_OVERFLOW: ::c_int = 14;
-
-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 SIGTRAP: ::c_int = 5;
-
-pub const GLOB_APPEND : ::c_int = 0x0001;
-pub const GLOB_DOOFFS : ::c_int = 0x0002;
-pub const GLOB_ERR : ::c_int = 0x0004;
-pub const GLOB_MARK : ::c_int = 0x0008;
-pub const GLOB_NOCHECK : ::c_int = 0x0010;
-pub const GLOB_NOSORT : ::c_int = 0x0020;
-pub const GLOB_NOESCAPE: ::c_int = 0x2000;
-
-pub const GLOB_NOSPACE : ::c_int = -1;
-pub const GLOB_ABORTED : ::c_int = -2;
-pub const GLOB_NOMATCH : ::c_int = -3;
-
-pub const POSIX_MADV_NORMAL: ::c_int = 0;
-pub const POSIX_MADV_RANDOM: ::c_int = 1;
-pub const POSIX_MADV_SEQUENTIAL: ::c_int = 2;
-pub const POSIX_MADV_WILLNEED: ::c_int = 3;
-pub const POSIX_MADV_DONTNEED: ::c_int = 4;
-
-pub const PTHREAD_PROCESS_PRIVATE: ::c_int = 0;
-pub const PTHREAD_PROCESS_SHARED: ::c_int = 1;
-pub const PTHREAD_CREATE_JOINABLE: ::c_int = 0;
-pub const PTHREAD_CREATE_DETACHED: ::c_int = 1;
-
-pub const RLIMIT_CPU: ::c_int = 0;
-pub const RLIMIT_FSIZE: ::c_int = 1;
-pub const RLIMIT_DATA: ::c_int = 2;
-pub const RLIMIT_STACK: ::c_int = 3;
-pub const RLIMIT_CORE: ::c_int = 4;
-pub const RLIMIT_RSS: ::c_int = 5;
-pub const RLIMIT_MEMLOCK: ::c_int = 6;
-pub const RLIMIT_NPROC: ::c_int = 7;
-pub const RLIMIT_NOFILE: ::c_int = 8;
-pub const RLIMIT_SBSIZE: ::c_int = 9;
-pub const RLIMIT_VMEM: ::c_int = 10;
-pub const RLIMIT_AS: ::c_int = RLIMIT_VMEM;
-pub const RLIM_INFINITY: rlim_t = 0x7fff_ffff_ffff_ffff;
-
-pub const RUSAGE_SELF: ::c_int = 0;
-pub const RUSAGE_CHILDREN: ::c_int = -1;
-
-pub const MADV_NORMAL: ::c_int = 0;
-pub const MADV_RANDOM: ::c_int = 1;
-pub const MADV_SEQUENTIAL: ::c_int = 2;
-pub const MADV_WILLNEED: ::c_int = 3;
-pub const MADV_DONTNEED: ::c_int = 4;
-pub const MADV_FREE: ::c_int = 5;
-pub const MADV_NOSYNC: ::c_int = 6;
-pub const MADV_AUTOSYNC: ::c_int = 7;
-pub const MADV_NOCORE: ::c_int = 8;
-pub const MADV_CORE: ::c_int = 9;
-
-pub const MINCORE_INCORE: ::c_int = 0x1;
-pub const MINCORE_REFERENCED: ::c_int = 0x2;
-pub const MINCORE_MODIFIED: ::c_int = 0x4;
-pub const MINCORE_REFERENCED_OTHER: ::c_int = 0x8;
-pub const MINCORE_MODIFIED_OTHER: ::c_int = 0x10;
-pub const MINCORE_SUPER: ::c_int = 0x20;
-
-pub const AF_UNSPEC: ::c_int = 0;
-pub const AF_LOCAL: ::c_int = 1;
-pub const AF_UNIX: ::c_int = AF_LOCAL;
-pub const AF_INET: ::c_int = 2;
-pub const AF_IMPLINK: ::c_int = 3;
-pub const AF_PUP: ::c_int = 4;
-pub const AF_CHAOS: ::c_int = 5;
-pub const AF_NETBIOS: ::c_int = 6;
-pub const AF_ISO: ::c_int = 7;
-pub const AF_OSI: ::c_int = AF_ISO;
-pub const AF_ECMA: ::c_int = 8;
-pub const AF_DATAKIT: ::c_int = 9;
-pub const AF_CCITT: ::c_int = 10;
-pub const AF_SNA: ::c_int = 11;
-pub const AF_DECnet: ::c_int = 12;
-pub const AF_DLI: ::c_int = 13;
-pub const AF_LAT: ::c_int = 14;
-pub const AF_HYLINK: ::c_int = 15;
-pub const AF_APPLETALK: ::c_int = 16;
-pub const AF_ROUTE: ::c_int = 17;
-pub const AF_LINK: ::c_int = 18;
-pub const pseudo_AF_XTP: ::c_int = 19;
-pub const AF_COIP: ::c_int = 20;
-pub const AF_CNT: ::c_int = 21;
-pub const pseudo_AF_RTIP: ::c_int = 22;
-pub const AF_IPX: ::c_int = 23;
-pub const AF_SIP: ::c_int = 24;
-pub const pseudo_AF_PIP: ::c_int = 25;
-pub const AF_ISDN: ::c_int = 26;
-pub const AF_E164: ::c_int = AF_ISDN;
-pub const pseudo_AF_KEY: ::c_int = 27;
-pub const AF_INET6: ::c_int = 28;
-pub const AF_NATM: ::c_int = 29;
-pub const AF_ATM: ::c_int = 30;
-pub const pseudo_AF_HDRCMPLT: ::c_int = 31;
-pub const AF_NETGRAPH: ::c_int = 32;
-
-pub const PF_UNSPEC: ::c_int = AF_UNSPEC;
-pub const PF_LOCAL: ::c_int = AF_LOCAL;
-pub const PF_UNIX: ::c_int = PF_LOCAL;
-pub const PF_INET: ::c_int = AF_INET;
-pub const PF_IMPLINK: ::c_int = AF_IMPLINK;
-pub const PF_PUP: ::c_int = AF_PUP;
-pub const PF_CHAOS: ::c_int = AF_CHAOS;
-pub const PF_NETBIOS: ::c_int = AF_NETBIOS;
-pub const PF_ISO: ::c_int = AF_ISO;
-pub const PF_OSI: ::c_int = AF_ISO;
-pub const PF_ECMA: ::c_int = AF_ECMA;
-pub const PF_DATAKIT: ::c_int = AF_DATAKIT;
-pub const PF_CCITT: ::c_int = AF_CCITT;
-pub const PF_SNA: ::c_int = AF_SNA;
-pub const PF_DECnet: ::c_int = AF_DECnet;
-pub const PF_DLI: ::c_int = AF_DLI;
-pub const PF_LAT: ::c_int = AF_LAT;
-pub const PF_HYLINK: ::c_int = AF_HYLINK;
-pub const PF_APPLETALK: ::c_int = AF_APPLETALK;
-pub const PF_ROUTE: ::c_int = AF_ROUTE;
-pub const PF_LINK: ::c_int = AF_LINK;
-pub const PF_XTP: ::c_int = pseudo_AF_XTP;
-pub const PF_COIP: ::c_int = AF_COIP;
-pub const PF_CNT: ::c_int = AF_CNT;
-pub const PF_SIP: ::c_int = AF_SIP;
-pub const PF_IPX: ::c_int = AF_IPX;
-pub const PF_RTIP: ::c_int = pseudo_AF_RTIP;
-pub const PF_PIP: ::c_int = pseudo_AF_PIP;
-pub const PF_ISDN: ::c_int = AF_ISDN;
-pub const PF_KEY: ::c_int = pseudo_AF_KEY;
-pub const PF_INET6: ::c_int = AF_INET6;
-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;
-pub const MSG_PEEK: ::c_int = 0x00000002;
-pub const MSG_DONTROUTE: ::c_int = 0x00000004;
-pub const MSG_EOR: ::c_int = 0x00000008;
-pub const MSG_TRUNC: ::c_int = 0x00000010;
-pub const MSG_CTRUNC: ::c_int = 0x00000020;
-pub const MSG_WAITALL: ::c_int = 0x00000040;
-pub const MSG_DONTWAIT: ::c_int = 0x00000080;
-pub const MSG_EOF: ::c_int = 0x00000100;
-
-pub const SCM_TIMESTAMP: ::c_int = 0x02;
-
-pub const SOCK_STREAM: ::c_int = 1;
-pub const SOCK_DGRAM: ::c_int = 2;
-pub const SOCK_RAW: ::c_int = 3;
-pub const SOCK_RDM: ::c_int = 4;
-pub const SOCK_SEQPACKET: ::c_int = 5;
-pub const SOCK_CLOEXEC: ::c_int = 0x10000000;
-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 IP_RECVIF: ::c_int = 20;
-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 IPV6_RECVTCLASS: ::c_int = 57;
-pub const IPV6_TCLASS: ::c_int = 61;
-
-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 SOL_SOCKET: ::c_int = 0xffff;
-pub const SO_DEBUG: ::c_int = 0x01;
-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_TIMESTAMP: ::c_int = 0x0400;
-pub const SO_NOSIGPIPE: ::c_int = 0x0800;
-pub const SO_ACCEPTFILTER: ::c_int = 0x1000;
-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 SHUT_RD: ::c_int = 0;
-pub const SHUT_WR: ::c_int = 1;
-pub const SHUT_RDWR: ::c_int = 2;
-
-pub const LOCK_SH: ::c_int = 1;
-pub const LOCK_EX: ::c_int = 2;
-pub const LOCK_NB: ::c_int = 4;
-pub const LOCK_UN: ::c_int = 8;
-
-pub const MAP_COPY: ::c_int = 0x0002;
-#[doc(hidden)]
-#[deprecated(since="0.2.54",note="Removed in FreeBSD 11")]
-pub const MAP_RENAME: ::c_int = 0x0020;
-#[doc(hidden)]
-#[deprecated(since="0.2.54",note="Removed in FreeBSD 11")]
-pub const MAP_NORESERVE: ::c_int = 0x0040;
-pub const MAP_HASSEMAPHORE: ::c_int = 0x0200;
-pub const MAP_STACK: ::c_int = 0x0400;
-pub const MAP_NOSYNC: ::c_int = 0x0800;
-pub const MAP_NOCORE: ::c_int = 0x020000;
-
-pub const IPPROTO_RAW: ::c_int = 255;
-
-pub const _PC_LINK_MAX: ::c_int = 1;
-pub const _PC_MAX_CANON: ::c_int = 2;
-pub const _PC_MAX_INPUT: ::c_int = 3;
-pub const _PC_NAME_MAX: ::c_int = 4;
-pub const _PC_PATH_MAX: ::c_int = 5;
-pub const _PC_PIPE_BUF: ::c_int = 6;
-pub const _PC_CHOWN_RESTRICTED: ::c_int = 7;
-pub const _PC_NO_TRUNC: ::c_int = 8;
-pub const _PC_VDISABLE: ::c_int = 9;
-pub const _PC_ALLOC_SIZE_MIN: ::c_int = 10;
-pub const _PC_FILESIZEBITS: ::c_int = 12;
-pub const _PC_REC_INCR_XFER_SIZE: ::c_int = 14;
-pub const _PC_REC_MAX_XFER_SIZE: ::c_int = 15;
-pub const _PC_REC_MIN_XFER_SIZE: ::c_int = 16;
-pub const _PC_REC_XFER_ALIGN: ::c_int = 17;
-pub const _PC_SYMLINK_MAX: ::c_int = 18;
-pub const _PC_MIN_HOLE_SIZE: ::c_int = 21;
-pub const _PC_ASYNC_IO: ::c_int = 53;
-pub const _PC_PRIO_IO: ::c_int = 54;
-pub const _PC_SYNC_IO: ::c_int = 55;
-pub const _PC_ACL_EXTENDED: ::c_int = 59;
-pub const _PC_ACL_PATH_MAX: ::c_int = 60;
-pub const _PC_CAP_PRESENT: ::c_int = 61;
-pub const _PC_INF_PRESENT: ::c_int = 62;
-pub const _PC_MAC_PRESENT: ::c_int = 63;
-
-pub const _SC_ARG_MAX: ::c_int = 1;
-pub const _SC_CHILD_MAX: ::c_int = 2;
-pub const _SC_CLK_TCK: ::c_int = 3;
-pub const _SC_NGROUPS_MAX: ::c_int = 4;
-pub const _SC_OPEN_MAX: ::c_int = 5;
-pub const _SC_JOB_CONTROL: ::c_int = 6;
-pub const _SC_SAVED_IDS: ::c_int = 7;
-pub const _SC_VERSION: ::c_int = 8;
-pub const _SC_BC_BASE_MAX: ::c_int = 9;
-pub const _SC_BC_DIM_MAX: ::c_int = 10;
-pub const _SC_BC_SCALE_MAX: ::c_int = 11;
-pub const _SC_BC_STRING_MAX: ::c_int = 12;
-pub const _SC_COLL_WEIGHTS_MAX: ::c_int = 13;
-pub const _SC_EXPR_NEST_MAX: ::c_int = 14;
-pub const _SC_LINE_MAX: ::c_int = 15;
-pub const _SC_RE_DUP_MAX: ::c_int = 16;
-pub const _SC_2_VERSION: ::c_int = 17;
-pub const _SC_2_C_BIND: ::c_int = 18;
-pub const _SC_2_C_DEV: ::c_int = 19;
-pub const _SC_2_CHAR_TERM: ::c_int = 20;
-pub const _SC_2_FORT_DEV: ::c_int = 21;
-pub const _SC_2_FORT_RUN: ::c_int = 22;
-pub const _SC_2_LOCALEDEF: ::c_int = 23;
-pub const _SC_2_SW_DEV: ::c_int = 24;
-pub const _SC_2_UPE: ::c_int = 25;
-pub const _SC_STREAM_MAX: ::c_int = 26;
-pub const _SC_TZNAME_MAX: ::c_int = 27;
-pub const _SC_ASYNCHRONOUS_IO: ::c_int = 28;
-pub const _SC_MAPPED_FILES: ::c_int = 29;
-pub const _SC_MEMLOCK: ::c_int = 30;
-pub const _SC_MEMLOCK_RANGE: ::c_int = 31;
-pub const _SC_MEMORY_PROTECTION: ::c_int = 32;
-pub const _SC_MESSAGE_PASSING: ::c_int = 33;
-pub const _SC_PRIORITIZED_IO: ::c_int = 34;
-pub const _SC_PRIORITY_SCHEDULING: ::c_int = 35;
-pub const _SC_REALTIME_SIGNALS: ::c_int = 36;
-pub const _SC_SEMAPHORES: ::c_int = 37;
-pub const _SC_FSYNC: ::c_int = 38;
-pub const _SC_SHARED_MEMORY_OBJECTS: ::c_int = 39;
-pub const _SC_SYNCHRONIZED_IO: ::c_int = 40;
-pub const _SC_TIMERS: ::c_int = 41;
-pub const _SC_AIO_LISTIO_MAX: ::c_int = 42;
-pub const _SC_AIO_MAX: ::c_int = 43;
-pub const _SC_AIO_PRIO_DELTA_MAX: ::c_int = 44;
-pub const _SC_DELAYTIMER_MAX: ::c_int = 45;
-pub const _SC_MQ_OPEN_MAX: ::c_int = 46;
-pub const _SC_PAGESIZE: ::c_int = 47;
-pub const _SC_PAGE_SIZE: ::c_int = _SC_PAGESIZE;
-pub const _SC_RTSIG_MAX: ::c_int = 48;
-pub const _SC_SEM_NSEMS_MAX: ::c_int = 49;
-pub const _SC_SEM_VALUE_MAX: ::c_int = 50;
-pub const _SC_SIGQUEUE_MAX: ::c_int = 51;
-pub const _SC_TIMER_MAX: ::c_int = 52;
-pub const _SC_IOV_MAX: ::c_int = 56;
-pub const _SC_NPROCESSORS_CONF: ::c_int = 57;
-pub const _SC_2_PBS: ::c_int = 59;
-pub const _SC_2_PBS_ACCOUNTING: ::c_int = 60;
-pub const _SC_2_PBS_CHECKPOINT: ::c_int = 61;
-pub const _SC_2_PBS_LOCATE: ::c_int = 62;
-pub const _SC_2_PBS_MESSAGE: ::c_int = 63;
-pub const _SC_2_PBS_TRACK: ::c_int = 64;
-pub const _SC_ADVISORY_INFO: ::c_int = 65;
-pub const _SC_BARRIERS: ::c_int = 66;
-pub const _SC_CLOCK_SELECTION: ::c_int = 67;
-pub const _SC_CPUTIME: ::c_int = 68;
-pub const _SC_FILE_LOCKING: ::c_int = 69;
-pub const _SC_NPROCESSORS_ONLN: ::c_int = 58;
-pub const _SC_GETGR_R_SIZE_MAX: ::c_int = 70;
-pub const _SC_GETPW_R_SIZE_MAX: ::c_int = 71;
-pub const _SC_HOST_NAME_MAX: ::c_int = 72;
-pub const _SC_LOGIN_NAME_MAX: ::c_int = 73;
-pub const _SC_MONOTONIC_CLOCK: ::c_int = 74;
-pub const _SC_MQ_PRIO_MAX: ::c_int = 75;
-pub const _SC_READER_WRITER_LOCKS: ::c_int = 76;
-pub const _SC_REGEXP: ::c_int = 77;
-pub const _SC_SHELL: ::c_int = 78;
-pub const _SC_SPAWN: ::c_int = 79;
-pub const _SC_SPIN_LOCKS: ::c_int = 80;
-pub const _SC_SPORADIC_SERVER: ::c_int = 81;
-pub const _SC_THREAD_ATTR_STACKADDR: ::c_int = 82;
-pub const _SC_THREAD_ATTR_STACKSIZE: ::c_int = 83;
-pub const _SC_THREAD_DESTRUCTOR_ITERATIONS: ::c_int = 85;
-pub const _SC_THREAD_KEYS_MAX: ::c_int = 86;
-pub const _SC_THREAD_PRIO_INHERIT: ::c_int = 87;
-pub const _SC_THREAD_PRIO_PROTECT: ::c_int = 88;
-pub const _SC_THREAD_PRIORITY_SCHEDULING: ::c_int = 89;
-pub const _SC_THREAD_PROCESS_SHARED: ::c_int = 90;
-pub const _SC_THREAD_SAFE_FUNCTIONS: ::c_int = 91;
-pub const _SC_THREAD_SPORADIC_SERVER: ::c_int = 92;
-pub const _SC_THREAD_STACK_MIN: ::c_int = 93;
-pub const _SC_THREAD_THREADS_MAX: ::c_int = 94;
-pub const _SC_TIMEOUTS: ::c_int = 95;
-pub const _SC_THREADS: ::c_int = 96;
-pub const _SC_TRACE: ::c_int = 97;
-pub const _SC_TRACE_EVENT_FILTER: ::c_int = 98;
-pub const _SC_TRACE_INHERIT: ::c_int = 99;
-pub const _SC_TRACE_LOG: ::c_int = 100;
-pub const _SC_TTY_NAME_MAX: ::c_int = 101;
-pub const _SC_TYPED_MEMORY_OBJECTS: ::c_int = 102;
-pub const _SC_V6_ILP32_OFF32: ::c_int = 103;
-pub const _SC_V6_ILP32_OFFBIG: ::c_int = 104;
-pub const _SC_V6_LP64_OFF64: ::c_int = 105;
-pub const _SC_V6_LPBIG_OFFBIG: ::c_int = 106;
-pub const _SC_ATEXIT_MAX: ::c_int = 107;
-pub const _SC_XOPEN_CRYPT: ::c_int = 108;
-pub const _SC_XOPEN_ENH_I18N: ::c_int = 109;
-pub const _SC_XOPEN_LEGACY: ::c_int = 110;
-pub const _SC_XOPEN_REALTIME: ::c_int = 111;
-pub const _SC_XOPEN_REALTIME_THREADS: ::c_int = 112;
-pub const _SC_XOPEN_SHM: ::c_int = 113;
-pub const _SC_XOPEN_STREAMS: ::c_int = 114;
-pub const _SC_XOPEN_UNIX: ::c_int = 115;
-pub const _SC_XOPEN_VERSION: ::c_int = 116;
-pub const _SC_XOPEN_XCU_VERSION: ::c_int = 117;
-pub const _SC_IPV6: ::c_int = 118;
-pub const _SC_RAW_SOCKETS: ::c_int = 119;
-pub const _SC_SYMLOOP_MAX: ::c_int = 120;
-pub const _SC_PHYS_PAGES: ::c_int = 121;
-
-pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = 0 as *mut _;
-pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = 0 as *mut _;
-pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = 0 as *mut _;
-pub const PTHREAD_MUTEX_ERRORCHECK: ::c_int = 1;
-pub const PTHREAD_MUTEX_RECURSIVE: ::c_int = 2;
-pub const PTHREAD_MUTEX_NORMAL: ::c_int = 3;
-pub const PTHREAD_MUTEX_DEFAULT: ::c_int = PTHREAD_MUTEX_ERRORCHECK;
-
-pub const SCHED_FIFO: ::c_int = 1;
-pub const SCHED_OTHER: ::c_int = 2;
-pub const SCHED_RR: ::c_int = 3;
-
-pub const FD_SETSIZE: usize = 1024;
-
-pub const ST_NOSUID: ::c_ulong = 2;
-
-pub const NI_MAXHOST: ::size_t = 1025;
-
-pub const RTLD_LOCAL: ::c_int = 0;
-pub const RTLD_NODELETE: ::c_int = 0x1000;
-pub const RTLD_NOLOAD: ::c_int = 0x2000;
-pub const RTLD_GLOBAL: ::c_int = 0x100;
-
-pub const LOG_NTP: ::c_int = 12 << 3;
-pub const LOG_SECURITY: ::c_int = 13 << 3;
-pub const LOG_CONSOLE: ::c_int = 14 << 3;
-pub const LOG_NFACILITIES: ::c_int = 24;
-
-pub const TIOCEXCL: ::c_uint = 0x2000740d;
-pub const TIOCNXCL: ::c_uint = 0x2000740e;
-pub const TIOCFLUSH: ::c_ulong = 0x80047410;
-pub const TIOCGETA: ::c_uint = 0x402c7413;
-pub const TIOCSETA: ::c_ulong = 0x802c7414;
-pub const TIOCSETAW: ::c_ulong = 0x802c7415;
-pub const TIOCSETAF: ::c_ulong = 0x802c7416;
-pub const TIOCGETD: ::c_uint = 0x4004741a;
-pub const TIOCSETD: ::c_ulong = 0x8004741b;
-pub const TIOCGDRAINWAIT: ::c_uint = 0x40047456;
-pub const TIOCSDRAINWAIT: ::c_ulong = 0x80047457;
-pub const TIOCTIMESTAMP: ::c_uint = 0x40107459;
-pub const TIOCMGDTRWAIT: ::c_uint = 0x4004745a;
-pub const TIOCMSDTRWAIT: ::c_ulong = 0x8004745b;
-pub const TIOCDRAIN: ::c_uint = 0x2000745e;
-pub const TIOCEXT: ::c_ulong = 0x80047460;
-pub const TIOCSCTTY: ::c_uint = 0x20007461;
-pub const TIOCCONS: ::c_ulong = 0x80047462;
-pub const TIOCGSID: ::c_uint = 0x40047463;
-pub const TIOCSTAT: ::c_uint = 0x20007465;
-pub const TIOCUCNTL: ::c_ulong = 0x80047466;
-pub const TIOCSWINSZ: ::c_ulong = 0x80087467;
-pub const TIOCGWINSZ: ::c_uint = 0x40087468;
-pub const TIOCMGET: ::c_uint = 0x4004746a;
-pub const TIOCM_LE: ::c_int = 0x1;
-pub const TIOCM_DTR: ::c_int = 0x2;
-pub const TIOCM_RTS: ::c_int = 0x4;
-pub const TIOCM_ST: ::c_int = 0x8;
-pub const TIOCM_SR: ::c_int = 0x10;
-pub const TIOCM_CTS: ::c_int = 0x20;
-pub const TIOCM_RI: ::c_int = 0x80;
-pub const TIOCM_DSR: ::c_int = 0x100;
-pub const TIOCM_CD: ::c_int = 0x40;
-pub const TIOCM_CAR: ::c_int = 0x40;
-pub const TIOCM_RNG: ::c_int = 0x80;
-pub const TIOCMBIC: ::c_ulong = 0x8004746b;
-pub const TIOCMBIS: ::c_ulong = 0x8004746c;
-pub const TIOCMSET: ::c_ulong = 0x8004746d;
-pub const TIOCSTART: ::c_uint = 0x2000746e;
-pub const TIOCSTOP: ::c_uint = 0x2000746f;
-pub const TIOCPKT: ::c_ulong = 0x80047470;
-pub const TIOCPKT_DATA: ::c_int = 0x0;
-pub const TIOCPKT_FLUSHREAD: ::c_int = 0x1;
-pub const TIOCPKT_FLUSHWRITE: ::c_int = 0x2;
-pub const TIOCPKT_STOP: ::c_int = 0x4;
-pub const TIOCPKT_START: ::c_int = 0x8;
-pub const TIOCPKT_NOSTOP: ::c_int = 0x10;
-pub const TIOCPKT_DOSTOP: ::c_int = 0x20;
-pub const TIOCPKT_IOCTL: ::c_int = 0x40;
-pub const TIOCNOTTY: ::c_uint = 0x20007471;
-pub const TIOCSTI: ::c_ulong = 0x80017472;
-pub const TIOCOUTQ: ::c_uint = 0x40047473;
-pub const TIOCSPGRP: ::c_ulong = 0x80047476;
-pub const TIOCGPGRP: ::c_uint = 0x40047477;
-pub const TIOCCDTR: ::c_uint = 0x20007478;
-pub const TIOCSDTR: ::c_uint = 0x20007479;
-pub const TIOCCBRK: ::c_uint = 0x2000747a;
-pub const TIOCSBRK: ::c_uint = 0x2000747b;
-pub const TTYDISC: ::c_int = 0x0;
-pub const SLIPDISC: ::c_int = 0x4;
-pub const PPPDISC: ::c_int = 0x5;
-pub const NETGRAPHDISC: ::c_int = 0x6;
-
-pub const B0: speed_t = 0;
-pub const B50: speed_t = 50;
-pub const B75: speed_t = 75;
-pub const B110: speed_t = 110;
-pub const B134: speed_t = 134;
-pub const B150: speed_t = 150;
-pub const B200: speed_t = 200;
-pub const B300: speed_t = 300;
-pub const B600: speed_t = 600;
-pub const B1200: speed_t = 1200;
-pub const B1800: speed_t = 1800;
-pub const B2400: speed_t = 2400;
-pub const B4800: speed_t = 4800;
-pub const B9600: speed_t = 9600;
-pub const B19200: speed_t = 19200;
-pub const B38400: speed_t = 38400;
-pub const B7200: speed_t = 7200;
-pub const B14400: speed_t = 14400;
-pub const B28800: speed_t = 28800;
-pub const B57600: speed_t = 57600;
-pub const B76800: speed_t = 76800;
-pub const B115200: speed_t = 115200;
-pub const B230400: speed_t = 230400;
-pub const EXTA: speed_t = 19200;
-pub const EXTB: speed_t = 38400;
-
-pub const SEM_FAILED: *mut sem_t = 0 as *mut sem_t;
-
-pub const CRTSCTS: ::tcflag_t = 0x00030000;
-pub const CCTS_OFLOW: ::tcflag_t = 0x00010000;
-pub const CRTS_IFLOW: ::tcflag_t = 0x00020000;
-pub const CDTR_IFLOW: ::tcflag_t = 0x00040000;
-pub const CDSR_OFLOW: ::tcflag_t = 0x00080000;
-pub const CCAR_OFLOW: ::tcflag_t = 0x00100000;
-pub const VERASE2: usize = 7;
-pub const OCRNL: ::tcflag_t = 0x10;
-pub const ONOCR: ::tcflag_t = 0x20;
-pub const ONLRET: ::tcflag_t = 0x40;
-
-pub const CMGROUP_MAX: usize = 16;
-
-// https://github.com/freebsd/freebsd/blob/master/sys/net/bpf.h
-// 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
- }
-
- pub fn WSTOPSIG(status: ::c_int) -> ::c_int {
- status >> 8
- }
-
- pub fn WIFSIGNALED(status: ::c_int) -> bool {
- (status & 0o177) != 0o177 && (status & 0o177) != 0
- }
-
- pub fn WIFSTOPPED(status: ::c_int) -> bool {
- (status & 0o177) == 0o177
- }
-}
-
-extern {
- pub fn sem_destroy(sem: *mut sem_t) -> ::c_int;
- pub fn sem_init(sem: *mut sem_t,
- pshared: ::c_int,
- value: ::c_uint)
- -> ::c_int;
-
- pub fn daemon(nochdir: ::c_int, noclose: ::c_int) -> ::c_int;
- pub fn gettimeofday(tp: *mut ::timeval,
- tz: *mut ::timezone) -> ::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 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;
- #[cfg_attr(
- all(target_os = "freebsd", not(freebsd12)),
- 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(
- all(target_os = "freebsd", not(freebsd12)),
- 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,
- msq_prio: *mut ::c_uint) -> ::ssize_t;
- pub fn mq_send(mqd: ::mqd_t,
- msg_ptr: *const ::c_char,
- msg_len: ::size_t,
- msq_prio: ::c_uint) -> ::c_int;
- pub fn mq_setattr(mqd: ::mqd_t,
- newattr: *const ::mq_attr,
- oldattr: *mut ::mq_attr) -> ::c_int;
- 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;
- pub fn mq_timedsend(mqd: ::mqd_t,
- msg_ptr: *const ::c_char,
- msg_len: ::size_t,
- msq_prio: ::c_uint,
- abs_timeout: *const ::timespec) -> ::c_int;
- pub fn mq_unlink(name: *const ::c_char) -> ::c_int;
- pub fn mincore(addr: *const ::c_void, len: ::size_t,
- vec: *mut ::c_char) -> ::c_int;
- pub fn newlocale(mask: ::c_int,
- locale: *const ::c_char,
- base: ::locale_t) -> ::locale_t;
- pub fn nl_langinfo_l(item: ::nl_item, locale: ::locale_t) -> *mut ::c_char;
- 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 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 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,
- nbytes: ::size_t,
- 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,
- termp: *mut termios,
- winp: *mut ::winsize) -> ::c_int;
- pub fn forkpty(amaster: *mut ::c_int,
- name: *mut ::c_char,
- termp: *mut termios,
- winp: *mut ::winsize) -> ::pid_t;
- pub fn login_tty(fd: ::c_int) -> ::c_int;
-}
-
-cfg_if! {
- if #[cfg(target_os = "freebsd")] {
- mod freebsd;
- pub use self::freebsd::*;
- } else if #[cfg(target_os = "dragonfly")] {
- mod dragonfly;
- pub use self::dragonfly::*;
- } else {
- // ...
- }
-}
diff --git a/libc/src/unix/bsd/mod.rs b/libc/src/unix/bsd/mod.rs
deleted file mode 100644
index 8bc6c7c..0000000
--- a/libc/src/unix/bsd/mod.rs
+++ /dev/null
@@ -1,689 +0,0 @@
-pub type wchar_t = i32;
-pub type off_t = i64;
-pub type useconds_t = u32;
-pub type blkcnt_t = i64;
-pub type socklen_t = u32;
-pub type sa_family_t = u8;
-pub type pthread_t = ::uintptr_t;
-pub type nfds_t = ::c_uint;
-
-s! {
- pub struct sockaddr {
- pub sa_len: u8,
- pub sa_family: sa_family_t,
- pub sa_data: [::c_char; 14],
- }
-
- 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 passwd {
- pub pw_name: *mut ::c_char,
- pub pw_passwd: *mut ::c_char,
- pub pw_uid: ::uid_t,
- pub pw_gid: ::gid_t,
- pub pw_change: ::time_t,
- pub pw_class: *mut ::c_char,
- pub pw_gecos: *mut ::c_char,
- pub pw_dir: *mut ::c_char,
- pub pw_shell: *mut ::c_char,
- pub pw_expire: ::time_t,
-
- #[cfg(not(any(target_os = "macos",
- target_os = "ios",
- target_os = "netbsd",
- target_os = "openbsd")))]
- pub pw_fields: ::c_int,
- }
-
- 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_dstaddr: *mut ::sockaddr,
- pub ifa_data: *mut ::c_void,
- #[cfg(target_os = "netbsd")]
- pub ifa_addrflags: ::c_uint
- }
-
- pub struct fd_set {
- #[cfg(all(target_pointer_width = "64",
- any(target_os = "freebsd", target_os = "dragonfly")))]
- fds_bits: [i64; FD_SETSIZE / 64],
- #[cfg(not(all(target_pointer_width = "64",
- any(target_os = "freebsd", target_os = "dragonfly"))))]
- fds_bits: [i32; FD_SETSIZE / 32],
- }
-
- 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 tm_gmtoff: ::c_long,
- pub tm_zone: *mut ::c_char,
- }
-
- pub struct msghdr {
- pub msg_name: *mut ::c_void,
- pub msg_namelen: ::socklen_t,
- pub msg_iov: *mut ::iovec,
- pub msg_iovlen: ::c_int,
- pub msg_control: *mut ::c_void,
- pub msg_controllen: ::socklen_t,
- pub msg_flags: ::c_int,
- }
-
- pub struct cmsghdr {
- pub cmsg_len: ::socklen_t,
- pub cmsg_level: ::c_int,
- pub cmsg_type: ::c_int,
- }
-
- pub struct fsid_t {
- __fsid_val: [i32; 2],
- }
-
- pub struct if_nameindex {
- pub if_index: ::c_uint,
- pub if_name: *mut ::c_char,
- }
-}
-
-s_no_extra_traits!{
- pub struct sockaddr_un {
- pub sun_len: u8,
- pub sun_family: sa_family_t,
- pub sun_path: [c_char; 104]
- }
-
- pub struct utsname {
- #[cfg(not(target_os = "dragonfly"))]
- pub sysname: [::c_char; 256],
- #[cfg(target_os = "dragonfly")]
- pub sysname: [::c_char; 32],
- #[cfg(not(target_os = "dragonfly"))]
- pub nodename: [::c_char; 256],
- #[cfg(target_os = "dragonfly")]
- pub nodename: [::c_char; 32],
- #[cfg(not(target_os = "dragonfly"))]
- pub release: [::c_char; 256],
- #[cfg(target_os = "dragonfly")]
- pub release: [::c_char; 32],
- #[cfg(not(target_os = "dragonfly"))]
- pub version: [::c_char; 256],
- #[cfg(target_os = "dragonfly")]
- pub version: [::c_char; 32],
- #[cfg(not(target_os = "dragonfly"))]
- pub machine: [::c_char; 256],
- #[cfg(target_os = "dragonfly")]
- pub machine: [::c_char; 32],
- }
-
-}
-
-cfg_if! {
- if #[cfg(feature = "extra_traits")] {
- impl PartialEq for sockaddr_un {
- fn eq(&self, other: &sockaddr_un) -> bool {
- self.sun_len == other.sun_len
- && self.sun_family == other.sun_family
- && self
- .sun_path
- .iter()
- .zip(other.sun_path.iter())
- .all(|(a,b)| a == b)
- }
- }
-
- impl Eq for sockaddr_un {}
-
- impl ::fmt::Debug for sockaddr_un {
- fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
- f.debug_struct("sockaddr_un")
- .field("sun_len", &self.sun_len)
- .field("sun_family", &self.sun_family)
- // FIXME: .field("sun_path", &self.sun_path)
- .finish()
- }
- }
-
- impl ::hash::Hash for sockaddr_un {
- fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
- self.sun_len.hash(state);
- self.sun_family.hash(state);
- self.sun_path.hash(state);
- }
- }
-
- impl PartialEq for utsname {
- fn eq(&self, other: &utsname) -> bool {
- self.sysname
- .iter()
- .zip(other.sysname.iter())
- .all(|(a,b)| a == b)
- && self
- .nodename
- .iter()
- .zip(other.nodename.iter())
- .all(|(a,b)| a == b)
- && self
- .release
- .iter()
- .zip(other.release.iter())
- .all(|(a,b)| a == b)
- && self
- .version
- .iter()
- .zip(other.version.iter())
- .all(|(a,b)| a == b)
- && self
- .machine
- .iter()
- .zip(other.machine.iter())
- .all(|(a,b)| a == b)
- }
- }
-
- impl Eq for utsname {}
-
- impl ::fmt::Debug for utsname {
- fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
- f.debug_struct("utsname")
- // FIXME: .field("sysname", &self.sysname)
- // FIXME: .field("nodename", &self.nodename)
- // FIXME: .field("release", &self.release)
- // FIXME: .field("version", &self.version)
- // FIXME: .field("machine", &self.machine)
- .finish()
- }
- }
-
- impl ::hash::Hash for utsname {
- fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
- self.sysname.hash(state);
- self.nodename.hash(state);
- self.release.hash(state);
- self.version.hash(state);
- self.machine.hash(state);
- }
- }
- }
-}
-
-pub const LC_ALL: ::c_int = 0;
-pub const LC_COLLATE: ::c_int = 1;
-pub const LC_CTYPE: ::c_int = 2;
-pub const LC_MONETARY: ::c_int = 3;
-pub const LC_NUMERIC: ::c_int = 4;
-pub const LC_TIME: ::c_int = 5;
-pub const LC_MESSAGES: ::c_int = 6;
-
-pub const FIOCLEX: ::c_ulong = 0x20006601;
-pub const FIONBIO: ::c_ulong = 0x8004667e;
-
-pub const PATH_MAX: ::c_int = 1024;
-
-pub const SA_ONSTACK: ::c_int = 0x0001;
-pub const SA_SIGINFO: ::c_int = 0x0040;
-pub const SA_RESTART: ::c_int = 0x0002;
-pub const SA_RESETHAND: ::c_int = 0x0004;
-pub const SA_NOCLDSTOP: ::c_int = 0x0008;
-pub const SA_NODEFER: ::c_int = 0x0010;
-pub const SA_NOCLDWAIT: ::c_int = 0x0020;
-
-pub const SS_ONSTACK: ::c_int = 1;
-pub const SS_DISABLE: ::c_int = 4;
-
-pub const SIGCHLD: ::c_int = 20;
-pub const SIGBUS: ::c_int = 10;
-pub const SIGUSR1: ::c_int = 30;
-pub const SIGUSR2: ::c_int = 31;
-pub const SIGCONT: ::c_int = 19;
-pub const SIGSTOP: ::c_int = 17;
-pub const SIGTSTP: ::c_int = 18;
-pub const SIGURG: ::c_int = 16;
-pub const SIGIO: ::c_int = 23;
-pub const SIGSYS: ::c_int = 12;
-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 SIGINFO: ::c_int = 29;
-
-pub const SIG_SETMASK: ::c_int = 3;
-pub const SIG_BLOCK: ::c_int = 0x1;
-pub const SIG_UNBLOCK: ::c_int = 0x2;
-
-pub const IP_TOS: ::c_int = 3;
-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;
-
-pub const IPTOS_ECN_NOTECT: u8 = 0x00;
-pub const IPTOS_ECN_MASK: u8 = 0x03;
-pub const IPTOS_ECN_ECT1: u8 = 0x01;
-pub const IPTOS_ECN_ECT0: u8 = 0x02;
-pub const IPTOS_ECN_CE: u8 = 0x03;
-
-pub const ST_RDONLY: ::c_ulong = 1;
-
-pub const SCM_RIGHTS: ::c_int = 0x01;
-
-pub const NCCS: usize = 20;
-
-pub const O_ACCMODE: ::c_int = 0x3;
-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 = 8;
-pub const O_CREAT: ::c_int = 512;
-pub const O_TRUNC: ::c_int = 1024;
-pub const O_EXCL: ::c_int = 2048;
-pub const O_ASYNC: ::c_int = 0x40;
-pub const O_SYNC: ::c_int = 0x80;
-pub const O_NONBLOCK: ::c_int = 0x4;
-pub const O_NOFOLLOW: ::c_int = 0x100;
-pub const O_SHLOCK: ::c_int = 0x10;
-pub const O_EXLOCK: ::c_int = 0x20;
-pub const O_FSYNC: ::c_int = O_SYNC;
-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;
-pub const Q_QUOTAON: ::c_int = 0x100;
-pub const Q_QUOTAOFF: ::c_int = 0x200;
-
-pub const TCIOFF: ::c_int = 3;
-pub const TCION: ::c_int = 4;
-pub const TCOOFF: ::c_int = 1;
-pub const TCOON: ::c_int = 2;
-pub const TCIFLUSH: ::c_int = 1;
-pub const TCOFLUSH: ::c_int = 2;
-pub const TCIOFLUSH: ::c_int = 3;
-pub const TCSANOW: ::c_int = 0;
-pub const TCSADRAIN: ::c_int = 1;
-pub const TCSAFLUSH: ::c_int = 2;
-pub const VEOF: usize = 0;
-pub const VEOL: usize = 1;
-pub const VEOL2: usize = 2;
-pub const VERASE: usize = 3;
-pub const VWERASE: usize = 4;
-pub const VKILL: usize = 5;
-pub const VREPRINT: usize = 6;
-pub const VINTR: usize = 8;
-pub const VQUIT: usize = 9;
-pub const VSUSP: usize = 10;
-pub const VDSUSP: usize = 11;
-pub const VSTART: usize = 12;
-pub const VSTOP: usize = 13;
-pub const VLNEXT: usize = 14;
-pub const VDISCARD: usize = 15;
-pub const VMIN: usize = 16;
-pub const VTIME: usize = 17;
-pub const VSTATUS: usize = 18;
-pub const _POSIX_VDISABLE: ::cc_t = 0xff;
-pub const IGNBRK: ::tcflag_t = 0x00000001;
-pub const BRKINT: ::tcflag_t = 0x00000002;
-pub const IGNPAR: ::tcflag_t = 0x00000004;
-pub const PARMRK: ::tcflag_t = 0x00000008;
-pub const INPCK: ::tcflag_t = 0x00000010;
-pub const ISTRIP: ::tcflag_t = 0x00000020;
-pub const INLCR: ::tcflag_t = 0x00000040;
-pub const IGNCR: ::tcflag_t = 0x00000080;
-pub const ICRNL: ::tcflag_t = 0x00000100;
-pub const IXON: ::tcflag_t = 0x00000200;
-pub const IXOFF: ::tcflag_t = 0x00000400;
-pub const IXANY: ::tcflag_t = 0x00000800;
-pub const IMAXBEL: ::tcflag_t = 0x00002000;
-pub const OPOST: ::tcflag_t = 0x1;
-pub const ONLCR: ::tcflag_t = 0x2;
-pub const OXTABS: ::tcflag_t = 0x4;
-pub const ONOEOT: ::tcflag_t = 0x8;
-pub const CIGNORE: ::tcflag_t = 0x00000001;
-pub const CSIZE: ::tcflag_t = 0x00000300;
-pub const CS5: ::tcflag_t = 0x00000000;
-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 ECHO: ::tcflag_t = 0x00000008;
-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 ALTWERASE: ::tcflag_t = 0x00000200;
-pub const IEXTEN: ::tcflag_t = 0x00000400;
-pub const EXTPROC: ::tcflag_t = 0x00000800;
-pub const TOSTOP: ::tcflag_t = 0x00400000;
-pub const FLUSHO: ::tcflag_t = 0x00800000;
-pub const NOKERNINFO: ::tcflag_t = 0x02000000;
-pub const PENDIN: ::tcflag_t = 0x20000000;
-pub const NOFLSH: ::tcflag_t = 0x80000000;
-pub const MDMBUF: ::tcflag_t = 0x00100000;
-
-pub const WNOHANG: ::c_int = 0x00000001;
-pub const WUNTRACED: ::c_int = 0x00000002;
-
-pub const RTLD_LAZY: ::c_int = 0x1;
-pub const RTLD_NOW: ::c_int = 0x2;
-pub const RTLD_NEXT: *mut ::c_void = -1isize as *mut ::c_void;
-pub const RTLD_DEFAULT: *mut ::c_void = -2isize as *mut ::c_void;
-pub const RTLD_SELF: *mut ::c_void = -3isize as *mut ::c_void;
-
-pub const LOG_CRON: ::c_int = 9 << 3;
-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;
-
-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 POLLRDNORM: ::c_short = 0x040;
-pub const POLLWRNORM: ::c_short = 0x004;
-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 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;
- (*set).fds_bits[fd / bits] &= !(1 << (fd % bits));
- return
- }
-
- pub fn FD_ISSET(fd: ::c_int, set: *mut fd_set) -> bool {
- let bits = ::mem::size_of_val(&(*set).fds_bits[0]) * 8;
- let fd = fd as usize;
- return ((*set).fds_bits[fd / bits] & (1 << (fd % bits))) != 0
- }
-
- pub fn FD_SET(fd: ::c_int, set: *mut fd_set) -> () {
- let bits = ::mem::size_of_val(&(*set).fds_bits[0]) * 8;
- let fd = fd as usize;
- (*set).fds_bits[fd / bits] |= 1 << (fd % bits);
- return
- }
-
- pub fn FD_ZERO(set: *mut fd_set) -> () {
- for slot in (*set).fds_bits.iter_mut() {
- *slot = 0;
- }
- }
-
- pub fn WTERMSIG(status: ::c_int) -> ::c_int {
- status & 0o177
- }
-
- pub fn WIFEXITED(status: ::c_int) -> bool {
- (status & 0o177) == 0
- }
-
- pub fn WEXITSTATUS(status: ::c_int) -> ::c_int {
- status >> 8
- }
-
- pub fn WCOREDUMP(status: ::c_int) -> bool {
- (status & 0o200) != 0
- }
-
- pub fn QCMD(cmd: ::c_int, type_: ::c_int) -> ::c_int {
- (cmd << 8) | (type_ & 0x00ff)
- }
-}
-
-extern {
- #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
- link_name = "getrlimit$UNIX2003")]
- pub fn getrlimit(resource: ::c_int, rlim: *mut ::rlimit) -> ::c_int;
- #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
- link_name = "setrlimit$UNIX2003")]
- pub fn setrlimit(resource: ::c_int, rlim: *const ::rlimit) -> ::c_int;
-
- pub fn strerror_r(errnum: ::c_int, buf: *mut c_char,
- buflen: ::size_t) -> ::c_int;
- 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,
- ptr: *const ::gid_t) -> ::c_int;
- pub fn ioctl(fd: ::c_int, request: ::c_ulong, ...) -> ::c_int;
- pub fn kqueue() -> ::c_int;
- pub fn unmount(target: *const ::c_char, arg: ::c_int) -> ::c_int;
- pub fn syscall(num: ::c_int, ...) -> ::c_int;
- #[cfg_attr(target_os = "netbsd", link_name = "__getpwent50")]
- pub fn getpwent() -> *mut passwd;
- pub fn setpwent();
- pub fn endpwent();
- 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;
- pub fn if_nameindex() -> *mut if_nameindex;
- pub fn if_freenameindex(ptr: *mut if_nameindex);
-
- pub fn getpeereid(socket: ::c_int,
- euid: *mut ::uid_t,
- egid: *mut ::gid_t) -> ::c_int;
-
- #[cfg_attr(target_os = "macos", link_name = "glob$INODE64")]
- #[cfg_attr(target_os = "netbsd", link_name = "__glob30")]
- #[cfg_attr(
- all(target_os = "freebsd", not(freebsd12)),
- 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(
- all(target_os = "freebsd", not(freebsd12)),
- 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)
- -> ::c_int;
-
- pub fn shm_unlink(name: *const ::c_char) -> ::c_int;
-
- #[cfg_attr(all(target_os = "macos", target_arch = "x86_64"),
- link_name = "seekdir$INODE64")]
- #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
- link_name = "seekdir$INODE64$UNIX2003")]
- pub fn seekdir(dirp: *mut ::DIR, loc: ::c_long);
-
- #[cfg_attr(all(target_os = "macos", target_arch = "x86_64"),
- link_name = "telldir$INODE64")]
- #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
- link_name = "telldir$INODE64$UNIX2003")]
- pub fn telldir(dirp: *mut ::DIR) -> ::c_long;
- pub fn madvise(addr: *mut ::c_void, len: ::size_t, advice: ::c_int)
- -> ::c_int;
-
- #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
- link_name = "msync$UNIX2003")]
- #[cfg_attr(target_os = "netbsd", link_name = "__msync13")]
- pub fn msync(addr: *mut ::c_void, len: ::size_t, flags: ::c_int) -> ::c_int;
-
- #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
- link_name = "recvfrom$UNIX2003")]
- 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 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;
-
- #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
- link_name = "bind$UNIX2003")]
- pub fn bind(socket: ::c_int, address: *const ::sockaddr,
- address_len: ::socklen_t) -> ::c_int;
-
- #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
- link_name = "writev$UNIX2003")]
- pub fn writev(fd: ::c_int,
- iov: *const ::iovec,
- iovcnt: ::c_int) -> ::ssize_t;
- #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
- link_name = "readv$UNIX2003")]
- pub fn readv(fd: ::c_int,
- iov: *const ::iovec,
- iovcnt: ::c_int) -> ::ssize_t;
-
- #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
- link_name = "sendmsg$UNIX2003")]
- pub fn sendmsg(fd: ::c_int,
- msg: *const ::msghdr,
- flags: ::c_int) -> ::ssize_t;
- #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
- link_name = "recvmsg$UNIX2003")]
- pub fn recvmsg(fd: ::c_int, msg: *mut ::msghdr, flags: ::c_int)
- -> ::ssize_t;
-
- pub fn sync();
- #[cfg_attr(target_os = "solaris", link_name = "__posix_getgrgid_r")]
- pub fn getgrgid_r(gid: ::gid_t,
- grp: *mut ::group,
- buf: *mut ::c_char,
- buflen: ::size_t,
- result: *mut *mut ::group) -> ::c_int;
- #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
- link_name = "sigaltstack$UNIX2003")]
- #[cfg_attr(target_os = "netbsd", link_name = "__sigaltstack14")]
- pub fn sigaltstack(ss: *const stack_t,
- oss: *mut stack_t) -> ::c_int;
- pub fn sem_close(sem: *mut sem_t) -> ::c_int;
- pub fn getdtablesize() -> ::c_int;
- #[cfg_attr(target_os = "solaris", link_name = "__posix_getgrnam_r")]
- pub fn getgrnam_r(name: *const ::c_char,
- grp: *mut ::group,
- buf: *mut ::c_char,
- buflen: ::size_t,
- result: *mut *mut ::group) -> ::c_int;
- #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
- link_name = "pthread_sigmask$UNIX2003")]
- pub fn pthread_sigmask(how: ::c_int, set: *const sigset_t,
- oldset: *mut sigset_t) -> ::c_int;
- pub fn sem_open(name: *const ::c_char, oflag: ::c_int, ...) -> *mut sem_t;
- pub fn getgrnam(name: *const ::c_char) -> *mut ::group;
- #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
- link_name = "pthread_cancel$UNIX2003")]
- pub fn pthread_cancel(thread: ::pthread_t) -> ::c_int;
- pub fn pthread_kill(thread: ::pthread_t, sig: ::c_int) -> ::c_int;
- pub fn sem_unlink(name: *const ::c_char) -> ::c_int;
- #[cfg_attr(target_os = "netbsd", link_name = "__getpwnam_r50")]
- #[cfg_attr(target_os = "solaris", link_name = "__posix_getpwnam_r")]
- pub fn getpwnam_r(name: *const ::c_char,
- pwd: *mut passwd,
- buf: *mut ::c_char,
- buflen: ::size_t,
- result: *mut *mut passwd) -> ::c_int;
- #[cfg_attr(target_os = "netbsd", link_name = "__getpwuid_r50")]
- #[cfg_attr(target_os = "solaris", link_name = "__posix_getpwuid_r")]
- pub fn getpwuid_r(uid: ::uid_t,
- pwd: *mut passwd,
- buf: *mut ::c_char,
- buflen: ::size_t,
- result: *mut *mut passwd) -> ::c_int;
- #[cfg_attr(all(target_os = "macos", target_arch ="x86"),
- link_name = "sigwait$UNIX2003")]
- #[cfg_attr(target_os = "solaris", link_name = "__posix_sigwait")]
- pub fn sigwait(set: *const sigset_t,
- sig: *mut ::c_int) -> ::c_int;
- pub fn pthread_atfork(prepare: ::Option<unsafe extern fn()>,
- parent: ::Option<unsafe extern fn()>,
- child: ::Option<unsafe extern fn()>) -> ::c_int;
- pub fn getgrgid(gid: ::gid_t) -> *mut ::group;
- #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
- link_name = "popen$UNIX2003")]
- pub fn popen(command: *const c_char,
- mode: *const c_char) -> *mut ::FILE;
- pub fn faccessat(dirfd: ::c_int, pathname: *const ::c_char,
- mode: ::c_int, flags: ::c_int) -> ::c_int;
- pub fn pthread_create(native: *mut ::pthread_t,
- 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! {
- if #[cfg(any(target_os = "macos", target_os = "ios"))] {
- mod apple;
- pub use self::apple::*;
- } else if #[cfg(any(target_os = "openbsd", target_os = "netbsd"))] {
- mod netbsdlike;
- pub use self::netbsdlike::*;
- } else if #[cfg(any(target_os = "freebsd", target_os = "dragonfly"))] {
- mod freebsdlike;
- pub use self::freebsdlike::*;
- } else {
- // Unknown target_os
- }
-}
diff --git a/libc/src/unix/bsd/netbsdlike/mod.rs b/libc/src/unix/bsd/netbsdlike/mod.rs
deleted file mode 100644
index 2630a2f..0000000
--- a/libc/src/unix/bsd/netbsdlike/mod.rs
+++ /dev/null
@@ -1,686 +0,0 @@
-pub type time_t = i64;
-pub type mode_t = u32;
-pub type nlink_t = u32;
-pub type ino_t = u64;
-pub type pthread_key_t = ::c_int;
-pub type rlim_t = u64;
-pub type speed_t = ::c_uint;
-pub type tcflag_t = ::c_uint;
-pub type nl_item = c_long;
-pub type clockid_t = ::c_int;
-pub type id_t = u32;
-pub type sem_t = *mut sem;
-
-#[cfg_attr(feature = "extra_traits", derive(Debug))]
-pub enum timezone {}
-impl ::Copy for timezone {}
-impl ::Clone for timezone {
- fn clone(&self) -> timezone { *self }
-}
-#[cfg_attr(feature = "extra_traits", derive(Debug))]
-pub enum sem {}
-impl ::Copy for sem {}
-impl ::Clone for sem {
- fn clone(&self) -> sem { *self }
-}
-
-s! {
- pub struct sigaction {
- pub sa_sigaction: ::sighandler_t,
- pub sa_mask: ::sigset_t,
- pub sa_flags: ::c_int,
- }
-
- pub struct stack_t {
- pub ss_sp: *mut ::c_void,
- pub ss_size: ::size_t,
- pub ss_flags: ::c_int,
- }
-
- 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,
- pub c_cflag: ::tcflag_t,
- pub c_lflag: ::tcflag_t,
- pub c_cc: [::cc_t; ::NCCS],
- pub c_ispeed: ::c_int,
- pub c_ospeed: ::c_int,
- }
-
- pub struct flock {
- pub l_start: ::off_t,
- pub l_len: ::off_t,
- pub l_pid: ::pid_t,
- pub l_type: ::c_short,
- pub l_whence: ::c_short,
- }
-}
-
-pub const D_T_FMT: ::nl_item = 0;
-pub const D_FMT: ::nl_item = 1;
-pub const T_FMT: ::nl_item = 2;
-pub const T_FMT_AMPM: ::nl_item = 3;
-pub const AM_STR: ::nl_item = 4;
-pub const PM_STR: ::nl_item = 5;
-
-pub const DAY_1: ::nl_item = 6;
-pub const DAY_2: ::nl_item = 7;
-pub const DAY_3: ::nl_item = 8;
-pub const DAY_4: ::nl_item = 9;
-pub const DAY_5: ::nl_item = 10;
-pub const DAY_6: ::nl_item = 11;
-pub const DAY_7: ::nl_item = 12;
-
-pub const ABDAY_1: ::nl_item = 13;
-pub const ABDAY_2: ::nl_item = 14;
-pub const ABDAY_3: ::nl_item = 15;
-pub const ABDAY_4: ::nl_item = 16;
-pub const ABDAY_5: ::nl_item = 17;
-pub const ABDAY_6: ::nl_item = 18;
-pub const ABDAY_7: ::nl_item = 19;
-
-pub const MON_1: ::nl_item = 20;
-pub const MON_2: ::nl_item = 21;
-pub const MON_3: ::nl_item = 22;
-pub const MON_4: ::nl_item = 23;
-pub const MON_5: ::nl_item = 24;
-pub const MON_6: ::nl_item = 25;
-pub const MON_7: ::nl_item = 26;
-pub const MON_8: ::nl_item = 27;
-pub const MON_9: ::nl_item = 28;
-pub const MON_10: ::nl_item = 29;
-pub const MON_11: ::nl_item = 30;
-pub const MON_12: ::nl_item = 31;
-
-pub const ABMON_1: ::nl_item = 32;
-pub const ABMON_2: ::nl_item = 33;
-pub const ABMON_3: ::nl_item = 34;
-pub const ABMON_4: ::nl_item = 35;
-pub const ABMON_5: ::nl_item = 36;
-pub const ABMON_6: ::nl_item = 37;
-pub const ABMON_7: ::nl_item = 38;
-pub const ABMON_8: ::nl_item = 39;
-pub const ABMON_9: ::nl_item = 40;
-pub const ABMON_10: ::nl_item = 41;
-pub const ABMON_11: ::nl_item = 42;
-pub const ABMON_12: ::nl_item = 43;
-
-pub const RADIXCHAR: ::nl_item = 44;
-pub const THOUSEP: ::nl_item = 45;
-pub const YESSTR: ::nl_item = 46;
-pub const YESEXPR: ::nl_item = 47;
-pub const NOSTR: ::nl_item = 48;
-pub const NOEXPR: ::nl_item = 49;
-pub const CRNCYSTR: ::nl_item = 50;
-
-pub const CODESET: ::nl_item = 51;
-
-pub const EXIT_FAILURE : ::c_int = 1;
-pub const EXIT_SUCCESS : ::c_int = 0;
-pub const RAND_MAX : ::c_int = 2147483647;
-pub const EOF : ::c_int = -1;
-pub const SEEK_SET : ::c_int = 0;
-pub const SEEK_CUR : ::c_int = 1;
-pub const SEEK_END : ::c_int = 2;
-pub const _IOFBF : ::c_int = 0;
-pub const _IONBF : ::c_int = 2;
-pub const _IOLBF : ::c_int = 1;
-pub const BUFSIZ : ::c_uint = 1024;
-pub const FOPEN_MAX : ::c_uint = 20;
-pub const FILENAME_MAX : ::c_uint = 1024;
-pub const L_tmpnam : ::c_uint = 1024;
-pub const O_NOCTTY : ::c_int = 32768;
-pub const S_IFIFO : mode_t = 4096;
-pub const S_IFCHR : mode_t = 8192;
-pub const S_IFBLK : mode_t = 24576;
-pub const S_IFDIR : mode_t = 16384;
-pub const S_IFREG : mode_t = 32768;
-pub const S_IFLNK : mode_t = 40960;
-pub const S_IFSOCK : mode_t = 49152;
-pub const S_IFMT : mode_t = 61440;
-pub const S_IEXEC : mode_t = 64;
-pub const S_IWRITE : mode_t = 128;
-pub const S_IREAD : mode_t = 256;
-pub const S_IRWXU : mode_t = 448;
-pub const S_IXUSR : mode_t = 64;
-pub const S_IWUSR : mode_t = 128;
-pub const S_IRUSR : mode_t = 256;
-pub const S_IRWXG : mode_t = 56;
-pub const S_IXGRP : mode_t = 8;
-pub const S_IWGRP : mode_t = 16;
-pub const S_IRGRP : mode_t = 32;
-pub const S_IRWXO : mode_t = 7;
-pub const S_IXOTH : mode_t = 1;
-pub const S_IWOTH : mode_t = 2;
-pub const S_IROTH : mode_t = 4;
-pub const F_OK : ::c_int = 0;
-pub const R_OK : ::c_int = 4;
-pub const W_OK : ::c_int = 2;
-pub const X_OK : ::c_int = 1;
-pub const STDIN_FILENO : ::c_int = 0;
-pub const STDOUT_FILENO : ::c_int = 1;
-pub const STDERR_FILENO : ::c_int = 2;
-pub const F_LOCK : ::c_int = 1;
-pub const F_TEST : ::c_int = 3;
-pub const F_TLOCK : ::c_int = 2;
-pub const F_ULOCK : ::c_int = 0;
-pub const F_GETLK: ::c_int = 7;
-pub const F_SETLK: ::c_int = 8;
-pub const F_SETLKW: ::c_int = 9;
-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 PROT_NONE : ::c_int = 0;
-pub const PROT_READ : ::c_int = 1;
-pub const PROT_WRITE : ::c_int = 2;
-pub const PROT_EXEC : ::c_int = 4;
-
-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_FAILED : *mut ::c_void = !0 as *mut ::c_void;
-
-pub const MCL_CURRENT : ::c_int = 0x0001;
-pub const MCL_FUTURE : ::c_int = 0x0002;
-
-pub const MS_ASYNC : ::c_int = 0x0001;
-
-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 EDEADLK : ::c_int = 11;
-pub const ENOMEM : ::c_int = 12;
-pub const EACCES : ::c_int = 13;
-pub const EFAULT : ::c_int = 14;
-pub const ENOTBLK : ::c_int = 15;
-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 EAGAIN : ::c_int = 35;
-pub const EWOULDBLOCK : ::c_int = 35;
-pub const EINPROGRESS : ::c_int = 36;
-pub const EALREADY : ::c_int = 37;
-pub const ENOTSOCK : ::c_int = 38;
-pub const EDESTADDRREQ : ::c_int = 39;
-pub const EMSGSIZE : ::c_int = 40;
-pub const EPROTOTYPE : ::c_int = 41;
-pub const ENOPROTOOPT : ::c_int = 42;
-pub const EPROTONOSUPPORT : ::c_int = 43;
-pub const ESOCKTNOSUPPORT : ::c_int = 44;
-pub const EOPNOTSUPP : ::c_int = 45;
-pub const EPFNOSUPPORT : ::c_int = 46;
-pub const EAFNOSUPPORT : ::c_int = 47;
-pub const EADDRINUSE : ::c_int = 48;
-pub const EADDRNOTAVAIL : ::c_int = 49;
-pub const ENETDOWN : ::c_int = 50;
-pub const ENETUNREACH : ::c_int = 51;
-pub const ENETRESET : ::c_int = 52;
-pub const ECONNABORTED : ::c_int = 53;
-pub const ECONNRESET : ::c_int = 54;
-pub const ENOBUFS : ::c_int = 55;
-pub const EISCONN : ::c_int = 56;
-pub const ENOTCONN : ::c_int = 57;
-pub const ESHUTDOWN : ::c_int = 58;
-pub const ETOOMANYREFS : ::c_int = 59;
-pub const ETIMEDOUT : ::c_int = 60;
-pub const ECONNREFUSED : ::c_int = 61;
-pub const ELOOP : ::c_int = 62;
-pub const ENAMETOOLONG : ::c_int = 63;
-pub const EHOSTDOWN : ::c_int = 64;
-pub const EHOSTUNREACH : ::c_int = 65;
-pub const ENOTEMPTY : ::c_int = 66;
-pub const EPROCLIM : ::c_int = 67;
-pub const EUSERS : ::c_int = 68;
-pub const EDQUOT : ::c_int = 69;
-pub const ESTALE : ::c_int = 70;
-pub const EREMOTE : ::c_int = 71;
-pub const EBADRPC : ::c_int = 72;
-pub const ERPCMISMATCH : ::c_int = 73;
-pub const EPROGUNAVAIL : ::c_int = 74;
-pub const EPROGMISMATCH : ::c_int = 75;
-pub const EPROCUNAVAIL : ::c_int = 76;
-pub const ENOLCK : ::c_int = 77;
-pub const ENOSYS : ::c_int = 78;
-pub const EFTYPE : ::c_int = 79;
-pub const EAUTH : ::c_int = 80;
-pub const ENEEDAUTH : ::c_int = 81;
-
-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 SIGTRAP : ::c_int = 5;
-
-pub const GLOB_APPEND : ::c_int = 0x0001;
-pub const GLOB_DOOFFS : ::c_int = 0x0002;
-pub const GLOB_ERR : ::c_int = 0x0004;
-pub const GLOB_MARK : ::c_int = 0x0008;
-pub const GLOB_NOCHECK : ::c_int = 0x0010;
-pub const GLOB_NOSORT : ::c_int = 0x0020;
-pub const GLOB_NOESCAPE : ::c_int = 0x1000;
-
-pub const GLOB_NOSPACE : ::c_int = -1;
-pub const GLOB_ABORTED : ::c_int = -2;
-pub const GLOB_NOMATCH : ::c_int = -3;
-pub const GLOB_NOSYS : ::c_int = -4;
-
-pub const POSIX_MADV_NORMAL : ::c_int = 0;
-pub const POSIX_MADV_RANDOM : ::c_int = 1;
-pub const POSIX_MADV_SEQUENTIAL : ::c_int = 2;
-pub const POSIX_MADV_WILLNEED : ::c_int = 3;
-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
-// the implementation rejects anything other than the below two
-//
-// http://netbsd.gw.com/cgi-bin/man-cgi?clock_gettime
-// https://github.com/jsonn/src/blob/HEAD/sys/kern/subr_time.c#L222
-// Basically the same goes for NetBSD
-pub const CLOCK_REALTIME: ::clockid_t = 0;
-pub const CLOCK_MONOTONIC: ::clockid_t = 3;
-
-pub const RLIMIT_CPU: ::c_int = 0;
-pub const RLIMIT_FSIZE: ::c_int = 1;
-pub const RLIMIT_DATA: ::c_int = 2;
-pub const RLIMIT_STACK: ::c_int = 3;
-pub const RLIMIT_CORE: ::c_int = 4;
-pub const RLIMIT_RSS: ::c_int = 5;
-pub const RLIMIT_MEMLOCK: ::c_int = 6;
-pub const RLIMIT_NPROC: ::c_int = 7;
-pub const RLIMIT_NOFILE: ::c_int = 8;
-
-pub const RLIM_INFINITY: rlim_t = 0x7fff_ffff_ffff_ffff;
-pub const RLIM_SAVED_MAX: rlim_t = RLIM_INFINITY;
-pub const RLIM_SAVED_CUR: rlim_t = RLIM_INFINITY;
-
-pub const RUSAGE_SELF: ::c_int = 0;
-pub const RUSAGE_CHILDREN: ::c_int = -1;
-
-pub const MADV_NORMAL : ::c_int = 0;
-pub const MADV_RANDOM : ::c_int = 1;
-pub const MADV_SEQUENTIAL : ::c_int = 2;
-pub const MADV_WILLNEED : ::c_int = 3;
-pub const MADV_DONTNEED : ::c_int = 4;
-pub const MADV_FREE : ::c_int = 6;
-
-pub const AF_UNSPEC: ::c_int = 0;
-pub const AF_LOCAL: ::c_int = 1;
-pub const AF_UNIX: ::c_int = AF_LOCAL;
-pub const AF_INET: ::c_int = 2;
-pub const AF_IMPLINK: ::c_int = 3;
-pub const AF_PUP: ::c_int = 4;
-pub const AF_CHAOS: ::c_int = 5;
-pub const AF_NS: ::c_int = 6;
-pub const AF_ISO: ::c_int = 7;
-pub const AF_OSI: ::c_int = AF_ISO;
-pub const AF_DATAKIT: ::c_int = 9;
-pub const AF_CCITT: ::c_int = 10;
-pub const AF_SNA: ::c_int = 11;
-pub const AF_DECnet: ::c_int = 12;
-pub const AF_DLI: ::c_int = 13;
-pub const AF_LAT: ::c_int = 14;
-pub const AF_HYLINK: ::c_int = 15;
-pub const AF_APPLETALK: ::c_int = 16;
-pub const AF_LINK: ::c_int = 18;
-pub const pseudo_AF_XTP: ::c_int = 19;
-pub const AF_COIP: ::c_int = 20;
-pub const AF_CNT: ::c_int = 21;
-pub const pseudo_AF_RTIP: ::c_int = 22;
-pub const AF_IPX: ::c_int = 23;
-pub const AF_INET6: ::c_int = 24;
-pub const pseudo_AF_PIP: ::c_int = 25;
-pub const AF_ISDN: ::c_int = 26;
-pub const AF_E164: ::c_int = AF_ISDN;
-pub const AF_NATM: ::c_int = 27;
-
-pub const PF_UNSPEC: ::c_int = AF_UNSPEC;
-pub const PF_LOCAL: ::c_int = AF_LOCAL;
-pub const PF_UNIX: ::c_int = PF_LOCAL;
-pub const PF_INET: ::c_int = AF_INET;
-pub const PF_IMPLINK: ::c_int = AF_IMPLINK;
-pub const PF_PUP: ::c_int = AF_PUP;
-pub const PF_CHAOS: ::c_int = AF_CHAOS;
-pub const PF_NS: ::c_int = AF_NS;
-pub const PF_ISO: ::c_int = AF_ISO;
-pub const PF_OSI: ::c_int = AF_ISO;
-pub const PF_DATAKIT: ::c_int = AF_DATAKIT;
-pub const PF_CCITT: ::c_int = AF_CCITT;
-pub const PF_SNA: ::c_int = AF_SNA;
-pub const PF_DECnet: ::c_int = AF_DECnet;
-pub const PF_DLI: ::c_int = AF_DLI;
-pub const PF_LAT: ::c_int = AF_LAT;
-pub const PF_HYLINK: ::c_int = AF_HYLINK;
-pub const PF_APPLETALK: ::c_int = AF_APPLETALK;
-pub const PF_LINK: ::c_int = AF_LINK;
-pub const PF_XTP: ::c_int = pseudo_AF_XTP;
-pub const PF_COIP: ::c_int = AF_COIP;
-pub const PF_CNT: ::c_int = AF_CNT;
-pub const PF_IPX: ::c_int = AF_IPX;
-pub const PF_INET6: ::c_int = AF_INET6;
-pub const PF_RTIP: ::c_int = pseudo_AF_RTIP;
-pub const PF_PIP: ::c_int = pseudo_AF_PIP;
-pub const PF_ISDN: ::c_int = AF_ISDN;
-pub const PF_NATM: ::c_int = AF_NATM;
-
-pub const SOCK_STREAM: ::c_int = 1;
-pub const SOCK_DGRAM: ::c_int = 2;
-pub const SOCK_RAW: ::c_int = 3;
-pub const SOCK_RDM: ::c_int = 4;
-pub const SOCK_SEQPACKET: ::c_int = 5;
-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 IPV6_RECVTCLASS: ::c_int = 57;
-pub const IPV6_TCLASS: ::c_int = 61;
-
-pub const SOL_SOCKET: ::c_int = 0xffff;
-pub const SO_DEBUG: ::c_int = 0x01;
-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_ERROR: ::c_int = 0x1007;
-pub const SO_TYPE: ::c_int = 0x1008;
-
-pub const SOMAXCONN: ::c_int = 128;
-
-pub const MSG_OOB: ::c_int = 0x1;
-pub const MSG_PEEK: ::c_int = 0x2;
-pub const MSG_DONTROUTE: ::c_int = 0x4;
-pub const MSG_EOR: ::c_int = 0x8;
-pub const MSG_TRUNC: ::c_int = 0x10;
-pub const MSG_CTRUNC: ::c_int = 0x20;
-pub const MSG_WAITALL: ::c_int = 0x40;
-pub const MSG_DONTWAIT: ::c_int = 0x80;
-pub const MSG_BCAST: ::c_int = 0x100;
-pub const MSG_MCAST: ::c_int = 0x200;
-pub const MSG_NOSIGNAL: ::c_int = 0x400;
-pub const MSG_CMSG_CLOEXEC: ::c_int = 0x800;
-
-pub const SHUT_RD: ::c_int = 0;
-pub const SHUT_WR: ::c_int = 1;
-pub const SHUT_RDWR: ::c_int = 2;
-
-pub const LOCK_SH: ::c_int = 1;
-pub const LOCK_EX: ::c_int = 2;
-pub const LOCK_NB: ::c_int = 4;
-pub const LOCK_UN: ::c_int = 8;
-
-pub const IPPROTO_RAW : ::c_int = 255;
-
-pub const _SC_ARG_MAX : ::c_int = 1;
-pub const _SC_CHILD_MAX : ::c_int = 2;
-pub const _SC_NGROUPS_MAX : ::c_int = 4;
-pub const _SC_OPEN_MAX : ::c_int = 5;
-pub const _SC_JOB_CONTROL : ::c_int = 6;
-pub const _SC_SAVED_IDS : ::c_int = 7;
-pub const _SC_VERSION : ::c_int = 8;
-pub const _SC_BC_BASE_MAX : ::c_int = 9;
-pub const _SC_BC_DIM_MAX : ::c_int = 10;
-pub const _SC_BC_SCALE_MAX : ::c_int = 11;
-pub const _SC_BC_STRING_MAX : ::c_int = 12;
-pub const _SC_COLL_WEIGHTS_MAX : ::c_int = 13;
-pub const _SC_EXPR_NEST_MAX : ::c_int = 14;
-pub const _SC_LINE_MAX : ::c_int = 15;
-pub const _SC_RE_DUP_MAX : ::c_int = 16;
-pub const _SC_2_VERSION : ::c_int = 17;
-pub const _SC_2_C_BIND : ::c_int = 18;
-pub const _SC_2_C_DEV : ::c_int = 19;
-pub const _SC_2_CHAR_TERM : ::c_int = 20;
-pub const _SC_2_FORT_DEV : ::c_int = 21;
-pub const _SC_2_FORT_RUN : ::c_int = 22;
-pub const _SC_2_LOCALEDEF : ::c_int = 23;
-pub const _SC_2_SW_DEV : ::c_int = 24;
-pub const _SC_2_UPE : ::c_int = 25;
-pub const _SC_STREAM_MAX : ::c_int = 26;
-pub const _SC_TZNAME_MAX : ::c_int = 27;
-pub const _SC_PAGESIZE : ::c_int = 28;
-pub const _SC_PAGE_SIZE: ::c_int = _SC_PAGESIZE;
-pub const _SC_FSYNC : ::c_int = 29;
-pub const _SC_XOPEN_SHM : ::c_int = 30;
-
-pub const Q_GETQUOTA: ::c_int = 0x300;
-pub const Q_SETQUOTA: ::c_int = 0x400;
-
-pub const RTLD_GLOBAL: ::c_int = 0x100;
-
-pub const LOG_NFACILITIES: ::c_int = 24;
-
-pub const HW_NCPU: ::c_int = 3;
-
-pub const B0: speed_t = 0;
-pub const B50: speed_t = 50;
-pub const B75: speed_t = 75;
-pub const B110: speed_t = 110;
-pub const B134: speed_t = 134;
-pub const B150: speed_t = 150;
-pub const B200: speed_t = 200;
-pub const B300: speed_t = 300;
-pub const B600: speed_t = 600;
-pub const B1200: speed_t = 1200;
-pub const B1800: speed_t = 1800;
-pub const B2400: speed_t = 2400;
-pub const B4800: speed_t = 4800;
-pub const B9600: speed_t = 9600;
-pub const B19200: speed_t = 19200;
-pub const B38400: speed_t = 38400;
-pub const B7200: speed_t = 7200;
-pub const B14400: speed_t = 14400;
-pub const B28800: speed_t = 28800;
-pub const B57600: speed_t = 57600;
-pub const B76800: speed_t = 76800;
-pub const B115200: speed_t = 115200;
-pub const B230400: speed_t = 230400;
-pub const EXTA: speed_t = 19200;
-pub const EXTB: speed_t = 38400;
-
-pub const SEM_FAILED: *mut sem_t = 0 as *mut sem_t;
-
-pub const CRTSCTS: ::tcflag_t = 0x00010000;
-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;
-pub const TIOCM_ST: ::c_int = 0o0010;
-pub const TIOCM_SR: ::c_int = 0o0020;
-pub const TIOCM_CTS: ::c_int = 0o0040;
-pub const TIOCM_CAR: ::c_int = 0o0100;
-pub const TIOCM_RNG: ::c_int = 0o0200;
-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;
-
-#[link(name = "util")]
-extern {
- pub fn setgrent();
- pub fn sem_destroy(sem: *mut sem_t) -> ::c_int;
- pub fn sem_init(sem: *mut sem_t,
- pshared: ::c_int,
- value: ::c_uint)
- -> ::c_int;
-
- pub fn daemon(nochdir: ::c_int, noclose: ::c_int) -> ::c_int;
- pub fn mincore(addr: *mut ::c_void, len: ::size_t,
- vec: *mut ::c_char) -> ::c_int;
- #[cfg_attr(target_os = "netbsd", link_name = "__clock_getres50")]
- pub fn clock_getres(clk_id: ::clockid_t, tp: *mut ::timespec) -> ::c_int;
- #[cfg_attr(target_os = "netbsd", link_name = "__clock_gettime50")]
- pub fn clock_gettime(clk_id: ::clockid_t, tp: *mut ::timespec) -> ::c_int;
- #[cfg_attr(target_os = "netbsd", link_name = "__clock_settime50")]
- pub fn clock_settime(clk_id: ::clockid_t, tp: *const ::timespec) -> ::c_int;
- pub fn __errno() -> *mut ::c_int;
- pub fn shm_open(name: *const ::c_char, oflag: ::c_int, mode: ::mode_t)
- -> ::c_int;
- pub fn memrchr(cx: *const ::c_void,
- c: ::c_int,
- n: ::size_t) -> *mut ::c_void;
- pub fn mkostemp(template: *mut ::c_char, flags: ::c_int) -> ::c_int;
- pub fn mkostemps(template: *mut ::c_char,
- suffixlen: ::c_int,
- flags: ::c_int) -> ::c_int;
- pub fn pwritev(fd: ::c_int,
- iov: *const ::iovec,
- iovcnt: ::c_int,
- offset: ::off_t) -> ::ssize_t;
- pub fn preadv(fd: ::c_int,
- iov: *const ::iovec,
- iovcnt: ::c_int,
- offset: ::off_t) -> ::ssize_t;
- 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 fdatasync(fd: ::c_int) -> ::c_int;
- pub fn openpty(amaster: *mut ::c_int,
- aslave: *mut ::c_int,
- name: *mut ::c_char,
- termp: *mut termios,
- winp: *mut ::winsize) -> ::c_int;
- pub fn forkpty(amaster: *mut ::c_int,
- name: *mut ::c_char,
- termp: *mut termios,
- winp: *mut ::winsize) -> ::pid_t;
- pub fn login_tty(fd: ::c_int) -> ::c_int;
- 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 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;
- 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 getgrouplist(name: *const ::c_char,
- basegid: ::gid_t,
- groups: *mut ::gid_t,
- ngroups: *mut ::c_int) -> ::c_int;
- pub fn initgroups(name: *const ::c_char, basegid: ::gid_t) -> ::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;
- pub fn uname(buf: *mut ::utsname) -> ::c_int;
-}
-
-cfg_if! {
- if #[cfg(target_os = "netbsd")] {
- mod netbsd;
- pub use self::netbsd::*;
- } else if #[cfg(target_os = "openbsd")] {
- mod openbsd;
- pub use self::openbsd::*;
- } else {
- // Unknown target_os
- }
-}
diff --git a/libc/src/unix/bsd/netbsdlike/netbsd/aarch64.rs b/libc/src/unix/bsd/netbsdlike/netbsd/aarch64.rs
deleted file mode 100644
index 58c4cf7..0000000
--- a/libc/src/unix/bsd/netbsdlike/netbsd/aarch64.rs
+++ /dev/null
@@ -1,22 +0,0 @@
-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;
-
-// should be pub(crate), but that requires Rust 1.18.0
-cfg_if! {
- if #[cfg(libc_const_size_of)] {
- #[doc(hidden)]
- pub const _ALIGNBYTES: usize = ::mem::size_of::<::c_int>() - 1;
- } else {
- #[doc(hidden)]
- pub const _ALIGNBYTES: usize = 4 - 1;
- }
-}
-
-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
deleted file mode 100644
index 4bf3ccd..0000000
--- a/libc/src/unix/bsd/netbsdlike/netbsd/arm.rs
+++ /dev/null
@@ -1,22 +0,0 @@
-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;
-
-// should be pub(crate), but that requires Rust 1.18.0
-cfg_if! {
- if #[cfg(libc_const_size_of)] {
- #[doc(hidden)]
- pub const _ALIGNBYTES: usize = ::mem::size_of::<::c_longlong>() - 1;
- } else {
- #[doc(hidden)]
- pub const _ALIGNBYTES: usize = 8 - 1;
- }
-}
-
-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
deleted file mode 100644
index 9d710eb..0000000
--- a/libc/src/unix/bsd/netbsdlike/netbsd/mod.rs
+++ /dev/null
@@ -1,1654 +0,0 @@
-pub type clock_t = ::c_uint;
-pub type suseconds_t = ::c_int;
-pub type dev_t = u64;
-pub type blksize_t = i32;
-pub type fsblkcnt_t = u64;
-pub type fsfilcnt_t = u64;
-pub type idtype_t = ::c_int;
-pub type mqd_t = ::c_int;
-type __pthread_spin_t = __cpu_simple_lock_nv_t;
-pub type vm_size_t = ::uintptr_t;
-
-s! {
- pub struct aiocb {
- pub aio_offset: ::off_t,
- pub aio_buf: *mut ::c_void,
- pub aio_nbytes: ::size_t,
- pub aio_fildes: ::c_int,
- pub aio_lio_opcode: ::c_int,
- pub aio_reqprio: ::c_int,
- pub aio_sigevent: ::sigevent,
- _state: ::c_int,
- _errno: ::c_int,
- _retval: ::ssize_t
- }
-
- pub struct glob_t {
- pub gl_pathc: ::size_t,
- pub gl_matchc: ::size_t,
- pub gl_offs: ::size_t,
- pub gl_flags: ::c_int,
- pub gl_pathv: *mut *mut ::c_char,
-
- __unused3: *mut ::c_void,
-
- __unused4: *mut ::c_void,
- __unused5: *mut ::c_void,
- __unused6: *mut ::c_void,
- __unused7: *mut ::c_void,
- __unused8: *mut ::c_void,
- }
-
- pub struct mq_attr {
- pub mq_flags: ::c_long,
- pub mq_maxmsg: ::c_long,
- pub mq_msgsize: ::c_long,
- pub mq_curmsgs: ::c_long,
- }
-
- pub struct sigevent {
- pub sigev_notify: ::c_int,
- pub sigev_signo: ::c_int,
- pub sigev_value: ::sigval,
- __unused1: *mut ::c_void, //actually a function pointer
- pub sigev_notify_attributes: *mut ::c_void
- }
-
- pub struct sigset_t {
- __bits: [u32; 4],
- }
-
- pub struct stat {
- pub st_dev: ::dev_t,
- pub st_mode: ::mode_t,
- pub st_ino: ::ino_t,
- pub st_nlink: ::nlink_t,
- pub st_uid: ::uid_t,
- pub st_gid: ::gid_t,
- pub st_rdev: ::dev_t,
- pub st_atime: ::time_t,
- pub st_atimensec: ::c_long,
- pub st_mtime: ::time_t,
- pub st_mtimensec: ::c_long,
- pub st_ctime: ::time_t,
- pub st_ctimensec: ::c_long,
- pub st_birthtime: ::time_t,
- pub st_birthtimensec: ::c_long,
- pub st_size: ::off_t,
- pub st_blocks: ::blkcnt_t,
- pub st_blksize: ::blksize_t,
- pub st_flags: u32,
- pub st_gen: u32,
- pub st_spare: [u32; 2],
- }
-
- 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_canonname: *mut ::c_char,
- pub ai_addr: *mut ::sockaddr,
- pub ai_next: *mut ::addrinfo,
- }
-
- pub struct siginfo_t {
- pub si_signo: ::c_int,
- pub si_code: ::c_int,
- pub si_errno: ::c_int,
- __pad1: ::c_int,
- pub si_addr: *mut ::c_void,
- __pad2: [u64; 13],
- }
-
- pub struct pthread_attr_t {
- pta_magic: ::c_uint,
- pta_flags: ::c_int,
- pta_private: *mut ::c_void,
- }
-
- pub struct pthread_mutex_t {
- ptm_magic: ::c_uint,
- ptm_errorcheck: __pthread_spin_t,
- #[cfg(any(target_arch = "sparc", target_arch = "sparc64",
- target_arch = "x86", target_arch = "x86_64"))]
- ptm_pad1: [u8; 3],
- // 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,
- ptm_recursed: ::c_uint,
- ptm_spare2: *mut ::c_void,
- }
-
- pub struct pthread_mutexattr_t {
- ptma_magic: ::c_uint,
- ptma_private: *mut ::c_void,
- }
-
- pub struct pthread_rwlockattr_t {
- ptra_magic: ::c_uint,
- ptra_private: *mut ::c_void,
- }
-
- pub struct pthread_cond_t {
- ptc_magic: ::c_uint,
- ptc_lock: __pthread_spin_t,
- ptc_waiters_first: *mut u8,
- ptc_waiters_last: *mut u8,
- ptc_mutex: *mut ::pthread_mutex_t,
- ptc_private: *mut ::c_void,
- }
-
- pub struct pthread_condattr_t {
- ptca_magic: ::c_uint,
- ptca_private: *mut ::c_void,
- }
-
- pub struct pthread_rwlock_t {
- ptr_magic: ::c_uint,
- ptr_interlock: __pthread_spin_t,
- ptr_rblocked_first: *mut u8,
- ptr_rblocked_last: *mut u8,
- ptr_wblocked_first: *mut u8,
- ptr_wblocked_last: *mut u8,
- ptr_nreaders: ::c_uint,
- ptr_owner: ::pthread_t,
- ptr_private: *mut ::c_void,
- }
-
- pub struct kevent {
- pub ident: ::uintptr_t,
- pub filter: u32,
- pub flags: u32,
- pub fflags: u32,
- pub data: i64,
- pub udata: ::intptr_t,
- }
-
- pub struct dqblk {
- pub dqb_bhardlimit: u32,
- pub dqb_bsoftlimit: u32,
- pub dqb_curblocks: u32,
- pub dqb_ihardlimit: u32,
- pub dqb_isoftlimit: u32,
- pub dqb_curinodes: u32,
- pub dqb_btime: i32,
- pub dqb_itime: i32,
- }
-
- pub struct Dl_info {
- pub dli_fname: *const ::c_char,
- pub dli_fbase: *mut ::c_void,
- pub dli_sname: *const ::c_char,
- pub dli_saddr: *const ::c_void,
- }
-
- 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_n_cs_precedes: ::c_char,
- pub int_p_sep_by_space: ::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 if_data {
- pub ifi_type: ::c_uchar,
- pub ifi_addrlen: ::c_uchar,
- pub ifi_hdrlen: ::c_uchar,
- pub ifi_link_state: ::c_int,
- pub ifi_mtu: u64,
- pub ifi_metric: u64,
- pub ifi_baudrate: u64,
- pub ifi_ipackets: u64,
- pub ifi_ierrors: u64,
- pub ifi_opackets: u64,
- pub ifi_oerrors: u64,
- pub ifi_collisions: u64,
- pub ifi_ibytes: u64,
- pub ifi_obytes: u64,
- pub ifi_imcasts: u64,
- pub ifi_omcasts: u64,
- pub ifi_iqdrops: u64,
- pub ifi_noproto: u64,
- pub ifi_lastchange: ::timespec,
- }
-
- pub struct if_msghdr {
- pub ifm_msglen: ::c_ushort,
- pub ifm_version: ::c_uchar,
- pub ifm_type: ::c_uchar,
- pub ifm_addrs: ::c_int,
- pub ifm_flags: ::c_int,
- pub ifm_index: ::c_ushort,
- pub ifm_data: if_data,
- }
-
- pub struct sockcred {
- pub sc_pid: ::pid_t,
- pub sc_uid: ::uid_t,
- pub sc_euid: ::uid_t,
- pub sc_gid: ::gid_t,
- pub sc_egid: ::gid_t,
- pub sc_ngroups: ::c_int,
- pub sc_groups: [::gid_t; 1],
- }
-
- pub struct sockaddr_dl {
- pub sdl_len: ::c_uchar,
- pub sdl_family: ::c_uchar,
- pub sdl_index: ::c_ushort,
- pub sdl_type: u8,
- pub sdl_nlen: u8,
- pub sdl_alen: u8,
- pub sdl_slen: u8,
- pub sdl_data: [::c_char; 12],
- }
-
- pub struct mmsghdr {
- pub msg_hdr: ::msghdr,
- pub msg_len: ::c_uint,
- }
-}
-
-s_no_extra_traits! {
- 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,
- }
-
- #[repr(packed)]
- pub struct in_addr {
- pub s_addr: ::in_addr_t,
- }
-
- pub struct ip_mreq {
- pub imr_multiaddr: in_addr,
- pub imr_interface: in_addr,
- }
-
- 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: [i8; 8],
- }
-
- pub struct dirent {
- pub d_fileno: ::ino_t,
- pub d_reclen: u16,
- pub d_namlen: u16,
- pub d_type: u8,
- pub d_name: [::c_char; 512],
- }
-
- pub struct statvfs {
- pub f_flag: ::c_ulong,
- pub f_bsize: ::c_ulong,
- pub f_frsize: ::c_ulong,
- pub f_iosize: ::c_ulong,
-
- pub f_blocks: ::fsblkcnt_t,
- pub f_bfree: ::fsblkcnt_t,
- pub f_bavail: ::fsblkcnt_t,
- pub f_bresvd: ::fsblkcnt_t,
-
- pub f_files: ::fsfilcnt_t,
- pub f_ffree: ::fsfilcnt_t,
- pub f_favail: ::fsfilcnt_t,
- pub f_fresvd: ::fsfilcnt_t,
-
- pub f_syncreads: u64,
- pub f_syncwrites: u64,
-
- pub f_asyncreads: u64,
- pub f_asyncwrites: u64,
-
- pub f_fsidx: ::fsid_t,
- pub f_fsid: ::c_ulong,
- pub f_namemax: ::c_ulong,
- pub f_owner: ::uid_t,
-
- pub f_spare: [u32; 4],
-
- pub f_fstypename: [::c_char; 32],
- pub f_mntonname: [::c_char; 1024],
- pub f_mntfromname: [::c_char; 1024],
- }
-
- pub struct sockaddr_storage {
- pub ss_len: u8,
- pub ss_family: ::sa_family_t,
- __ss_pad1: [u8; 6],
- __ss_pad2: i64,
- __ss_pad3: [u8; 112],
- }
-}
-
-cfg_if! {
- if #[cfg(feature = "extra_traits")] {
- impl PartialEq for in_pktinfo {
- fn eq(&self, other: &in_pktinfo) -> bool {
- self.ipi_addr == other.ipi_addr
- && self.ipi_ifindex == other.ipi_ifindex
- }
- }
- impl Eq for in_pktinfo {}
- impl ::fmt::Debug for in_pktinfo {
- fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
- f.debug_struct("in_pktinfo")
- .field("ipi_addr", &self.ipi_addr)
- .field("ipi_ifindex", &self.ipi_ifindex)
- .finish()
- }
- }
- impl ::hash::Hash for in_pktinfo {
- fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
- self.ipi_addr.hash(state);
- self.ipi_ifindex.hash(state);
- }
- }
-
- impl PartialEq for arphdr {
- fn eq(&self, other: &arphdr) -> bool {
- self.ar_hrd == other.ar_hrd
- && self.ar_pro == other.ar_pro
- && self.ar_hln == other.ar_hln
- && self.ar_pln == other.ar_pln
- && self.ar_op == other.ar_op
- }
- }
- impl Eq for arphdr {}
- impl ::fmt::Debug for arphdr {
- fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
- let ar_hrd = self.ar_hrd;
- let ar_pro = self.ar_pro;
- let ar_op = self.ar_op;
- f.debug_struct("arphdr")
- .field("ar_hrd", &ar_hrd)
- .field("ar_pro", &ar_pro)
- .field("ar_hln", &self.ar_hln)
- .field("ar_pln", &self.ar_pln)
- .field("ar_op", &ar_op)
- .finish()
- }
- }
- impl ::hash::Hash for arphdr {
- fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
- let ar_hrd = self.ar_hrd;
- let ar_pro = self.ar_pro;
- let ar_op = self.ar_op;
- ar_hrd.hash(state);
- ar_pro.hash(state);
- self.ar_hln.hash(state);
- self.ar_pln.hash(state);
- ar_op.hash(state);
- }
- }
-
- impl PartialEq for in_addr {
- fn eq(&self, other: &in_addr) -> bool {
- self.s_addr == other.s_addr
- }
- }
- impl Eq for in_addr {}
- impl ::fmt::Debug for in_addr {
- fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
- let s_addr = self.s_addr;
- f.debug_struct("in_addr")
- .field("s_addr", &s_addr)
- .finish()
- }
- }
- impl ::hash::Hash for in_addr {
- fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
- let s_addr = self.s_addr;
- s_addr.hash(state);
- }
- }
-
- impl PartialEq for ip_mreq {
- fn eq(&self, other: &ip_mreq) -> bool {
- self.imr_multiaddr == other.imr_multiaddr
- && self.imr_interface == other.imr_interface
- }
- }
- impl Eq for ip_mreq {}
- impl ::fmt::Debug for ip_mreq {
- fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
- f.debug_struct("ip_mreq")
- .field("imr_multiaddr", &self.imr_multiaddr)
- .field("imr_interface", &self.imr_interface)
- .finish()
- }
- }
- impl ::hash::Hash for ip_mreq {
- fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
- self.imr_multiaddr.hash(state);
- self.imr_interface.hash(state);
- }
- }
-
- impl PartialEq for sockaddr_in {
- fn eq(&self, other: &sockaddr_in) -> bool {
- self.sin_len == other.sin_len
- && self.sin_family == other.sin_family
- && self.sin_port == other.sin_port
- && self.sin_addr == other.sin_addr
- && self.sin_zero == other.sin_zero
- }
- }
- impl Eq for sockaddr_in {}
- impl ::fmt::Debug for sockaddr_in {
- fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
- f.debug_struct("sockaddr_in")
- .field("sin_len", &self.sin_len)
- .field("sin_family", &self.sin_family)
- .field("sin_port", &self.sin_port)
- .field("sin_addr", &self.sin_addr)
- .field("sin_zero", &self.sin_zero)
- .finish()
- }
- }
- impl ::hash::Hash for sockaddr_in {
- fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
- self.sin_len.hash(state);
- self.sin_family.hash(state);
- self.sin_port.hash(state);
- self.sin_addr.hash(state);
- self.sin_zero.hash(state);
- }
- }
-
- impl PartialEq for dirent {
- fn eq(&self, other: &dirent) -> bool {
- self.d_fileno == other.d_fileno
- && self.d_reclen == other.d_reclen
- && self.d_namlen == other.d_namlen
- && self.d_type == other.d_type
- && self
- .d_name
- .iter()
- .zip(other.d_name.iter())
- .all(|(a,b)| a == b)
- }
- }
- impl Eq for dirent {}
- impl ::fmt::Debug for dirent {
- fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
- f.debug_struct("dirent")
- .field("d_fileno", &self.d_fileno)
- .field("d_reclen", &self.d_reclen)
- .field("d_namlen", &self.d_namlen)
- .field("d_type", &self.d_type)
- // FIXME: .field("d_name", &self.d_name)
- .finish()
- }
- }
- impl ::hash::Hash for dirent {
- fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
- self.d_fileno.hash(state);
- self.d_reclen.hash(state);
- self.d_namlen.hash(state);
- self.d_type.hash(state);
- self.d_name.hash(state);
- }
- }
-
- impl PartialEq for statvfs {
- fn eq(&self, other: &statvfs) -> bool {
- self.f_flag == other.f_flag
- && self.f_bsize == other.f_bsize
- && self.f_frsize == other.f_frsize
- && self.f_iosize == other.f_iosize
- && self.f_blocks == other.f_blocks
- && self.f_bfree == other.f_bfree
- && self.f_bavail == other.f_bavail
- && self.f_bresvd == other.f_bresvd
- && self.f_files == other.f_files
- && self.f_ffree == other.f_ffree
- && self.f_favail == other.f_favail
- && self.f_fresvd == other.f_fresvd
- && self.f_syncreads == other.f_syncreads
- && self.f_syncwrites == other.f_syncwrites
- && self.f_asyncreads == other.f_asyncreads
- && self.f_asyncwrites == other.f_asyncwrites
- && self.f_fsidx == other.f_fsidx
- && self.f_fsid == other.f_fsid
- && self.f_namemax == other.f_namemax
- && self.f_owner == other.f_owner
- && self.f_spare == other.f_spare
- && self.f_fstypename == other.f_fstypename
- && self
- .f_mntonname
- .iter()
- .zip(other.f_mntonname.iter())
- .all(|(a,b)| a == b)
- && self
- .f_mntfromname
- .iter()
- .zip(other.f_mntfromname.iter())
- .all(|(a,b)| a == b)
- }
- }
- impl Eq for statvfs {}
- impl ::fmt::Debug for statvfs {
- fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
- f.debug_struct("statvfs")
- .field("f_flag", &self.f_flag)
- .field("f_bsize", &self.f_bsize)
- .field("f_frsize", &self.f_frsize)
- .field("f_iosize", &self.f_iosize)
- .field("f_blocks", &self.f_blocks)
- .field("f_bfree", &self.f_bfree)
- .field("f_bavail", &self.f_bavail)
- .field("f_bresvd", &self.f_bresvd)
- .field("f_files", &self.f_files)
- .field("f_ffree", &self.f_ffree)
- .field("f_favail", &self.f_favail)
- .field("f_fresvd", &self.f_fresvd)
- .field("f_syncreads", &self.f_syncreads)
- .field("f_syncwrites", &self.f_syncwrites)
- .field("f_asyncreads", &self.f_asyncreads)
- .field("f_asyncwrites", &self.f_asyncwrites)
- .field("f_fsidx", &self.f_fsidx)
- .field("f_fsid", &self.f_fsid)
- .field("f_namemax", &self.f_namemax)
- .field("f_owner", &self.f_owner)
- .field("f_spare", &self.f_spare)
- .field("f_fstypename", &self.f_fstypename)
- // FIXME: .field("f_mntonname", &self.f_mntonname)
- // FIXME: .field("f_mntfromname", &self.f_mntfromname)
- .finish()
- }
- }
- impl ::hash::Hash for statvfs {
- fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
- self.f_flag.hash(state);
- self.f_bsize.hash(state);
- self.f_frsize.hash(state);
- self.f_iosize.hash(state);
- self.f_blocks.hash(state);
- self.f_bfree.hash(state);
- self.f_bavail.hash(state);
- self.f_bresvd.hash(state);
- self.f_files.hash(state);
- self.f_ffree.hash(state);
- self.f_favail.hash(state);
- self.f_fresvd.hash(state);
- self.f_syncreads.hash(state);
- self.f_syncwrites.hash(state);
- self.f_asyncreads.hash(state);
- self.f_asyncwrites.hash(state);
- self.f_fsidx.hash(state);
- self.f_fsid.hash(state);
- self.f_namemax.hash(state);
- self.f_owner.hash(state);
- self.f_spare.hash(state);
- self.f_fstypename.hash(state);
- self.f_mntonname.hash(state);
- self.f_mntfromname.hash(state);
- }
- }
-
- impl PartialEq for sockaddr_storage {
- fn eq(&self, other: &sockaddr_storage) -> bool {
- self.ss_len == other.ss_len
- && self.ss_family == other.ss_family
- && self.__ss_pad1 == other.__ss_pad1
- && self.__ss_pad2 == other.__ss_pad2
- && self
- .__ss_pad3
- .iter()
- .zip(other.__ss_pad3.iter())
- .all(|(a,b)| a == b)
- }
- }
- impl Eq for sockaddr_storage {}
- impl ::fmt::Debug for sockaddr_storage {
- fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
- f.debug_struct("sockaddr_storage")
- .field("ss_len", &self.ss_len)
- .field("ss_family", &self.ss_family)
- .field("__ss_pad1", &self.__ss_pad1)
- .field("__ss_pad2", &self.__ss_pad2)
- // FIXME: .field("__ss_pad3", &self.__ss_pad3)
- .finish()
- }
- }
- impl ::hash::Hash for sockaddr_storage {
- fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
- self.ss_len.hash(state);
- self.ss_family.hash(state);
- self.__ss_pad1.hash(state);
- self.__ss_pad2.hash(state);
- self.__ss_pad3.hash(state);
- }
- }
- }
-}
-
-pub const AT_FDCWD: ::c_int = -100;
-pub const AT_EACCESS: ::c_int = 0x100;
-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);
-pub const LC_NUMERIC_MASK: ::c_int = (1 << ::LC_NUMERIC);
-pub const LC_TIME_MASK: ::c_int = (1 << ::LC_TIME);
-pub const LC_MESSAGES_MASK: ::c_int = (1 << ::LC_MESSAGES);
-pub const LC_ALL_MASK: ::c_int = !0;
-
-pub const ERA: ::nl_item = 52;
-pub const ERA_D_FMT: ::nl_item = 53;
-pub const ERA_D_T_FMT: ::nl_item = 54;
-pub const ERA_T_FMT: ::nl_item = 55;
-pub const ALT_DIGITS: ::nl_item = 56;
-
-pub const O_CLOEXEC: ::c_int = 0x400000;
-pub const O_ALT_IO: ::c_int = 0x40000;
-pub const O_NOSIGPIPE: ::c_int = 0x1000000;
-pub const O_SEARCH: ::c_int = 0x800000;
-pub const O_DIRECTORY: ::c_int = 0x200000;
-pub const O_DIRECT : ::c_int = 0x00080000;
-pub const O_RSYNC : ::c_int = 0x00020000;
-
-pub const MS_SYNC : ::c_int = 0x4;
-pub const MS_INVALIDATE : ::c_int = 0x2;
-
-pub const RLIM_NLIMITS: ::c_int = 12;
-
-pub const EIDRM: ::c_int = 82;
-pub const ENOMSG: ::c_int = 83;
-pub const EOVERFLOW: ::c_int = 84;
-pub const EILSEQ: ::c_int = 85;
-pub const ENOTSUP: ::c_int = 86;
-pub const ECANCELED: ::c_int = 87;
-pub const EBADMSG: ::c_int = 88;
-pub const ENODATA: ::c_int = 89;
-pub const ENOSR: ::c_int = 90;
-pub const ENOSTR: ::c_int = 91;
-pub const ETIME: ::c_int = 92;
-pub const ENOATTR: ::c_int = 93;
-pub const EMULTIHOP: ::c_int = 94;
-pub const ENOLINK: ::c_int = 95;
-pub const EPROTO: ::c_int = 96;
-pub const ELAST: ::c_int = 96;
-
-pub const F_DUPFD_CLOEXEC : ::c_int = 12;
-pub const F_CLOSEM: ::c_int = 10;
-pub const F_GETNOSIGPIPE: ::c_int = 13;
-pub const F_SETNOSIGPIPE: ::c_int = 14;
-pub const F_MAXFD: ::c_int = 11;
-
-pub const IP_RECVDSTADDR: ::c_int = 7;
-pub const IP_SENDSRCADDR: ::c_int = IP_RECVDSTADDR;
-pub const IP_RECVIF: ::c_int = 20;
-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;
-pub const SOCK_FLAGS_MASK: ::c_int = 0xf0000000;
-
-pub const SO_SNDTIMEO: ::c_int = 0x100b;
-pub const SO_RCVTIMEO: ::c_int = 0x100c;
-pub const SO_ACCEPTFILTER: ::c_int = 0x1000;
-pub const SO_TIMESTAMP: ::c_int = 0x2000;
-pub const SO_OVERFLOWED: ::c_int = 0x1009;
-pub const SO_NOHEADER: ::c_int = 0x100a;
-
-// https://github.com/NetBSD/src/blob/trunk/sys/net/if.h#L373
-pub const IFF_UP: ::c_int = 0x0001; // interface is up
-pub const IFF_BROADCAST: ::c_int = 0x0002; // broadcast address valid
-pub const IFF_DEBUG: ::c_int = 0x0004; // turn on debugging
-pub const IFF_LOOPBACK: ::c_int = 0x0008; // is a loopback net
-pub const IFF_POINTOPOINT: ::c_int = 0x0010; // interface is point-to-point link
-pub const IFF_NOTRAILERS: ::c_int = 0x0020; // avoid use of trailers
-pub const IFF_RUNNING: ::c_int = 0x0040; // resources allocated
-pub const IFF_NOARP: ::c_int = 0x0080; // no address resolution protocol
-pub const IFF_PROMISC: ::c_int = 0x0100; // receive all packets
-pub const IFF_ALLMULTI: ::c_int = 0x0200; // receive all multicast packets
-pub const IFF_OACTIVE: ::c_int = 0x0400; // transmission in progress
-pub const IFF_SIMPLEX: ::c_int = 0x0800; // 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
-
-// IPPROTO_IP defined in src/unix/mod.rs
-/// Hop-by-hop option header
-pub const IPPROTO_HOPOPTS: ::c_int = 0;
-// IPPROTO_ICMP defined in src/unix/mod.rs
-/// group mgmt protocol
-pub const IPPROTO_IGMP: ::c_int = 2;
-/// gateway^2 (deprecated)
-pub const IPPROTO_GGP: ::c_int = 3;
-/// for compatibility
-pub const IPPROTO_IPIP: ::c_int = 4;
-// IPPROTO_TCP defined in src/unix/mod.rs
-/// exterior gateway protocol
-pub const IPPROTO_EGP: ::c_int = 8;
-/// pup
-pub const IPPROTO_PUP: ::c_int = 12;
-// IPPROTO_UDP defined in src/unix/mod.rs
-/// xns idp
-pub const IPPROTO_IDP: ::c_int = 22;
-/// tp-4 w/ class negotiation
-pub const IPPROTO_TP: ::c_int = 29;
-/// DCCP
-pub const IPPROTO_DCCP: ::c_int = 33;
-// IPPROTO_IPV6 defined in src/unix/mod.rs
-/// IP6 routing header
-pub const IPPROTO_ROUTING: ::c_int = 43;
-/// IP6 fragmentation header
-pub const IPPROTO_FRAGMENT: ::c_int = 44;
-/// resource reservation
-pub const IPPROTO_RSVP: ::c_int = 46;
-/// General Routing Encap.
-pub const IPPROTO_GRE: ::c_int = 47;
-/// IP6 Encap Sec. Payload
-pub const IPPROTO_ESP: ::c_int = 50;
-/// IP6 Auth Header
-pub const IPPROTO_AH: ::c_int = 51;
-/// IP Mobility RFC 2004
-pub const IPPROTO_MOBILE: ::c_int = 55;
-/// IPv6 ICMP
-pub const IPPROTO_IPV6_ICMP: ::c_int = 58;
-// IPPROTO_ICMPV6 defined in src/unix/mod.rs
-/// IP6 no next header
-pub const IPPROTO_NONE: ::c_int = 59;
-/// IP6 destination option
-pub const IPPROTO_DSTOPTS: ::c_int = 60;
-/// ISO cnlp
-pub const IPPROTO_EON: ::c_int = 80;
-/// Ethernet-in-IP
-pub const IPPROTO_ETHERIP: ::c_int = 97;
-/// encapsulation header
-pub const IPPROTO_ENCAP: ::c_int = 98;
-/// Protocol indep. multicast
-pub const IPPROTO_PIM: ::c_int = 103;
-/// IP Payload Comp. Protocol
-pub const IPPROTO_IPCOMP: ::c_int = 108;
-/// VRRP RFC 2338
-pub const IPPROTO_VRRP: ::c_int = 112;
-/// Common Address Resolution Protocol
-pub const IPPROTO_CARP: ::c_int = 112;
-/// L2TPv3
-// TEMP: Disabled for now; this constant was added to NetBSD on 2017-02-16,
-// but isn't yet supported by the NetBSD rumprun kernel image used for
-// libc testing.
-//pub const IPPROTO_L2TP: ::c_int = 115;
-/// SCTP
-pub const IPPROTO_SCTP: ::c_int = 132;
-/// PFSYNC
-pub const IPPROTO_PFSYNC: ::c_int = 240;
-pub const IPPROTO_MAX: ::c_int = 256;
-
-/// last return value of *_input(), meaning "all job for this pkt is done".
-pub const IPPROTO_DONE: ::c_int = 257;
-
-/// sysctl placeholder for (FAST_)IPSEC
-pub const CTL_IPPROTO_IPSEC: ::c_int = 258;
-
-pub const AF_OROUTE: ::c_int = 17;
-pub const AF_ARP: ::c_int = 28;
-pub const pseudo_AF_KEY: ::c_int = 29;
-pub const pseudo_AF_HDRCMPLT: ::c_int = 30;
-pub const AF_BLUETOOTH: ::c_int = 31;
-pub const AF_IEEE80211: ::c_int = 32;
-pub const AF_MPLS: ::c_int = 33;
-pub const AF_ROUTE: ::c_int = 34;
-#[doc(hidden)]
-#[deprecated(
- since = "0.2.55",
- note = "If you are using this report to: \
- https://github.com/rust-lang/libc/issues/665"
-)]
-pub const AF_MAX: ::c_int = 36;
-
-#[doc(hidden)]
-#[deprecated(
- since = "0.2.55",
- note = "If you are using this report to: \
- https://github.com/rust-lang/libc/issues/665"
-)]
-#[allow(deprecated)]
-pub const NET_MAXID: ::c_int = AF_MAX;
-pub const NET_RT_DUMP: ::c_int = 1;
-pub const NET_RT_FLAGS: ::c_int = 2;
-pub const NET_RT_OOOIFLIST: ::c_int = 3;
-pub const NET_RT_OOIFLIST: ::c_int = 4;
-pub const NET_RT_OIFLIST: ::c_int = 5;
-pub const NET_RT_IFLIST: ::c_int = 6;
-pub const NET_RT_MAXID: ::c_int = 7;
-
-pub const PF_OROUTE: ::c_int = AF_OROUTE;
-pub const PF_ARP: ::c_int = AF_ARP;
-pub const PF_KEY: ::c_int = pseudo_AF_KEY;
-pub const PF_BLUETOOTH: ::c_int = AF_BLUETOOTH;
-pub const PF_MPLS: ::c_int = AF_MPLS;
-pub const PF_ROUTE: ::c_int = AF_ROUTE;
-
-#[doc(hidden)]
-#[deprecated(
- since = "0.2.55",
- note = "If you are using this report to: \
- https://github.com/rust-lang/libc/issues/665"
-)]
-#[allow(deprecated)]
-pub const PF_MAX: ::c_int = AF_MAX;
-
-pub const MSG_NBIO: ::c_int = 0x1000;
-pub const MSG_WAITFORONE: ::c_int = 0x2000;
-pub const MSG_NOTIFICATION: ::c_int = 0x4000;
-
-pub const SCM_TIMESTAMP: ::c_int = 0x08;
-pub const SCM_CREDS: ::c_int = 0x10;
-
-pub const O_DSYNC : ::c_int = 0x10000;
-
-pub const MAP_RENAME : ::c_int = 0x20;
-pub const MAP_NORESERVE : ::c_int = 0x40;
-pub const MAP_HASSEMAPHORE : ::c_int = 0x200;
-pub const MAP_WIRED: ::c_int = 0x800;
-
-pub const DCCP_TYPE_REQUEST: ::c_int = 0;
-pub const DCCP_TYPE_RESPONSE: ::c_int = 1;
-pub const DCCP_TYPE_DATA: ::c_int = 2;
-pub const DCCP_TYPE_ACK: ::c_int = 3;
-pub const DCCP_TYPE_DATAACK: ::c_int = 4;
-pub const DCCP_TYPE_CLOSEREQ: ::c_int = 5;
-pub const DCCP_TYPE_CLOSE: ::c_int = 6;
-pub const DCCP_TYPE_RESET: ::c_int = 7;
-pub const DCCP_TYPE_MOVE: ::c_int = 8;
-
-pub const DCCP_FEATURE_CC: ::c_int = 1;
-pub const DCCP_FEATURE_ECN: ::c_int = 2;
-pub const DCCP_FEATURE_ACKRATIO: ::c_int = 3;
-pub const DCCP_FEATURE_ACKVECTOR: ::c_int = 4;
-pub const DCCP_FEATURE_MOBILITY: ::c_int = 5;
-pub const DCCP_FEATURE_LOSSWINDOW: ::c_int = 6;
-pub const DCCP_FEATURE_CONN_NONCE: ::c_int = 8;
-pub const DCCP_FEATURE_IDENTREG: ::c_int = 7;
-
-pub const DCCP_OPT_PADDING: ::c_int = 0;
-pub const DCCP_OPT_DATA_DISCARD: ::c_int = 1;
-pub const DCCP_OPT_SLOW_RECV: ::c_int = 2;
-pub const DCCP_OPT_BUF_CLOSED: ::c_int = 3;
-pub const DCCP_OPT_CHANGE_L: ::c_int = 32;
-pub const DCCP_OPT_CONFIRM_L: ::c_int = 33;
-pub const DCCP_OPT_CHANGE_R: ::c_int = 34;
-pub const DCCP_OPT_CONFIRM_R: ::c_int = 35;
-pub const DCCP_OPT_INIT_COOKIE: ::c_int = 36;
-pub const DCCP_OPT_NDP_COUNT: ::c_int = 37;
-pub const DCCP_OPT_ACK_VECTOR0: ::c_int = 38;
-pub const DCCP_OPT_ACK_VECTOR1: ::c_int = 39;
-pub const DCCP_OPT_RECV_BUF_DROPS: ::c_int = 40;
-pub const DCCP_OPT_TIMESTAMP: ::c_int = 41;
-pub const DCCP_OPT_TIMESTAMP_ECHO: ::c_int = 42;
-pub const DCCP_OPT_ELAPSEDTIME: ::c_int = 43;
-pub const DCCP_OPT_DATACHECKSUM: ::c_int = 44;
-
-pub const DCCP_REASON_UNSPEC: ::c_int = 0;
-pub const DCCP_REASON_CLOSED: ::c_int = 1;
-pub const DCCP_REASON_INVALID: ::c_int = 2;
-pub const DCCP_REASON_OPTION_ERR: ::c_int = 3;
-pub const DCCP_REASON_FEA_ERR: ::c_int = 4;
-pub const DCCP_REASON_CONN_REF: ::c_int = 5;
-pub const DCCP_REASON_BAD_SNAME: ::c_int = 6;
-pub const DCCP_REASON_BAD_COOKIE: ::c_int = 7;
-pub const DCCP_REASON_INV_MOVE: ::c_int = 8;
-pub const DCCP_REASON_UNANSW_CH: ::c_int = 10;
-pub const DCCP_REASON_FRUITLESS_NEG: ::c_int = 11;
-
-pub const DCCP_CCID: ::c_int = 1;
-pub const DCCP_CSLEN: ::c_int = 2;
-pub const DCCP_MAXSEG: ::c_int = 4;
-pub const DCCP_SERVICE: ::c_int = 8;
-
-pub const DCCP_NDP_LIMIT: ::c_int = 16;
-pub const DCCP_SEQ_NUM_LIMIT: ::c_int = 16777216;
-pub const DCCP_MAX_OPTIONS: ::c_int = 32;
-pub const DCCP_MAX_PKTS: ::c_int = 100;
-
-pub const _PC_LINK_MAX : ::c_int = 1;
-pub const _PC_MAX_CANON : ::c_int = 2;
-pub const _PC_MAX_INPUT : ::c_int = 3;
-pub const _PC_NAME_MAX : ::c_int = 4;
-pub const _PC_PATH_MAX : ::c_int = 5;
-pub const _PC_PIPE_BUF : ::c_int = 6;
-pub const _PC_CHOWN_RESTRICTED : ::c_int = 7;
-pub const _PC_NO_TRUNC : ::c_int = 8;
-pub const _PC_VDISABLE : ::c_int = 9;
-pub const _PC_SYNC_IO : ::c_int = 10;
-pub const _PC_FILESIZEBITS : ::c_int = 11;
-pub const _PC_SYMLINK_MAX : ::c_int = 12;
-pub const _PC_2_SYMLINKS : ::c_int = 13;
-pub const _PC_ACL_EXTENDED : ::c_int = 14;
-pub const _PC_MIN_HOLE_SIZE : ::c_int = 15;
-
-pub const _SC_SYNCHRONIZED_IO : ::c_int = 31;
-pub const _SC_IOV_MAX : ::c_int = 32;
-pub const _SC_MAPPED_FILES : ::c_int = 33;
-pub const _SC_MEMLOCK : ::c_int = 34;
-pub const _SC_MEMLOCK_RANGE : ::c_int = 35;
-pub const _SC_MEMORY_PROTECTION : ::c_int = 36;
-pub const _SC_LOGIN_NAME_MAX : ::c_int = 37;
-pub const _SC_MONOTONIC_CLOCK : ::c_int = 38;
-pub const _SC_CLK_TCK : ::c_int = 39;
-pub const _SC_ATEXIT_MAX : ::c_int = 40;
-pub const _SC_THREADS : ::c_int = 41;
-pub const _SC_SEMAPHORES : ::c_int = 42;
-pub const _SC_BARRIERS : ::c_int = 43;
-pub const _SC_TIMERS : ::c_int = 44;
-pub const _SC_SPIN_LOCKS : ::c_int = 45;
-pub const _SC_READER_WRITER_LOCKS : ::c_int = 46;
-pub const _SC_GETGR_R_SIZE_MAX : ::c_int = 47;
-pub const _SC_GETPW_R_SIZE_MAX : ::c_int = 48;
-pub const _SC_CLOCK_SELECTION : ::c_int = 49;
-pub const _SC_ASYNCHRONOUS_IO : ::c_int = 50;
-pub const _SC_AIO_LISTIO_MAX : ::c_int = 51;
-pub const _SC_AIO_MAX : ::c_int = 52;
-pub const _SC_MESSAGE_PASSING : ::c_int = 53;
-pub const _SC_MQ_OPEN_MAX : ::c_int = 54;
-pub const _SC_MQ_PRIO_MAX : ::c_int = 55;
-pub const _SC_PRIORITY_SCHEDULING : ::c_int = 56;
-pub const _SC_THREAD_DESTRUCTOR_ITERATIONS : ::c_int = 57;
-pub const _SC_THREAD_KEYS_MAX : ::c_int = 58;
-pub const _SC_THREAD_STACK_MIN : ::c_int = 59;
-pub const _SC_THREAD_THREADS_MAX : ::c_int = 60;
-pub const _SC_THREAD_ATTR_STACKADDR : ::c_int = 61;
-pub const _SC_THREAD_ATTR_STACKSIZE : ::c_int = 62;
-pub const _SC_THREAD_PRIORITY_SCHEDULING : ::c_int = 63;
-pub const _SC_THREAD_PRIO_INHERIT : ::c_int = 64;
-pub const _SC_THREAD_PRIO_PROTECT : ::c_int = 65;
-pub const _SC_THREAD_PROCESS_SHARED : ::c_int = 66;
-pub const _SC_THREAD_SAFE_FUNCTIONS : ::c_int = 67;
-pub const _SC_TTY_NAME_MAX : ::c_int = 68;
-pub const _SC_HOST_NAME_MAX : ::c_int = 69;
-pub const _SC_PASS_MAX : ::c_int = 70;
-pub const _SC_REGEXP : ::c_int = 71;
-pub const _SC_SHELL : ::c_int = 72;
-pub const _SC_SYMLOOP_MAX : ::c_int = 73;
-pub const _SC_V6_ILP32_OFF32 : ::c_int = 74;
-pub const _SC_V6_ILP32_OFFBIG : ::c_int = 75;
-pub const _SC_V6_LP64_OFF64 : ::c_int = 76;
-pub const _SC_V6_LPBIG_OFFBIG : ::c_int = 77;
-pub const _SC_2_PBS : ::c_int = 80;
-pub const _SC_2_PBS_ACCOUNTING : ::c_int = 81;
-pub const _SC_2_PBS_CHECKPOINT : ::c_int = 82;
-pub const _SC_2_PBS_LOCATE : ::c_int = 83;
-pub const _SC_2_PBS_MESSAGE : ::c_int = 84;
-pub const _SC_2_PBS_TRACK : ::c_int = 85;
-pub const _SC_SPAWN : ::c_int = 86;
-pub const _SC_SHARED_MEMORY_OBJECTS : ::c_int = 87;
-pub const _SC_TIMER_MAX : ::c_int = 88;
-pub const _SC_SEM_NSEMS_MAX : ::c_int = 89;
-pub const _SC_CPUTIME : ::c_int = 90;
-pub const _SC_THREAD_CPUTIME : ::c_int = 91;
-pub const _SC_DELAYTIMER_MAX : ::c_int = 92;
-// These two variables will be supported in NetBSD 8.0
-// pub const _SC_SIGQUEUE_MAX : ::c_int = 93;
-// pub const _SC_REALTIME_SIGNALS : ::c_int = 94;
-pub const _SC_PHYS_PAGES : ::c_int = 121;
-pub const _SC_NPROCESSORS_CONF : ::c_int = 1001;
-pub const _SC_NPROCESSORS_ONLN : ::c_int = 1002;
-pub const _SC_SCHED_RT_TS : ::c_int = 2001;
-pub const _SC_SCHED_PRI_MIN : ::c_int = 2002;
-pub const _SC_SCHED_PRI_MAX : ::c_int = 2003;
-
-pub const FD_SETSIZE: usize = 0x100;
-
-pub const ST_NOSUID: ::c_ulong = 8;
-
-cfg_if! {
- if #[cfg(any(target_arch = "sparc", target_arch = "sparc64",
- target_arch = "x86", target_arch = "x86_64"))] {
- pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t {
- ptm_magic: 0x33330003,
- ptm_errorcheck: 0,
- ptm_pad1: [0; 3],
- ptm_unused: 0,
- ptm_pad2: [0; 3],
- ptm_waiters: 0 as *mut _,
- ptm_owner: 0,
- ptm_recursed: 0,
- ptm_spare2: 0 as *mut _,
- };
- } else {
- pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t {
- ptm_magic: 0x33330003,
- ptm_errorcheck: 0,
- ptm_unused: 0,
- 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,
- ptc_waiters_first: 0 as *mut _,
- ptc_waiters_last: 0 as *mut _,
- ptc_mutex: 0 as *mut _,
- ptc_private: 0 as *mut _,
-};
-pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = pthread_rwlock_t {
- ptr_magic: 0x99990009,
- ptr_interlock: 0,
- ptr_rblocked_first: 0 as *mut _,
- ptr_rblocked_last: 0 as *mut _,
- ptr_wblocked_first: 0 as *mut _,
- ptr_wblocked_last: 0 as *mut _,
- ptr_nreaders: 0,
- ptr_owner: 0,
- ptr_private: 0 as *mut _,
-};
-pub const PTHREAD_MUTEX_NORMAL: ::c_int = 0;
-pub const PTHREAD_MUTEX_ERRORCHECK: ::c_int = 1;
-pub const PTHREAD_MUTEX_RECURSIVE: ::c_int = 2;
-pub const PTHREAD_MUTEX_DEFAULT: ::c_int = PTHREAD_MUTEX_NORMAL;
-
-pub const EVFILT_AIO: u32 = 2;
-pub const EVFILT_PROC: u32 = 4;
-pub const EVFILT_READ: u32 = 0;
-pub const EVFILT_SIGNAL: u32 = 5;
-pub const EVFILT_TIMER: u32 = 6;
-pub const EVFILT_VNODE: u32 = 3;
-pub const EVFILT_WRITE: u32 = 1;
-
-pub const EV_ADD: u32 = 0x1;
-pub const EV_DELETE: u32 = 0x2;
-pub const EV_ENABLE: u32 = 0x4;
-pub const EV_DISABLE: u32 = 0x8;
-pub const EV_ONESHOT: u32 = 0x10;
-pub const EV_CLEAR: u32 = 0x20;
-pub const EV_RECEIPT: u32 = 0x40;
-pub const EV_DISPATCH: u32 = 0x80;
-pub const EV_FLAG1: u32 = 0x2000;
-pub const EV_ERROR: u32 = 0x4000;
-pub const EV_EOF: u32 = 0x8000;
-pub const EV_SYSFLAGS: u32 = 0xf000;
-
-pub const NOTE_LOWAT: u32 = 0x00000001;
-pub const NOTE_DELETE: u32 = 0x00000001;
-pub const NOTE_WRITE: u32 = 0x00000002;
-pub const NOTE_EXTEND: u32 = 0x00000004;
-pub const NOTE_ATTRIB: u32 = 0x00000008;
-pub const NOTE_LINK: u32 = 0x00000010;
-pub const NOTE_RENAME: u32 = 0x00000020;
-pub const NOTE_REVOKE: u32 = 0x00000040;
-pub const NOTE_EXIT: u32 = 0x80000000;
-pub const NOTE_FORK: u32 = 0x40000000;
-pub const NOTE_EXEC: u32 = 0x20000000;
-pub const NOTE_PDATAMASK: u32 = 0x000fffff;
-pub const NOTE_PCTRLMASK: u32 = 0xf0000000;
-pub const NOTE_TRACK: u32 = 0x00000001;
-pub const NOTE_TRACKERR: u32 = 0x00000002;
-pub const NOTE_CHILD: u32 = 0x00000004;
-
-pub const TMP_MAX : ::c_uint = 308915776;
-
-pub const NI_MAXHOST: ::socklen_t = 1025;
-
-pub const RTLD_NOLOAD: ::c_int = 0x2000;
-pub const RTLD_LOCAL: ::c_int = 0x200;
-
-pub const CTL_MAXNAME: ::c_int = 12;
-pub const SYSCTL_NAMELEN: ::c_int = 32;
-pub const SYSCTL_DEFSIZE: ::c_int = 8;
-pub const CTLTYPE_NODE: ::c_int = 1;
-pub const CTLTYPE_INT: ::c_int = 2;
-pub const CTLTYPE_STRING: ::c_int = 3;
-pub const CTLTYPE_QUAD: ::c_int = 4;
-pub const CTLTYPE_STRUCT: ::c_int = 5;
-pub const CTLTYPE_BOOL: ::c_int = 6;
-pub const CTLFLAG_READONLY: ::c_int = 0x00000000;
-pub const CTLFLAG_READWRITE: ::c_int = 0x00000070;
-pub const CTLFLAG_ANYWRITE: ::c_int = 0x00000080;
-pub const CTLFLAG_PRIVATE: ::c_int = 0x00000100;
-pub const CTLFLAG_PERMANENT: ::c_int = 0x00000200;
-pub const CTLFLAG_OWNDATA: ::c_int = 0x00000400;
-pub const CTLFLAG_IMMEDIATE: ::c_int = 0x00000800;
-pub const CTLFLAG_HEX: ::c_int = 0x00001000;
-pub const CTLFLAG_ROOT: ::c_int = 0x00002000;
-pub const CTLFLAG_ANYNUMBER: ::c_int = 0x00004000;
-pub const CTLFLAG_HIDDEN: ::c_int = 0x00008000;
-pub const CTLFLAG_ALIAS: ::c_int = 0x00010000;
-pub const CTLFLAG_MMAP: ::c_int = 0x00020000;
-pub const CTLFLAG_OWNDESC: ::c_int = 0x00040000;
-pub const CTLFLAG_UNSIGNED: ::c_int = 0x00080000;
-pub const SYSCTL_VERS_MASK: ::c_int = 0xff000000;
-pub const SYSCTL_VERS_0: ::c_int = 0x00000000;
-pub const SYSCTL_VERS_1: ::c_int = 0x01000000;
-pub const SYSCTL_VERSION: ::c_int = SYSCTL_VERS_1;
-pub const CTL_EOL: ::c_int = -1;
-pub const CTL_QUERY: ::c_int = -2;
-pub const CTL_CREATE: ::c_int = -3;
-pub const CTL_CREATESYM: ::c_int = -4;
-pub const CTL_DESTROY: ::c_int = -5;
-pub const CTL_MMAP: ::c_int = -6;
-pub const CTL_DESCRIBE: ::c_int = -7;
-pub const CTL_UNSPEC: ::c_int = 0;
-pub const CTL_KERN: ::c_int = 1;
-pub const CTL_VM: ::c_int = 2;
-pub const CTL_VFS: ::c_int = 3;
-pub const CTL_NET: ::c_int = 4;
-pub const CTL_DEBUG: ::c_int = 5;
-pub const CTL_HW: ::c_int = 6;
-pub const CTL_MACHDEP: ::c_int = 7;
-pub const CTL_USER: ::c_int = 8;
-pub const CTL_DDB: ::c_int = 9;
-pub const CTL_PROC: ::c_int = 10;
-pub const CTL_VENDOR: ::c_int = 11;
-pub const CTL_EMUL: ::c_int = 12;
-pub const CTL_SECURITY: ::c_int = 13;
-pub const CTL_MAXID: ::c_int = 14;
-pub const KERN_OSTYPE: ::c_int = 1;
-pub const KERN_OSRELEASE: ::c_int = 2;
-pub const KERN_OSREV: ::c_int = 3;
-pub const KERN_VERSION: ::c_int = 4;
-pub const KERN_MAXVNODES: ::c_int = 5;
-pub const KERN_MAXPROC: ::c_int = 6;
-pub const KERN_MAXFILES: ::c_int = 7;
-pub const KERN_ARGMAX: ::c_int = 8;
-pub const KERN_SECURELVL: ::c_int = 9;
-pub const KERN_HOSTNAME: ::c_int = 10;
-pub const KERN_HOSTID: ::c_int = 11;
-pub const KERN_CLOCKRATE: ::c_int = 12;
-pub const KERN_VNODE: ::c_int = 13;
-pub const KERN_PROC: ::c_int = 14;
-pub const KERN_FILE: ::c_int = 15;
-pub const KERN_PROF: ::c_int = 16;
-pub const KERN_POSIX1: ::c_int = 17;
-pub const KERN_NGROUPS: ::c_int = 18;
-pub const KERN_JOB_CONTROL: ::c_int = 19;
-pub const KERN_SAVED_IDS: ::c_int = 20;
-pub const KERN_OBOOTTIME: ::c_int = 21;
-pub const KERN_DOMAINNAME: ::c_int = 22;
-pub const KERN_MAXPARTITIONS: ::c_int = 23;
-pub const KERN_RAWPARTITION: ::c_int = 24;
-pub const KERN_NTPTIME: ::c_int = 25;
-pub const KERN_TIMEX: ::c_int = 26;
-pub const KERN_AUTONICETIME: ::c_int = 27;
-pub const KERN_AUTONICEVAL: ::c_int = 28;
-pub const KERN_RTC_OFFSET: ::c_int = 29;
-pub const KERN_ROOT_DEVICE: ::c_int = 30;
-pub const KERN_MSGBUFSIZE: ::c_int = 31;
-pub const KERN_FSYNC: ::c_int = 32;
-pub const KERN_OLDSYSVMSG: ::c_int = 33;
-pub const KERN_OLDSYSVSEM: ::c_int = 34;
-pub const KERN_OLDSYSVSHM: ::c_int = 35;
-pub const KERN_OLDSHORTCORENAME: ::c_int = 36;
-pub const KERN_SYNCHRONIZED_IO: ::c_int = 37;
-pub const KERN_IOV_MAX: ::c_int = 38;
-pub const KERN_MBUF: ::c_int = 39;
-pub const KERN_MAPPED_FILES: ::c_int = 40;
-pub const KERN_MEMLOCK: ::c_int = 41;
-pub const KERN_MEMLOCK_RANGE: ::c_int = 42;
-pub const KERN_MEMORY_PROTECTION: ::c_int = 43;
-pub const KERN_LOGIN_NAME_MAX: ::c_int = 44;
-pub const KERN_DEFCORENAME: ::c_int = 45;
-pub const KERN_LOGSIGEXIT: ::c_int = 46;
-pub const KERN_PROC2: ::c_int = 47;
-pub const KERN_PROC_ARGS: ::c_int = 48;
-pub const KERN_FSCALE: ::c_int = 49;
-pub const KERN_CCPU: ::c_int = 50;
-pub const KERN_CP_TIME: ::c_int = 51;
-pub const KERN_OLDSYSVIPC_INFO: ::c_int = 52;
-pub const KERN_MSGBUF: ::c_int = 53;
-pub const KERN_CONSDEV: ::c_int = 54;
-pub const KERN_MAXPTYS: ::c_int = 55;
-pub const KERN_PIPE: ::c_int = 56;
-pub const KERN_MAXPHYS: ::c_int = 57;
-pub const KERN_SBMAX: ::c_int = 58;
-pub const KERN_TKSTAT: ::c_int = 59;
-pub const KERN_MONOTONIC_CLOCK: ::c_int = 60;
-pub const KERN_URND: ::c_int = 61;
-pub const KERN_LABELSECTOR: ::c_int = 62;
-pub const KERN_LABELOFFSET: ::c_int = 63;
-pub const KERN_LWP: ::c_int = 64;
-pub const KERN_FORKFSLEEP: ::c_int = 65;
-pub const KERN_POSIX_THREADS: ::c_int = 66;
-pub const KERN_POSIX_SEMAPHORES: ::c_int = 67;
-pub const KERN_POSIX_BARRIERS: ::c_int = 68;
-pub const KERN_POSIX_TIMERS: ::c_int = 69;
-pub const KERN_POSIX_SPIN_LOCKS: ::c_int = 70;
-pub const KERN_POSIX_READER_WRITER_LOCKS: ::c_int = 71;
-pub const KERN_DUMP_ON_PANIC: ::c_int = 72;
-pub const KERN_SOMAXKVA: ::c_int = 73;
-pub const KERN_ROOT_PARTITION: ::c_int = 74;
-pub const KERN_DRIVERS: ::c_int = 75;
-pub const KERN_BUF: ::c_int = 76;
-pub const KERN_FILE2: ::c_int = 77;
-pub const KERN_VERIEXEC: ::c_int = 78;
-pub const KERN_CP_ID: ::c_int = 79;
-pub const KERN_HARDCLOCK_TICKS: ::c_int = 80;
-pub const KERN_ARND: ::c_int = 81;
-pub const KERN_SYSVIPC: ::c_int = 82;
-pub const KERN_BOOTTIME: ::c_int = 83;
-pub const KERN_EVCNT: ::c_int = 84;
-pub const KERN_MAXID: ::c_int = 85;
-pub const KERN_PROC_ALL: ::c_int = 0;
-pub const KERN_PROC_PID: ::c_int = 1;
-pub const KERN_PROC_PGRP: ::c_int = 2;
-pub const KERN_PROC_SESSION: ::c_int = 3;
-pub const KERN_PROC_TTY: ::c_int = 4;
-pub const KERN_PROC_UID: ::c_int = 5;
-pub const KERN_PROC_RUID: ::c_int = 6;
-pub const KERN_PROC_GID: ::c_int = 7;
-pub const KERN_PROC_RGID: ::c_int = 8;
-pub const KERN_PROC_ARGV: ::c_int = 1;
-pub const KERN_PROC_NARGV: ::c_int = 2;
-pub const KERN_PROC_ENV: ::c_int = 3;
-pub const KERN_PROC_NENV: ::c_int = 4;
-pub const KERN_PROC_PATHNAME: ::c_int = 5;
-
-pub const EAI_AGAIN: ::c_int = 2;
-pub const EAI_BADFLAGS: ::c_int = 3;
-pub const EAI_FAIL: ::c_int = 4;
-pub const EAI_FAMILY: ::c_int = 5;
-pub const EAI_MEMORY: ::c_int = 6;
-pub const EAI_NODATA: ::c_int = 7;
-pub const EAI_NONAME: ::c_int = 8;
-pub const EAI_SERVICE: ::c_int = 9;
-pub const EAI_SOCKTYPE: ::c_int = 10;
-pub const EAI_SYSTEM: ::c_int = 11;
-pub const EAI_OVERFLOW: ::c_int = 14;
-
-pub const AIO_CANCELED: ::c_int = 1;
-pub const AIO_NOTCANCELED: ::c_int = 2;
-pub const AIO_ALLDONE: ::c_int = 3;
-pub const LIO_NOP: ::c_int = 0;
-pub const LIO_WRITE: ::c_int = 1;
-pub const LIO_READ: ::c_int = 2;
-pub const LIO_WAIT: ::c_int = 1;
-pub const LIO_NOWAIT: ::c_int = 0;
-
-pub const SIGEV_NONE: ::c_int = 0;
-pub const SIGEV_SIGNAL: ::c_int = 1;
-pub const SIGEV_THREAD: ::c_int = 2;
-
-pub const WSTOPPED: ::c_int = 0x00000002; // same as WUNTRACED
-pub const WCONTINUED: ::c_int = 0x00000010;
-pub const WEXITED: ::c_int = 0x000000020;
-pub const WNOWAIT: ::c_int = 0x00010000;
-
-pub const P_ALL: idtype_t = 0;
-pub const P_PID: idtype_t = 1;
-pub const P_PGID: idtype_t = 4;
-
-pub const B460800: ::speed_t = 460800;
-pub const B921600: ::speed_t = 921600;
-
-pub const ONOCR: ::tcflag_t = 0x20;
-pub const ONLRET: ::tcflag_t = 0x40;
-pub const CDTRCTS: ::tcflag_t = 0x00020000;
-pub const CHWFLOW: ::tcflag_t = ::MDMBUF | ::CRTSCTS | ::CDTRCTS;
-
-pub const SOCK_CLOEXEC: ::c_int = 0x10000000;
-pub const SOCK_NONBLOCK: ::c_int = 0x20000000;
-
-pub const FIONCLEX: ::c_ulong = 0x20006602;
-// Uncomment on next NetBSD release
-// pub const FIOSEEKDATA: ::c_ulong = 0xc0086661;
-// pub const FIOSEEKHOLE: ::c_ulong = 0xc0086662;
-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 OFIOGETBMAP: ::c_ulong = 0xc004667a;
-pub const FIOGETBMAP: ::c_ulong = 0xc008667a;
-pub const FIONWRITE: ::c_ulong = 0x40046679;
-pub const FIONSPACE: ::c_ulong = 0x40046678;
-pub const FIBMAP: ::c_ulong = 0xc008667a;
-
-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;
-
-fn _ALIGN(p: usize) -> usize {
- (p + _ALIGNBYTES) & !_ALIGNBYTES
-}
-
-f! {
- pub fn CMSG_DATA(cmsg: *const ::cmsghdr) -> *mut ::c_uchar {
- (cmsg as *mut ::c_uchar)
- .offset(_ALIGN(::mem::size_of::<::cmsghdr>()) as isize)
- }
-
- pub fn CMSG_LEN(length: ::c_uint) -> ::c_uint {
- _ALIGN(::mem::size_of::<::cmsghdr>()) as ::c_uint + length
- }
-
- pub fn CMSG_NXTHDR(mhdr: *const ::msghdr, cmsg: *const ::cmsghdr)
- -> *mut ::cmsghdr
- {
- if cmsg.is_null() {
- return ::CMSG_FIRSTHDR(mhdr);
- };
- let next = cmsg as usize + _ALIGN((*cmsg).cmsg_len as usize)
- + _ALIGN(::mem::size_of::<::cmsghdr>());
- let max = (*mhdr).msg_control as usize
- + (*mhdr).msg_controllen as usize;
- if next > max {
- 0 as *mut ::cmsghdr
- } else {
- (cmsg as usize + _ALIGN((*cmsg).cmsg_len as usize))
- as *mut ::cmsghdr
- }
- }
-
- pub fn CMSG_SPACE(length: ::c_uint) -> ::c_uint {
- (_ALIGN(::mem::size_of::<::cmsghdr>()) + _ALIGN(length as usize))
- as ::c_uint
- }
-
- pub fn WSTOPSIG(status: ::c_int) -> ::c_int {
- status >> 8
- }
-
- pub fn WIFSIGNALED(status: ::c_int) -> bool {
- (status & 0o177) != 0o177 && (status & 0o177) != 0
- }
-
- pub fn WIFSTOPPED(status: ::c_int) -> bool {
- (status & 0o177) == 0o177
- }
-
- // 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
- pub fn dirfd(dirp: *mut ::DIR) -> ::c_int {
- *(dirp as *const ::c_int)
- }
-
- pub fn WIFCONTINUED(status: ::c_int) -> bool {
- status == 0xffff
- }
-
- pub fn SOCKCREDSIZE(ngrps: usize) -> usize {
- let ngrps = if ngrps > 0 {
- ngrps - 1
- } else {
- 0
- };
- ::mem::size_of::<sockcred>() + ::mem::size_of::<::gid_t>() * ngrps
- }
-}
-
-#[link(name = "rt")]
-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;
- #[link_name = "__aio_suspend50"]
- pub fn aio_suspend(aiocb_list: *const *const aiocb, nitems: ::c_int,
- timeout: *const ::timespec) -> ::c_int;
- pub fn aio_cancel(fd: ::c_int, aiocbp: *mut aiocb) -> ::c_int;
- pub fn lio_listio(mode: ::c_int, aiocb_list: *const *mut aiocb,
- nitems: ::c_int, sevp: *mut sigevent) -> ::c_int;
-}
-
-extern {
- 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;
- #[link_name = "__gettimeofday50"]
- pub fn gettimeofday(tp: *mut ::timeval,
- tz: *mut ::c_void) -> ::c_int;
- pub fn getnameinfo(sa: *const ::sockaddr,
- salen: ::socklen_t,
- host: *mut ::c_char,
- hostlen: ::socklen_t,
- serv: *mut ::c_char,
- sevlen: ::socklen_t,
- flags: ::c_int) -> ::c_int;
- pub fn mprotect(addr: *mut ::c_void, len: ::size_t, prot: ::c_int)
- -> ::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;
- #[link_name = "__kevent50"]
- pub fn kevent(kq: ::c_int,
- changelist: *const ::kevent,
- nchanges: ::size_t,
- eventlist: *mut ::kevent,
- nevents: ::size_t,
- timeout: *const ::timespec) -> ::c_int;
- #[link_name = "__mount50"]
- pub fn mount(src: *const ::c_char,
- target: *const ::c_char,
- flags: ::c_int,
- data: *mut ::c_void,
- size: ::size_t) -> ::c_int;
- pub fn mq_open(name: *const ::c_char, oflag: ::c_int, ...) -> ::mqd_t;
- 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_receive(mqd: ::mqd_t,
- msg_ptr: *mut ::c_char,
- msg_len: ::size_t,
- msq_prio: *mut ::c_uint) -> ::ssize_t;
- pub fn mq_send(mqd: ::mqd_t,
- msg_ptr: *const ::c_char,
- msg_len: ::size_t,
- msq_prio: ::c_uint) -> ::c_int;
- 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,
- msq_prio: ::c_uint,
- abs_timeout: *const ::timespec) -> ::c_int;
- pub fn mq_unlink(name: *const ::c_char) -> ::c_int;
- pub fn ptrace(request: ::c_int,
- pid: ::pid_t,
- addr: *mut ::c_void,
- data: ::c_int) -> ::c_int;
- pub fn pthread_setname_np(t: ::pthread_t,
- name: *const ::c_char,
- arg: *mut ::c_void) -> ::c_int;
- pub fn pthread_getattr_np(native: ::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;
- #[link_name = "__sigtimedwait50"]
- 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 duplocale(base: ::locale_t) -> ::locale_t;
- pub fn freelocale(loc: ::locale_t);
- pub fn localeconv_l(loc: ::locale_t) -> *mut lconv;
- pub fn newlocale(mask: ::c_int,
- locale: *const ::c_char,
- 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;
-
- pub fn sendmmsg(sockfd: ::c_int, msgvec: *mut ::mmsghdr, vlen: ::c_uint,
- flags: ::c_int) -> ::c_int;
- pub fn recvmmsg(sockfd: ::c_int, msgvec: *mut ::mmsghdr, vlen: ::c_uint,
- flags: ::c_int, timeout: *mut ::timespec) -> ::c_int;
-}
-
-#[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/powerpc.rs b/libc/src/unix/bsd/netbsdlike/netbsd/powerpc.rs
deleted file mode 100644
index e12fd5e..0000000
--- a/libc/src/unix/bsd/netbsdlike/netbsd/powerpc.rs
+++ /dev/null
@@ -1,21 +0,0 @@
-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;
-
-// should be pub(crate), but that requires Rust 1.18.0
-cfg_if! {
- if #[cfg(libc_const_size_of)] {
- #[doc(hidden)]
- pub const _ALIGNBYTES: usize = ::mem::size_of::<::c_double>() - 1;
- } else {
- #[doc(hidden)]
- pub const _ALIGNBYTES: usize = 8 - 1;
- }
-}
-
-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
deleted file mode 100644
index 6a86759..0000000
--- a/libc/src/unix/bsd/netbsdlike/netbsd/sparc64.rs
+++ /dev/null
@@ -1,8 +0,0 @@
-pub type c_long = i64;
-pub type c_ulong = u64;
-pub type c_char = i8;
-pub type __cpu_simple_lock_nv_t = ::c_uchar;
-
-// should be pub(crate), but that requires Rust 1.18.0
-#[doc(hidden)]
-pub const _ALIGNBYTES: usize = 0xf;
diff --git a/libc/src/unix/bsd/netbsdlike/netbsd/x86.rs b/libc/src/unix/bsd/netbsdlike/netbsd/x86.rs
deleted file mode 100644
index daa89a1..0000000
--- a/libc/src/unix/bsd/netbsdlike/netbsd/x86.rs
+++ /dev/null
@@ -1,15 +0,0 @@
-pub type c_long = i32;
-pub type c_ulong = u32;
-pub type c_char = i8;
-pub type __cpu_simple_lock_nv_t = ::c_uchar;
-
-// should be pub(crate), but that requires Rust 1.18.0
-cfg_if! {
- if #[cfg(libc_const_size_of)] {
- #[doc(hidden)]
- pub const _ALIGNBYTES: usize = ::mem::size_of::<::c_int>() - 1;
- } else {
- #[doc(hidden)]
- pub const _ALIGNBYTES: usize = 4 - 1;
- }
-}
diff --git a/libc/src/unix/bsd/netbsdlike/netbsd/x86_64.rs b/libc/src/unix/bsd/netbsdlike/netbsd/x86_64.rs
deleted file mode 100644
index 0860d4f..0000000
--- a/libc/src/unix/bsd/netbsdlike/netbsd/x86_64.rs
+++ /dev/null
@@ -1,23 +0,0 @@
-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;
-
-// should be pub(crate), but that requires Rust 1.18.0
-cfg_if! {
- if #[cfg(libc_const_size_of)] {
- #[doc(hidden)]
- pub const _ALIGNBYTES: usize = ::mem::size_of::<::c_long>() - 1;
- } else {
- #[doc(hidden)]
- pub const _ALIGNBYTES: usize = 8 - 1;
- }
-}
-
-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/openbsd/aarch64.rs b/libc/src/unix/bsd/netbsdlike/openbsd/aarch64.rs
deleted file mode 100644
index 6a8cbb5..0000000
--- a/libc/src/unix/bsd/netbsdlike/openbsd/aarch64.rs
+++ /dev/null
@@ -1,14 +0,0 @@
-pub type c_long = i64;
-pub type c_ulong = u64;
-pub type c_char = u8;
-
-// should be pub(crate), but that requires Rust 1.18.0
-cfg_if! {
- if #[cfg(libc_const_size_of)] {
- #[doc(hidden)]
- pub const _ALIGNBYTES: usize = ::mem::size_of::<::c_long>() - 1;
- } else {
- #[doc(hidden)]
- pub const _ALIGNBYTES: usize = 8 - 1;
- }
-}
diff --git a/libc/src/unix/bsd/netbsdlike/openbsd/mod.rs b/libc/src/unix/bsd/netbsdlike/openbsd/mod.rs
deleted file mode 100644
index 09739cb..0000000
--- a/libc/src/unix/bsd/netbsdlike/openbsd/mod.rs
+++ /dev/null
@@ -1,1451 +0,0 @@
-use unix::bsd::O_SYNC;
-
-pub type clock_t = i64;
-pub type suseconds_t = ::c_long;
-pub type dev_t = i32;
-pub type sigset_t = ::c_uint;
-pub type blksize_t = i32;
-pub type fsblkcnt_t = u64;
-pub type fsfilcnt_t = u64;
-pub type pthread_attr_t = *mut ::c_void;
-pub type pthread_mutex_t = *mut ::c_void;
-pub type pthread_mutexattr_t = *mut ::c_void;
-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 glob_t {
- pub gl_pathc: ::size_t,
- pub gl_matchc: ::size_t,
- pub gl_offs: ::size_t,
- pub gl_flags: ::c_int,
- pub gl_pathv: *mut *mut ::c_char,
- __unused1: *mut ::c_void,
- __unused2: *mut ::c_void,
- __unused3: *mut ::c_void,
- __unused4: *mut ::c_void,
- __unused5: *mut ::c_void,
- __unused6: *mut ::c_void,
- __unused7: *mut ::c_void,
- }
-
- 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 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: u32,
- }
-
- 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,
- }
-
- pub struct ip_mreq {
- pub imr_multiaddr: in_addr,
- pub imr_interface: in_addr,
- }
-
- pub struct in_addr {
- pub s_addr: ::in_addr_t,
- }
-
- 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: [i8; 8],
- }
-
- pub struct kevent {
- pub ident: ::uintptr_t,
- pub filter: ::c_short,
- pub flags: ::c_ushort,
- pub fflags: ::c_uint,
- pub data: i64,
- pub udata: *mut ::c_void,
- }
-
- pub struct stat {
- pub st_mode: ::mode_t,
- pub st_dev: ::dev_t,
- pub st_ino: ::ino_t,
- pub st_nlink: ::nlink_t,
- pub st_uid: ::uid_t,
- pub st_gid: ::gid_t,
- pub st_rdev: ::dev_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_size: ::off_t,
- pub st_blocks: ::blkcnt_t,
- pub st_blksize: ::blksize_t,
- pub st_flags: u32,
- pub st_gen: u32,
- pub st_birthtime: ::time_t,
- pub st_birthtime_nsec: ::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,
- pub f_flag: ::c_ulong,
- pub f_namemax: ::c_ulong,
- }
-
- 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 Dl_info {
- pub dli_fname: *const ::c_char,
- pub dli_fbase: *mut ::c_void,
- pub dli_sname: *const ::c_char,
- pub dli_saddr: *mut ::c_void,
- }
-
- pub struct if_data {
- pub ifi_type: ::c_uchar,
- pub ifi_addrlen: ::c_uchar,
- pub ifi_hdrlen: ::c_uchar,
- pub ifi_link_state: ::c_uchar,
- pub ifi_mtu: u32,
- pub ifi_metric: u32,
- pub ifi_rdomain: u32,
- pub ifi_baudrate: u64,
- pub ifi_ipackets: u64,
- pub ifi_ierrors: u64,
- pub ifi_opackets: u64,
- pub ifi_oerrors: u64,
- pub ifi_collisions: u64,
- pub ifi_ibytes: u64,
- pub ifi_obytes: u64,
- pub ifi_imcasts: u64,
- pub ifi_omcasts: u64,
- pub ifi_iqdrops: u64,
- pub ifi_oqdrops: u64,
- pub ifi_noproto: u64,
- pub ifi_capabilities: u32,
- pub ifi_lastchange: ::timeval,
- }
-
- pub struct if_msghdr {
- pub ifm_msglen: ::c_ushort,
- pub ifm_version: ::c_uchar,
- pub ifm_type: ::c_uchar,
- pub ifm_hdrlen: ::c_ushort,
- pub ifm_index: ::c_ushort,
- pub ifm_tableid: ::c_ushort,
- pub ifm_pad1: ::c_uchar,
- pub ifm_pad2: ::c_uchar,
- pub ifm_addrs: ::c_int,
- pub ifm_flags: ::c_int,
- pub ifm_xflags: ::c_int,
- pub ifm_data: if_data,
- }
-
- pub struct sockaddr_dl {
- pub sdl_len: ::c_uchar,
- pub sdl_family: ::c_uchar,
- pub sdl_index: ::c_ushort,
- pub sdl_type: ::c_uchar,
- pub sdl_nlen: ::c_uchar,
- pub sdl_alen: ::c_uchar,
- 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,
- }
-}
-
-s_no_extra_traits! {
- pub struct dirent {
- pub d_fileno: ::ino_t,
- pub d_off: ::off_t,
- pub d_reclen: u16,
- pub d_type: u8,
- pub d_namlen: u8,
- __d_padding: [u8; 4],
- pub d_name: [::c_char; 256],
- }
-
- pub struct sockaddr_storage {
- pub ss_len: u8,
- pub ss_family: ::sa_family_t,
- __ss_pad1: [u8; 6],
- __ss_pad2: i64,
- __ss_pad3: [u8; 240],
- }
-
- pub struct siginfo_t {
- pub si_signo: ::c_int,
- pub si_code: ::c_int,
- pub si_errno: ::c_int,
- pub si_addr: *mut ::c_char,
- #[cfg(target_pointer_width = "32")]
- __pad: [u8; 112],
- #[cfg(target_pointer_width = "64")]
- __pad: [u8; 108],
- }
-
- pub struct lastlog {
- ll_time: ::time_t,
- ll_line: [::c_char; UT_LINESIZE],
- ll_host: [::c_char; UT_HOSTSIZE],
- }
-
- pub struct utmp {
- pub ut_line: [::c_char; UT_LINESIZE],
- pub ut_name: [::c_char; UT_NAMESIZE],
- pub ut_host: [::c_char; UT_HOSTSIZE],
- pub ut_time: ::time_t,
- }
-
- 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],
- }
-
-}
-
-cfg_if! {
- if #[cfg(feature = "extra_traits")] {
- impl PartialEq for dirent {
- fn eq(&self, other: &dirent) -> bool {
- self.d_fileno == other.d_fileno
- && self.d_off == other.d_off
- && self.d_reclen == other.d_reclen
- && self.d_type == other.d_type
- && self.d_namlen == other.d_namlen
- && self
- .d_name
- .iter()
- .zip(other.d_name.iter())
- .all(|(a,b)| a == b)
- }
- }
-
- impl Eq for dirent {}
-
- impl ::fmt::Debug for dirent {
- fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
- f.debug_struct("dirent")
- .field("d_fileno", &self.d_fileno)
- .field("d_off", &self.d_off)
- .field("d_reclen", &self.d_reclen)
- .field("d_type", &self.d_type)
- .field("d_namlen", &self.d_namlen)
- // FIXME: .field("d_name", &self.d_name)
- .finish()
- }
- }
-
- impl ::hash::Hash for dirent {
- fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
- self.d_fileno.hash(state);
- self.d_off.hash(state);
- self.d_reclen.hash(state);
- self.d_type.hash(state);
- self.d_namlen.hash(state);
- self.d_name.hash(state);
- }
- }
-
- impl PartialEq for sockaddr_storage {
- fn eq(&self, other: &sockaddr_storage) -> bool {
- self.ss_len == other.ss_len
- && self.ss_family == other.ss_family
- }
- }
-
- impl Eq for sockaddr_storage {}
-
- impl ::fmt::Debug for sockaddr_storage {
- fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
- f.debug_struct("sockaddr_storage")
- .field("ss_len", &self.ss_len)
- .field("ss_family", &self.ss_family)
- .finish()
- }
- }
-
- impl ::hash::Hash for sockaddr_storage {
- fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
- self.ss_len.hash(state);
- self.ss_family.hash(state);
- }
- }
-
- impl PartialEq for siginfo_t {
- fn eq(&self, other: &siginfo_t) -> bool {
- self.si_signo == other.si_signo
- && self.si_code == other.si_code
- && self.si_errno == other.si_errno
- && self.si_addr == other.si_addr
- }
- }
-
- impl Eq for siginfo_t {}
-
- impl ::fmt::Debug for siginfo_t {
- fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
- f.debug_struct("siginfo_t")
- .field("si_signo", &self.si_signo)
- .field("si_code", &self.si_code)
- .field("si_errno", &self.si_errno)
- .field("si_addr", &self.si_addr)
- .finish()
- }
- }
-
- impl ::hash::Hash for siginfo_t {
- fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
- self.si_signo.hash(state);
- self.si_code.hash(state);
- self.si_errno.hash(state);
- self.si_addr.hash(state);
- }
- }
-
- impl PartialEq for lastlog {
- fn eq(&self, other: &lastlog) -> bool {
- self.ll_time == other.ll_time
- && self
- .ll_line
- .iter()
- .zip(other.ll_line.iter())
- .all(|(a,b)| a == b)
- && self
- .ll_host
- .iter()
- .zip(other.ll_host.iter())
- .all(|(a,b)| a == b)
- }
- }
-
- impl Eq for lastlog {}
-
- impl ::fmt::Debug for lastlog {
- fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
- f.debug_struct("lastlog")
- .field("ll_time", &self.ll_time)
- // FIXME: .field("ll_line", &self.ll_line)
- // FIXME: .field("ll_host", &self.ll_host)
- .finish()
- }
- }
-
- impl ::hash::Hash for lastlog {
- fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
- self.ll_time.hash(state);
- self.ll_line.hash(state);
- self.ll_host.hash(state);
- }
- }
-
- impl PartialEq for utmp {
- fn eq(&self, other: &utmp) -> bool {
- self.ut_time == other.ut_time
- && self
- .ut_line
- .iter()
- .zip(other.ut_line.iter())
- .all(|(a,b)| a == b)
- && self
- .ut_name
- .iter()
- .zip(other.ut_name.iter())
- .all(|(a,b)| a == b)
- && self
- .ut_host
- .iter()
- .zip(other.ut_host.iter())
- .all(|(a,b)| a == b)
- }
- }
-
- impl Eq for utmp {}
-
- impl ::fmt::Debug for utmp {
- fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
- f.debug_struct("utmp")
- // FIXME: .field("ut_line", &self.ut_line)
- // FIXME: .field("ut_name", &self.ut_name)
- // FIXME: .field("ut_host", &self.ut_host)
- .field("ut_time", &self.ut_time)
- .finish()
- }
- }
-
- impl ::hash::Hash for utmp {
- fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
- self.ut_line.hash(state);
- self.ut_name.hash(state);
- self.ut_host.hash(state);
- self.ut_time.hash(state);
- }
- }
-
- impl PartialEq for mount_info {
- fn eq(&self, other: &mount_info) -> bool {
- unsafe {
- self.align
- .iter()
- .zip(other.align.iter())
- .all(|(a,b)| a == b)
- }
- }
- }
-
- impl Eq for mount_info { }
-
- impl ::fmt::Debug for mount_info {
- fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
- f.debug_struct("mount_info")
- // FIXME: .field("align", &self.align)
- .finish()
- }
- }
-
- impl ::hash::Hash for mount_info {
- fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
- unsafe { self.align.hash(state) };
- }
- }
- }
-}
-
-cfg_if! {
- if #[cfg(libc_union)] {
- s_no_extra_traits! {
- // This type uses the union mount_info:
- pub struct statfs {
- pub f_flags: u32,
- pub f_bsize: u32,
- pub f_iosize: u32,
- pub f_blocks: u64,
- pub f_bfree: u64,
- pub f_bavail: i64,
- pub f_files: u64,
- pub f_ffree: u64,
- pub f_favail: i64,
- pub f_syncwrites: u64,
- pub f_syncreads: u64,
- pub f_asyncwrites: u64,
- pub f_asyncreads: u64,
- pub f_fsid: ::fsid_t,
- pub f_namemax: u32,
- pub f_owner: ::uid_t,
- pub f_ctime: u64,
- 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,
- }
- }
-
- cfg_if! {
- if #[cfg(feature = "extra_traits")] {
- impl PartialEq for statfs {
- fn eq(&self, other: &statfs) -> bool {
- self.f_flags == other.f_flags
- && self.f_bsize == other.f_bsize
- && self.f_iosize == other.f_iosize
- && self.f_blocks == other.f_blocks
- && self.f_bfree == other.f_bfree
- && self.f_bavail == other.f_bavail
- && self.f_files == other.f_files
- && self.f_ffree == other.f_ffree
- && self.f_favail == other.f_favail
- && self.f_syncwrites == other.f_syncwrites
- && self.f_syncreads == other.f_syncreads
- && self.f_asyncwrites == other.f_asyncwrites
- && self.f_asyncreads == other.f_asyncreads
- && self.f_fsid == other.f_fsid
- && self.f_namemax == other.f_namemax
- && self.f_owner == other.f_owner
- && self.f_ctime == other.f_ctime
- && self.f_fstypename
- .iter()
- .zip(other.f_fstypename.iter())
- .all(|(a,b)| a == b)
- && self.f_mntonname
- .iter()
- .zip(other.f_mntonname.iter())
- .all(|(a,b)| a == b)
- && self.f_mntfromname
- .iter()
- .zip(other.f_mntfromname.iter())
- .all(|(a,b)| a == b)
- && self.f_mntfromspec
- .iter()
- .zip(other.f_mntfromspec.iter())
- .all(|(a,b)| a == b)
- && self.mount_info == other.mount_info
- }
- }
-
- impl Eq for statfs { }
-
- impl ::fmt::Debug for statfs {
- fn fmt(&self, f: &mut ::fmt::Formatter)
- -> ::fmt::Result {
- f.debug_struct("statfs")
- .field("f_flags", &self.f_flags)
- .field("f_bsize", &self.f_bsize)
- .field("f_iosize", &self.f_iosize)
- .field("f_blocks", &self.f_blocks)
- .field("f_bfree", &self.f_bfree)
- .field("f_bavail", &self.f_bavail)
- .field("f_files", &self.f_files)
- .field("f_ffree", &self.f_ffree)
- .field("f_favail", &self.f_favail)
- .field("f_syncwrites", &self.f_syncwrites)
- .field("f_syncreads", &self.f_syncreads)
- .field("f_asyncwrites", &self.f_asyncwrites)
- .field("f_asyncreads", &self.f_asyncreads)
- .field("f_fsid", &self.f_fsid)
- .field("f_namemax", &self.f_namemax)
- .field("f_owner", &self.f_owner)
- .field("f_ctime", &self.f_ctime)
- // FIXME: .field("f_fstypename", &self.f_fstypename)
- // FIXME: .field("f_mntonname", &self.f_mntonname)
- // FIXME: .field("f_mntfromname", &self.f_mntfromname)
- // FIXME: .field("f_mntfromspec", &self.f_mntfromspec)
- .field("mount_info", &self.mount_info)
- .finish()
- }
- }
-
- impl ::hash::Hash for statfs {
- fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
- self.f_flags.hash(state);
- self.f_bsize.hash(state);
- self.f_iosize.hash(state);
- self.f_blocks.hash(state);
- self.f_bfree.hash(state);
- self.f_bavail.hash(state);
- self.f_files.hash(state);
- self.f_ffree.hash(state);
- self.f_favail.hash(state);
- self.f_syncwrites.hash(state);
- self.f_syncreads.hash(state);
- self.f_asyncwrites.hash(state);
- self.f_asyncreads.hash(state);
- self.f_fsid.hash(state);
- self.f_namemax.hash(state);
- self.f_owner.hash(state);
- self.f_ctime.hash(state);
- self.f_fstypename.hash(state);
- self.f_mntonname.hash(state);
- self.f_mntfromname.hash(state);
- self.f_mntfromspec.hash(state);
- self.mount_info.hash(state);
- }
- }
- }
- }
- }
-}
-
-pub const UT_NAMESIZE: usize = 32;
-pub const UT_LINESIZE: usize = 8;
-pub const UT_HOSTSIZE: usize = 256;
-
-pub const O_CLOEXEC: ::c_int = 0x10000;
-pub const O_DIRECTORY: ::c_int = 0x20000;
-pub const O_RSYNC: ::c_int = O_SYNC;
-
-pub const MS_SYNC : ::c_int = 0x0002;
-pub const MS_INVALIDATE : ::c_int = 0x0004;
-
-pub const POLLNORM: ::c_short = ::POLLRDNORM;
-
-pub const ENOATTR : ::c_int = 83;
-pub const EILSEQ : ::c_int = 84;
-pub const EOVERFLOW : ::c_int = 87;
-pub const ECANCELED : ::c_int = 88;
-pub const EIDRM : ::c_int = 89;
-pub const ENOMSG : ::c_int = 90;
-pub const ENOTSUP : ::c_int = 91;
-pub const EBADMSG : ::c_int = 92;
-pub const ENOTRECOVERABLE : ::c_int = 93;
-pub const EOWNERDEAD : ::c_int = 94;
-pub const EPROTO : ::c_int = 95;
-pub const ELAST : ::c_int = 95;
-
-pub const F_DUPFD_CLOEXEC : ::c_int = 10;
-
-pub const AT_FDCWD: ::c_int = -100;
-pub const AT_EACCESS: ::c_int = 0x01;
-pub const AT_SYMLINK_NOFOLLOW: ::c_int = 0x02;
-pub const AT_SYMLINK_FOLLOW: ::c_int = 0x04;
-pub const AT_REMOVEDIR: ::c_int = 0x08;
-
-pub const RLIM_NLIMITS: ::c_int = 9;
-
-pub const SO_TIMESTAMP: ::c_int = 0x0800;
-pub const SO_SNDTIMEO: ::c_int = 0x1005;
-pub const SO_RCVTIMEO: ::c_int = 0x1006;
-pub const SO_BINDANY: ::c_int = 0x1000;
-pub const SO_NETPROC: ::c_int = 0x1020;
-pub const SO_RTABLE: ::c_int = 0x1021;
-pub const SO_PEERCRED: ::c_int = 0x1022;
-pub const SO_SPLICE: ::c_int = 0x1023;
-
-// sys/netinet/in.h
-// Protocols (RFC 1700)
-// NOTE: These are in addition to the constants defined in src/unix/mod.rs
-
-// IPPROTO_IP defined in src/unix/mod.rs
-/// Hop-by-hop option header
-pub const IPPROTO_HOPOPTS: ::c_int = 0;
-// IPPROTO_ICMP defined in src/unix/mod.rs
-/// group mgmt protocol
-pub const IPPROTO_IGMP: ::c_int = 2;
-/// gateway^2 (deprecated)
-pub const IPPROTO_GGP: ::c_int = 3;
-/// for compatibility
-pub const IPPROTO_IPIP: ::c_int = 4;
-// IPPROTO_TCP defined in src/unix/mod.rs
-/// exterior gateway protocol
-pub const IPPROTO_EGP: ::c_int = 8;
-/// pup
-pub const IPPROTO_PUP: ::c_int = 12;
-// IPPROTO_UDP defined in src/unix/mod.rs
-/// xns idp
-pub const IPPROTO_IDP: ::c_int = 22;
-/// tp-4 w/ class negotiation
-pub const IPPROTO_TP: ::c_int = 29;
-// IPPROTO_IPV6 defined in src/unix/mod.rs
-/// IP6 routing header
-pub const IPPROTO_ROUTING: ::c_int = 43;
-/// IP6 fragmentation header
-pub const IPPROTO_FRAGMENT: ::c_int = 44;
-/// resource reservation
-pub const IPPROTO_RSVP: ::c_int = 46;
-/// General Routing Encap.
-pub const IPPROTO_GRE: ::c_int = 47;
-/// IP6 Encap Sec. Payload
-pub const IPPROTO_ESP: ::c_int = 50;
-/// IP6 Auth Header
-pub const IPPROTO_AH: ::c_int = 51;
-/// IP Mobility RFC 2004
-pub const IPPROTO_MOBILE: ::c_int = 55;
-// IPPROTO_ICMPV6 defined in src/unix/mod.rs
-/// IP6 no next header
-pub const IPPROTO_NONE: ::c_int = 59;
-/// IP6 destination option
-pub const IPPROTO_DSTOPTS: ::c_int = 60;
-/// ISO cnlp
-pub const IPPROTO_EON: ::c_int = 80;
-/// Ethernet-in-IP
-pub const IPPROTO_ETHERIP: ::c_int = 97;
-/// encapsulation header
-pub const IPPROTO_ENCAP: ::c_int = 98;
-/// Protocol indep. multicast
-pub const IPPROTO_PIM: ::c_int = 103;
-/// IP Payload Comp. Protocol
-pub const IPPROTO_IPCOMP: ::c_int = 108;
-/// CARP
-pub const IPPROTO_CARP: ::c_int = 112;
-/// unicast MPLS packet
-pub const IPPROTO_MPLS: ::c_int = 137;
-/// PFSYNC
-pub const IPPROTO_PFSYNC: ::c_int = 240;
-pub const IPPROTO_MAX: ::c_int = 256;
-
-/* Only used internally, so it can be outside the range of valid IP protocols */
-/// Divert sockets
-pub const IPPROTO_DIVERT: ::c_int = 258;
-
-pub const IP_RECVDSTADDR: ::c_int = 7;
-pub const IP_SENDSRCADDR: ::c_int = IP_RECVDSTADDR;
-pub const IP_RECVIF: ::c_int = 30;
-
-// 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;
-pub const AF_SIP: ::c_int = 29;
-pub const AF_KEY: ::c_int = 30;
-pub const pseudo_AF_HDRCMPLT: ::c_int = 31;
-pub const AF_BLUETOOTH: ::c_int = 32;
-pub const AF_MPLS: ::c_int = 33;
-pub const pseudo_AF_PFLOW: ::c_int = 34;
-pub const pseudo_AF_PIPEX: ::c_int = 35;
-#[doc(hidden)]
-#[deprecated(
- since = "0.2.55",
- note = "If you are using this report to: \
- https://github.com/rust-lang/libc/issues/665"
-)]
-pub const AF_MAX: ::c_int = 36;
-
-#[doc(hidden)]
-#[allow(deprecated)]
-#[deprecated(
- since = "0.2.55",
- note = "If you are using this report to: \
- https://github.com/rust-lang/libc/issues/665"
-)]
-pub const NET_MAXID: ::c_int = AF_MAX;
-pub const NET_RT_DUMP: ::c_int = 1;
-pub const NET_RT_FLAGS: ::c_int = 2;
-pub const NET_RT_IFLIST: ::c_int = 3;
-pub const NET_RT_STATS: ::c_int = 4;
-pub const NET_RT_TABLE: ::c_int = 5;
-pub const NET_RT_IFNAMES: ::c_int = 6;
-#[doc(hidden)]
-pub const NET_RT_MAXID: ::c_int = 7;
-
-pub const IPV6_JOIN_GROUP: ::c_int = 12;
-pub const IPV6_LEAVE_GROUP: ::c_int = 13;
-
-pub const PF_ROUTE: ::c_int = AF_ROUTE;
-pub const PF_ECMA: ::c_int = AF_ECMA;
-pub const PF_ENCAP: ::c_int = AF_ENCAP;
-pub const PF_SIP: ::c_int = AF_SIP;
-pub const PF_KEY: ::c_int = AF_KEY;
-pub const PF_BPF: ::c_int = pseudo_AF_HDRCMPLT;
-pub const PF_BLUETOOTH: ::c_int = AF_BLUETOOTH;
-pub const PF_MPLS: ::c_int = AF_MPLS;
-pub const PF_PFLOW: ::c_int = pseudo_AF_PFLOW;
-pub const PF_PIPEX: ::c_int = pseudo_AF_PIPEX;
-#[doc(hidden)]
-#[allow(deprecated)]
-#[deprecated(
- since = "0.2.55",
- note = "If you are using this report to: \
- https://github.com/rust-lang/libc/issues/665"
-)]
-pub const PF_MAX: ::c_int = AF_MAX;
-
-pub const SCM_TIMESTAMP: ::c_int = 0x04;
-
-pub const O_DSYNC : ::c_int = 128;
-
-pub const MAP_RENAME : ::c_int = 0x0000;
-pub const MAP_NORESERVE : ::c_int = 0x0000;
-pub const MAP_HASSEMAPHORE : ::c_int = 0x0000;
-
-pub const EIPSEC : ::c_int = 82;
-pub const ENOMEDIUM : ::c_int = 85;
-pub const EMEDIUMTYPE : ::c_int = 86;
-
-pub const EAI_BADFLAGS: ::c_int = -1;
-pub const EAI_NONAME: ::c_int = -2;
-pub const EAI_AGAIN: ::c_int = -3;
-pub const EAI_FAIL: ::c_int = -4;
-pub const EAI_NODATA: ::c_int = -5;
-pub const EAI_FAMILY: ::c_int = -6;
-pub const EAI_SOCKTYPE: ::c_int = -7;
-pub const EAI_SERVICE: ::c_int = -8;
-pub const EAI_MEMORY: ::c_int = -10;
-pub const EAI_SYSTEM: ::c_int = -11;
-pub const EAI_OVERFLOW: ::c_int = -14;
-
-pub const RUSAGE_THREAD: ::c_int = 1;
-
-pub const MAP_COPY : ::c_int = 0x0002;
-pub const MAP_NOEXTEND : ::c_int = 0x0000;
-
-pub const _PC_LINK_MAX : ::c_int = 1;
-pub const _PC_MAX_CANON : ::c_int = 2;
-pub const _PC_MAX_INPUT : ::c_int = 3;
-pub const _PC_NAME_MAX : ::c_int = 4;
-pub const _PC_PATH_MAX : ::c_int = 5;
-pub const _PC_PIPE_BUF : ::c_int = 6;
-pub const _PC_CHOWN_RESTRICTED : ::c_int = 7;
-pub const _PC_NO_TRUNC : ::c_int = 8;
-pub const _PC_VDISABLE : ::c_int = 9;
-pub const _PC_2_SYMLINKS : ::c_int = 10;
-pub const _PC_ALLOC_SIZE_MIN : ::c_int = 11;
-pub const _PC_ASYNC_IO : ::c_int = 12;
-pub const _PC_FILESIZEBITS : ::c_int = 13;
-pub const _PC_PRIO_IO : ::c_int = 14;
-pub const _PC_REC_INCR_XFER_SIZE : ::c_int = 15;
-pub const _PC_REC_MAX_XFER_SIZE : ::c_int = 16;
-pub const _PC_REC_MIN_XFER_SIZE : ::c_int = 17;
-pub const _PC_REC_XFER_ALIGN : ::c_int = 18;
-pub const _PC_SYMLINK_MAX : ::c_int = 19;
-pub const _PC_SYNC_IO : ::c_int = 20;
-pub const _PC_TIMESTAMP_RESOLUTION : ::c_int = 21;
-
-pub const _SC_CLK_TCK : ::c_int = 3;
-pub const _SC_SEM_NSEMS_MAX : ::c_int = 31;
-pub const _SC_SEM_VALUE_MAX : ::c_int = 32;
-pub const _SC_HOST_NAME_MAX : ::c_int = 33;
-pub const _SC_MONOTONIC_CLOCK : ::c_int = 34;
-pub const _SC_2_PBS : ::c_int = 35;
-pub const _SC_2_PBS_ACCOUNTING : ::c_int = 36;
-pub const _SC_2_PBS_CHECKPOINT : ::c_int = 37;
-pub const _SC_2_PBS_LOCATE : ::c_int = 38;
-pub const _SC_2_PBS_MESSAGE : ::c_int = 39;
-pub const _SC_2_PBS_TRACK : ::c_int = 40;
-pub const _SC_ADVISORY_INFO : ::c_int = 41;
-pub const _SC_AIO_LISTIO_MAX : ::c_int = 42;
-pub const _SC_AIO_MAX : ::c_int = 43;
-pub const _SC_AIO_PRIO_DELTA_MAX : ::c_int = 44;
-pub const _SC_ASYNCHRONOUS_IO : ::c_int = 45;
-pub const _SC_ATEXIT_MAX : ::c_int = 46;
-pub const _SC_BARRIERS : ::c_int = 47;
-pub const _SC_CLOCK_SELECTION : ::c_int = 48;
-pub const _SC_CPUTIME : ::c_int = 49;
-pub const _SC_DELAYTIMER_MAX : ::c_int = 50;
-pub const _SC_IOV_MAX : ::c_int = 51;
-pub const _SC_IPV6 : ::c_int = 52;
-pub const _SC_MAPPED_FILES : ::c_int = 53;
-pub const _SC_MEMLOCK : ::c_int = 54;
-pub const _SC_MEMLOCK_RANGE : ::c_int = 55;
-pub const _SC_MEMORY_PROTECTION : ::c_int = 56;
-pub const _SC_MESSAGE_PASSING : ::c_int = 57;
-pub const _SC_MQ_OPEN_MAX : ::c_int = 58;
-pub const _SC_MQ_PRIO_MAX : ::c_int = 59;
-pub const _SC_PRIORITIZED_IO : ::c_int = 60;
-pub const _SC_PRIORITY_SCHEDULING : ::c_int = 61;
-pub const _SC_RAW_SOCKETS : ::c_int = 62;
-pub const _SC_READER_WRITER_LOCKS : ::c_int = 63;
-pub const _SC_REALTIME_SIGNALS : ::c_int = 64;
-pub const _SC_REGEXP : ::c_int = 65;
-pub const _SC_RTSIG_MAX : ::c_int = 66;
-pub const _SC_SEMAPHORES : ::c_int = 67;
-pub const _SC_SHARED_MEMORY_OBJECTS : ::c_int = 68;
-pub const _SC_SHELL : ::c_int = 69;
-pub const _SC_SIGQUEUE_MAX : ::c_int = 70;
-pub const _SC_SPAWN : ::c_int = 71;
-pub const _SC_SPIN_LOCKS : ::c_int = 72;
-pub const _SC_SPORADIC_SERVER : ::c_int = 73;
-pub const _SC_SS_REPL_MAX : ::c_int = 74;
-pub const _SC_SYNCHRONIZED_IO : ::c_int = 75;
-pub const _SC_SYMLOOP_MAX : ::c_int = 76;
-pub const _SC_THREAD_ATTR_STACKADDR : ::c_int = 77;
-pub const _SC_THREAD_ATTR_STACKSIZE : ::c_int = 78;
-pub const _SC_THREAD_CPUTIME : ::c_int = 79;
-pub const _SC_THREAD_DESTRUCTOR_ITERATIONS : ::c_int = 80;
-pub const _SC_THREAD_KEYS_MAX : ::c_int = 81;
-pub const _SC_THREAD_PRIO_INHERIT : ::c_int = 82;
-pub const _SC_THREAD_PRIO_PROTECT : ::c_int = 83;
-pub const _SC_THREAD_PRIORITY_SCHEDULING : ::c_int = 84;
-pub const _SC_THREAD_PROCESS_SHARED : ::c_int = 85;
-pub const _SC_THREAD_ROBUST_PRIO_INHERIT : ::c_int = 86;
-pub const _SC_THREAD_ROBUST_PRIO_PROTECT : ::c_int = 87;
-pub const _SC_THREAD_SPORADIC_SERVER : ::c_int = 88;
-pub const _SC_THREAD_STACK_MIN : ::c_int = 89;
-pub const _SC_THREAD_THREADS_MAX : ::c_int = 90;
-pub const _SC_THREADS : ::c_int = 91;
-pub const _SC_TIMEOUTS : ::c_int = 92;
-pub const _SC_TIMER_MAX : ::c_int = 93;
-pub const _SC_TIMERS : ::c_int = 94;
-pub const _SC_TRACE : ::c_int = 95;
-pub const _SC_TRACE_EVENT_FILTER : ::c_int = 96;
-pub const _SC_TRACE_EVENT_NAME_MAX : ::c_int = 97;
-pub const _SC_TRACE_INHERIT : ::c_int = 98;
-pub const _SC_TRACE_LOG : ::c_int = 99;
-pub const _SC_GETGR_R_SIZE_MAX : ::c_int = 100;
-pub const _SC_GETPW_R_SIZE_MAX : ::c_int = 101;
-pub const _SC_LOGIN_NAME_MAX : ::c_int = 102;
-pub const _SC_THREAD_SAFE_FUNCTIONS : ::c_int = 103;
-pub const _SC_TRACE_NAME_MAX : ::c_int = 104;
-pub const _SC_TRACE_SYS_MAX : ::c_int = 105;
-pub const _SC_TRACE_USER_EVENT_MAX : ::c_int = 106;
-pub const _SC_TTY_NAME_MAX : ::c_int = 107;
-pub const _SC_TYPED_MEMORY_OBJECTS : ::c_int = 108;
-pub const _SC_V6_ILP32_OFF32 : ::c_int = 109;
-pub const _SC_V6_ILP32_OFFBIG : ::c_int = 110;
-pub const _SC_V6_LP64_OFF64 : ::c_int = 111;
-pub const _SC_V6_LPBIG_OFFBIG : ::c_int = 112;
-pub const _SC_V7_ILP32_OFF32 : ::c_int = 113;
-pub const _SC_V7_ILP32_OFFBIG : ::c_int = 114;
-pub const _SC_V7_LP64_OFF64 : ::c_int = 115;
-pub const _SC_V7_LPBIG_OFFBIG : ::c_int = 116;
-pub const _SC_XOPEN_CRYPT : ::c_int = 117;
-pub const _SC_XOPEN_ENH_I18N : ::c_int = 118;
-pub const _SC_XOPEN_LEGACY : ::c_int = 119;
-pub const _SC_XOPEN_REALTIME : ::c_int = 120;
-pub const _SC_XOPEN_REALTIME_THREADS : ::c_int = 121;
-pub const _SC_XOPEN_STREAMS : ::c_int = 122;
-pub const _SC_XOPEN_UNIX : ::c_int = 123;
-pub const _SC_XOPEN_UUCP : ::c_int = 124;
-pub const _SC_XOPEN_VERSION : ::c_int = 125;
-pub const _SC_PHYS_PAGES : ::c_int = 500;
-pub const _SC_AVPHYS_PAGES : ::c_int = 501;
-pub const _SC_NPROCESSORS_CONF : ::c_int = 502;
-pub const _SC_NPROCESSORS_ONLN : ::c_int = 503;
-
-pub const FD_SETSIZE: usize = 1024;
-
-pub const ST_NOSUID: ::c_ulong = 2;
-
-pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = 0 as *mut _;
-pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = 0 as *mut _;
-pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = 0 as *mut _;
-
-pub const PTHREAD_MUTEX_ERRORCHECK: ::c_int = 1;
-pub const PTHREAD_MUTEX_RECURSIVE: ::c_int = 2;
-pub const PTHREAD_MUTEX_NORMAL: ::c_int = 3;
-pub const PTHREAD_MUTEX_STRICT_NP: ::c_int = 4;
-pub const PTHREAD_MUTEX_DEFAULT: ::c_int = PTHREAD_MUTEX_STRICT_NP;
-
-pub const EVFILT_AIO: i16 = -3;
-pub const EVFILT_PROC: i16 = -5;
-pub const EVFILT_READ: i16 = -1;
-pub const EVFILT_SIGNAL: i16 = -6;
-pub const EVFILT_TIMER: i16 = -7;
-pub const EVFILT_VNODE: i16 = -4;
-pub const EVFILT_WRITE: i16 = -2;
-
-pub const EV_ADD: u16 = 0x1;
-pub const EV_DELETE: u16 = 0x2;
-pub const EV_ENABLE: u16 = 0x4;
-pub const EV_DISABLE: u16 = 0x8;
-pub const EV_ONESHOT: u16 = 0x10;
-pub const EV_CLEAR: u16 = 0x20;
-pub const EV_RECEIPT: u16 = 0x40;
-pub const EV_DISPATCH: u16 = 0x80;
-pub const EV_FLAG1: u16 = 0x2000;
-pub const EV_ERROR: u16 = 0x4000;
-pub const EV_EOF: u16 = 0x8000;
-pub const EV_SYSFLAGS: u16 = 0xf000;
-
-pub const NOTE_LOWAT: u32 = 0x00000001;
-pub const NOTE_EOF: u32 = 0x00000002;
-pub const NOTE_DELETE: u32 = 0x00000001;
-pub const NOTE_WRITE: u32 = 0x00000002;
-pub const NOTE_EXTEND: u32 = 0x00000004;
-pub const NOTE_ATTRIB: u32 = 0x00000008;
-pub const NOTE_LINK: u32 = 0x00000010;
-pub const NOTE_RENAME: u32 = 0x00000020;
-pub const NOTE_REVOKE: u32 = 0x00000040;
-pub const NOTE_TRUNCATE: u32 = 0x00000080;
-pub const NOTE_EXIT: u32 = 0x80000000;
-pub const NOTE_FORK: u32 = 0x40000000;
-pub const NOTE_EXEC: u32 = 0x20000000;
-pub const NOTE_PDATAMASK: u32 = 0x000fffff;
-pub const NOTE_PCTRLMASK: u32 = 0xf0000000;
-pub const NOTE_TRACK: u32 = 0x00000001;
-pub const NOTE_TRACKERR: u32 = 0x00000002;
-pub const NOTE_CHILD: u32 = 0x00000004;
-
-pub const TMP_MAX : ::c_uint = 0x7fffffff;
-
-pub const NI_MAXHOST: ::size_t = 256;
-
-pub const RTLD_LOCAL: ::c_int = 0;
-
-pub const CTL_MAXNAME: ::c_int = 12;
-
-pub const CTLTYPE_NODE: ::c_int = 1;
-pub const CTLTYPE_INT: ::c_int = 2;
-pub const CTLTYPE_STRING: ::c_int = 3;
-pub const CTLTYPE_QUAD: ::c_int = 4;
-pub const CTLTYPE_STRUCT: ::c_int = 5;
-
-pub const CTL_UNSPEC: ::c_int = 0;
-pub const CTL_KERN: ::c_int = 1;
-pub const CTL_VM: ::c_int = 2;
-pub const CTL_FS: ::c_int = 3;
-pub const CTL_NET: ::c_int = 4;
-pub const CTL_DEBUG: ::c_int = 5;
-pub const CTL_HW: ::c_int = 6;
-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;
-pub const KERN_VERSION: ::c_int = 4;
-pub const KERN_MAXVNODES: ::c_int = 5;
-pub const KERN_MAXPROC: ::c_int = 6;
-pub const KERN_MAXFILES: ::c_int = 7;
-pub const KERN_ARGMAX: ::c_int = 8;
-pub const KERN_SECURELVL: ::c_int = 9;
-pub const KERN_HOSTNAME: ::c_int = 10;
-pub const KERN_HOSTID: ::c_int = 11;
-pub const KERN_CLOCKRATE: ::c_int = 12;
-pub const KERN_PROF: ::c_int = 16;
-pub const KERN_POSIX1: ::c_int = 17;
-pub const KERN_NGROUPS: ::c_int = 18;
-pub const KERN_JOB_CONTROL: ::c_int = 19;
-pub const KERN_SAVED_IDS: ::c_int = 20;
-pub const KERN_BOOTTIME: ::c_int = 21;
-pub const KERN_DOMAINNAME: ::c_int = 22;
-pub const KERN_MAXPARTITIONS: ::c_int = 23;
-pub const KERN_RAWPARTITION: ::c_int = 24;
-pub const KERN_MAXTHREAD: ::c_int = 25;
-pub const KERN_NTHREADS: ::c_int = 26;
-pub const KERN_OSVERSION: ::c_int = 27;
-pub const KERN_SOMAXCONN: ::c_int = 28;
-pub const KERN_SOMINCONN: ::c_int = 29;
-pub const KERN_USERMOUNT: ::c_int = 30;
-pub const KERN_NOSUIDCOREDUMP: ::c_int = 32;
-pub const KERN_FSYNC: ::c_int = 33;
-pub const KERN_SYSVMSG: ::c_int = 34;
-pub const KERN_SYSVSEM: ::c_int = 35;
-pub const KERN_SYSVSHM: ::c_int = 36;
-pub const KERN_ARND: ::c_int = 37;
-pub const KERN_MSGBUFSIZE: ::c_int = 38;
-pub const KERN_MALLOCSTATS: ::c_int = 39;
-pub const KERN_CPTIME: ::c_int = 40;
-pub const KERN_NCHSTATS: ::c_int = 41;
-pub const KERN_FORKSTAT: ::c_int = 42;
-pub const KERN_NSELCOLL: ::c_int = 43;
-pub const KERN_TTY: ::c_int = 44;
-pub const KERN_CCPU: ::c_int = 45;
-pub const KERN_FSCALE: ::c_int = 46;
-pub const KERN_NPROCS: ::c_int = 47;
-pub const KERN_MSGBUF: ::c_int = 48;
-pub const KERN_POOL: ::c_int = 49;
-pub const KERN_STACKGAPRANDOM: ::c_int = 50;
-pub const KERN_SYSVIPC_INFO: ::c_int = 51;
-pub const KERN_SPLASSERT: ::c_int = 54;
-pub const KERN_PROC_ARGS: ::c_int = 55;
-pub const KERN_NFILES: ::c_int = 56;
-pub const KERN_TTYCOUNT: ::c_int = 57;
-pub const KERN_NUMVNODES: ::c_int = 58;
-pub const KERN_MBSTAT: ::c_int = 59;
-pub const KERN_SEMINFO: ::c_int = 61;
-pub const KERN_SHMINFO: ::c_int = 62;
-pub const KERN_INTRCNT: ::c_int = 63;
-pub const KERN_WATCHDOG: ::c_int = 64;
-pub const KERN_PROC: ::c_int = 66;
-pub const KERN_MAXCLUSTERS: ::c_int = 67;
-pub const KERN_EVCOUNT: ::c_int = 68;
-pub const KERN_TIMECOUNTER: ::c_int = 69;
-pub const KERN_MAXLOCKSPERUID: ::c_int = 70;
-pub const KERN_CPTIME2: ::c_int = 71;
-pub const KERN_CACHEPCT: ::c_int = 72;
-pub const KERN_FILE: ::c_int = 73;
-pub const KERN_CONSDEV: ::c_int = 75;
-pub const KERN_NETLIVELOCKS: ::c_int = 76;
-pub const KERN_POOL_DEBUG: ::c_int = 77;
-pub const KERN_PROC_CWD: ::c_int = 78;
-pub const KERN_PROC_NOBROADCASTKILL: ::c_int = 79;
-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_AUDIO: ::c_int = 84;
-pub const KERN_CPUSTATS: ::c_int = 85;
-pub const KERN_PFSTATUS: ::c_int = 86;
-pub const KERN_MAXID: ::c_int = 87;
-
-pub const KERN_PROC_ALL: ::c_int = 0;
-pub const KERN_PROC_PID: ::c_int = 1;
-pub const KERN_PROC_PGRP: ::c_int = 2;
-pub const KERN_PROC_SESSION: ::c_int = 3;
-pub const KERN_PROC_TTY: ::c_int = 4;
-pub const KERN_PROC_UID: ::c_int = 5;
-pub const KERN_PROC_RUID: ::c_int = 6;
-pub const KERN_PROC_KTHREAD: ::c_int = 7;
-pub const KERN_PROC_SHOW_THREADS: ::c_int = 0x40000000;
-
-pub const KERN_SYSVIPC_MSG_INFO: ::c_int = 1;
-pub const KERN_SYSVIPC_SEM_INFO: ::c_int = 2;
-pub const KERN_SYSVIPC_SHM_INFO: ::c_int = 3;
-
-pub const KERN_PROC_ARGV: ::c_int = 1;
-pub const KERN_PROC_NARGV: ::c_int = 2;
-pub const KERN_PROC_ENV: ::c_int = 3;
-pub const KERN_PROC_NENV: ::c_int = 4;
-
-pub const KI_NGROUPS: ::c_int = 16;
-pub const KI_MAXCOMLEN: ::c_int = 24;
-pub const KI_WMESGLEN: ::c_int = 8;
-pub const KI_MAXLOGNAME: ::c_int = 32;
-pub const KI_EMULNAMELEN: ::c_int = 8;
-
-pub const CHWFLOW: ::tcflag_t = ::MDMBUF | ::CRTSCTS;
-pub const OLCUC: ::tcflag_t = 0x20;
-pub const ONOCR: ::tcflag_t = 0x40;
-pub const ONLRET: ::tcflag_t = 0x80;
-
-//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 PTHREAD_STACK_MIN : ::size_t = 4096;
-pub const SIGSTKSZ : ::size_t = 28672;
-
-pub const PT_FIRSTMACH: ::c_int = 32;
-
-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;
-
-fn _ALIGN(p: usize) -> usize {
- (p + _ALIGNBYTES) & !_ALIGNBYTES
-}
-
-f! {
- pub fn WIFCONTINUED(status: ::c_int) -> bool {
- status & 0o177777 == 0o177777
- }
-
- pub fn CMSG_DATA(cmsg: *const ::cmsghdr) -> *mut ::c_uchar {
- (cmsg as *mut ::c_uchar)
- .offset(_ALIGN(::mem::size_of::<::cmsghdr>()) as isize)
- }
-
- pub fn CMSG_LEN(length: ::c_uint) -> ::c_uint {
- _ALIGN(::mem::size_of::<::cmsghdr>()) as ::c_uint + length
- }
-
- pub fn CMSG_NXTHDR(mhdr: *const ::msghdr, cmsg: *const ::cmsghdr)
- -> *mut ::cmsghdr
- {
- if cmsg.is_null() {
- return ::CMSG_FIRSTHDR(mhdr);
- };
- let next = cmsg as usize + _ALIGN((*cmsg).cmsg_len as usize)
- + _ALIGN(::mem::size_of::<::cmsghdr>());
- let max = (*mhdr).msg_control as usize
- + (*mhdr).msg_controllen as usize;
- if next > max {
- 0 as *mut ::cmsghdr
- } else {
- (cmsg as usize + _ALIGN((*cmsg).cmsg_len as usize))
- as *mut ::cmsghdr
- }
- }
-
- pub fn CMSG_SPACE(length: ::c_uint) -> ::c_uint {
- (_ALIGN(::mem::size_of::<::cmsghdr>()) + _ALIGN(length as usize))
- as ::c_uint
- }
-
- pub fn WSTOPSIG(status: ::c_int) -> ::c_int {
- status >> 8
- }
-
- pub fn WIFSIGNALED(status: ::c_int) -> bool {
- (status & 0o177) != 0o177 && (status & 0o177) != 0
- }
-
- pub fn WIFSTOPPED(status: ::c_int) -> bool {
- (status & 0o177) == 0o177
- }
-}
-
-extern {
- pub fn gettimeofday(tp: *mut ::timeval,
- tz: *mut ::timezone) -> ::c_int;
- 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 dup3(src: ::c_int, dst: ::c_int, flags: ::c_int) -> ::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 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,
- 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 mprotect(addr: *mut ::c_void, len: ::size_t, prot: ::c_int)
- -> ::c_int;
- pub fn pthread_main_np() -> ::c_int;
- pub fn pthread_set_name_np(tid: ::pthread_t, name: *const ::c_char);
- pub fn pthread_stackseg_np(thread: ::pthread_t,
- sinfo: *mut ::stack_t) -> ::c_int;
- pub fn sysctl(name: *const ::c_int,
- namelen: ::c_uint,
- oldp: *mut ::c_void,
- oldlenp: *mut ::size_t,
- newp: *mut ::c_void,
- newlen: ::size_t)
- -> ::c_int;
- pub fn getentropy(buf: *mut ::c_void, buflen: ::size_t) -> ::c_int;
- pub fn setresgid(rgid: ::gid_t, egid: ::gid_t, sgid: ::gid_t) -> ::c_int;
- pub fn setresuid(ruid: ::uid_t, euid: ::uid_t, suid: ::uid_t) -> ::c_int;
- pub fn ptrace(request: ::c_int,
- pid: ::pid_t,
- addr: caddr_t,
- data: ::c_int) -> ::c_int;
-}
-
-cfg_if! {
- if #[cfg(libc_union)] {
- extern {
- // these functions use statfs which uses the union mount_info:
- pub fn statfs(path: *const ::c_char, buf: *mut statfs) -> ::c_int;
- pub fn fstatfs(fd: ::c_int, buf: *mut statfs) -> ::c_int;
- }
- }
-}
-
-cfg_if! {
- if #[cfg(target_arch = "x86")] {
- mod x86;
- pub use self::x86::*;
- } else if #[cfg(target_arch = "x86_64")] {
- mod x86_64;
- pub use self::x86_64::*;
- } else if #[cfg(target_arch = "aarch64")] {
- mod aarch64;
- pub use self::aarch64::*;
- } else {
- // Unknown target_arch
- }
-}
diff --git a/libc/src/unix/bsd/netbsdlike/openbsd/x86.rs b/libc/src/unix/bsd/netbsdlike/openbsd/x86.rs
deleted file mode 100644
index 05538cd..0000000
--- a/libc/src/unix/bsd/netbsdlike/openbsd/x86.rs
+++ /dev/null
@@ -1,14 +0,0 @@
-pub type c_long = i32;
-pub type c_ulong = u32;
-pub type c_char = i8;
-
-// should be pub(crate), but that requires Rust 1.18.0
-cfg_if! {
- if #[cfg(libc_const_size_of)] {
- #[doc(hidden)]
- pub const _ALIGNBYTES: usize = ::mem::size_of::<::c_int>() - 1;
- } else {
- #[doc(hidden)]
- pub const _ALIGNBYTES: usize = 4 - 1;
- }
-}
diff --git a/libc/src/unix/bsd/netbsdlike/openbsd/x86_64.rs b/libc/src/unix/bsd/netbsdlike/openbsd/x86_64.rs
deleted file mode 100644
index 7daa9d8..0000000
--- a/libc/src/unix/bsd/netbsdlike/openbsd/x86_64.rs
+++ /dev/null
@@ -1,22 +0,0 @@
-use PT_FIRSTMACH;
-
-pub type c_long = i64;
-pub type c_ulong = u64;
-pub type c_char = i8;
-
-// should be pub(crate), but that requires Rust 1.18.0
-cfg_if! {
- if #[cfg(libc_const_size_of)] {
- #[doc(hidden)]
- pub const _ALIGNBYTES: usize = ::mem::size_of::<::c_long>() - 1;
- } else {
- #[doc(hidden)]
- pub const _ALIGNBYTES: usize = 8 - 1;
- }
-}
-
-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/b32.rs b/libc/src/unix/haiku/b32.rs
deleted file mode 100644
index cce8864..0000000
--- a/libc/src/unix/haiku/b32.rs
+++ /dev/null
@@ -1,3 +0,0 @@
-pub type c_long = i32;
-pub type c_ulong = u32;
-pub type time_t = i32;
diff --git a/libc/src/unix/haiku/b64.rs b/libc/src/unix/haiku/b64.rs
deleted file mode 100644
index 3e66f14..0000000
--- a/libc/src/unix/haiku/b64.rs
+++ /dev/null
@@ -1,3 +0,0 @@
-pub type c_ulong = u64;
-pub type c_long = i64;
-pub type time_t = i64;
diff --git a/libc/src/unix/haiku/mod.rs b/libc/src/unix/haiku/mod.rs
deleted file mode 100644
index be9a6cf..0000000
--- a/libc/src/unix/haiku/mod.rs
+++ /dev/null
@@ -1,1396 +0,0 @@
-pub type rlim_t = ::uintptr_t;
-pub type sa_family_t = u8;
-pub type pthread_key_t = ::c_int;
-pub type nfds_t = ::c_long;
-pub type tcflag_t = ::c_uint;
-pub type speed_t = ::c_uint;
-pub type c_char = i8;
-pub type clock_t = i32;
-pub type clockid_t = i32;
-pub type suseconds_t = i32;
-pub type wchar_t = i32;
-pub type off_t = i64;
-pub type ino_t = i64;
-pub type blkcnt_t = i64;
-pub type blksize_t = i32;
-pub type dev_t = i32;
-pub type mode_t = u32;
-pub type nlink_t = i32;
-pub type useconds_t = u32;
-pub type socklen_t = u32;
-pub type pthread_t = ::uintptr_t;
-pub type pthread_mutexattr_t = ::uintptr_t;
-pub type pthread_rwlockattr_t = ::uintptr_t;
-pub type sigset_t = u64;
-pub type fsblkcnt_t = i64;
-pub type fsfilcnt_t = i64;
-pub type pthread_attr_t = *mut ::c_void;
-pub type nl_item = ::c_int;
-pub type id_t = i32;
-pub type idtype_t = ::c_uint;
-
-#[cfg_attr(feature = "extra_traits", derive(Debug))]
-pub enum timezone {}
-impl ::Copy for timezone {}
-impl ::Clone for timezone {
- fn clone(&self) -> timezone { *self }
-}
-
-s! {
- pub struct in_addr {
- pub s_addr: ::in_addr_t,
- }
-
- pub struct ip_mreq {
- pub imr_multiaddr: in_addr,
- pub imr_interface: in_addr,
- }
-
- pub struct sockaddr {
- pub sa_len: u8,
- pub sa_family: sa_family_t,
- pub sa_data: [::c_char; 30],
- }
-
- 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: [u8; 24],
- }
-
- 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 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_canonname: *mut c_char,
- pub ai_addr: *mut ::sockaddr,
- pub ai_next: *mut addrinfo,
- }
-
- pub struct fd_set {
- fds_bits: [c_ulong; FD_SETSIZE / ULONG_SIZE],
- }
-
- 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 tm_gmtoff: ::c_long,
- pub tm_zone: *const ::c_char,
- }
-
- pub struct utsname {
- pub sysname: [::c_char; 32],
- pub nodename: [::c_char; 32],
- pub release: [::c_char; 32],
- pub version: [::c_char; 32],
- pub machine: [::c_char; 32],
- }
-
- 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 msghdr {
- pub msg_name: *mut ::c_void,
- pub msg_namelen: ::socklen_t,
- pub msg_iov: *mut ::iovec,
- pub msg_iovlen: ::c_int,
- pub msg_control: *mut ::c_void,
- pub msg_controllen: ::socklen_t,
- pub msg_flags: ::c_int,
- }
-
- pub struct cmsghdr {
- pub cmsg_len: ::size_t,
- pub cmsg_level: ::c_int,
- pub cmsg_type: ::c_int,
- }
-
- pub struct Dl_info {
- pub dli_fname: *const ::c_char,
- pub dli_fbase: *mut ::c_void,
- pub dli_sname: *const ::c_char,
- pub dli_saddr: *mut ::c_void,
- }
-
- pub struct termios {
- pub c_iflag: ::tcflag_t,
- pub c_oflag: ::tcflag_t,
- pub c_cflag: ::tcflag_t,
- pub c_lflag: ::tcflag_t,
- pub c_line: ::c_char,
- pub c_ispeed: ::speed_t,
- pub c_ospeed: ::speed_t,
- pub c_cc: [::cc_t; ::NCCS],
- }
-
- pub struct flock {
- pub l_type: ::c_short,
- pub l_whence: ::c_short,
- pub l_start: ::off_t,
- pub l_len: ::off_t,
- pub l_pid: ::pid_t,
- }
-
- pub struct 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_size: off_t,
- pub st_rdev: dev_t,
- pub st_blksize: blksize_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_crtime: time_t,
- pub st_crtime_nsec: c_long,
- pub st_type: u32,
- pub st_blocks: blkcnt_t,
- }
-
- pub struct glob_t {
- pub gl_pathc: ::size_t,
- __unused1: ::size_t,
- pub gl_offs: ::size_t,
- __unused2: ::size_t,
- pub gl_pathv: *mut *mut c_char,
-
- __unused3: *mut ::c_void,
- __unused4: *mut ::c_void,
- __unused5: *mut ::c_void,
- __unused6: *mut ::c_void,
- __unused7: *mut ::c_void,
- __unused8: *mut ::c_void,
- }
-
- pub struct pthread_mutex_t {
- flags: u32,
- lock: i32,
- unused: i32,
- owner: i32,
- owner_count: i32,
- }
-
- pub struct pthread_cond_t {
- flags: u32,
- unused: i32,
- mutex: *mut ::c_void,
- waiter_count: i32,
- lock: i32,
- }
-
- pub struct pthread_rwlock_t {
- flags: u32,
- owner: i32,
- lock_sem: i32, // this is actually a union
- lock_count: i32,
- reader_count: i32,
- writer_count: i32,
- waiters: [*mut ::c_void; 2],
- }
-
- pub struct passwd {
- pub pw_name: *mut ::c_char,
- pub pw_passwd: *mut ::c_char,
- pub pw_uid: ::uid_t,
- pub pw_gid: ::gid_t,
- pub pw_dir: *mut ::c_char,
- pub pw_shell: *mut ::c_char,
- pub pw_gecos: *mut ::c_char,
- }
-
- 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,
- }
-
- pub struct stack_t {
- pub ss_sp: *mut ::c_void,
- pub ss_size: ::size_t,
- pub ss_flags: ::c_int,
- }
-
- pub struct siginfo_t {
- pub si_signo: ::c_int,
- pub si_code: ::c_int,
- pub si_errno: ::c_int,
- pub si_pid: ::pid_t,
- pub si_uid: ::uid_t,
- pub si_addr: *mut ::c_void,
- pub si_status: ::c_int,
- pub si_band: c_long,
- pub sigval: *mut ::c_void,
- }
-
- pub struct sigaction {
- pub sa_sigaction: ::sighandler_t,
- pub sa_mask: ::sigset_t,
- pub sa_flags: ::c_int,
- sa_userdata: *mut ::c_void,
- }
-
- pub struct sigevent {
- pub sigev_notify: ::c_int,
- pub sigev_signo: ::c_int,
- pub sigev_value: ::sigval,
- __unused1: *mut ::c_void, // actually a function pointer
- pub sigev_notify_attributes: *mut ::pthread_attr_t,
- }
-
- pub struct sem_t {
- pub se_type: i32,
- pub se_named_id: i32, // this is actually a union
- pub se_unnamed: i32,
- pub se_padding: [i32; 4],
- }
-
- pub struct pthread_condattr_t {
- pub process_shared: bool,
- pub clock_id: i32,
- }
-}
-
-s_no_extra_traits! {
- pub struct sockaddr_un {
- pub sun_len: u8,
- pub sun_family: sa_family_t,
- pub sun_path: [::c_char; 126]
- }
- pub struct sockaddr_storage {
- pub ss_len: u8,
- pub ss_family: sa_family_t,
- __ss_pad1: [u8; 6],
- __ss_pad2: u64,
- __ss_pad3: [u8; 112],
- }
- pub struct dirent {
- pub d_dev: dev_t,
- pub d_pdev: dev_t,
- pub d_ino: ino_t,
- pub d_pino: i64,
- pub d_reclen: ::c_ushort,
- pub d_name: [::c_char; 1024], // Max length is _POSIX_PATH_MAX
- }
-}
-
-cfg_if! {
- if #[cfg(feature = "extra_traits")] {
- impl PartialEq for sockaddr_un {
- fn eq(&self, other: &sockaddr_un) -> bool {
- self.sun_len == other.sun_len
- && self.sun_family == other.sun_family
- && self
- .sun_path
- .iter()
- .zip(other.sun_path.iter())
- .all(|(a,b)| a == b)
- }
- }
- impl Eq for sockaddr_un {}
- impl ::fmt::Debug for sockaddr_un {
- fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
- f.debug_struct("sockaddr_un")
- .field("sun_len", &self.sun_len)
- .field("sun_family", &self.sun_family)
- // FIXME: .field("sun_path", &self.sun_path)
- .finish()
- }
- }
- impl ::hash::Hash for sockaddr_un {
- fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
- self.sun_len.hash(state);
- self.sun_family.hash(state);
- self.sun_path.hash(state);
- }
- }
-
- impl PartialEq for sockaddr_storage {
- fn eq(&self, other: &sockaddr_storage) -> bool {
- self.ss_len == other.ss_len
- && self.ss_family == other.ss_family
- && self
- .__ss_pad1
- .iter()
- .zip(other.__ss_pad1.iter())
- .all(|(a, b)| a == b)
- && self.__ss_pad2 == other.__ss_pad2
- && self
- .__ss_pad3
- .iter()
- .zip(other.__ss_pad3.iter())
- .all(|(a, b)| a == b)
- }
- }
- impl Eq for sockaddr_storage {}
- impl ::fmt::Debug for sockaddr_storage {
- fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
- f.debug_struct("sockaddr_storage")
- .field("ss_len", &self.ss_len)
- .field("ss_family", &self.ss_family)
- .field("__ss_pad1", &self.__ss_pad1)
- .field("__ss_pad2", &self.__ss_pad2)
- // FIXME: .field("__ss_pad3", &self.__ss_pad3)
- .finish()
- }
- }
- impl ::hash::Hash for sockaddr_storage {
- fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
- self.ss_len.hash(state);
- self.ss_family.hash(state);
- self.__ss_pad1.hash(state);
- self.__ss_pad2.hash(state);
- self.__ss_pad3.hash(state);
- }
- }
-
- impl PartialEq for dirent {
- fn eq(&self, other: &dirent) -> bool {
- self.d_dev == other.d_dev
- && self.d_pdev == other.d_pdev
- && self.d_ino == other.d_ino
- && self.d_pino == other.d_pino
- && self.d_reclen == other.d_reclen
- && self
- .d_name
- .iter()
- .zip(other.d_name.iter())
- .all(|(a,b)| a == b)
- }
- }
- impl Eq for dirent {}
- impl ::fmt::Debug for dirent {
- fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
- f.debug_struct("dirent")
- .field("d_dev", &self.d_dev)
- .field("d_pdev", &self.d_pdev)
- .field("d_ino", &self.d_ino)
- .field("d_pino", &self.d_pino)
- .field("d_reclen", &self.d_reclen)
- // FIXME: .field("d_name", &self.d_name)
- .finish()
- }
- }
- impl ::hash::Hash for dirent {
- fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
- self.d_dev.hash(state);
- self.d_pdev.hash(state);
- self.d_ino.hash(state);
- self.d_pino.hash(state);
- self.d_reclen.hash(state);
- self.d_name.hash(state);
- }
- }
- }
-}
-
-// intentionally not public, only used for fd_set
-cfg_if! {
- if #[cfg(target_pointer_width = "32")] {
- const ULONG_SIZE: usize = 32;
- } else if #[cfg(target_pointer_width = "64")] {
- const ULONG_SIZE: usize = 64;
- } else {
- // Unknown target_pointer_width
- }
-}
-
-pub const EXIT_FAILURE: ::c_int = 1;
-pub const EXIT_SUCCESS: ::c_int = 0;
-pub const RAND_MAX: ::c_int = 2147483647;
-pub const EOF: ::c_int = -1;
-pub const SEEK_SET: ::c_int = 0;
-pub const SEEK_CUR: ::c_int = 1;
-pub const SEEK_END: ::c_int = 2;
-pub const _IOFBF: ::c_int = 0;
-pub const _IONBF: ::c_int = 2;
-pub const _IOLBF: ::c_int = 1;
-
-pub const F_DUPFD: ::c_int = 0x0001;
-pub const F_GETFD: ::c_int = 0x0002;
-pub const F_SETFD: ::c_int = 0x0004;
-pub const F_GETFL: ::c_int = 0x0008;
-pub const F_SETFL: ::c_int = 0x0010;
-pub const F_GETLK: ::c_int = 0x0020;
-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;
-pub const AT_REMOVEDIR: ::c_int = 0x04;
-pub const AT_EACCESS: ::c_int = 0x08;
-
-pub const POLLIN: ::c_short = 0x0001;
-pub const POLLOUT: ::c_short = 0x0002;
-pub const POLLRDNORM: ::c_short = POLLIN;
-pub const POLLWRNORM: ::c_short = POLLOUT;
-pub const POLLRDBAND: ::c_short = 0x0008;
-pub const POLLWRBAND: ::c_short = 0x0010;
-pub const POLLPRI: ::c_short = 0x0020;
-pub const POLLERR: ::c_short = 0x0004;
-pub const POLLHUP: ::c_short = 0x0080;
-pub const POLLNVAL: ::c_short = 0x1000;
-
-pub const PTHREAD_CREATE_JOINABLE: ::c_int = 0;
-pub const PTHREAD_CREATE_DETACHED: ::c_int = 1;
-
-pub const CLOCK_REALTIME: ::c_int = -1;
-pub const CLOCK_MONOTONIC: ::c_int = 0;
-
-pub const RLIMIT_CORE: ::c_int = 0;
-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;
-pub const RLIMIT_NLIMITS: ::c_int = 8;
-
-pub const RUSAGE_SELF: ::c_int = 0;
-
-pub const RTLD_LAZY: ::c_int = 0;
-
-pub const NCCS: usize = 11;
-
-pub const O_RDONLY: ::c_int = 0x0000;
-pub const O_WRONLY: ::c_int = 0x0001;
-pub const O_RDWR: ::c_int = 0x0002;
-pub const O_ACCMODE: ::c_int = 0x0003;
-
-pub const O_EXCL: ::c_int = 0x0100;
-pub const O_CREAT: ::c_int = 0x0200;
-pub const O_TRUNC: ::c_int = 0x0400;
-pub const O_NOCTTY: ::c_int = 0x1000;
-pub const O_NOTRAVERSE: ::c_int = 0x2000;
-
-pub const O_CLOEXEC: ::c_int = 0x00000040;
-pub const O_NONBLOCK: ::c_int = 0x00000080;
-pub const O_APPEND: ::c_int = 0x00000800;
-pub const O_SYNC: ::c_int = 0x00010000;
-pub const O_RSYNC: ::c_int = 0x00020000;
-pub const O_DSYNC: ::c_int = 0x00040000;
-pub const O_NOFOLLOW: ::c_int = 0x00080000;
-pub const O_NOCACHE: ::c_int = 0x00100000;
-pub const O_DIRECTORY: ::c_int = 0x00200000;
-
-pub const S_IFIFO: ::mode_t = 61440;
-pub const S_IFCHR: ::mode_t = 49152;
-pub const S_IFBLK: ::mode_t = 24576;
-pub const S_IFDIR: ::mode_t = 16384;
-pub const S_IFREG: ::mode_t = 32768;
-pub const S_IFLNK: ::mode_t = 40960;
-pub const S_IFSOCK: ::mode_t = 49152;
-pub const S_IFMT: ::mode_t = 61440;
-pub const S_IRWXU: ::mode_t = 448;
-pub const S_IXUSR: ::mode_t = 64;
-pub const S_IWUSR: ::mode_t = 128;
-pub const S_IRUSR: ::mode_t = 256;
-pub const S_IRWXG: ::mode_t = 70;
-pub const S_IXGRP: ::mode_t = 10;
-pub const S_IWGRP: ::mode_t = 20;
-pub const S_IRGRP: ::mode_t = 40;
-pub const S_IRWXO: ::mode_t = 7;
-pub const S_IXOTH: ::mode_t = 1;
-pub const S_IWOTH: ::mode_t = 2;
-pub const S_IROTH: ::mode_t = 4;
-pub const F_OK: ::c_int = 0;
-pub const R_OK: ::c_int = 4;
-pub const W_OK: ::c_int = 2;
-pub const X_OK: ::c_int = 1;
-pub const STDIN_FILENO: ::c_int = 0;
-pub const STDOUT_FILENO: ::c_int = 1;
-pub const STDERR_FILENO: ::c_int = 2;
-
-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 SIGCHLD: ::c_int = 5;
-pub const SIGABRT: ::c_int = 6;
-pub const SIGPIPE: ::c_int = 7;
-pub const SIGFPE: ::c_int = 8;
-pub const SIGKILL: ::c_int = 9;
-pub const SIGSTOP: ::c_int = 10;
-pub const SIGSEGV: ::c_int = 11;
-pub const SIGCONT: ::c_int = 12;
-pub const SIGTSTP: ::c_int = 13;
-pub const SIGALRM: ::c_int = 14;
-pub const SIGTERM: ::c_int = 15;
-pub const SIGTTIN: ::c_int = 16;
-pub const SIGTTOU: ::c_int = 17;
-pub const SIGUSR1: ::c_int = 18;
-pub const SIGUSR2: ::c_int = 19;
-pub const SIGWINCH: ::c_int = 20;
-pub const SIGKILLTHR: ::c_int = 21;
-pub const SIGTRAP: ::c_int = 22;
-pub const SIGPOLL: ::c_int = 23;
-pub const SIGPROF: ::c_int = 24;
-pub const SIGSYS: ::c_int = 25;
-pub const SIGURG: ::c_int = 26;
-pub const SIGVTALRM: ::c_int = 27;
-pub const SIGXCPU: ::c_int = 28;
-pub const SIGXFSZ: ::c_int = 29;
-pub const SIGBUS: ::c_int = 30;
-
-pub const SIG_BLOCK: ::c_int = 1;
-pub const SIG_UNBLOCK: ::c_int = 2;
-pub const SIG_SETMASK: ::c_int = 3;
-
-pub const SIGEV_NONE: ::c_int = 0;
-pub const SIGEV_SIGNAL: ::c_int = 1;
-pub const SIGEV_THREAD: ::c_int = 2;
-
-pub const EAI_AGAIN: ::c_int = 2;
-pub const EAI_BADFLAGS: ::c_int = 3;
-pub const EAI_FAIL: ::c_int = 4;
-pub const EAI_FAMILY: ::c_int = 5;
-pub const EAI_MEMORY: ::c_int = 6;
-pub const EAI_NODATA: ::c_int = 7;
-pub const EAI_NONAME: ::c_int = 8;
-pub const EAI_SERVICE: ::c_int = 9;
-pub const EAI_SOCKTYPE: ::c_int = 10;
-pub const EAI_SYSTEM: ::c_int = 11;
-pub const EAI_OVERFLOW: ::c_int = 14;
-
-pub const PROT_NONE: ::c_int = 0;
-pub const PROT_READ: ::c_int = 1;
-pub const PROT_WRITE: ::c_int = 2;
-pub const PROT_EXEC: ::c_int = 4;
-
-pub const LC_ALL: ::c_int = 0;
-pub const LC_COLLATE: ::c_int = 1;
-pub const LC_CTYPE: ::c_int = 2;
-pub const LC_MONETARY: ::c_int = 3;
-pub const LC_NUMERIC: ::c_int = 4;
-pub const LC_TIME: ::c_int = 5;
-pub const LC_MESSAGES: ::c_int = 6;
-
-// TODO: Haiku does not have MAP_FILE, but libstd/os.rs requires it
-pub const MAP_FILE: ::c_int = 0x00;
-pub const MAP_SHARED: ::c_int = 0x01;
-pub const MAP_PRIVATE: ::c_int = 0x02;
-pub const MAP_FIXED: ::c_int = 0x04;
-pub const MAP_ANONYMOUS: ::c_int = 0x08;
-pub const MAP_ANON: ::c_int = MAP_ANONYMOUS;
-
-pub const MAP_FAILED: *mut ::c_void = !0 as *mut ::c_void;
-
-pub const MS_ASYNC: ::c_int = 0x01;
-pub const MS_INVALIDATE: ::c_int = 0x04;
-pub const MS_SYNC: ::c_int = 0x02;
-
-pub const E2BIG : ::c_int = -2147454975;
-pub const ECHILD : ::c_int = -2147454974;
-pub const EDEADLK : ::c_int = -2147454973;
-pub const EFBIG : ::c_int = -2147454972;
-pub const EMLINK : ::c_int = -2147454971;
-pub const ENFILE : ::c_int = -2147454970;
-pub const ENODEV : ::c_int = -2147454969;
-pub const ENOLCK : ::c_int = -2147454968;
-pub const ENOSYS : ::c_int = -2147454967;
-pub const ENOTTY : ::c_int = -2147454966;
-pub const ENXIO : ::c_int = -2147454965;
-pub const ESPIPE : ::c_int = -2147454964;
-pub const ESRCH : ::c_int = -2147454963;
-pub const EFPOS : ::c_int = -2147457962;
-pub const ESIGPARM : ::c_int = -2147457961;
-pub const EDOM : ::c_int = -2147454960;
-pub const ERANGE : ::c_int = -2147454959;
-pub const EPROTOTYPE : ::c_int = -2147454958;
-pub const EPROTONOSUPPORT : ::c_int = -2147454957;
-pub const EPFNOSUPPORT : ::c_int = -2147454956;
-pub const EAFNOSUPPORT : ::c_int = -2147454955;
-pub const EADDRINUSE : ::c_int = -2147454954;
-pub const EADDRNOTAVAIL : ::c_int = -2147454953;
-pub const ENETDOWN : ::c_int = -2147454952;
-pub const ENETUNREACH : ::c_int = -2147454951;
-pub const ENETRESET : ::c_int = -2147454950;
-pub const ECONNABORTED : ::c_int = -2147454949;
-pub const ECONNRESET : ::c_int = -2147454948;
-pub const EISCONN : ::c_int = -2147454947;
-pub const ENOTCONN : ::c_int = -2147454946;
-pub const ESHUTDOWN : ::c_int = -2147454945;
-pub const ECONNREFUSED : ::c_int = -2147454944;
-pub const EHOSTUNREACH : ::c_int = -2147454943;
-pub const ENOPROTOOPT : ::c_int = -2147454942;
-pub const ENOBUFS : ::c_int = -2147454941;
-pub const EINPROGRESS : ::c_int = -2147454940;
-pub const EALREADY : ::c_int = -2147454939;
-pub const EILSEQ : ::c_int = -2147454938;
-pub const ENOMSG : ::c_int = -2147454937;
-pub const ESTALE : ::c_int = -2147454936;
-pub const EOVERFLOW : ::c_int = -2147454935;
-pub const EMSGSIZE : ::c_int = -2147454934;
-pub const EOPNOTSUPP : ::c_int = -2147454933;
-pub const ENOTSOCK : ::c_int = -2147454932;
-pub const EHOSTDOWN : ::c_int = -2147454931;
-pub const EBADMSG : ::c_int = -2147454930;
-pub const ECANCELED : ::c_int = -2147454929;
-pub const EDESTADDRREQ : ::c_int = -2147454928;
-pub const EDQUOT : ::c_int = -2147454927;
-pub const EIDRM : ::c_int = -2147454926;
-pub const EMULTIHOP : ::c_int = -2147454925;
-pub const ENODATA : ::c_int = -2147454924;
-pub const ENOLINK : ::c_int = -2147454923;
-pub const ENOSR : ::c_int = -2147454922;
-pub const ENOSTR : ::c_int = -2147454921;
-pub const ENOTSUP : ::c_int = -2147454920;
-pub const EPROTO : ::c_int = -2147454919;
-pub const ETIME : ::c_int = -2147454918;
-pub const ETXTBSY : ::c_int = -2147454917;
-pub const ENOATTR : ::c_int = -2147454916;
-
-// INT_MIN
-pub const ENOMEM : ::c_int = -2147454976;
-
-// POSIX errors that can be mapped to BeOS error codes
-pub const EACCES : ::c_int = -2147483646;
-pub const EINTR : ::c_int = -2147483638;
-pub const EIO : ::c_int = -2147483647;
-pub const EBUSY : ::c_int = -2147483634;
-pub const EFAULT : ::c_int = -2147478783;
-pub const ETIMEDOUT : ::c_int = -2147483639;
-pub const EAGAIN : ::c_int = -2147483637;
-pub const EWOULDBLOCK : ::c_int = -2147483637;
-pub const EBADF : ::c_int = -2147459072;
-pub const EEXIST : ::c_int = -2147459070;
-pub const EINVAL : ::c_int = -2147483643;
-pub const ENAMETOOLONG : ::c_int = -2147459068;
-pub const ENOENT : ::c_int = -2147459069;
-pub const EPERM : ::c_int = -2147483633;
-pub const ENOTDIR : ::c_int = -2147459067;
-pub const EISDIR : ::c_int = -2147459063;
-pub const ENOTEMPTY : ::c_int = -2147459066;
-pub const ENOSPC : ::c_int = -2147459065;
-pub const EROFS : ::c_int = -2147459064;
-pub const EMFILE : ::c_int = -2147459062;
-pub const EXDEV : ::c_int = -2147459061;
-pub const ELOOP : ::c_int = -2147459060;
-pub const ENOEXEC : ::c_int = -2147478782;
-pub const EPIPE : ::c_int = -2147459059;
-
-pub const IPPROTO_RAW: ::c_int = 255;
-
-// These are prefixed with POSIX_ on Haiku
-pub const MADV_NORMAL: ::c_int = 1;
-pub const MADV_SEQUENTIAL: ::c_int = 2;
-pub const MADV_RANDOM: ::c_int = 3;
-pub const MADV_WILLNEED: ::c_int = 4;
-pub const MADV_DONTNEED: ::c_int = 5;
-
-// https://github.com/haiku/haiku/blob/master/headers/posix/net/if.h#L80
-pub const IFF_UP: ::c_int = 0x0001;
-pub const IFF_BROADCAST: ::c_int = 0x0002; // valid broadcast address
-pub const IFF_LOOPBACK: ::c_int = 0x0008;
-pub const IFF_POINTOPOINT: ::c_int = 0x0010; // point-to-point link
-pub const IFF_NOARP: ::c_int = 0x0040; // no address resolution
-pub const IFF_AUTOUP: ::c_int = 0x0080; // auto dial
-pub const IFF_PROMISC: ::c_int = 0x0100; // receive all packets
-pub const IFF_ALLMULTI: ::c_int = 0x0200; // receive all multicast packets
-pub const IFF_SIMPLEX: ::c_int = 0x0800; // doesn't receive own transmissions
-pub const IFF_LINK: ::c_int = 0x1000; // has link
-pub const IFF_AUTO_CONFIGURED: ::c_int = 0x2000;
-pub const IFF_CONFIGURING: ::c_int = 0x4000;
-pub const IFF_MULTICAST: ::c_int = 0x8000; // supports multicast
-
-pub const AF_UNSEC: ::c_int = 0;
-pub const AF_INET: ::c_int = 1;
-pub const AF_APPLETALK: ::c_int = 2;
-pub const AF_ROUTE: ::c_int = 3;
-pub const AF_LINK: ::c_int = 4;
-pub const AF_INET6: ::c_int = 5;
-pub const AF_DLI: ::c_int = 6;
-pub const AF_IPX: ::c_int = 7;
-pub const AF_NOTIFY: ::c_int = 8;
-pub const AF_LOCAL: ::c_int = 9;
-pub const AF_UNIX: ::c_int = AF_LOCAL;
-pub const AF_BLUETOOTH: ::c_int = 10;
-#[doc(hidden)]
-#[deprecated(
- since = "0.2.55",
- note = "If you are using this report to: \
- https://github.com/rust-lang/libc/issues/665"
-)]
-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_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;
-pub const MSG_DONTROUTE: ::c_int = 0x0004;
-pub const MSG_EOR: ::c_int = 0x0008;
-pub const MSG_TRUNC: ::c_int = 0x0010;
-pub const MSG_CTRUNC: ::c_int = 0x0020;
-pub const MSG_WAITALL: ::c_int = 0x0040;
-pub const MSG_DONTWAIT: ::c_int = 0x0080;
-pub const MSG_BCAST: ::c_int = 0x0100;
-pub const MSG_MCAST: ::c_int = 0x0200;
-pub const MSG_EOF: ::c_int = 0x0400;
-pub const MSG_NOSIGNAL: ::c_int = 0x0800;
-
-pub const SHUT_RD: ::c_int = 0;
-pub const SHUT_WR: ::c_int = 1;
-pub const SHUT_RDWR: ::c_int = 2;
-
-pub const LOCK_SH: ::c_int = 0x01;
-pub const LOCK_EX: ::c_int = 0x02;
-pub const LOCK_NB: ::c_int = 0x04;
-pub const LOCK_UN: ::c_int = 0x08;
-
-pub const SIGSTKSZ: ::size_t = 16384;
-
-pub const PATH_MAX: ::c_int = 1024;
-
-pub const SA_NOCLDSTOP: ::c_int = 0x01;
-pub const SA_NOCLDWAIT: ::c_int = 0x02;
-pub const SA_RESETHAND: ::c_int = 0x04;
-pub const SA_NODEFER: ::c_int = 0x08;
-pub const SA_RESTART: ::c_int = 0x10;
-pub const SA_ONSTACK: ::c_int = 0x20;
-pub const SA_SIGINFO: ::c_int = 0x40;
-pub const SA_NOMASK: ::c_int = SA_NODEFER;
-pub const SA_STACK: ::c_int = SA_ONSTACK;
-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;
-pub const FILENAME_MAX: ::c_uint = 256;
-pub const FOPEN_MAX: ::c_uint = 128;
-pub const L_tmpnam: ::c_uint = 512;
-pub const TMP_MAX: ::c_uint = 32768;
-
-pub const _PC_CHOWN_RESTRICTED: ::c_int = 1;
-pub const _PC_MAX_CANON: ::c_int = 2;
-pub const _PC_MAX_INPUT: ::c_int = 3;
-pub const _PC_NAME_MAX: ::c_int = 4;
-pub const _PC_NO_TRUNC: ::c_int = 5;
-pub const _PC_PATH_MAX: ::c_int = 6;
-pub const _PC_PIPE_BUF: ::c_int = 7;
-pub const _PC_VDISABLE: ::c_int = 8;
-pub const _PC_LINK_MAX: ::c_int = 25;
-pub const _PC_SYNC_IO: ::c_int = 26;
-pub const _PC_ASYNC_IO: ::c_int = 27;
-pub const _PC_PRIO_IO: ::c_int = 28;
-pub const _PC_SOCK_MAXBUF: ::c_int = 29;
-pub const _PC_FILESIZEBITS: ::c_int = 30;
-pub const _PC_REC_INCR_XFER_SIZE: ::c_int = 31;
-pub const _PC_REC_MAX_XFER_SIZE: ::c_int = 32;
-pub const _PC_REC_MIN_XFER_SIZE: ::c_int = 33;
-pub const _PC_REC_XFER_ALIGN: ::c_int = 34;
-pub const _PC_ALLOC_SIZE_MIN: ::c_int = 35;
-pub const _PC_SYMLINK_MAX: ::c_int = 36;
-pub const _PC_2_SYMLINKS: ::c_int = 37;
-pub const _PC_XATTR_EXISTS: ::c_int = 38;
-pub const _PC_XATTR_ENABLED: ::c_int = 39;
-
-pub const FIONBIO: ::c_int = 0xbe000000;
-
-pub const _SC_ARG_MAX : ::c_int = 15;
-pub const _SC_CHILD_MAX : ::c_int = 16;
-pub const _SC_CLK_TCK : ::c_int = 17;
-pub const _SC_JOB_CONTROL : ::c_int = 18;
-pub const _SC_NGROUPS_MAX : ::c_int = 19;
-pub const _SC_OPEN_MAX : ::c_int = 20;
-pub const _SC_SAVED_IDS : ::c_int = 21;
-pub const _SC_STREAM_MAX : ::c_int = 22;
-pub const _SC_TZNAME_MAX : ::c_int = 23;
-pub const _SC_VERSION : ::c_int = 24;
-pub const _SC_GETGR_R_SIZE_MAX : ::c_int = 25;
-pub const _SC_GETPW_R_SIZE_MAX : ::c_int = 26;
-pub const _SC_PAGESIZE : ::c_int = 27;
-pub const _SC_PAGE_SIZE : ::c_int = 27;
-pub const _SC_SEM_NSEMS_MAX : ::c_int = 28;
-pub const _SC_SEM_VALUE_MAX : ::c_int = 29;
-pub const _SC_SEMAPHORES : ::c_int = 30;
-pub const _SC_THREADS : ::c_int = 31;
-pub const _SC_IOV_MAX : ::c_int = 32;
-pub const _SC_UIO_MAXIOV : ::c_int = 32;
-pub const _SC_NPROCESSORS_CONF : ::c_int = 34;
-pub const _SC_NPROCESSORS_ONLN : ::c_int = 35;
-pub const _SC_ATEXIT_MAX : ::c_int = 37;
-pub const _SC_PASS_MAX : ::c_int = 39;
-pub const _SC_PHYS_PAGES : ::c_int = 40;
-pub const _SC_AVPHYS_PAGES : ::c_int = 41;
-pub const _SC_PIPE : ::c_int = 42;
-pub const _SC_SELECT : ::c_int = 43;
-pub const _SC_POLL : ::c_int = 44;
-pub const _SC_MAPPED_FILES : ::c_int = 45;
-pub const _SC_THREAD_PROCESS_SHARED : ::c_int = 46;
-pub const _SC_THREAD_STACK_MIN : ::c_int = 47;
-pub const _SC_THREAD_ATTR_STACKADDR : ::c_int = 48;
-pub const _SC_THREAD_ATTR_STACKSIZE : ::c_int = 49;
-pub const _SC_THREAD_PRIORITY_SCHEDULING : ::c_int = 50;
-pub const _SC_REALTIME_SIGNALS : ::c_int = 51;
-pub const _SC_MEMORY_PROTECTION : ::c_int = 52;
-pub const _SC_SIGQUEUE_MAX : ::c_int = 53;
-pub const _SC_RTSIG_MAX : ::c_int = 54;
-pub const _SC_MONOTONIC_CLOCK : ::c_int = 55;
-pub const _SC_DELAYTIMER_MAX : ::c_int = 56;
-pub const _SC_TIMER_MAX : ::c_int = 57;
-pub const _SC_TIMERS : ::c_int = 58;
-pub const _SC_CPUTIME : ::c_int = 59;
-pub const _SC_THREAD_CPUTIME : ::c_int = 60;
-
-pub const PTHREAD_STACK_MIN: ::size_t = 8192;
-
-pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t {
- flags: 0,
- lock: 0,
- unused: -42,
- owner: -1,
- owner_count: 0,
-};
-pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = pthread_cond_t {
- flags: 0,
- unused: -42,
- mutex: 0 as *mut _,
- waiter_count: 0,
- lock: 0,
-};
-pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = pthread_rwlock_t {
- flags: 0,
- owner: -1,
- lock_sem: 0,
- lock_count: 0,
- reader_count: 0,
- writer_count: 0,
- waiters: [0 as *mut _; 2],
-};
-
-pub const PTHREAD_MUTEX_DEFAULT: ::c_int = 0;
-pub const PTHREAD_MUTEX_NORMAL: ::c_int = 1;
-pub const PTHREAD_MUTEX_ERRORCHECK: ::c_int = 2;
-pub const PTHREAD_MUTEX_RECURSIVE: ::c_int = 3;
-
-pub const FIOCLEX: c_ulong = 0; // TODO: does not exist on Haiku!
-
-pub const RUSAGE_CHILDREN: ::c_int = -1;
-
-pub const SOCK_STREAM: ::c_int = 1;
-pub const SOCK_DGRAM: ::c_int = 2;
-pub const SOCK_RAW: ::c_int = 3;
-pub const SOCK_SEQPACKET: ::c_int = 5;
-
-pub const SOL_SOCKET: ::c_int = -1;
-pub const SO_ACCEPTCONN: ::c_int = 0x00000001;
-pub const SO_BROADCAST: ::c_int = 0x00000002;
-pub const SO_DEBUG: ::c_int = 0x00000004;
-pub const SO_DONTROUTE: ::c_int = 0x00000008;
-pub const SO_KEEPALIVE: ::c_int = 0x00000010;
-pub const SO_OOBINLINE: ::c_int = 0x00000020;
-pub const SO_REUSEADDR: ::c_int = 0x00000040;
-pub const SO_REUSEPORT: ::c_int = 0x00000080;
-pub const SO_USELOOPBACK: ::c_int = 0x00000100;
-pub const SO_LINGER: ::c_int = 0x00000200;
-pub const SO_SNDBUF: ::c_int = 0x40000001;
-pub const SO_SNDLOWAT: ::c_int = 0x40000002;
-pub const SO_SNDTIMEO: ::c_int = 0x40000003;
-pub const SO_RCVBUF: ::c_int = 0x40000004;
-pub const SO_RCVLOWAT: ::c_int = 0x40000005;
-pub const SO_RCVTIMEO: ::c_int = 0x40000006;
-pub const SO_ERROR: ::c_int = 0x40000007;
-pub const SO_TYPE: ::c_int = 0x40000008;
-pub const SO_NONBLOCK: ::c_int = 0x40000009;
-pub const SO_BINDTODEVICE: ::c_int = 0x4000000a;
-pub const SO_PEERCRED: ::c_int = 0x4000000b;
-
-pub const SCM_RIGHTS: ::c_int = 0x01;
-
-pub const NI_MAXHOST: ::size_t = 1025;
-
-pub const WNOHANG: ::c_int = 0x01;
-pub const WUNTRACED: ::c_int = 0x02;
-pub const WCONTINUED: ::c_int = 0x04;
-pub const WEXITED: ::c_int = 0x08;
-pub const WSTOPPED: ::c_int = 0x10;
-pub const WNOWAIT: ::c_int = 0x20;
-
-pub const P_ALL: idtype_t = 0;
-pub const P_PID: idtype_t = 1;
-pub const P_PGID: idtype_t = 2;
-
-pub const VINTR: usize = 0;
-pub const VQUIT: usize = 1;
-pub const VERASE: usize = 2;
-pub const VKILL: usize = 3;
-pub const VEOF: usize = 4;
-pub const VEOL: usize = 5;
-pub const VMIN: usize = 4;
-pub const VTIME: usize = 5;
-pub const VEOL2: usize = 6;
-pub const VSWTCH: usize = 7;
-pub const VSTART: usize = 8;
-pub const VSTOP: usize = 9;
-pub const VSUSP: usize = 10;
-
-pub const IGNBRK: ::tcflag_t = 0x01;
-pub const BRKINT: ::tcflag_t = 0x02;
-pub const IGNPAR: ::tcflag_t = 0x04;
-pub const PARMRK: ::tcflag_t = 0x08;
-pub const INPCK: ::tcflag_t = 0x10;
-pub const ISTRIP: ::tcflag_t = 0x20;
-pub const INLCR: ::tcflag_t = 0x40;
-pub const IGNCR: ::tcflag_t = 0x80;
-pub const ICRNL: ::tcflag_t = 0x100;
-pub const IUCLC: ::tcflag_t = 0x200;
-pub const IXON: ::tcflag_t = 0x400;
-pub const IXANY: ::tcflag_t = 0x800;
-pub const IXOFF: ::tcflag_t = 0x1000;
-
-pub const OPOST: ::tcflag_t = 0x00000001;
-pub const OLCUC: ::tcflag_t = 0x00000002;
-pub const ONLCR: ::tcflag_t = 0x00000004;
-pub const OCRNL: ::tcflag_t = 0x00000008;
-pub const ONOCR: ::tcflag_t = 0x00000010;
-pub const ONLRET: ::tcflag_t = 0x00000020;
-pub const OFILL: ::tcflag_t = 0x00000040;
-pub const OFDEL: ::tcflag_t = 0x00000080;
-pub const NLDLY: ::tcflag_t = 0x00000100;
-pub const NL0: ::tcflag_t = 0x00000000;
-pub const NL1: ::tcflag_t = 0x00000100;
-pub const CRDLY: ::tcflag_t = 0x00000600;
-pub const CR0: ::tcflag_t = 0x00000000;
-pub const CR1: ::tcflag_t = 0x00000200;
-pub const CR2: ::tcflag_t = 0x00000400;
-pub const CR3: ::tcflag_t = 0x00000600;
-pub const TABDLY: ::tcflag_t = 0x00001800;
-pub const TAB0: ::tcflag_t = 0x00000000;
-pub const TAB1: ::tcflag_t = 0x00000800;
-pub const TAB2: ::tcflag_t = 0x00001000;
-pub const TAB3: ::tcflag_t = 0x00001800;
-pub const BSDLY: ::tcflag_t = 0x00002000;
-pub const BS0: ::tcflag_t = 0x00000000;
-pub const BS1: ::tcflag_t = 0x00002000;
-pub const VTDLY: ::tcflag_t = 0x00004000;
-pub const VT0: ::tcflag_t = 0x00000000;
-pub const VT1: ::tcflag_t = 0x00004000;
-pub const FFDLY: ::tcflag_t = 0x00008000;
-pub const FF0: ::tcflag_t = 0x00000000;
-pub const FF1: ::tcflag_t = 0x00008000;
-
-pub const CSIZE: ::tcflag_t = 0x00000020;
-pub const CS5: ::tcflag_t = 0x00000000;
-pub const CS6: ::tcflag_t = 0x00000000;
-pub const CS7: ::tcflag_t = 0x00000000;
-pub const CS8: ::tcflag_t = 0x00000020;
-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 XLOBLK: ::tcflag_t = 0x00001000;
-pub const CTSFLOW: ::tcflag_t = 0x00002000;
-pub const RTSFLOW: ::tcflag_t = 0x00004000;
-pub const CRTSCTS: ::tcflag_t = RTSFLOW | CTSFLOW;
-
-pub const ISIG: ::tcflag_t = 0x00000001;
-pub const ICANON: ::tcflag_t = 0x00000002;
-pub const XCASE: ::tcflag_t = 0x00000004;
-pub const ECHO: ::tcflag_t = 0x00000008;
-pub const ECHOE: ::tcflag_t = 0x00000010;
-pub const ECHOK: ::tcflag_t = 0x00000020;
-pub const ECHONL: ::tcflag_t = 0x00000040;
-pub const NOFLSH: ::tcflag_t = 0x00000080;
-pub const TOSTOP: ::tcflag_t = 0x00000100;
-pub const IEXTEN: ::tcflag_t = 0x00000200;
-pub const ECHOCTL: ::tcflag_t = 0x00000400;
-pub const ECHOPRT: ::tcflag_t = 0x00000800;
-pub const ECHOKE: ::tcflag_t = 0x00001000;
-pub const FLUSHO: ::tcflag_t = 0x00002000;
-pub const PENDIN: ::tcflag_t = 0x00004000;
-
-pub const TCGB_CTS: ::c_int = 0x01;
-pub const TCGB_DSR: ::c_int = 0x02;
-pub const TCGB_RI: ::c_int = 0x04;
-pub const TCGB_DCD: ::c_int = 0x08;
-pub const TIOCM_CTS: ::c_int = TCGB_CTS;
-pub const TIOCM_CD: ::c_int = TCGB_DCD;
-pub const TIOCM_CAR: ::c_int = TIOCM_CD;
-pub const TIOCM_RI: ::c_int = TCGB_RI;
-pub const TIOCM_DSR: ::c_int = TCGB_DSR;
-pub const TIOCM_DTR: ::c_int = 0x10;
-pub const TIOCM_RTS: ::c_int = 0x20;
-
-pub const B0: speed_t = 0x00;
-pub const B50: speed_t = 0x01;
-pub const B75: speed_t = 0x02;
-pub const B110: speed_t = 0x03;
-pub const B134: speed_t = 0x04;
-pub const B150: speed_t = 0x05;
-pub const B200: speed_t = 0x06;
-pub const B300: speed_t = 0x07;
-pub const B600: speed_t = 0x08;
-pub const B1200: speed_t = 0x09;
-pub const B1800: speed_t = 0x0A;
-pub const B2400: speed_t = 0x0B;
-pub const B4800: speed_t = 0x0C;
-pub const B9600: speed_t = 0x0D;
-pub const B19200: speed_t = 0x0E;
-pub const B38400: speed_t = 0x0F;
-pub const B57600: speed_t = 0x10;
-pub const B115200: speed_t = 0x11;
-pub const B230400: speed_t = 0x12;
-pub const B31250: speed_t = 0x13;
-
-pub const TCSANOW: ::c_int = 0x01;
-pub const TCSADRAIN: ::c_int = 0x02;
-pub const TCSAFLUSH: ::c_int = 0x04;
-
-pub const TCOOFF: ::c_int = 0x01;
-pub const TCOON: ::c_int = 0x02;
-pub const TCIOFF: ::c_int = 0x04;
-pub const TCION: ::c_int = 0x08;
-
-pub const TCIFLUSH: ::c_int = 0x01;
-pub const TCOFLUSH: ::c_int = 0x02;
-pub const TCIOFLUSH: ::c_int = 0x03;
-
-f! {
- 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;
- (*set).fds_bits[fd / size] &= !(1 << (fd % size));
- return
- }
-
- pub fn FD_ISSET(fd: ::c_int, set: *mut fd_set) -> bool {
- let fd = fd as usize;
- let size = ::mem::size_of_val(&(*set).fds_bits[0]) * 8;
- return ((*set).fds_bits[fd / size] & (1 << (fd % size))) != 0
- }
-
- pub fn FD_SET(fd: ::c_int, set: *mut fd_set) -> () {
- let fd = fd as usize;
- let size = ::mem::size_of_val(&(*set).fds_bits[0]) * 8;
- (*set).fds_bits[fd / size] |= 1 << (fd % size);
- return
- }
-
- pub fn FD_ZERO(set: *mut fd_set) -> () {
- for slot in (*set).fds_bits.iter_mut() {
- *slot = 0;
- }
- }
-
- pub fn WIFEXITED(status: ::c_int) -> bool {
- (status & !0xff) == 0
- }
-
- pub fn WEXITSTATUS(status: ::c_int) -> ::c_int {
- (status & 0xff)
- }
-
- pub fn WIFSIGNALED(status: ::c_int) -> bool {
- ((status >> 8) & 0xff) != 0
- }
-
- pub fn WTERMSIG(status: ::c_int) -> ::c_int {
- (status >> 8) & 0xff
- }
-
- pub fn WIFSTOPPED(status: ::c_int) -> bool {
- ((status >> 16) & 0xff) != 0
- }
-
- pub fn WSTOPSIG(status: ::c_int) -> ::c_int {
- (status >> 16) & 0xff
- }
-
- // actually WIFCORED, but this is used everywhere else
- pub fn WCOREDUMP(status: ::c_int) -> bool {
- (status & 0x10000) != 0
- }
-
- pub fn WIFCONTINUED(status: ::c_int) -> bool {
- (status & 0x20000) != 0
- }
-}
-
-extern {
- pub fn getrlimit(resource: ::c_int, rlim: *mut ::rlimit) -> ::c_int;
- pub fn setrlimit(resource: ::c_int, rlim: *const ::rlimit) -> ::c_int;
- pub fn strerror_r(errnum: ::c_int, buf: *mut c_char,
- buflen: ::size_t) -> ::c_int;
-
- 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 sem_destroy(sem: *mut sem_t) -> ::c_int;
- pub fn sem_init(sem: *mut sem_t,
- pshared: ::c_int,
- value: ::c_uint)
- -> ::c_int;
-
- pub fn clock_gettime(clk_id: ::c_int, tp: *mut ::timespec) -> ::c_int;
- pub fn clock_settime(clk_id: ::c_int, tp: *const ::timespec) -> ::c_int;
- pub fn pthread_create(thread: *mut ::pthread_t,
- attr: *const ::pthread_attr_t,
- f: extern fn(*mut ::c_void) -> *mut ::c_void,
- value: *mut ::c_void) -> ::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_setclock(attr: *mut pthread_condattr_t,
- clock_id: ::clockid_t) -> ::c_int;
- pub fn memalign(align: ::size_t, size: ::size_t) -> *mut ::c_void;
- pub fn setgroups(ngroups: ::size_t,
- ptr: *const ::gid_t) -> ::c_int;
- pub fn ioctl(fd: ::c_int, request: ::c_int, ...) -> ::c_int;
- pub fn mprotect(addr: *const ::c_void, len: ::size_t, prot: ::c_int)
- -> ::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,
- sevlen: ::size_t,
- flags: ::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,
- options: ::c_int) -> ::c_int;
-
- 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;
- pub fn globfree(pglob: *mut ::glob_t);
- pub fn gettimeofday(tp: *mut ::timeval,
- tz: *mut ::c_void) -> ::c_int;
- pub fn posix_madvise(addr: *mut ::c_void, len: ::size_t, advice: ::c_int)
- -> ::c_int;
-
- pub fn shm_open(name: *const ::c_char, oflag: ::c_int, mode: ::mode_t)
- -> ::c_int;
- pub fn shm_unlink(name: *const ::c_char) -> ::c_int;
-
- pub fn seekdir(dirp: *mut ::DIR, loc: ::c_long);
-
- pub fn telldir(dirp: *mut ::DIR) -> ::c_long;
- pub fn madvise(addr: *mut ::c_void, len: ::size_t, advice: ::c_int)
- -> ::c_int;
-
- pub fn msync(addr: *mut ::c_void, len: ::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;
- pub fn mkstemps(template: *mut ::c_char, suffixlen: ::c_int) -> ::c_int;
- pub fn futimes(fd: ::c_int, times: *const ::timeval) -> ::c_int;
- pub fn lutimes(file: *const ::c_char, 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 execvpe(file: *const ::c_char, argv: *const *const ::c_char,
- environment: *const *const ::c_char) -> ::c_int;
- #[cfg_attr(target_os = "solaris", link_name = "__posix_getgrgid_r")]
- pub fn getgrgid_r(gid: ::gid_t,
- grp: *mut ::group,
- buf: *mut ::c_char,
- buflen: ::size_t,
- result: *mut *mut ::group) -> ::c_int;
- #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
- link_name = "sigaltstack$UNIX2003")]
- #[cfg_attr(target_os = "netbsd", link_name = "__sigaltstack14")]
- pub fn sigaltstack(ss: *const stack_t,
- oss: *mut stack_t) -> ::c_int;
- pub fn sem_close(sem: *mut sem_t) -> ::c_int;
- pub fn getdtablesize() -> ::c_int;
- #[cfg_attr(target_os = "solaris", link_name = "__posix_getgrnam_r")]
- pub fn getgrnam_r(name: *const ::c_char,
- grp: *mut ::group,
- buf: *mut ::c_char,
- buflen: ::size_t,
- result: *mut *mut ::group) -> ::c_int;
- #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
- link_name = "pthread_sigmask$UNIX2003")]
- pub fn pthread_sigmask(how: ::c_int, set: *const sigset_t,
- oldset: *mut sigset_t) -> ::c_int;
- pub fn sem_open(name: *const ::c_char, oflag: ::c_int, ...) -> *mut sem_t;
- pub fn getgrnam(name: *const ::c_char) -> *mut ::group;
- pub fn pthread_kill(thread: ::pthread_t, sig: ::c_int) -> ::c_int;
- pub fn sem_unlink(name: *const ::c_char) -> ::c_int;
- pub fn daemon(nochdir: ::c_int, noclose: ::c_int) -> ::c_int;
- #[cfg_attr(target_os = "netbsd", link_name = "__getpwnam_r50")]
- #[cfg_attr(target_os = "solaris", link_name = "__posix_getpwnam_r")]
- pub fn getpwnam_r(name: *const ::c_char,
- pwd: *mut passwd,
- buf: *mut ::c_char,
- buflen: ::size_t,
- result: *mut *mut passwd) -> ::c_int;
- #[cfg_attr(target_os = "netbsd", link_name = "__getpwuid_r50")]
- #[cfg_attr(target_os = "solaris", link_name = "__posix_getpwuid_r")]
- pub fn getpwuid_r(uid: ::uid_t,
- pwd: *mut passwd,
- buf: *mut ::c_char,
- buflen: ::size_t,
- result: *mut *mut passwd) -> ::c_int;
- #[cfg_attr(all(target_os = "macos", target_arch ="x86"),
- link_name = "sigwait$UNIX2003")]
- #[cfg_attr(target_os = "solaris", link_name = "__posix_sigwait")]
- pub fn sigwait(set: *const sigset_t,
- sig: *mut ::c_int) -> ::c_int;
- pub fn pthread_atfork(prepare: ::Option<unsafe extern fn()>,
- parent: ::Option<unsafe extern fn()>,
- child: ::Option<unsafe extern fn()>) -> ::c_int;
- pub fn getgrgid(gid: ::gid_t) -> *mut ::group;
- #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
- link_name = "popen$UNIX2003")]
- pub fn popen(command: *const c_char,
- mode: *const c_char) -> *mut ::FILE;
- pub fn openpty(amaster: *mut ::c_int,
- aslave: *mut ::c_int,
- name: *mut ::c_char,
- termp: *mut termios,
- winp: *mut ::winsize) -> ::c_int;
- pub fn forkpty(amaster: *mut ::c_int,
- name: *mut ::c_char,
- termp: *mut termios,
- winp: *mut ::winsize) -> ::pid_t;
- pub fn sethostname(name: *const ::c_char, len: ::size_t) -> ::c_int;
- pub fn uname(buf: *mut ::utsname) -> ::c_int;
-}
-
-cfg_if! {
- if #[cfg(target_pointer_width = "64")] {
- mod b64;
- pub use self::b64::*;
- } else {
- mod b32;
- pub use self::b32::*;
- }
-}
diff --git a/libc/src/unix/hermit/aarch64.rs b/libc/src/unix/hermit/aarch64.rs
deleted file mode 100644
index 1a92e3b..0000000
--- a/libc/src/unix/hermit/aarch64.rs
+++ /dev/null
@@ -1,2 +0,0 @@
-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
deleted file mode 100644
index 4bc03ef..0000000
--- a/libc/src/unix/hermit/mod.rs
+++ /dev/null
@@ -1,1024 +0,0 @@
-// 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 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_no_extra_traits! {
- pub struct dirent {
- pub d_ino: ::c_long,
- pub d_off: off_t,
- pub d_reclen: u16,
- pub d_name: [::c_char; 256],
- }
-
- // Dummy
- pub struct sockaddr_un {
- pub sun_family: sa_family_t,
- pub sun_path: [::c_char; 108],
- }
-
- 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 fd_set {
- fds_bits: [::c_ulong; FD_SETSIZE / ULONG_SIZE],
- }
-
- 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],
- }
-
- 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],
- }
-}
-
-cfg_if! {
- if #[cfg(feature = "extra_traits")] {
- impl PartialEq for dirent {
- fn eq(&self, other: &dirent) -> bool {
- self.d_ino == other.d_ino
- && self.d_off == other.d_off
- && self.d_reclen == other.d_reclen
- && self
- .d_name
- .iter()
- .zip(other.d_name.iter())
- .all(|(a,b)| a == b)
- }
- }
- impl Eq for dirent {}
- impl ::fmt::Debug for dirent {
- fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
- f.debug_struct("dirent")
- .field("d_ino", &self.d_ino)
- .field("d_off", &self.d_off)
- .field("d_reclen", &self.d_reclen)
- // FIXME: .field("d_name", &self.d_name)
- .finish()
- }
- }
- impl ::hash::Hash for dirent {
- fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
- self.d_ino.hash(state);
- self.d_off.hash(state);
- self.d_reclen.hash(state);
- self.d_name.hash(state);
- }
- }
-
- impl PartialEq for sockaddr_un {
- fn eq(&self, other: &sockaddr_un) -> bool {
- self.sun_family == other.sun_family
- && self
- .sun_path
- .iter()
- .zip(other.sun_path.iter())
- .all(|(a,b)| a == b)
- }
- }
- impl Eq for sockaddr_un {}
- impl ::fmt::Debug for sockaddr_un {
- fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
- f.debug_struct("sockaddr_un")
- .field("sun_family", &self.sun_family)
- // FIXME: .field("sun_path", &self.sun_path)
- .finish()
- }
- }
- impl ::hash::Hash for sockaddr_un {
- fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
- self.sun_family.hash(state);
- self.sun_path.hash(state);
- }
- }
-
- impl PartialEq for sockaddr {
- fn eq(&self, other: &sockaddr) -> bool {
- self.sa_len == other.sa_len
- && self.sa_family == other.sa_family
- && self
- .sa_data
- .iter()
- .zip(other.sa_data.iter())
- .all(|(a,b)| a == b)
- }
- }
- impl Eq for sockaddr {}
- impl ::fmt::Debug for sockaddr {
- fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
- f.debug_struct("sockaddr")
- .field("sa_len", &self.sa_len)
- .field("sa_family", &self.sa_family)
- // FIXME: .field("sa_data", &self.sa_data)
- .finish()
- }
- }
- impl ::hash::Hash for sockaddr {
- fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
- self.sa_len.hash(state);
- self.sa_family.hash(state);
- self.sa_data.hash(state);
- }
- }
-
- impl PartialEq for sockaddr_in {
- fn eq(&self, other: &sockaddr_in) -> bool {
- self.sin_len == other.sin_len
- && self.sin_family == other.sin_family
- && self.sin_port == other.sin_port
- && self.sin_addr == other.sin_addr
- && self
- .sin_zero
- .iter()
- .zip(other.sin_zero.iter())
- .all(|(a,b)| a == b)
- }
- }
- impl Eq for sockaddr_in {}
- impl ::fmt::Debug for sockaddr_in {
- fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
- f.debug_struct("sockaddr_in")
- .field("sin_len", &self.sin_len)
- .field("sin_family", &self.sin_family)
- .field("sin_port", &self.sin_port)
- .field("sin_addr", &self.sin_addr)
- // FIXME: .field("sin_zero", &self.sin_zero)
- .finish()
- }
- }
- impl ::hash::Hash for sockaddr_in {
- fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
- self.sin_len.hash(state);
- self.sin_family.hash(state);
- self.sin_port.hash(state);
- self.sin_addr.hash(state);
- self.sin_zero.hash(state);
- }
- }
-
- impl PartialEq for fd_set {
- fn eq(&self, other: &fd_set) -> bool {
- self.fds_bits
- .iter()
- .zip(other.fds_bits.iter())
- .all(|(a,b)| a == b)
- }
- }
- impl Eq for fd_set {}
- impl ::fmt::Debug for fd_set {
- fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
- f.debug_struct("fd_set")
- // FIXME: .field("fds_bits", &self.fds_bits)
- .finish()
- }
- }
- impl ::hash::Hash for fd_set {
- fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
- self.fds_bits.hash(state);
- }
- }
-
- impl PartialEq for sockaddr_storage {
- fn eq(&self, other: &sockaddr_storage) -> bool {
- self.s2_len == other.s2_len
- && self.ss_family == other.ss_family
- && self.s2_data1
- .iter()
- .zip(other.s2_data1.iter())
- .all(|(a,b)| a == b)
- && self.s2_data2
- .iter()
- .zip(other.s2_data2.iter())
- .all(|(a,b)| a == b)
- && self.s2_data3
- .iter()
- .zip(other.s2_data3.iter())
- .all(|(a,b)| a == b)
- }
- }
- impl Eq for sockaddr_storage {}
- impl ::fmt::Debug for sockaddr_storage {
- fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
- f.debug_struct("sockaddr_storage")
- .field("s2_len", &self.s2_len)
- .field("ss_family", &self.ss_family)
- // FIXME: .field("s2_data1", &self.s2_data1)
- // FIXME: .field("s2_data2", &self.s2_data2)
- // FIXME: .field("s2_data3", &self.s2_data3)
- .finish()
- }
- }
- impl ::hash::Hash for sockaddr_storage {
- fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
- self.s2_len.hash(state);
- self.ss_family.hash(state);
- self.s2_data1.hash(state);
- self.s2_data2.hash(state);
- self.s2_data3.hash(state);
- }
- }
-
- impl PartialEq for stat {
- fn eq(&self, other: &stat) -> bool {
- self.st_dev == other.st_dev
- && self.st_ino == other.st_ino
- && self.st_mode == other.st_mode
- && self.st_nlink == other.st_nlink
- && self.st_uid == other.st_uid
- && self.st_gid == other.st_gid
- && self.st_rdev == other.st_rdev
- && self.st_size == other.st_size
- && self.st_atime == other.st_atime
- && self.st_atime_nsec == other.st_atime_nsec
- && self.st_mtime == other.st_mtime
- && self.st_mtime_nsec == other.st_mtime_nsec
- && self.st_ctime == other.st_ctime
- && self.st_ctime_nsec == other.st_ctime_nsec
- && self.st_blksize == other.st_blksize
- && self.st_blocks == other.st_blocks
- && self
- .st_spare4
- .iter()
- .zip(other.st_spare4.iter())
- .all(|(a,b)| a == b)
- }
- }
- impl Eq for stat {}
- impl ::fmt::Debug for stat {
- fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
- f.debug_struct("stat")
- .field("st_dev", &self.st_dev)
- .field("st_ino", &self.st_ino)
- .field("st_mode", &self.st_mode)
- .field("st_nlink", &self.st_nlink)
- .field("st_uid", &self.st_uid)
- .field("st_gid", &self.st_gid)
- .field("st_rdev", &self.st_rdev)
- .field("st_size", &self.st_size)
- .field("st_atime", &self.st_atime)
- .field("st_atime_nsec", &self.st_atime_nsec)
- .field("st_mtime", &self.st_mtime)
- .field("st_mtime_nsec", &self.st_mtime_nsec)
- .field("st_ctime", &self.st_ctime)
- .field("st_ctime_nsec", &self.st_ctime_nsec)
- .field("st_blksize", &self.st_blksize)
- .field("st_blocks", &self.st_blocks)
- // FIXME: .field("st_spare4", &self.st_spare4)
- .finish()
- }
- }
- impl ::hash::Hash for stat {
- fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
- self.st_dev.hash(state);
- self.st_ino.hash(state);
- self.st_mode.hash(state);
- self.st_nlink.hash(state);
- self.st_uid.hash(state);
- self.st_gid.hash(state);
- self.st_rdev.hash(state);
- self.st_size.hash(state);
- self.st_atime.hash(state);
- self.st_atime_nsec.hash(state);
- self.st_mtime.hash(state);
- self.st_mtime_nsec.hash(state);
- self.st_ctime.hash(state);
- self.st_ctime_nsec.hash(state);
- self.st_blksize.hash(state);
- self.st_blocks.hash(state);
- self.st_spare4.hash(state);
- }
- }
- }
-}
-
-s! {
- pub struct in_addr {
- pub s_addr: ::in_addr_t,
- }
-
- pub struct ip_mreq {
- pub imr_multiaddr: in_addr,
- pub imr_interface: in_addr,
- }
-
- 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 Dl_info {}
-
- 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_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 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 getrlimit(resource: ::c_int, rlim: *mut ::rlimit) -> ::c_int;
- pub fn setrlimit(resource: ::c_int, rlim: *const ::rlimit) -> ::c_int;
- pub fn strerror_r(errnum: ::c_int, buf: *mut c_char,
- buflen: ::size_t) -> ::c_int;
-
- pub fn sem_destroy(sem: *mut sem_t) -> ::c_int;
- pub fn sem_init(sem: *mut sem_t,
- pshared: ::c_int,
- value: ::c_uint)
- -> ::c_int;
-
- 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 gettimeofday(tp: *mut ::timeval,
- tz: *mut ::c_void) -> ::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;
- pub fn uname(buf: *mut ::utsname) -> ::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
deleted file mode 100644
index 76ec3ce..0000000
--- a/libc/src/unix/hermit/x86_64.rs
+++ /dev/null
@@ -1,2 +0,0 @@
-pub type c_char = i8;
-pub type wchar_t = i32;
diff --git a/libc/src/unix/mod.rs b/libc/src/unix/mod.rs
deleted file mode 100644
index efaad41..0000000
--- a/libc/src/unix/mod.rs
+++ /dev/null
@@ -1,1206 +0,0 @@
-//! Definitions found commonly among almost all Unix derivatives
-//!
-//! More functions and definitions can be found in the more specific modules
-//! according to the platform in question.
-
-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;
-pub type in_addr_t = u32;
-pub type in_port_t = u16;
-pub type sighandler_t = ::size_t;
-pub type cc_t = ::c_uchar;
-
-#[cfg_attr(feature = "extra_traits", derive(Debug))]
-pub enum DIR {}
-impl ::Copy for DIR {}
-impl ::Clone for DIR {
- fn clone(&self) -> DIR { *self }
-}
-pub type locale_t = *mut :: c_void;
-
-s! {
- pub struct group {
- pub gr_name: *mut ::c_char,
- pub gr_passwd: *mut ::c_char,
- pub gr_gid: ::gid_t,
- pub gr_mem: *mut *mut ::c_char,
- }
-
- pub struct utimbuf {
- pub actime: time_t,
- pub modtime: time_t,
- }
-
- pub struct timeval {
- pub tv_sec: time_t,
- 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,
- }
-
- pub struct rlimit {
- pub rlim_cur: rlim_t,
- pub rlim_max: rlim_t,
- }
-
- pub struct rusage {
- pub ru_utime: timeval,
- pub ru_stime: timeval,
- pub ru_maxrss: c_long,
- #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
- __pad1: u32,
- pub ru_ixrss: c_long,
- #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
- __pad2: u32,
- pub ru_idrss: c_long,
- #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
- __pad3: u32,
- pub ru_isrss: c_long,
- #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
- __pad4: u32,
- pub ru_minflt: c_long,
- #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
- __pad5: u32,
- pub ru_majflt: c_long,
- #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
- __pad6: u32,
- pub ru_nswap: c_long,
- #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
- __pad7: u32,
- pub ru_inblock: c_long,
- #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
- __pad8: u32,
- pub ru_oublock: c_long,
- #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
- __pad9: u32,
- pub ru_msgsnd: c_long,
- #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
- __pad10: u32,
- pub ru_msgrcv: c_long,
- #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
- __pad11: u32,
- pub ru_nsignals: c_long,
- #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
- __pad12: u32,
- pub ru_nvcsw: c_long,
- #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
- __pad13: u32,
- pub ru_nivcsw: c_long,
- #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
- __pad14: u32,
-
- #[cfg(any(target_env = "musl", target_os = "emscripten"))]
- __reserved: [c_long; 16],
- }
-
- 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,
- }
-
- pub struct hostent {
- pub h_name: *mut ::c_char,
- pub h_aliases: *mut *mut ::c_char,
- pub h_addrtype: ::c_int,
- pub h_length: ::c_int,
- pub h_addr_list: *mut *mut ::c_char,
- }
-
- pub struct iovec {
- pub iov_base: *mut ::c_void,
- pub iov_len: ::size_t,
- }
-
- pub struct pollfd {
- pub fd: ::c_int,
- pub events: ::c_short,
- pub revents: ::c_short,
- }
-
- pub struct winsize {
- pub ws_row: ::c_ushort,
- pub ws_col: ::c_ushort,
- pub ws_xpixel: ::c_ushort,
- pub ws_ypixel: ::c_ushort,
- }
-
- pub struct linger {
- pub l_onoff: ::c_int,
- pub l_linger: ::c_int,
- }
-
- pub struct sigval {
- // Actually a union of an int and a void*
- pub sival_ptr: *mut ::c_void
- }
-
- // <sys/time.h>
- pub struct itimerval {
- pub it_interval: ::timeval,
- pub it_value: ::timeval,
- }
-
- // <sys/times.h>
- 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 servent {
- pub s_name: *mut ::c_char,
- pub s_aliases: *mut *mut ::c_char,
- pub s_port: ::c_int,
- pub s_proto: *mut ::c_char,
- }
-
- pub struct protoent {
- pub p_name: *mut ::c_char,
- pub p_aliases: *mut *mut ::c_char,
- pub p_proto: ::c_int,
- }
-}
-
-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;
-pub const DT_BLK: u8 = 6;
-pub const DT_REG: u8 = 8;
-pub const DT_LNK: u8 = 10;
-pub const DT_SOCK: u8 = 12;
-
-cfg_if! {
- if #[cfg(not(target_os = "redox"))] {
- pub const FD_CLOEXEC: ::c_int = 0x1;
- }
-}
-
-pub const USRQUOTA: ::c_int = 0;
-pub const GRPQUOTA: ::c_int = 1;
-
-pub const SIGIOT: ::c_int = 6;
-
-pub const S_ISUID: ::mode_t = 0x800;
-pub const S_ISGID: ::mode_t = 0x400;
-pub const S_ISVTX: ::mode_t = 0x200;
-
-pub const IF_NAMESIZE: ::size_t = 16;
-pub const IFNAMSIZ: ::size_t = IF_NAMESIZE;
-
-pub const LOG_EMERG: ::c_int = 0;
-pub const LOG_ALERT: ::c_int = 1;
-pub const LOG_CRIT: ::c_int = 2;
-pub const LOG_ERR: ::c_int = 3;
-pub const LOG_WARNING: ::c_int = 4;
-pub const LOG_NOTICE: ::c_int = 5;
-pub const LOG_INFO: ::c_int = 6;
-pub const LOG_DEBUG: ::c_int = 7;
-
-pub const LOG_KERN: ::c_int = 0;
-pub const LOG_USER: ::c_int = 1 << 3;
-pub const LOG_MAIL: ::c_int = 2 << 3;
-pub const LOG_DAEMON: ::c_int = 3 << 3;
-pub const LOG_AUTH: ::c_int = 4 << 3;
-pub const LOG_SYSLOG: ::c_int = 5 << 3;
-pub const LOG_LPR: ::c_int = 6 << 3;
-pub const LOG_NEWS: ::c_int = 7 << 3;
-pub const LOG_UUCP: ::c_int = 8 << 3;
-pub const LOG_LOCAL0: ::c_int = 16 << 3;
-pub const LOG_LOCAL1: ::c_int = 17 << 3;
-pub const LOG_LOCAL2: ::c_int = 18 << 3;
-pub const LOG_LOCAL3: ::c_int = 19 << 3;
-pub const LOG_LOCAL4: ::c_int = 20 << 3;
-pub const LOG_LOCAL5: ::c_int = 21 << 3;
-pub const LOG_LOCAL6: ::c_int = 22 << 3;
-pub const LOG_LOCAL7: ::c_int = 23 << 3;
-
-pub const LOG_PID: ::c_int = 0x01;
-pub const LOG_CONS: ::c_int = 0x02;
-pub const LOG_ODELAY: ::c_int = 0x04;
-pub const LOG_NDELAY: ::c_int = 0x08;
-pub const LOG_NOWAIT: ::c_int = 0x10;
-
-pub const LOG_PRIMASK: ::c_int = 7;
-pub const LOG_FACMASK: ::c_int = 0x3f8;
-
-pub const PRIO_PROCESS: ::c_int = 0;
-pub const PRIO_PGRP: ::c_int = 1;
-pub const PRIO_USER: ::c_int = 2;
-
-pub const PRIO_MIN: ::c_int = -20;
-pub const PRIO_MAX: ::c_int = 20;
-
-pub const IPPROTO_ICMP: ::c_int = 1;
-pub const IPPROTO_ICMPV6: ::c_int = 58;
-pub const IPPROTO_TCP: ::c_int = 6;
-pub const IPPROTO_UDP: ::c_int = 17;
-pub const IPPROTO_IP: ::c_int = 0;
-pub const IPPROTO_IPV6: ::c_int = 41;
-
-pub const INADDR_LOOPBACK: in_addr_t = 2130706433;
-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(target_os = "l4re")] {
- // required libraries for L4Re are linked externally, ATM
- } else if #[cfg(feature = "std")] {
- // cargo build, don't pull in anything extra as the libstd dep
- // already pulls in all libs.
- } 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",
- 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.
- #[link(name = "m")]
- extern {}
- } else if #[cfg(any(target_os = "macos",
- target_os = "ios",
- target_os = "android",
- target_os = "openbsd"))] {
- #[link(name = "c")]
- #[link(name = "m")]
- extern {}
- } else if #[cfg(target_os = "haiku")] {
- #[link(name = "root")]
- #[link(name = "network")]
- 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 if #[cfg(target_env = "illumos")] {
- #[link(name = "c")]
- #[link(name = "m")]
- extern {}
- } else if #[cfg(target_os = "redox")] {
- #[cfg_attr(feature = "rustc-dep-of-std",
- link(name = "c", kind = "static-nobundle",
- cfg(target_feature = "crt-static")))]
- #[cfg_attr(feature = "rustc-dep-of-std",
- link(name = "c", cfg(not(target_feature = "crt-static"))))]
- extern {}
- } else {
- #[link(name = "c")]
- #[link(name = "m")]
- #[link(name = "rt")]
- #[link(name = "pthread")]
- extern {}
- }
-}
-
-#[cfg_attr(feature = "extra_traits", derive(Debug))]
-pub enum FILE {}
-impl ::Copy for FILE {}
-impl ::Clone for FILE {
- fn clone(&self) -> FILE { *self }
-}
-#[cfg_attr(feature = "extra_traits", derive(Debug))]
-pub enum fpos_t {} // TODO: fill this out with a struct
-impl ::Copy for fpos_t {}
-impl ::Clone for fpos_t {
- fn clone(&self) -> fpos_t { *self }
-}
-
-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;
- #[cfg_attr(target_os = "netbsd", link_name = "__getpwuid50")]
- pub fn getpwuid(uid: ::uid_t) -> *mut passwd;
-
- pub fn fprintf(stream: *mut ::FILE,
- format: *const ::c_char, ...) -> ::c_int;
- pub fn printf(format: *const ::c_char, ...) -> ::c_int;
- pub fn snprintf(s: *mut ::c_char, n: ::size_t,
- format: *const ::c_char, ...) -> ::c_int;
- pub fn sprintf(s: *mut ::c_char, format: *const ::c_char, ...) -> ::c_int;
- #[cfg_attr(target_os = "linux", link_name = "__isoc99_fscanf")]
- pub fn fscanf(stream: *mut ::FILE, format: *const ::c_char, ...) -> ::c_int;
- #[cfg_attr(target_os = "linux", link_name = "__isoc99_scanf")]
- pub fn scanf(format: *const ::c_char, ...) -> ::c_int;
- #[cfg_attr(target_os = "linux", link_name = "__isoc99_sscanf")]
- pub fn sscanf(s: *const ::c_char, format: *const ::c_char, ...) -> ::c_int;
- pub fn getchar_unlocked() -> ::c_int;
- pub fn putchar_unlocked(c: ::c_int) -> ::c_int;
-
- #[cfg_attr(target_os = "netbsd", link_name = "__socket30")]
- #[cfg_attr(target_os = "illumos", link_name = "__xnet_socket")]
- pub fn socket(domain: ::c_int, ty: ::c_int, protocol: ::c_int) -> ::c_int;
- #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
- link_name = "connect$UNIX2003")]
- #[cfg_attr(target_os = "illumos", link_name = "__xnet_connect")]
- pub fn connect(socket: ::c_int, address: *const sockaddr,
- len: socklen_t) -> ::c_int;
- #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
- link_name = "listen$UNIX2003")]
- #[cfg_attr(target_os = "illumos", link_name = "__xnet_listen")]
- pub fn listen(socket: ::c_int, backlog: ::c_int) -> ::c_int;
- #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
- link_name = "accept$UNIX2003")]
- pub fn accept(socket: ::c_int, address: *mut sockaddr,
- address_len: *mut socklen_t) -> ::c_int;
- #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
- link_name = "getpeername$UNIX2003")]
- pub fn getpeername(socket: ::c_int, address: *mut sockaddr,
- address_len: *mut socklen_t) -> ::c_int;
- #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
- link_name = "getsockname$UNIX2003")]
- pub fn getsockname(socket: ::c_int, address: *mut sockaddr,
- address_len: *mut socklen_t) -> ::c_int;
- pub fn setsockopt(socket: ::c_int, level: ::c_int, name: ::c_int,
- value: *const ::c_void,
- option_len: socklen_t) -> ::c_int;
- #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
- link_name = "socketpair$UNIX2003")]
- #[cfg_attr(target_os = "illumos", link_name = "__xnet_socketpair")]
- pub fn socketpair(domain: ::c_int, type_: ::c_int, protocol: ::c_int,
- socket_vector: *mut ::c_int) -> ::c_int;
- #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
- link_name = "sendto$UNIX2003")]
- #[cfg_attr(target_os = "illumos", link_name = "__xnet_sendto")]
- 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 shutdown(socket: ::c_int, how: ::c_int) -> ::c_int;
-
- #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
- link_name = "chmod$UNIX2003")]
- pub fn chmod(path: *const c_char, mode: mode_t) -> ::c_int;
- #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
- link_name = "fchmod$UNIX2003")]
- pub fn fchmod(fd: ::c_int, mode: mode_t) -> ::c_int;
-
- #[cfg_attr(target_os = "macos", link_name = "fstat$INODE64")]
- #[cfg_attr(target_os = "netbsd", link_name = "__fstat50")]
- #[cfg_attr(
- all(target_os = "freebsd", not(freebsd12)),
- 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(
- all(target_os = "freebsd", not(freebsd12)),
- 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;
- #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
- link_name = "fdopen$UNIX2003")]
- pub fn fdopen(fd: ::c_int, mode: *const c_char) -> *mut ::FILE;
- pub fn fileno(stream: *mut ::FILE) -> ::c_int;
-
- #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
- link_name = "open$UNIX2003")]
- pub fn open(path: *const c_char, oflag: ::c_int, ...) -> ::c_int;
- #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
- link_name = "creat$UNIX2003")]
- pub fn creat(path: *const c_char, mode: mode_t) -> ::c_int;
- #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
- link_name = "fcntl$UNIX2003")]
- pub fn fcntl(fd: ::c_int, cmd: ::c_int, ...) -> ::c_int;
-
- #[cfg_attr(all(target_os = "macos", target_arch = "x86_64"),
- link_name = "opendir$INODE64")]
- #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
- 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(
- all(target_os = "freebsd", not(freebsd12)),
- 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(
- all(target_os = "freebsd", not(freebsd12)),
- link_name = "readdir_r@FBSD_1.0"
- )]
- /// The 64-bit libc on Solaris and illumos only has readdir_r. If a
- /// 32-bit Solaris or illumos target is ever created, it should use
- /// __posix_readdir_r. See libc(3LIB) on Solaris or illumos:
- /// https://illumos.org/man/3lib/libc
- /// https://docs.oracle.com/cd/E36784_01/html/E36873/libc-3lib.html
- /// https://www.unix.com/man-page/opensolaris/3LIB/libc/
- 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"),
- link_name = "closedir$UNIX2003")]
- pub fn closedir(dirp: *mut ::DIR) -> ::c_int;
- #[cfg_attr(all(target_os = "macos", target_arch = "x86_64"),
- link_name = "rewinddir$INODE64")]
- #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
- link_name = "rewinddir$INODE64$UNIX2003")]
- pub fn rewinddir(dirp: *mut ::DIR);
-
- pub fn openat(dirfd: ::c_int, pathname: *const ::c_char,
- flags: ::c_int, ...) -> ::c_int;
- pub fn fchmodat(dirfd: ::c_int, pathname: *const ::c_char,
- mode: ::mode_t, flags: ::c_int) -> ::c_int;
- pub fn fchown(fd: ::c_int,
- owner: ::uid_t,
- group: ::gid_t) -> ::c_int;
- pub fn fchownat(dirfd: ::c_int, pathname: *const ::c_char,
- owner: ::uid_t, group: ::gid_t,
- flags: ::c_int) -> ::c_int;
- #[cfg_attr(target_os = "macos", link_name = "fstatat$INODE64")]
- #[cfg_attr(
- all(target_os = "freebsd", not(freebsd12)),
- 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,
- newdirfd: ::c_int, newpath: *const ::c_char,
- flags: ::c_int) -> ::c_int;
- pub fn mkdirat(dirfd: ::c_int, pathname: *const ::c_char,
- mode: ::mode_t) -> ::c_int;
- pub fn readlinkat(dirfd: ::c_int, pathname: *const ::c_char,
- buf: *mut ::c_char, bufsiz: ::size_t) -> ::ssize_t;
- pub fn renameat(olddirfd: ::c_int, oldpath: *const ::c_char,
- newdirfd: ::c_int, newpath: *const ::c_char)
- -> ::c_int;
- pub fn symlinkat(target: *const ::c_char, newdirfd: ::c_int,
- linkpath: *const ::c_char) -> ::c_int;
- pub fn unlinkat(dirfd: ::c_int, pathname: *const ::c_char,
- flags: ::c_int) -> ::c_int;
-
- pub fn access(path: *const c_char, amode: ::c_int) -> ::c_int;
- pub fn alarm(seconds: ::c_uint) -> ::c_uint;
- pub fn chdir(dir: *const c_char) -> ::c_int;
- pub fn fchdir(dirfd: ::c_int) -> ::c_int;
- pub fn chown(path: *const c_char, uid: uid_t,
- gid: gid_t) -> ::c_int;
- #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
- link_name = "lchown$UNIX2003")]
- pub fn lchown(path: *const c_char, uid: uid_t,
- gid: gid_t) -> ::c_int;
- #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
- link_name = "close$NOCANCEL$UNIX2003")]
- #[cfg_attr(all(target_os = "macos", target_arch = "x86_64"),
- link_name = "close$NOCANCEL")]
- pub fn close(fd: ::c_int) -> ::c_int;
- pub fn dup(fd: ::c_int) -> ::c_int;
- pub fn dup2(src: ::c_int, dst: ::c_int) -> ::c_int;
- pub fn execl(path: *const c_char,
- arg0: *const c_char, ...) -> ::c_int;
- pub fn execle(path: *const ::c_char,
- arg0: *const ::c_char, ...) -> ::c_int;
- pub fn execlp(file: *const ::c_char,
- arg0: *const ::c_char, ...) -> ::c_int;
- pub fn execv(prog: *const c_char,
- argv: *const *const c_char) -> ::c_int;
- pub fn execve(prog: *const c_char, argv: *const *const c_char,
- envp: *const *const c_char)
- -> ::c_int;
- pub fn execvp(c: *const c_char,
- argv: *const *const c_char) -> ::c_int;
- pub fn fork() -> pid_t;
- pub fn fpathconf(filedes: ::c_int, name: ::c_int) -> c_long;
- pub fn getcwd(buf: *mut c_char, size: ::size_t) -> *mut c_char;
- pub fn getegid() -> gid_t;
- pub fn geteuid() -> uid_t;
- pub fn getgid() -> gid_t;
- pub fn getgroups(ngroups_max: ::c_int, groups: *mut gid_t)
- -> ::c_int;
- pub fn getlogin() -> *mut c_char;
- #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
- link_name = "getopt$UNIX2003")]
- pub fn getopt(argc: ::c_int, argv: *const *mut c_char,
- optstr: *const c_char) -> ::c_int;
- pub fn getpgid(pid: pid_t) -> pid_t;
- pub fn getpgrp() -> pid_t;
- pub fn getpid() -> pid_t;
- pub fn getppid() -> pid_t;
- pub fn getuid() -> uid_t;
- pub fn isatty(fd: ::c_int) -> ::c_int;
- pub fn link(src: *const c_char, dst: *const c_char) -> ::c_int;
- pub fn lseek(fd: ::c_int, offset: off_t, whence: ::c_int) -> off_t;
- pub fn pathconf(path: *const c_char, name: ::c_int) -> c_long;
- #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
- link_name = "pause$UNIX2003")]
- pub fn pause() -> ::c_int;
- pub fn pipe(fds: *mut ::c_int) -> ::c_int;
- pub fn posix_memalign(memptr: *mut *mut ::c_void,
- align: ::size_t,
- size: ::size_t) -> ::c_int;
- #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
- link_name = "read$UNIX2003")]
- pub fn read(fd: ::c_int, buf: *mut ::c_void, count: ::size_t)
- -> ::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;
- pub fn setuid(uid: uid_t) -> ::c_int;
- #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
- link_name = "sleep$UNIX2003")]
- pub fn sleep(secs: ::c_uint) -> ::c_uint;
- #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
- link_name = "nanosleep$UNIX2003")]
- #[cfg_attr(target_os = "netbsd", link_name = "__nanosleep50")]
- pub fn nanosleep(rqtp: *const timespec,
- rmtp: *mut timespec) -> ::c_int;
- pub fn tcgetpgrp(fd: ::c_int) -> pid_t;
- pub fn tcsetpgrp(fd: ::c_int, pgrp: ::pid_t) -> ::c_int;
- pub fn ttyname(fd: ::c_int) -> *mut c_char;
- pub fn unlink(c: *const c_char) -> ::c_int;
- #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
- link_name = "wait$UNIX2003")]
- pub fn wait(status: *mut ::c_int) -> pid_t;
- #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
- link_name = "waitpid$UNIX2003")]
- pub fn waitpid(pid: pid_t, status: *mut ::c_int, options: ::c_int)
- -> pid_t;
- #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
- link_name = "write$UNIX2003")]
- pub fn write(fd: ::c_int, buf: *const ::c_void, count: ::size_t)
- -> ::ssize_t;
- #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
- link_name = "pread$UNIX2003")]
- pub fn pread(fd: ::c_int, buf: *mut ::c_void, count: ::size_t,
- offset: off_t) -> ::ssize_t;
- #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
- link_name = "pwrite$UNIX2003")]
- pub fn pwrite(fd: ::c_int, buf: *const ::c_void, count: ::size_t,
- offset: off_t) -> ::ssize_t;
- pub fn umask(mask: mode_t) -> mode_t;
-
- #[cfg_attr(target_os = "netbsd", link_name = "__utime50")]
- pub fn utime(file: *const c_char, buf: *const utimbuf) -> ::c_int;
-
- #[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;
- pub fn mlockall(flags: ::c_int) -> ::c_int;
- pub fn munlockall() -> ::c_int;
-
- #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
- link_name = "mmap$UNIX2003")]
- pub fn mmap(addr: *mut ::c_void,
- len: ::size_t,
- prot: ::c_int,
- flags: ::c_int,
- fd: ::c_int,
- offset: off_t)
- -> *mut ::c_void;
- #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
- link_name = "munmap$UNIX2003")]
- pub fn munmap(addr: *mut ::c_void, len: ::size_t) -> ::c_int;
-
- pub fn if_nametoindex(ifname: *const c_char) -> ::c_uint;
- pub fn if_indextoname(ifindex: ::c_uint,
- ifname: *mut ::c_char) -> *mut ::c_char;
-
- #[cfg_attr(target_os = "macos", link_name = "lstat$INODE64")]
- #[cfg_attr(target_os = "netbsd", link_name = "__lstat50")]
- #[cfg_attr(
- all(target_os = "freebsd", not(freebsd12)),
- 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"),
- link_name = "fsync$UNIX2003")]
- pub fn fsync(fd: ::c_int) -> ::c_int;
-
- #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
- link_name = "setenv$UNIX2003")]
- pub fn setenv(name: *const c_char, val: *const c_char,
- overwrite: ::c_int) -> ::c_int;
- #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
- link_name = "unsetenv$UNIX2003")]
- #[cfg_attr(target_os = "netbsd", link_name = "__unsetenv13")]
- pub fn unsetenv(name: *const c_char) -> ::c_int;
-
- 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;
-
- #[cfg_attr(target_os = "netbsd", link_name = "__getrusage50")]
- pub fn getrusage(resource: ::c_int, usage: *mut rusage) -> ::c_int;
-
- #[cfg_attr(any(target_os = "macos", target_os = "ios"),
- link_name = "realpath$DARWIN_EXTSN")]
- pub fn realpath(pathname: *const ::c_char, resolved: *mut ::c_char)
- -> *mut ::c_char;
-
- pub fn flock(fd: ::c_int, operation: ::c_int) -> ::c_int;
-
- #[cfg_attr(target_os = "netbsd", link_name = "__times13")]
- pub fn times(buf: *mut ::tms) -> ::clock_t;
-
- pub fn pthread_self() -> ::pthread_t;
- #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
- link_name = "pthread_join$UNIX2003")]
- pub fn pthread_join(native: ::pthread_t,
- value: *mut *mut ::c_void) -> ::c_int;
- pub fn pthread_exit(value: *mut ::c_void);
- pub fn pthread_attr_init(attr: *mut ::pthread_attr_t) -> ::c_int;
- pub fn pthread_attr_destroy(attr: *mut ::pthread_attr_t) -> ::c_int;
- pub fn pthread_attr_setstacksize(attr: *mut ::pthread_attr_t,
- stack_size: ::size_t) -> ::c_int;
- pub fn pthread_attr_setdetachstate(attr: *mut ::pthread_attr_t,
- state: ::c_int) -> ::c_int;
- pub fn pthread_detach(thread: ::pthread_t) -> ::c_int;
- #[cfg_attr(target_os = "netbsd", link_name = "__libc_thr_yield")]
- pub fn sched_yield() -> ::c_int;
- pub fn pthread_key_create(key: *mut pthread_key_t,
- dtor: ::Option<unsafe extern fn(*mut ::c_void)>)
- -> ::c_int;
- pub fn pthread_key_delete(key: pthread_key_t) -> ::c_int;
- pub fn pthread_getspecific(key: pthread_key_t) -> *mut ::c_void;
- pub fn pthread_setspecific(key: pthread_key_t, value: *const ::c_void)
- -> ::c_int;
- pub fn pthread_mutex_init(lock: *mut pthread_mutex_t,
- attr: *const pthread_mutexattr_t) -> ::c_int;
- pub fn pthread_mutex_destroy(lock: *mut pthread_mutex_t) -> ::c_int;
- pub fn pthread_mutex_lock(lock: *mut pthread_mutex_t) -> ::c_int;
- pub fn pthread_mutex_trylock(lock: *mut pthread_mutex_t) -> ::c_int;
- pub fn pthread_mutex_unlock(lock: *mut pthread_mutex_t) -> ::c_int;
-
- pub fn pthread_mutexattr_init(attr: *mut pthread_mutexattr_t) -> ::c_int;
- #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
- link_name = "pthread_mutexattr_destroy$UNIX2003")]
- pub fn pthread_mutexattr_destroy(attr: *mut pthread_mutexattr_t) -> ::c_int;
- pub fn pthread_mutexattr_settype(attr: *mut pthread_mutexattr_t,
- _type: ::c_int) -> ::c_int;
-
- #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
- link_name = "pthread_cond_init$UNIX2003")]
- pub fn pthread_cond_init(cond: *mut pthread_cond_t,
- attr: *const pthread_condattr_t) -> ::c_int;
- #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
- link_name = "pthread_cond_wait$UNIX2003")]
- pub fn pthread_cond_wait(cond: *mut pthread_cond_t,
- lock: *mut pthread_mutex_t) -> ::c_int;
- #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
- link_name = "pthread_cond_timedwait$UNIX2003")]
- pub fn pthread_cond_timedwait(cond: *mut pthread_cond_t,
- lock: *mut pthread_mutex_t,
- abstime: *const ::timespec) -> ::c_int;
- pub fn pthread_cond_signal(cond: *mut pthread_cond_t) -> ::c_int;
- pub fn pthread_cond_broadcast(cond: *mut pthread_cond_t) -> ::c_int;
- pub fn pthread_cond_destroy(cond: *mut pthread_cond_t) -> ::c_int;
- pub fn pthread_condattr_init(attr: *mut pthread_condattr_t) -> ::c_int;
- pub fn pthread_condattr_destroy(attr: *mut pthread_condattr_t) -> ::c_int;
- #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
- link_name = "pthread_rwlock_init$UNIX2003")]
- pub fn pthread_rwlock_init(lock: *mut pthread_rwlock_t,
- attr: *const pthread_rwlockattr_t) -> ::c_int;
- #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
- link_name = "pthread_rwlock_destroy$UNIX2003")]
- pub fn pthread_rwlock_destroy(lock: *mut pthread_rwlock_t) -> ::c_int;
- #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
- link_name = "pthread_rwlock_rdlock$UNIX2003")]
- pub fn pthread_rwlock_rdlock(lock: *mut pthread_rwlock_t) -> ::c_int;
- #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
- link_name = "pthread_rwlock_tryrdlock$UNIX2003")]
- pub fn pthread_rwlock_tryrdlock(lock: *mut pthread_rwlock_t) -> ::c_int;
- #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
- link_name = "pthread_rwlock_wrlock$UNIX2003")]
- pub fn pthread_rwlock_wrlock(lock: *mut pthread_rwlock_t) -> ::c_int;
- #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
- link_name = "pthread_rwlock_trywrlock$UNIX2003")]
- pub fn pthread_rwlock_trywrlock(lock: *mut pthread_rwlock_t) -> ::c_int;
- #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
- link_name = "pthread_rwlock_unlock$UNIX2003")]
- pub fn pthread_rwlock_unlock(lock: *mut pthread_rwlock_t) -> ::c_int;
- pub fn pthread_rwlockattr_init(attr: *mut pthread_rwlockattr_t) -> ::c_int;
- pub fn pthread_rwlockattr_destroy(attr: *mut pthread_rwlockattr_t)
- -> ::c_int;
-
- #[cfg_attr(target_os = "illumos", link_name = "__xnet_getsockopt")]
- pub fn getsockopt(sockfd: ::c_int,
- level: ::c_int,
- optname: ::c_int,
- optval: *mut ::c_void,
- optlen: *mut ::socklen_t) -> ::c_int;
- pub fn raise(signum: ::c_int) -> ::c_int;
- #[cfg_attr(target_os = "netbsd", link_name = "__sigaction14")]
- pub fn sigaction(signum: ::c_int,
- act: *const sigaction,
- oldact: *mut sigaction) -> ::c_int;
-
- #[cfg_attr(target_os = "netbsd", link_name = "__utimes50")]
- pub fn utimes(filename: *const ::c_char,
- times: *const ::timeval) -> ::c_int;
- pub fn dlopen(filename: *const ::c_char,
- flag: ::c_int) -> *mut ::c_void;
- pub fn dlerror() -> *mut ::c_char;
- pub fn dlsym(handle: *mut ::c_void,
- symbol: *const ::c_char) -> *mut ::c_void;
- pub fn dlclose(handle: *mut ::c_void) -> ::c_int;
- pub fn dladdr(addr: *const ::c_void, info: *mut Dl_info) -> ::c_int;
-
- pub fn getaddrinfo(node: *const c_char,
- service: *const c_char,
- hints: *const addrinfo,
- res: *mut *mut addrinfo) -> ::c_int;
- pub fn freeaddrinfo(res: *mut addrinfo);
- pub fn gai_strerror(errcode: ::c_int) -> *const ::c_char;
- #[cfg_attr(any(
- all(target_os = "linux", not(target_env = "musl")),
- target_os = "freebsd",
- target_os = "dragonfly",
- target_os = "haiku"),
- link_name = "__res_init")]
- #[cfg_attr(any(target_os = "macos", target_os = "ios"),
- link_name = "res_9_init")]
- pub fn res_init() -> ::c_int;
-
- #[cfg_attr(target_os = "netbsd", link_name = "__gmtime_r50")]
- pub fn gmtime_r(time_p: *const time_t, result: *mut tm) -> *mut tm;
- #[cfg_attr(target_os = "netbsd", link_name = "__localtime_r50")]
- pub fn localtime_r(time_p: *const time_t, result: *mut tm) -> *mut tm;
- #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
- link_name = "mktime$UNIX2003")]
- #[cfg_attr(target_os = "netbsd", link_name = "__mktime50")]
- pub fn mktime(tm: *mut tm) -> time_t;
- #[cfg_attr(target_os = "netbsd", link_name = "__time50")]
- pub fn time(time: *mut time_t) -> time_t;
- #[cfg_attr(target_os = "netbsd", link_name = "__gmtime50")]
- pub fn gmtime(time_p: *const time_t) -> *mut tm;
- #[cfg_attr(target_os = "netbsd", link_name = "__locatime50")]
- pub fn localtime(time_p: *const time_t) -> *mut tm;
- #[cfg_attr(target_os = "netbsd", link_name = "__difftime50")]
- pub fn difftime(time1: time_t, time0: time_t) -> ::c_double;
-
- #[cfg_attr(target_os = "netbsd", link_name = "__mknod50")]
- #[cfg_attr(
- all(target_os = "freebsd", not(freebsd12)),
- link_name = "mknod@FBSD_1.0"
- )]
- pub fn mknod(pathname: *const ::c_char, mode: ::mode_t,
- dev: ::dev_t) -> ::c_int;
- pub fn gethostname(name: *mut ::c_char, len: ::size_t) -> ::c_int;
- pub fn getservbyname(name: *const ::c_char,
- proto: *const ::c_char) -> *mut servent;
- pub fn getprotobyname(name: *const ::c_char) -> *mut protoent;
- pub fn getprotobynumber(proto: ::c_int) -> *mut protoent;
- pub fn chroot(name: *const ::c_char) -> ::c_int;
- #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
- link_name = "usleep$UNIX2003")]
- pub fn usleep(secs: ::c_uint) -> ::c_int;
- #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
- link_name = "send$UNIX2003")]
- pub fn send(socket: ::c_int, buf: *const ::c_void, len: ::size_t,
- flags: ::c_int) -> ::ssize_t;
- #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
- link_name = "recv$UNIX2003")]
- pub fn recv(socket: ::c_int, buf: *mut ::c_void, len: ::size_t,
- flags: ::c_int) -> ::ssize_t;
- #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
- link_name = "putenv$UNIX2003")]
- #[cfg_attr(target_os = "netbsd", link_name = "__putenv50")]
- pub fn putenv(string: *mut c_char) -> ::c_int;
- #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
- link_name = "poll$UNIX2003")]
- pub fn poll(fds: *mut pollfd, nfds: nfds_t, timeout: ::c_int) -> ::c_int;
- #[cfg_attr(all(target_os = "macos", target_arch = "x86_64"),
- link_name = "select$1050")]
- #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
- link_name = "select$UNIX2003")]
- #[cfg_attr(target_os = "netbsd", link_name = "__select50")]
- pub fn select(nfds: ::c_int,
- readfs: *mut fd_set,
- writefds: *mut fd_set,
- errorfds: *mut fd_set,
- timeout: *mut timeval) -> ::c_int;
- #[cfg_attr(target_os = "netbsd", link_name = "__setlocale50")]
- pub fn setlocale(category: ::c_int,
- locale: *const ::c_char) -> *mut ::c_char;
- pub fn localeconv() -> *mut lconv;
-
- #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
- link_name = "sem_wait$UNIX2003")]
- pub fn sem_wait(sem: *mut sem_t) -> ::c_int;
- pub fn sem_trywait(sem: *mut sem_t) -> ::c_int;
- pub fn sem_post(sem: *mut sem_t) -> ::c_int;
- pub fn statvfs(path: *const c_char, buf: *mut statvfs) -> ::c_int;
- pub fn fstatvfs(fd: ::c_int, buf: *mut statvfs) -> ::c_int;
-
- pub fn readlink(path: *const c_char,
- buf: *mut c_char,
- bufsz: ::size_t)
- -> ::ssize_t;
-
- #[cfg_attr(target_os = "netbsd", link_name = "__sigemptyset14")]
- pub fn sigemptyset(set: *mut sigset_t) -> ::c_int;
- #[cfg_attr(target_os = "netbsd", link_name = "__sigaddset14")]
- pub fn sigaddset(set: *mut sigset_t, signum: ::c_int) -> ::c_int;
- #[cfg_attr(target_os = "netbsd", link_name = "__sigfillset14")]
- pub fn sigfillset(set: *mut sigset_t) -> ::c_int;
- #[cfg_attr(target_os = "netbsd", link_name = "__sigdelset14")]
- pub fn sigdelset(set: *mut sigset_t, signum: ::c_int) -> ::c_int;
- #[cfg_attr(target_os = "netbsd", link_name = "__sigismember14")]
- pub fn sigismember(set: *const sigset_t, signum: ::c_int) -> ::c_int;
-
- #[cfg_attr(target_os = "netbsd", link_name = "__sigprocmask14")]
- pub fn sigprocmask(how: ::c_int,
- set: *const sigset_t,
- oldset: *mut sigset_t)
- -> ::c_int;
- #[cfg_attr(target_os = "netbsd", link_name = "__sigpending14")]
- pub fn sigpending(set: *mut sigset_t) -> ::c_int;
-
- #[cfg_attr(target_os = "netbsd", link_name = "__timegm50")]
- pub fn timegm(tm: *mut ::tm) -> time_t;
-
- pub fn getsid(pid: pid_t) -> pid_t;
-
- pub fn sysconf(name: ::c_int) -> ::c_long;
-
- pub fn mkfifo(path: *const c_char, mode: mode_t) -> ::c_int;
-
- #[cfg_attr(all(target_os = "macos", target_arch = "x86_64"),
- link_name = "pselect$1050")]
- #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
- link_name = "pselect$UNIX2003")]
- #[cfg_attr(target_os = "netbsd", link_name = "__pselect50")]
- pub fn pselect(nfds: ::c_int,
- readfs: *mut fd_set,
- writefds: *mut fd_set,
- errorfds: *mut fd_set,
- timeout: *const timespec,
- sigmask: *const sigset_t) -> ::c_int;
- pub fn fseeko(stream: *mut ::FILE,
- offset: ::off_t,
- whence: ::c_int) -> ::c_int;
- pub fn ftello(stream: *mut ::FILE) -> ::off_t;
- #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
- link_name = "tcdrain$UNIX2003")]
- pub fn tcdrain(fd: ::c_int) -> ::c_int;
- pub fn cfgetispeed(termios: *const ::termios) -> ::speed_t;
- pub fn cfgetospeed(termios: *const ::termios) -> ::speed_t;
- pub fn cfsetispeed(termios: *mut ::termios, speed: ::speed_t) -> ::c_int;
- pub fn cfsetospeed(termios: *mut ::termios, speed: ::speed_t) -> ::c_int;
- pub fn tcgetattr(fd: ::c_int, termios: *mut ::termios) -> ::c_int;
- pub fn tcsetattr(fd: ::c_int,
- optional_actions: ::c_int,
- termios: *const ::termios) -> ::c_int;
- pub fn tcflow(fd: ::c_int, action: ::c_int) -> ::c_int;
- pub fn tcflush(fd: ::c_int, action: ::c_int) -> ::c_int;
- pub fn tcgetsid(fd: ::c_int) -> ::pid_t;
- pub fn tcsendbreak(fd: ::c_int, duration: ::c_int) -> ::c_int;
- pub fn mkstemp(template: *mut ::c_char) -> ::c_int;
- pub fn mkdtemp(template: *mut ::c_char) -> *mut ::c_char;
-
- pub fn tmpnam(ptr: *mut ::c_char) -> *mut ::c_char;
-
- 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")]
- pub fn nice(incr: ::c_int) -> ::c_int;
-
- pub fn grantpt(fd: ::c_int) -> ::c_int;
- 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! {
- if #[cfg(not(any(target_os = "solaris", target_os = "illumos")))] {
- extern {
- pub fn cfmakeraw(termios: *mut ::termios);
- pub fn cfsetspeed(termios: *mut ::termios,
- speed: ::speed_t) -> ::c_int;
- }
- }
-}
-
-cfg_if! {
- if #[cfg(target_env = "uclibc")] {
- mod uclibc;
- pub use self::uclibc::*;
- } else if #[cfg(target_env = "newlib")] {
- mod newlib;
- pub use self::newlib::*;
- } else if #[cfg(any(target_os = "linux",
- target_os = "android",
- target_os = "emscripten"))] {
- mod notbsd;
- pub use self::notbsd::*;
- } else if #[cfg(any(target_os = "macos",
- target_os = "ios",
- target_os = "freebsd",
- target_os = "dragonfly",
- target_os = "openbsd",
- target_os = "netbsd"))] {
- mod bsd;
- pub use self::bsd::*;
- } else if #[cfg(any(target_os = "solaris",
- target_os = "illumos"))] {
- mod solarish;
- pub use self::solarish::*;
- } 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 if #[cfg(target_os = "redox")] {
- mod redox;
- pub use self::redox::*;
- } else {
- // Unknown target_os
- }
-}
-
-cfg_if! {
- if #[cfg(libc_core_cvoid)] {
- pub use ::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)]
- #[allow(missing_copy_implementations)]
- #[allow(missing_debug_implementations)]
- pub enum c_void {
- // Two dummy variants so the #[repr] attribute can be used.
- #[doc(hidden)]
- __variant1,
- #[doc(hidden)]
- __variant2,
- }
- }
-}
-
-cfg_if! {
- if #[cfg(libc_align)] {
- mod align;
- pub use self::align::*;
- } else {
- mod no_align;
- pub use self::no_align::*;
- }
-}
diff --git a/libc/src/unix/newlib/aarch64/mod.rs b/libc/src/unix/newlib/aarch64/mod.rs
deleted file mode 100644
index 96f381a..0000000
--- a/libc/src/unix/newlib/aarch64/mod.rs
+++ /dev/null
@@ -1,5 +0,0 @@
-pub type c_char = u8;
-pub type wchar_t = u32;
-
-pub type c_long = i64;
-pub type c_ulong = u64;
diff --git a/libc/src/unix/newlib/align.rs b/libc/src/unix/newlib/align.rs
deleted file mode 100644
index c018fbc..0000000
--- a/libc/src/unix/newlib/align.rs
+++ /dev/null
@@ -1,61 +0,0 @@
-macro_rules! expand_align {
- () => {
- s! {
- #[cfg_attr(all(target_pointer_width = "32",
- any(target_arch = "mips",
- target_arch = "arm",
- target_arch = "powerpc")),
- repr(align(4)))]
- #[cfg_attr(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
- size: [u8; ::__SIZEOF_PTHREAD_MUTEX_T],
- }
-
- #[cfg_attr(all(target_pointer_width = "32",
- any(target_arch = "mips",
- target_arch = "arm",
- target_arch = "powerpc")),
- repr(align(4)))]
- #[cfg_attr(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
- size: [u8; ::__SIZEOF_PTHREAD_RWLOCK_T],
- }
-
- #[cfg_attr(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(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
- size: [u8; ::__SIZEOF_PTHREAD_MUTEXATTR_T],
- }
-
- #[repr(align(8))]
- pub struct pthread_cond_t { // Unverified
- size: [u8; ::__SIZEOF_PTHREAD_COND_T],
- }
-
- #[repr(align(4))]
- pub struct pthread_condattr_t { // Unverified
- size: [u8; ::__SIZEOF_PTHREAD_CONDATTR_T],
- }
- }
- }
-}
diff --git a/libc/src/unix/newlib/arm/mod.rs b/libc/src/unix/newlib/arm/mod.rs
deleted file mode 100644
index 372a48c..0000000
--- a/libc/src/unix/newlib/arm/mod.rs
+++ /dev/null
@@ -1,5 +0,0 @@
-pub type c_char = u8;
-pub type wchar_t = u32;
-
-pub type c_long = i32;
-pub type c_ulong = u32;
diff --git a/libc/src/unix/newlib/mod.rs b/libc/src/unix/newlib/mod.rs
deleted file mode 100644
index f27874c..0000000
--- a/libc/src/unix/newlib/mod.rs
+++ /dev/null
@@ -1,717 +0,0 @@
-pub type blkcnt_t = i32;
-pub type blksize_t = i32;
-pub type clock_t = i32;
-pub type clockid_t = ::c_ulong;
-pub type dev_t = u32;
-pub type fsblkcnt_t = u64;
-pub type fsfilcnt_t = u32;
-pub type id_t = u32;
-pub type ino_t = u32;
-pub type key_t = ::c_int;
-pub type loff_t = ::c_longlong;
-pub type mode_t = ::c_uint;
-pub type nfds_t = u32;
-pub type nlink_t = ::c_ushort;
-pub type off_t = i64;
-pub type pthread_t = ::c_ulong;
-pub type pthread_key_t = ::c_uint;
-pub type rlim_t = u32;
-pub type sa_family_t = u8;
-pub type socklen_t = u32;
-pub type speed_t = u32;
-pub type suseconds_t = i32;
-pub type tcflag_t = ::c_uint;
-pub type time_t = i32;
-pub type useconds_t = u32;
-
-s! {
- pub struct sockaddr {
- pub sa_family: sa_family_t,
- pub sa_data: [::c_char; 14],
- }
-
- pub struct sockaddr_in {
- pub sin_family: sa_family_t,
- pub sin_port: ::in_port_t,
- pub sin_addr: ::in_addr,
- pub sin_zero: [u8; 8],
- }
-
- pub struct sockaddr_in6 { // Unverified
- pub sin6_family: sa_family_t,
- pub sin6_port: ::in_port_t,
- pub sin6_flowinfo: u32,
- pub sin6_addr: ::in6_addr,
- pub sin6_scope_id: u32,
- }
-
- pub struct sockaddr_storage {
- pub ss_family: sa_family_t,
- pub __ss_padding: [u8; 26],
- }
-
- 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_canonname: *mut ::c_char,
- pub ai_addr: *mut sockaddr,
- pub ai_next: *mut addrinfo,
- }
-
- pub struct ip_mreq {
- pub imr_multiaddr: in_addr,
- pub imr_interface: in_addr,
- }
-
- pub struct linger {
- pub l_onoff: ::c_int,
- pub l_linger: ::c_int,
- }
-
- pub struct in_addr {
- pub s_addr: ::in_addr_t,
- }
-
- pub struct hostent {
- pub h_name: *mut ::c_char,
- pub h_aliases: *mut *mut ::c_char,
- pub h_addrtype: ::c_int,
- pub h_length: ::c_int,
- pub h_addr_list: *mut *mut ::c_char,
- pub h_addr: *mut ::c_char,
- }
-
- pub struct pollfd {
- pub fd: ::c_int,
- pub events: ::c_int,
- pub revents: ::c_int,
- }
-
- 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_n_cs_precedes: ::c_char,
- pub int_n_sep_by_space: ::c_char,
- pub int_n_sign_posn: ::c_char,
- pub int_p_cs_precedes: ::c_char,
- pub int_p_sep_by_space: ::c_char,
- pub int_p_sign_posn: ::c_char,
- }
-
- 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 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_spare1: ::c_long,
- pub st_mtime: time_t,
- pub st_spare2: ::c_long,
- pub st_ctime: time_t,
- pub st_spare3: ::c_long,
- pub st_blksize: blksize_t,
- pub st_blocks: blkcnt_t,
- pub st_spare4: [::c_long; 2usize],
- }
-
- 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,
- }
-
- pub struct sigset_t {
- __val: [::c_ulong; 16],
- }
-
- pub struct sigaction {
- pub sa_handler: extern fn(arg1: ::c_int),
- pub sa_mask: sigset_t,
- pub sa_flags: ::c_int,
- }
-
- pub struct dirent {
- pub d_ino: ino_t,
- pub d_type: ::c_uchar,
- pub d_name: [::c_char; 256usize],
- }
-
- pub struct stack_t {
- pub ss_sp: *mut ::c_void,
- pub ss_flags: ::c_int,
- pub ss_size: usize,
- }
-
- pub struct fd_set { // Unverified
- fds_bits: [::c_ulong; FD_SETSIZE / ULONG_SIZE],
- }
-
- 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 termios { // Unverified
- pub c_iflag: ::tcflag_t,
- pub c_oflag: ::tcflag_t,
- pub c_cflag: ::tcflag_t,
- pub c_lflag: ::tcflag_t,
- pub c_line: ::cc_t,
- pub c_cc: [::cc_t; ::NCCS],
- }
-
- pub struct sem_t { // Unverified
- __size: [::c_char; 16],
- }
-
- pub struct Dl_info { // Unverified
- pub dli_fname: *const ::c_char,
- pub dli_fbase: *mut ::c_void,
- pub dli_sname: *const ::c_char,
- pub dli_saddr: *mut ::c_void,
- }
-
- pub struct utsname { // Unverified
- pub sysname: [::c_char; 65],
- pub nodename: [::c_char; 65],
- pub release: [::c_char; 65],
- pub version: [::c_char; 65],
- pub machine: [::c_char; 65],
- pub domainname: [::c_char; 65]
- }
-
- pub struct cpu_set_t { // Unverified
- bits: [u32; 32],
- }
-
- pub struct pthread_attr_t { // Unverified
- __size: [u64; 7]
- }
-
- pub struct pthread_rwlockattr_t { // Unverified
- __lockkind: ::c_int,
- __pshared: ::c_int,
- }
-}
-
-// unverified constants
-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;
-pub const __SIZEOF_PTHREAD_MUTEXATTR_T: usize = 4;
-pub const __SIZEOF_PTHREAD_COND_T: usize = 48;
-pub const __SIZEOF_PTHREAD_CONDATTR_T: usize = 4;
-pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 56;
-pub const __SIZEOF_PTHREAD_RWLOCKATTR_T: usize = 8;
-pub const __SIZEOF_PTHREAD_BARRIER_T: usize = 32;
-pub const __SIZEOF_PTHREAD_BARRIERATTR_T: usize = 4;
-pub const __PTHREAD_MUTEX_HAVE_PREV: usize = 1;
-pub const __PTHREAD_RWLOCK_INT_FLAGS_SHARED: usize = 1;
-pub const PTHREAD_MUTEX_NORMAL: ::c_int = 0;
-pub const PTHREAD_MUTEX_RECURSIVE: ::c_int = 1;
-pub const PTHREAD_MUTEX_ERRORCHECK: ::c_int = 2;
-pub const FD_SETSIZE: usize = 1024;
-// intentionally not public, only used for fd_set
-const ULONG_SIZE: usize = 32;
-
-// Other constants
-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 ENOMSG: ::c_int = 35;
-pub const EIDRM: ::c_int = 36;
-pub const EDEADLK: ::c_int = 45;
-pub const ENOLCK: ::c_int = 46;
-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 ENOLINK: ::c_int = 67;
-pub const EPROTO: ::c_int = 71;
-pub const EMULTIHOP: ::c_int = 74;
-pub const EBADMSG: ::c_int = 77;
-pub const EFTYPE: ::c_int = 79;
-pub const ENOSYS: ::c_int = 88;
-pub const ENOTEMPTY: ::c_int = 90;
-pub const ENAMETOOLONG: ::c_int = 91;
-pub const ELOOP: ::c_int = 92;
-pub const EOPNOTSUPP: ::c_int = 95;
-pub const EPFNOSUPPORT: ::c_int = 96;
-pub const ECONNRESET: ::c_int = 104;
-pub const ENOBUFS: ::c_int = 105;
-pub const EAFNOSUPPORT: ::c_int = 106;
-pub const EPROTOTYPE: ::c_int = 107;
-pub const ENOTSOCK: ::c_int = 108;
-pub const ENOPROTOOPT: ::c_int = 109;
-pub const ECONNREFUSED: ::c_int = 111;
-pub const EADDRINUSE: ::c_int = 112;
-pub const ECONNABORTED: ::c_int = 113;
-pub const ENETUNREACH: ::c_int = 114;
-pub const ENETDOWN: ::c_int = 115;
-pub const ETIMEDOUT: ::c_int = 116;
-pub const EHOSTDOWN: ::c_int = 117;
-pub const EHOSTUNREACH: ::c_int = 118;
-pub const EINPROGRESS: ::c_int = 119;
-pub const EALREADY: ::c_int = 120;
-pub const EDESTADDRREQ: ::c_int = 121;
-pub const EMSGSIZE: ::c_int = 122;
-pub const EPROTONOSUPPORT: ::c_int = 123;
-pub const EADDRNOTAVAIL: ::c_int = 125;
-pub const ENETRESET: ::c_int = 126;
-pub const EISCONN: ::c_int = 127;
-pub const ENOTCONN: ::c_int = 128;
-pub const ETOOMANYREFS: ::c_int = 129;
-pub const EDQUOT: ::c_int = 132;
-pub const ESTALE: ::c_int = 133;
-pub const ENOTSUP: ::c_int = 134;
-pub const EILSEQ: ::c_int = 138;
-pub const EOVERFLOW: ::c_int = 139;
-pub const ECANCELED: ::c_int = 140;
-pub const ENOTRECOVERABLE: ::c_int = 141;
-pub const EOWNERDEAD: ::c_int = 142;
-pub const EWOULDBLOCK: ::c_int = 11;
-
-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 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 = 8;
-pub const O_CREAT: ::c_int = 512;
-pub const O_TRUNC: ::c_int = 1024;
-pub const O_EXCL: ::c_int = 2048;
-pub const O_SYNC: ::c_int = 8192;
-pub const O_NONBLOCK: ::c_int = 16384;
-
-pub const O_ACCMODE: ::c_int = 3;
-pub const O_CLOEXEC: ::c_int = 0x80000;
-
-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 RTLD_LAZY: ::c_int = 0x1;
-
-pub const STDIN_FILENO: ::c_int = 0;
-pub const STDOUT_FILENO: ::c_int = 1;
-pub const STDERR_FILENO: ::c_int = 2;
-
-pub const SEEK_SET: ::c_int = 0;
-pub const SEEK_CUR: ::c_int = 1;
-pub const SEEK_END: ::c_int = 2;
-
-pub const FIONBIO: ::c_ulong = 1;
-pub const FIOCLEX: ::c_ulong = 0x20006601;
-
-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 SOL_SOCKET: ::c_int = 65535;
-pub const SOL_TCP: ::c_int = 6;
-
-pub const PF_UNSPEC: ::c_int = 0;
-pub const PF_INET: ::c_int = 2;
-pub const PF_INET6: ::c_int = 23;
-
-pub const AF_UNSPEC: ::c_int = 0;
-pub const AF_INET: ::c_int = 2;
-pub const AF_INET6: ::c_int = 23;
-
-pub const SOCK_STREAM: ::c_int = 1;
-pub const SOCK_DGRAM: ::c_int = 2;
-
-pub const MSG_OOB: ::c_int = 1;
-pub const MSG_PEEK: ::c_int = 2;
-pub const MSG_DONTWAIT: ::c_int = 4;
-pub const MSG_DONTROUTE: ::c_int = 0;
-pub const MSG_WAITALL: ::c_int = 0;
-pub const MSG_MORE: ::c_int = 0;
-pub const MSG_NOSIGNAL: ::c_int = 0;
-
-pub const SHUT_RD: ::c_int = 0;
-pub const SHUT_WR: ::c_int = 1;
-pub const SHUT_RDWR: ::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;
-pub const SO_LISTENQLEN: ::c_int = 0x1012;
-pub const SO_LISTENINCQLEN: ::c_int = 0x1013;
-pub const SO_SETFIB: ::c_int = 0x1014;
-pub const SO_USER_COOKIE: ::c_int = 0x1015;
-pub const SO_PROTOCOL: ::c_int = 0x1016;
-pub const SO_PROTOTYPE: ::c_int = SO_PROTOCOL;
-pub const SO_VENDOR: ::c_int = 0x80000000;
-pub const SO_DEBUG: ::c_int = 0x01;
-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_TIMESTAMP: ::c_int = 0x0400;
-pub const SO_NOSIGPIPE: ::c_int = 0x0800;
-pub const SO_ACCEPTFILTER: ::c_int = 0x1000;
-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 SOCK_CLOEXEC: ::c_int = O_CLOEXEC;
-
-pub const INET_ADDRSTRLEN: ::c_int = 16;
-
-// https://github.
-// com/bminor/newlib/blob/master/newlib/libc/sys/linux/include/net/if.h#L121
-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_ALTPHYS: ::c_int = IFF_LINK2; // use alternate physical connection
-pub const IFF_MULTICAST: ::c_int = 0x8000; // supports multicast
-
-pub const TCP_NODELAY: ::c_int = 8193;
-pub const TCP_MAXSEG: ::c_int = 8194;
-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 IP_TOS: ::c_int = 3;
-pub const IP_TTL: ::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_ADD_MEMBERSHIP: ::c_int = 11;
-pub const IP_DROP_MEMBERSHIP: ::c_int = 12;
-
-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;
-pub const IPV6_JOIN_GROUP: ::c_int = 12;
-pub const IPV6_LEAVE_GROUP: ::c_int = 13;
-pub const IPV6_ADD_MEMBERSHIP: ::c_int = 12;
-pub const IPV6_DROP_MEMBERSHIP: ::c_int = 13;
-
-pub const HOST_NOT_FOUND: ::c_int = 1;
-pub const NO_DATA: ::c_int = 2;
-pub const NO_ADDRESS: ::c_int = 2;
-pub const NO_RECOVERY: ::c_int = 3;
-pub const TRY_AGAIN: ::c_int = 4;
-
-pub const AI_PASSIVE: ::c_int = 1;
-pub const AI_CANONNAME: ::c_int = 2;
-pub const AI_NUMERICHOST: ::c_int = 4;
-pub const AI_NUMERICSERV: ::c_int = 0;
-pub const AI_ADDRCONFIG: ::c_int = 0;
-
-pub const NI_MAXHOST: ::c_int = 1025;
-pub const NI_MAXSERV: ::c_int = 32;
-pub const NI_NOFQDN: ::c_int = 1;
-pub const NI_NUMERICHOST: ::c_int = 2;
-pub const NI_NAMEREQD: ::c_int = 4;
-pub const NI_NUMERICSERV: ::c_int = 0;
-pub const NI_DGRAM: ::c_int = 0;
-
-pub const EAI_FAMILY: ::c_int = -303;
-pub const EAI_MEMORY: ::c_int = -304;
-pub const EAI_NONAME: ::c_int = -305;
-pub const EAI_SOCKTYPE: ::c_int = -307;
-
-f! {
- 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;
- (*set).fds_bits[fd / bits] &= !(1 << (fd % bits));
- return
- }
-
- pub fn FD_ISSET(fd: ::c_int, set: *mut fd_set) -> bool {
- let bits = ::mem::size_of_val(&(*set).fds_bits[0]) * 8;
- let fd = fd as usize;
- return ((*set).fds_bits[fd / bits] & (1 << (fd % bits))) != 0
- }
-
- pub fn FD_SET(fd: ::c_int, set: *mut fd_set) -> () {
- let bits = ::mem::size_of_val(&(*set).fds_bits[0]) * 8;
- let fd = fd as usize;
- (*set).fds_bits[fd / bits] |= 1 << (fd % bits);
- return
- }
-
- pub fn FD_ZERO(set: *mut fd_set) -> () {
- for slot in (*set).fds_bits.iter_mut() {
- *slot = 0;
- }
- }
-}
-
-extern {
- pub fn getrlimit(resource: ::c_int, rlim: *mut ::rlimit) -> ::c_int;
- pub fn setrlimit(resource: ::c_int, rlim: *const ::rlimit) -> ::c_int;
-
- #[cfg_attr(target_os = "linux",
- link_name = "__xpg_strerror_r")]
- pub fn strerror_r(errnum: ::c_int, buf: *mut c_char,
- buflen: ::size_t) -> ::c_int;
-
- pub fn sem_destroy(sem: *mut sem_t) -> ::c_int;
- pub fn sem_init(sem: *mut sem_t,
- pshared: ::c_int,
- value: ::c_uint)
- -> ::c_int;
-
- 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;
- pub fn recvfrom(fd: ::c_int, buf: *mut ::c_void, n: usize, flags: ::c_int,
- addr: *mut sockaddr, addr_len: *mut socklen_t) -> isize;
- pub fn getnameinfo(sa: *const sockaddr, salen: socklen_t,
- host: *mut ::c_char, hostlen: socklen_t,
- serv: *mut ::c_char, servlen: socklen_t,
- flags: ::c_int) -> ::c_int;
- pub fn memalign(align: ::size_t, size: ::size_t) -> *mut ::c_void;
- pub fn fexecve(fd: ::c_int, argv: *const *const ::c_char,
- envp: *const *const ::c_char)
- -> ::c_int;
- pub fn gettimeofday(tp: *mut ::timeval,
- tz: *mut ::c_void) -> ::c_int;
- #[cfg_attr(target_os = "solaris", link_name = "__posix_getgrgid_r")]
- pub fn getgrgid_r(gid: ::gid_t,
- grp: *mut ::group,
- buf: *mut ::c_char,
- buflen: ::size_t,
- result: *mut *mut ::group) -> ::c_int;
- #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
- link_name = "sigaltstack$UNIX2003")]
- #[cfg_attr(target_os = "netbsd", link_name = "__sigaltstack14")]
- pub fn sigaltstack(ss: *const stack_t,
- oss: *mut stack_t) -> ::c_int;
- pub fn sem_close(sem: *mut sem_t) -> ::c_int;
- pub fn getdtablesize() -> ::c_int;
- #[cfg_attr(target_os = "solaris", link_name = "__posix_getgrnam_r")]
- pub fn getgrnam_r(name: *const ::c_char,
- grp: *mut ::group,
- buf: *mut ::c_char,
- buflen: ::size_t,
- result: *mut *mut ::group) -> ::c_int;
- #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
- link_name = "pthread_sigmask$UNIX2003")]
- pub fn pthread_sigmask(how: ::c_int, set: *const sigset_t,
- oldset: *mut sigset_t) -> ::c_int;
- pub fn sem_open(name: *const ::c_char, oflag: ::c_int, ...) -> *mut sem_t;
- pub fn getgrnam(name: *const ::c_char) -> *mut ::group;
- pub fn pthread_kill(thread: ::pthread_t, sig: ::c_int) -> ::c_int;
- pub fn sem_unlink(name: *const ::c_char) -> ::c_int;
- pub fn daemon(nochdir: ::c_int, noclose: ::c_int) -> ::c_int;
- #[cfg_attr(target_os = "netbsd", link_name = "__getpwnam_r50")]
- #[cfg_attr(target_os = "solaris", link_name = "__posix_getpwnam_r")]
- pub fn getpwnam_r(name: *const ::c_char,
- pwd: *mut passwd,
- buf: *mut ::c_char,
- buflen: ::size_t,
- result: *mut *mut passwd) -> ::c_int;
- #[cfg_attr(target_os = "netbsd", link_name = "__getpwuid_r50")]
- #[cfg_attr(target_os = "solaris", link_name = "__posix_getpwuid_r")]
- pub fn getpwuid_r(uid: ::uid_t,
- pwd: *mut passwd,
- buf: *mut ::c_char,
- buflen: ::size_t,
- result: *mut *mut passwd) -> ::c_int;
- #[cfg_attr(all(target_os = "macos", target_arch ="x86"),
- link_name = "sigwait$UNIX2003")]
- #[cfg_attr(target_os = "solaris", link_name = "__posix_sigwait")]
- pub fn sigwait(set: *const sigset_t,
- sig: *mut ::c_int) -> ::c_int;
- pub fn pthread_atfork(prepare: ::Option<unsafe extern fn()>,
- parent: ::Option<unsafe extern fn()>,
- child: ::Option<unsafe extern fn()>) -> ::c_int;
- pub fn getgrgid(gid: ::gid_t) -> *mut ::group;
- #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
- link_name = "popen$UNIX2003")]
- pub fn popen(command: *const c_char,
- mode: *const c_char) -> *mut ::FILE;
- pub fn uname(buf: *mut ::utsname) -> ::c_int;
-}
-
-cfg_if! {
- if #[cfg(target_arch = "arm")] {
- mod arm;
- pub use self::arm::*;
- } else if #[cfg(target_arch = "aarch64")] {
- mod aarch64;
- pub use self::aarch64::*;
- } else {
- // Only tested on ARM so far. Other platforms might have different
- // definitions for types and constants.
- pub use target_arch_not_implemented;
- }
-}
-
-cfg_if! {
- if #[cfg(libc_align)] {
- #[macro_use]
- mod align;
- } else {
- #[macro_use]
- mod no_align;
- }
-}
-expand_align!();
diff --git a/libc/src/unix/newlib/no_align.rs b/libc/src/unix/newlib/no_align.rs
deleted file mode 100644
index 316c464..0000000
--- a/libc/src/unix/newlib/no_align.rs
+++ /dev/null
@@ -1,51 +0,0 @@
-macro_rules! expand_align {
- () => {
- s! {
- pub struct pthread_mutex_t { // Unverified
- #[cfg(any(target_arch = "mips",
- target_arch = "arm",
- target_arch = "powerpc"))]
- __align: [::c_long; 0],
- #[cfg(not(any(target_arch = "mips",
- target_arch = "arm",
- target_arch = "powerpc")))]
- __align: [::c_longlong; 0],
- size: [u8; ::__SIZEOF_PTHREAD_MUTEX_T],
- }
-
- pub struct pthread_rwlock_t { // Unverified
- #[cfg(any(target_arch = "mips",
- target_arch = "arm",
- target_arch = "powerpc"))]
- __align: [::c_long; 0],
- #[cfg(not(any(target_arch = "mips",
- target_arch = "arm",
- target_arch = "powerpc")))]
- __align: [::c_longlong; 0],
- size: [u8; ::__SIZEOF_PTHREAD_RWLOCK_T],
- }
-
- 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",
- target_arch = "mips64", target_arch = "s390x",
- target_arch = "sparc64")))]
- __align: [::c_long; 0],
- size: [u8; ::__SIZEOF_PTHREAD_MUTEXATTR_T],
- }
-
- pub struct pthread_cond_t { // Unverified
- __align: [::c_longlong; 0],
- size: [u8; ::__SIZEOF_PTHREAD_COND_T],
- }
-
- pub struct pthread_condattr_t { // Unverified
- __align: [::c_int; 0],
- size: [u8; ::__SIZEOF_PTHREAD_CONDATTR_T],
- }
- }
- }
-}
diff --git a/libc/src/unix/no_align.rs b/libc/src/unix/no_align.rs
deleted file mode 100644
index f6b9f4c..0000000
--- a/libc/src/unix/no_align.rs
+++ /dev/null
@@ -1,6 +0,0 @@
-s! {
- pub struct in6_addr {
- pub s6_addr: [u8; 16],
- __align: [u32; 0],
- }
-}
diff --git a/libc/src/unix/notbsd/android/b32/arm.rs b/libc/src/unix/notbsd/android/b32/arm.rs
deleted file mode 100644
index 1320b16..0000000
--- a/libc/src/unix/notbsd/android/b32/arm.rs
+++ /dev/null
@@ -1,357 +0,0 @@
-pub type c_char = u8;
-pub type wchar_t = u32;
-
-pub const O_DIRECT: ::c_int = 0x10000;
-pub const O_DIRECTORY: ::c_int = 0x4000;
-pub const O_NOFOLLOW: ::c_int = 0x8000;
-pub const O_LARGEFILE: ::c_int = 0o400000;
-
-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_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_mknod: ::c_long = 14;
-pub const SYS_chmod: ::c_long = 15;
-pub const SYS_lchown: ::c_long = 16;
-pub const SYS_lseek: ::c_long = 19;
-pub const SYS_getpid: ::c_long = 20;
-pub const SYS_mount: ::c_long = 21;
-pub const SYS_setuid: ::c_long = 23;
-pub const SYS_getuid: ::c_long = 24;
-pub const SYS_ptrace: ::c_long = 26;
-pub const SYS_pause: ::c_long = 29;
-pub const SYS_access: ::c_long = 33;
-pub const SYS_nice: ::c_long = 34;
-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_brk: ::c_long = 45;
-pub const SYS_setgid: ::c_long = 46;
-pub const SYS_getgid: ::c_long = 47;
-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_ioctl: ::c_long = 54;
-pub const SYS_fcntl: ::c_long = 55;
-pub const SYS_setpgid: ::c_long = 57;
-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_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_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_symlink: ::c_long = 83;
-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_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_statfs: ::c_long = 99;
-pub const SYS_fstatfs: ::c_long = 100;
-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_vhangup: ::c_long = 111;
-pub const SYS_wait4: ::c_long = 114;
-pub const SYS_swapoff: ::c_long = 115;
-pub const SYS_sysinfo: ::c_long = 116;
-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_adjtimex: ::c_long = 124;
-pub const SYS_mprotect: ::c_long = 125;
-pub const SYS_sigprocmask: ::c_long = 126;
-pub const SYS_init_module: ::c_long = 128;
-pub const SYS_delete_module: ::c_long = 129;
-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_setfsuid: ::c_long = 138;
-pub const SYS_setfsgid: ::c_long = 139;
-pub const SYS_getdents: ::c_long = 141;
-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_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_poll: ::c_long = 168;
-pub const SYS_nfsservctl: ::c_long = 169;
-pub const SYS_setresgid: ::c_long = 170;
-pub const SYS_getresgid: ::c_long = 171;
-pub const SYS_prctl: ::c_long = 172;
-pub const SYS_rt_sigreturn: ::c_long = 173;
-pub const SYS_rt_sigaction: ::c_long = 174;
-pub const SYS_rt_sigprocmask: ::c_long = 175;
-pub const SYS_rt_sigpending: ::c_long = 176;
-pub const SYS_rt_sigtimedwait: ::c_long = 177;
-pub const SYS_rt_sigqueueinfo: ::c_long = 178;
-pub const SYS_rt_sigsuspend: ::c_long = 179;
-pub const SYS_pread64: ::c_long = 180;
-pub const SYS_pwrite64: ::c_long = 181;
-pub const SYS_chown: ::c_long = 182;
-pub const SYS_getcwd: ::c_long = 183;
-pub const SYS_capget: ::c_long = 184;
-pub const SYS_capset: ::c_long = 185;
-pub const SYS_sigaltstack: ::c_long = 186;
-pub const SYS_sendfile: ::c_long = 187;
-pub const SYS_vfork: ::c_long = 190;
-pub const SYS_ugetrlimit: ::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_lchown32: ::c_long = 198;
-pub const SYS_getuid32: ::c_long = 199;
-pub const SYS_getgid32: ::c_long = 200;
-pub const SYS_geteuid32: ::c_long = 201;
-pub const SYS_getegid32: ::c_long = 202;
-pub const SYS_setreuid32: ::c_long = 203;
-pub const SYS_setregid32: ::c_long = 204;
-pub const SYS_getgroups32: ::c_long = 205;
-pub const SYS_setgroups32: ::c_long = 206;
-pub const SYS_fchown32: ::c_long = 207;
-pub const SYS_setresuid32: ::c_long = 208;
-pub const SYS_getresuid32: ::c_long = 209;
-pub const SYS_setresgid32: ::c_long = 210;
-pub const SYS_getresgid32: ::c_long = 211;
-pub const SYS_chown32: ::c_long = 212;
-pub const SYS_setuid32: ::c_long = 213;
-pub const SYS_setgid32: ::c_long = 214;
-pub const SYS_setfsuid32: ::c_long = 215;
-pub const SYS_setfsgid32: ::c_long = 216;
-pub const SYS_getdents64: ::c_long = 217;
-pub const SYS_pivot_root: ::c_long = 218;
-pub const SYS_mincore: ::c_long = 219;
-pub const SYS_madvise: ::c_long = 220;
-pub const SYS_fcntl64: ::c_long = 221;
-pub const SYS_gettid: ::c_long = 224;
-pub const SYS_readahead: ::c_long = 225;
-pub const SYS_setxattr: ::c_long = 226;
-pub const SYS_lsetxattr: ::c_long = 227;
-pub const SYS_fsetxattr: ::c_long = 228;
-pub const SYS_getxattr: ::c_long = 229;
-pub const SYS_lgetxattr: ::c_long = 230;
-pub const SYS_fgetxattr: ::c_long = 231;
-pub const SYS_listxattr: ::c_long = 232;
-pub const SYS_llistxattr: ::c_long = 233;
-pub const SYS_flistxattr: ::c_long = 234;
-pub const SYS_removexattr: ::c_long = 235;
-pub const SYS_lremovexattr: ::c_long = 236;
-pub const SYS_fremovexattr: ::c_long = 237;
-pub const SYS_tkill: ::c_long = 238;
-pub const SYS_sendfile64: ::c_long = 239;
-pub const SYS_futex: ::c_long = 240;
-pub const SYS_sched_setaffinity: ::c_long = 241;
-pub const SYS_sched_getaffinity: ::c_long = 242;
-pub const SYS_io_setup: ::c_long = 243;
-pub const SYS_io_destroy: ::c_long = 244;
-pub const SYS_io_getevents: ::c_long = 245;
-pub const SYS_io_submit: ::c_long = 246;
-pub const SYS_io_cancel: ::c_long = 247;
-pub const SYS_exit_group: ::c_long = 248;
-pub const SYS_lookup_dcookie: ::c_long = 249;
-pub const SYS_epoll_create: ::c_long = 250;
-pub const SYS_epoll_ctl: ::c_long = 251;
-pub const SYS_epoll_wait: ::c_long = 252;
-pub const SYS_remap_file_pages: ::c_long = 253;
-pub const SYS_set_tid_address: ::c_long = 256;
-pub const SYS_timer_create: ::c_long = 257;
-pub const SYS_timer_settime: ::c_long = 258;
-pub const SYS_timer_gettime: ::c_long = 259;
-pub const SYS_timer_getoverrun: ::c_long = 260;
-pub const SYS_timer_delete: ::c_long = 261;
-pub const SYS_clock_settime: ::c_long = 262;
-pub const SYS_clock_gettime: ::c_long = 263;
-pub const SYS_clock_getres: ::c_long = 264;
-pub const SYS_clock_nanosleep: ::c_long = 265;
-pub const SYS_statfs64: ::c_long = 266;
-pub const SYS_fstatfs64: ::c_long = 267;
-pub const SYS_tgkill: ::c_long = 268;
-pub const SYS_utimes: ::c_long = 269;
-pub const SYS_arm_fadvise64_64: ::c_long = 270;
-pub const SYS_pciconfig_iobase: ::c_long = 271;
-pub const SYS_pciconfig_read: ::c_long = 272;
-pub const SYS_pciconfig_write: ::c_long = 273;
-pub const SYS_mq_open: ::c_long = 274;
-pub const SYS_mq_unlink: ::c_long = 275;
-pub const SYS_mq_timedsend: ::c_long = 276;
-pub const SYS_mq_timedreceive: ::c_long = 277;
-pub const SYS_mq_notify: ::c_long = 278;
-pub const SYS_mq_getsetattr: ::c_long = 279;
-pub const SYS_waitid: ::c_long = 280;
-pub const SYS_socket: ::c_long = 281;
-pub const SYS_bind: ::c_long = 282;
-pub const SYS_connect: ::c_long = 283;
-pub const SYS_listen: ::c_long = 284;
-pub const SYS_accept: ::c_long = 285;
-pub const SYS_getsockname: ::c_long = 286;
-pub const SYS_getpeername: ::c_long = 287;
-pub const SYS_socketpair: ::c_long = 288;
-pub const SYS_send: ::c_long = 289;
-pub const SYS_sendto: ::c_long = 290;
-pub const SYS_recv: ::c_long = 291;
-pub const SYS_recvfrom: ::c_long = 292;
-pub const SYS_shutdown: ::c_long = 293;
-pub const SYS_setsockopt: ::c_long = 294;
-pub const SYS_getsockopt: ::c_long = 295;
-pub const SYS_sendmsg: ::c_long = 296;
-pub const SYS_recvmsg: ::c_long = 297;
-pub const SYS_semop: ::c_long = 298;
-pub const SYS_semget: ::c_long = 299;
-pub const SYS_semctl: ::c_long = 300;
-pub const SYS_msgsnd: ::c_long = 301;
-pub const SYS_msgrcv: ::c_long = 302;
-pub const SYS_msgget: ::c_long = 303;
-pub const SYS_msgctl: ::c_long = 304;
-pub const SYS_shmat: ::c_long = 305;
-pub const SYS_shmdt: ::c_long = 306;
-pub const SYS_shmget: ::c_long = 307;
-pub const SYS_shmctl: ::c_long = 308;
-pub const SYS_add_key: ::c_long = 309;
-pub const SYS_request_key: ::c_long = 310;
-pub const SYS_keyctl: ::c_long = 311;
-pub const SYS_semtimedop: ::c_long = 312;
-pub const SYS_vserver: ::c_long = 313;
-pub const SYS_ioprio_set: ::c_long = 314;
-pub const SYS_ioprio_get: ::c_long = 315;
-pub const SYS_inotify_init: ::c_long = 316;
-pub const SYS_inotify_add_watch: ::c_long = 317;
-pub const SYS_inotify_rm_watch: ::c_long = 318;
-pub const SYS_mbind: ::c_long = 319;
-pub const SYS_get_mempolicy: ::c_long = 320;
-pub const SYS_set_mempolicy: ::c_long = 321;
-pub const SYS_openat: ::c_long = 322;
-pub const SYS_mkdirat: ::c_long = 323;
-pub const SYS_mknodat: ::c_long = 324;
-pub const SYS_fchownat: ::c_long = 325;
-pub const SYS_futimesat: ::c_long = 326;
-pub const SYS_fstatat64: ::c_long = 327;
-pub const SYS_unlinkat: ::c_long = 328;
-pub const SYS_renameat: ::c_long = 329;
-pub const SYS_linkat: ::c_long = 330;
-pub const SYS_symlinkat: ::c_long = 331;
-pub const SYS_readlinkat: ::c_long = 332;
-pub const SYS_fchmodat: ::c_long = 333;
-pub const SYS_faccessat: ::c_long = 334;
-pub const SYS_pselect6: ::c_long = 335;
-pub const SYS_ppoll: ::c_long = 336;
-pub const SYS_unshare: ::c_long = 337;
-pub const SYS_set_robust_list: ::c_long = 338;
-pub const SYS_get_robust_list: ::c_long = 339;
-pub const SYS_splice: ::c_long = 340;
-pub const SYS_arm_sync_file_range: ::c_long = 341;
-pub const SYS_tee: ::c_long = 342;
-pub const SYS_vmsplice: ::c_long = 343;
-pub const SYS_move_pages: ::c_long = 344;
-pub const SYS_getcpu: ::c_long = 345;
-pub const SYS_epoll_pwait: ::c_long = 346;
-pub const SYS_kexec_load: ::c_long = 347;
-pub const SYS_utimensat: ::c_long = 348;
-pub const SYS_signalfd: ::c_long = 349;
-pub const SYS_timerfd_create: ::c_long = 350;
-pub const SYS_eventfd: ::c_long = 351;
-pub const SYS_fallocate: ::c_long = 352;
-pub const SYS_timerfd_settime: ::c_long = 353;
-pub const SYS_timerfd_gettime: ::c_long = 354;
-pub const SYS_signalfd4: ::c_long = 355;
-pub const SYS_eventfd2: ::c_long = 356;
-pub const SYS_epoll_create1: ::c_long = 357;
-pub const SYS_dup3: ::c_long = 358;
-pub const SYS_pipe2: ::c_long = 359;
-pub const SYS_inotify_init1: ::c_long = 360;
-pub const SYS_preadv: ::c_long = 361;
-pub const SYS_pwritev: ::c_long = 362;
-pub const SYS_rt_tgsigqueueinfo: ::c_long = 363;
-pub const SYS_perf_event_open: ::c_long = 364;
-pub const SYS_recvmmsg: ::c_long = 365;
-pub const SYS_accept4: ::c_long = 366;
-pub const SYS_fanotify_init: ::c_long = 367;
-pub const SYS_fanotify_mark: ::c_long = 368;
-pub const SYS_prlimit64: ::c_long = 369;
-pub const SYS_name_to_handle_at: ::c_long = 370;
-pub const SYS_open_by_handle_at: ::c_long = 371;
-pub const SYS_clock_adjtime: ::c_long = 372;
-pub const SYS_syncfs: ::c_long = 373;
-pub const SYS_sendmmsg: ::c_long = 374;
-pub const SYS_setns: ::c_long = 375;
-pub const SYS_process_vm_readv: ::c_long = 376;
-pub const SYS_process_vm_writev: ::c_long = 377;
-pub const SYS_kcmp: ::c_long = 378;
-pub const SYS_finit_module: ::c_long = 379;
-pub const SYS_sched_setattr: ::c_long = 380;
-pub const SYS_sched_getattr: ::c_long = 381;
-pub const SYS_renameat2: ::c_long = 382;
-pub const SYS_seccomp: ::c_long = 383;
-pub const SYS_getrandom: ::c_long = 384;
-pub const SYS_memfd_create: ::c_long = 385;
-pub const SYS_bpf: ::c_long = 386;
-pub const SYS_execveat: ::c_long = 387;
-pub const SYS_userfaultfd: ::c_long = 388;
-pub const SYS_membarrier: ::c_long = 389;
-pub const SYS_mlock2: ::c_long = 390;
-pub const SYS_copy_file_range: ::c_long = 391;
-pub const SYS_preadv2: ::c_long = 392;
-pub const SYS_pwritev2: ::c_long = 393;
-pub const SYS_pkey_mprotect: ::c_long = 394;
-pub const SYS_pkey_alloc: ::c_long = 395;
-pub const SYS_pkey_free: ::c_long = 396;
diff --git a/libc/src/unix/notbsd/android/b32/mod.rs b/libc/src/unix/notbsd/android/b32/mod.rs
deleted file mode 100644
index e8fd20e..0000000
--- a/libc/src/unix/notbsd/android/b32/mod.rs
+++ /dev/null
@@ -1,223 +0,0 @@
-// The following definitions are correct for arm and i686,
-// but may be wrong for mips
-
-pub type c_long = i32;
-pub type c_ulong = u32;
-pub type mode_t = u16;
-pub type off64_t = ::c_longlong;
-pub type sigset_t = ::c_ulong;
-pub type socklen_t = i32;
-pub type time64_t = i64;
-
-s! {
- pub struct sigaction {
- pub sa_sigaction: ::sighandler_t,
- pub sa_mask: ::sigset_t,
- pub sa_flags: ::c_int,
- pub sa_restorer: ::Option<extern fn()>,
- }
-
- pub struct rlimit64 {
- pub rlim_cur: u64,
- pub rlim_max: u64,
- }
-
- pub struct stat {
- pub st_dev: ::c_ulonglong,
- __pad0: [::c_uchar; 4],
- __st_ino: ::ino_t,
- pub st_mode: ::c_uint,
- pub st_nlink: ::c_uint,
- pub st_uid: ::uid_t,
- pub st_gid: ::gid_t,
- pub st_rdev: ::c_ulonglong,
- __pad3: [::c_uchar; 4],
- pub st_size: ::c_longlong,
- pub st_blksize: ::blksize_t,
- pub st_blocks: ::c_ulonglong,
- pub st_atime: ::c_long,
- pub st_atime_nsec: ::c_long,
- pub st_mtime: ::c_long,
- pub st_mtime_nsec: ::c_long,
- pub st_ctime: ::c_long,
- pub st_ctime_nsec: ::c_long,
- pub st_ino: ::c_ulonglong,
- }
-
- pub struct stat64 {
- pub st_dev: ::c_ulonglong,
- __pad0: [::c_uchar; 4],
- __st_ino: ::ino_t,
- pub st_mode: ::c_uint,
- pub st_nlink: ::c_uint,
- pub st_uid: ::uid_t,
- pub st_gid: ::gid_t,
- pub st_rdev: ::c_ulonglong,
- __pad3: [::c_uchar; 4],
- pub st_size: ::c_longlong,
- pub st_blksize: ::blksize_t,
- pub st_blocks: ::c_ulonglong,
- pub st_atime: ::c_long,
- pub st_atime_nsec: ::c_long,
- pub st_mtime: ::c_long,
- pub st_mtime_nsec: ::c_long,
- pub st_ctime: ::c_long,
- pub st_ctime_nsec: ::c_long,
- pub st_ino: ::c_ulonglong,
- }
-
- pub struct statfs64 {
- pub f_type: u32,
- pub f_bsize: u32,
- pub f_blocks: u64,
- pub f_bfree: u64,
- pub f_bavail: u64,
- pub f_files: u64,
- pub f_ffree: u64,
- f_fsid: [u32; 2],
- pub f_namelen: u32,
- pub f_frsize: u32,
- pub f_flags: u32,
- pub f_spare: [u32; 4],
- }
-
- pub struct statvfs64 {
- pub f_bsize: ::c_ulong,
- pub f_frsize: ::c_ulong,
- pub f_blocks: ::c_ulong,
- pub f_bfree: ::c_ulong,
- pub f_bavail: ::c_ulong,
- pub f_files: ::c_ulong,
- pub f_ffree: ::c_ulong,
- pub f_favail: ::c_ulong,
- pub f_fsid: ::c_ulong,
- pub f_flag: ::c_ulong,
- pub f_namemax: ::c_ulong,
- }
-
- pub struct pthread_attr_t {
- pub flags: u32,
- pub stack_base: *mut ::c_void,
- pub stack_size: ::size_t,
- pub guard_size: ::size_t,
- pub sched_policy: i32,
- pub sched_priority: i32,
- }
-
- pub struct pthread_mutex_t { value: ::c_int }
-
- pub struct pthread_cond_t { value: ::c_int }
-
- pub struct pthread_rwlock_t {
- lock: pthread_mutex_t,
- cond: pthread_cond_t,
- numLocks: ::c_int,
- writerThreadId: ::c_int,
- pendingReaders: ::c_int,
- pendingWriters: ::c_int,
- attr: i32,
- __reserved: [::c_char; 12],
- }
-
- pub struct passwd {
- pub pw_name: *mut ::c_char,
- pub pw_passwd: *mut ::c_char,
- pub pw_uid: ::uid_t,
- pub pw_gid: ::gid_t,
- pub pw_dir: *mut ::c_char,
- pub pw_shell: *mut ::c_char,
- }
-
- pub struct statfs {
- pub f_type: u32,
- pub f_bsize: u32,
- pub f_blocks: u64,
- pub f_bfree: u64,
- pub f_bavail: u64,
- pub f_files: u64,
- pub f_ffree: u64,
- pub f_fsid: ::__fsid_t,
- pub f_namelen: u32,
- pub f_frsize: u32,
- pub f_flags: u32,
- pub f_spare: [u32; 4],
- }
-
- pub struct sysinfo {
- pub uptime: ::c_long,
- pub loads: [::c_ulong; 3],
- pub totalram: ::c_ulong,
- pub freeram: ::c_ulong,
- pub sharedram: ::c_ulong,
- pub bufferram: ::c_ulong,
- pub totalswap: ::c_ulong,
- pub freeswap: ::c_ulong,
- pub procs: ::c_ushort,
- pub pad: ::c_ushort,
- pub totalhigh: ::c_ulong,
- pub freehigh: ::c_ulong,
- pub mem_unit: ::c_uint,
- pub _f: [::c_char; 8],
- }
-}
-
-// These constants must be of the same type of sigaction.sa_flags
-pub const SA_NOCLDSTOP: ::c_int = 0x00000001;
-pub const SA_NOCLDWAIT: ::c_int = 0x00000002;
-pub const SA_NODEFER: ::c_int = 0x40000000;
-pub const SA_ONSTACK: ::c_int = 0x08000000;
-pub const SA_RESETHAND: ::c_int = 0x80000000;
-pub const SA_RESTART: ::c_int = 0x10000000;
-pub const SA_SIGINFO: ::c_int = 0x00000004;
-
-pub const RTLD_GLOBAL: ::c_int = 2;
-pub const RTLD_NOW: ::c_int = 0;
-pub const RTLD_DEFAULT: *mut ::c_void = -1isize as *mut ::c_void;
-
-pub const PTRACE_GETFPREGS: ::c_int = 14;
-pub const PTRACE_SETFPREGS: ::c_int = 15;
-pub const PTRACE_GETREGS: ::c_int = 12;
-pub const PTRACE_SETREGS: ::c_int = 13;
-
-pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t {
- value: 0,
-};
-pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = pthread_cond_t {
- value: 0,
-};
-pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = pthread_rwlock_t {
- lock: PTHREAD_MUTEX_INITIALIZER,
- cond: PTHREAD_COND_INITIALIZER,
- numLocks: 0,
- writerThreadId: 0,
- pendingReaders: 0,
- pendingWriters: 0,
- attr: 0,
- __reserved: [0; 12],
-};
-pub const PTHREAD_STACK_MIN: ::size_t = 4096 * 2;
-pub const CPU_SETSIZE: ::size_t = 32;
-pub const __CPU_BITS: ::size_t = 32;
-
-pub const UT_LINESIZE: usize = 8;
-pub const UT_NAMESIZE: usize = 8;
-pub const UT_HOSTSIZE: usize = 16;
-
-pub const SIGSTKSZ: ::size_t = 8192;
-pub const MINSIGSTKSZ: ::size_t = 2048;
-
-extern {
- pub fn timegm64(tm: *const ::tm) -> ::time64_t;
-}
-
-cfg_if! {
- if #[cfg(target_arch = "x86")] {
- mod x86;
- pub use self::x86::*;
- } else if #[cfg(target_arch = "arm")] {
- mod arm;
- pub use self::arm::*;
- } else {
- // Unknown target_arch
- }
-}
diff --git a/libc/src/unix/notbsd/android/b32/x86.rs b/libc/src/unix/notbsd/android/b32/x86.rs
deleted file mode 100644
index a56fa00..0000000
--- a/libc/src/unix/notbsd/android/b32/x86.rs
+++ /dev/null
@@ -1,415 +0,0 @@
-pub type c_char = i8;
-pub type wchar_t = i32;
-
-pub const O_DIRECT: ::c_int = 0x4000;
-pub const O_DIRECTORY: ::c_int = 0x10000;
-pub const O_NOFOLLOW: ::c_int = 0x20000;
-pub const O_LARGEFILE: ::c_int = 0o0100000;
-
-pub const MAP_32BIT: ::c_int = 0x40;
-
-// 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_vm86old: ::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;
-// FIXME: SYS__llseek is in the NDK sources but for some reason is
-// not available in the tests
-// pub const SYS__llseek: ::c_long = 140;
-pub const SYS_getdents: ::c_long = 141;
-// FIXME: SYS__newselect is in the NDK sources but for some reason is
-// not available in the tests
-// 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;
-// FIXME: SYS__llseek is in the NDK sources but for some reason is
-// not available in the tests
-// 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_vm86: ::c_long = 166;
-pub const SYS_query_module: ::c_long = 167;
-pub const SYS_poll: ::c_long = 168;
-pub const SYS_nfsservctl: ::c_long = 169;
-pub const SYS_setresgid: ::c_long = 170;
-pub const SYS_getresgid: ::c_long = 171;
-pub const SYS_prctl: ::c_long = 172;
-pub const SYS_rt_sigreturn: ::c_long = 173;
-pub const SYS_rt_sigaction: ::c_long = 174;
-pub const SYS_rt_sigprocmask: ::c_long = 175;
-pub const SYS_rt_sigpending: ::c_long = 176;
-pub const SYS_rt_sigtimedwait: ::c_long = 177;
-pub const SYS_rt_sigqueueinfo: ::c_long = 178;
-pub const SYS_rt_sigsuspend: ::c_long = 179;
-pub const SYS_pread64: ::c_long = 180;
-pub const SYS_pwrite64: ::c_long = 181;
-pub const SYS_chown: ::c_long = 182;
-pub const SYS_getcwd: ::c_long = 183;
-pub const SYS_capget: ::c_long = 184;
-pub const SYS_capset: ::c_long = 185;
-pub const SYS_sigaltstack: ::c_long = 186;
-pub const SYS_sendfile: ::c_long = 187;
-pub const SYS_getpmsg: ::c_long = 188;
-pub const SYS_putpmsg: ::c_long = 189;
-pub const SYS_vfork: ::c_long = 190;
-pub const SYS_ugetrlimit: ::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_lchown32: ::c_long = 198;
-pub const SYS_getuid32: ::c_long = 199;
-pub const SYS_getgid32: ::c_long = 200;
-pub const SYS_geteuid32: ::c_long = 201;
-pub const SYS_getegid32: ::c_long = 202;
-pub const SYS_setreuid32: ::c_long = 203;
-pub const SYS_setregid32: ::c_long = 204;
-pub const SYS_getgroups32: ::c_long = 205;
-pub const SYS_setgroups32: ::c_long = 206;
-pub const SYS_fchown32: ::c_long = 207;
-pub const SYS_setresuid32: ::c_long = 208;
-pub const SYS_getresuid32: ::c_long = 209;
-pub const SYS_setresgid32: ::c_long = 210;
-pub const SYS_getresgid32: ::c_long = 211;
-pub const SYS_chown32: ::c_long = 212;
-pub const SYS_setuid32: ::c_long = 213;
-pub const SYS_setgid32: ::c_long = 214;
-pub const SYS_setfsuid32: ::c_long = 215;
-pub const SYS_setfsgid32: ::c_long = 216;
-pub const SYS_pivot_root: ::c_long = 217;
-pub const SYS_mincore: ::c_long = 218;
-pub const SYS_madvise: ::c_long = 219;
-pub const SYS_getdents64: ::c_long = 220;
-pub const SYS_fcntl64: ::c_long = 221;
-pub const SYS_gettid: ::c_long = 224;
-pub const SYS_readahead: ::c_long = 225;
-pub const SYS_setxattr: ::c_long = 226;
-pub const SYS_lsetxattr: ::c_long = 227;
-pub const SYS_fsetxattr: ::c_long = 228;
-pub const SYS_getxattr: ::c_long = 229;
-pub const SYS_lgetxattr: ::c_long = 230;
-pub const SYS_fgetxattr: ::c_long = 231;
-pub const SYS_listxattr: ::c_long = 232;
-pub const SYS_llistxattr: ::c_long = 233;
-pub const SYS_flistxattr: ::c_long = 234;
-pub const SYS_removexattr: ::c_long = 235;
-pub const SYS_lremovexattr: ::c_long = 236;
-pub const SYS_fremovexattr: ::c_long = 237;
-pub const SYS_tkill: ::c_long = 238;
-pub const SYS_sendfile64: ::c_long = 239;
-pub const SYS_futex: ::c_long = 240;
-pub const SYS_sched_setaffinity: ::c_long = 241;
-pub const SYS_sched_getaffinity: ::c_long = 242;
-pub const SYS_set_thread_area: ::c_long = 243;
-pub const SYS_get_thread_area: ::c_long = 244;
-pub const SYS_io_setup: ::c_long = 245;
-pub const SYS_io_destroy: ::c_long = 246;
-pub const SYS_io_getevents: ::c_long = 247;
-pub const SYS_io_submit: ::c_long = 248;
-pub const SYS_io_cancel: ::c_long = 249;
-pub const SYS_fadvise64: ::c_long = 250;
-pub const SYS_exit_group: ::c_long = 252;
-pub const SYS_lookup_dcookie: ::c_long = 253;
-pub const SYS_epoll_create: ::c_long = 254;
-pub const SYS_epoll_ctl: ::c_long = 255;
-pub const SYS_epoll_wait: ::c_long = 256;
-pub const SYS_remap_file_pages: ::c_long = 257;
-pub const SYS_set_tid_address: ::c_long = 258;
-pub const SYS_timer_create: ::c_long = 259;
-pub const SYS_timer_settime: ::c_long = 260;
-pub const SYS_timer_gettime: ::c_long = 261;
-pub const SYS_timer_getoverrun: ::c_long = 262;
-pub const SYS_timer_delete: ::c_long = 263;
-pub const SYS_clock_settime: ::c_long = 264;
-pub const SYS_clock_gettime: ::c_long = 265;
-pub const SYS_clock_getres: ::c_long = 266;
-pub const SYS_clock_nanosleep: ::c_long = 267;
-pub const SYS_statfs64: ::c_long = 268;
-pub const SYS_fstatfs64: ::c_long = 269;
-pub const SYS_tgkill: ::c_long = 270;
-pub const SYS_utimes: ::c_long = 271;
-pub const SYS_fadvise64_64: ::c_long = 272;
-pub const SYS_vserver: ::c_long = 273;
-pub const SYS_mbind: ::c_long = 274;
-pub const SYS_get_mempolicy: ::c_long = 275;
-pub const SYS_set_mempolicy: ::c_long = 276;
-pub const SYS_mq_open: ::c_long = 277;
-pub const SYS_mq_unlink: ::c_long = 278;
-pub const SYS_mq_timedsend: ::c_long = 279;
-pub const SYS_mq_timedreceive: ::c_long = 280;
-pub const SYS_mq_notify: ::c_long = 281;
-pub const SYS_mq_getsetattr: ::c_long = 282;
-pub const SYS_kexec_load: ::c_long = 283;
-pub const SYS_waitid: ::c_long = 284;
-pub const SYS_add_key: ::c_long = 286;
-pub const SYS_request_key: ::c_long = 287;
-pub const SYS_keyctl: ::c_long = 288;
-pub const SYS_ioprio_set: ::c_long = 289;
-pub const SYS_ioprio_get: ::c_long = 290;
-pub const SYS_inotify_init: ::c_long = 291;
-pub const SYS_inotify_add_watch: ::c_long = 292;
-pub const SYS_inotify_rm_watch: ::c_long = 293;
-pub const SYS_migrate_pages: ::c_long = 294;
-pub const SYS_openat: ::c_long = 295;
-pub const SYS_mkdirat: ::c_long = 296;
-pub const SYS_mknodat: ::c_long = 297;
-pub const SYS_fchownat: ::c_long = 298;
-pub const SYS_futimesat: ::c_long = 299;
-pub const SYS_fstatat64: ::c_long = 300;
-pub const SYS_unlinkat: ::c_long = 301;
-pub const SYS_renameat: ::c_long = 302;
-pub const SYS_linkat: ::c_long = 303;
-pub const SYS_symlinkat: ::c_long = 304;
-pub const SYS_readlinkat: ::c_long = 305;
-pub const SYS_fchmodat: ::c_long = 306;
-pub const SYS_faccessat: ::c_long = 307;
-pub const SYS_pselect6: ::c_long = 308;
-pub const SYS_ppoll: ::c_long = 309;
-pub const SYS_unshare: ::c_long = 310;
-pub const SYS_set_robust_list: ::c_long = 311;
-pub const SYS_get_robust_list: ::c_long = 312;
-pub const SYS_splice: ::c_long = 313;
-pub const SYS_sync_file_range: ::c_long = 314;
-pub const SYS_tee: ::c_long = 315;
-pub const SYS_vmsplice: ::c_long = 316;
-pub const SYS_move_pages: ::c_long = 317;
-pub const SYS_getcpu: ::c_long = 318;
-pub const SYS_epoll_pwait: ::c_long = 319;
-pub const SYS_utimensat: ::c_long = 320;
-pub const SYS_signalfd: ::c_long = 321;
-pub const SYS_timerfd_create: ::c_long = 322;
-pub const SYS_eventfd: ::c_long = 323;
-pub const SYS_fallocate: ::c_long = 324;
-pub const SYS_timerfd_settime: ::c_long = 325;
-pub const SYS_timerfd_gettime: ::c_long = 326;
-pub const SYS_signalfd4: ::c_long = 327;
-pub const SYS_eventfd2: ::c_long = 328;
-pub const SYS_epoll_create1: ::c_long = 329;
-pub const SYS_dup3: ::c_long = 330;
-pub const SYS_pipe2: ::c_long = 331;
-pub const SYS_inotify_init1: ::c_long = 332;
-pub const SYS_preadv: ::c_long = 333;
-pub const SYS_pwritev: ::c_long = 334;
-pub const SYS_rt_tgsigqueueinfo: ::c_long = 335;
-pub const SYS_perf_event_open: ::c_long = 336;
-pub const SYS_recvmmsg: ::c_long = 337;
-pub const SYS_fanotify_init: ::c_long = 338;
-pub const SYS_fanotify_mark: ::c_long = 339;
-pub const SYS_prlimit64: ::c_long = 340;
-pub const SYS_name_to_handle_at: ::c_long = 341;
-pub const SYS_open_by_handle_at: ::c_long = 342;
-pub const SYS_clock_adjtime: ::c_long = 343;
-pub const SYS_syncfs: ::c_long = 344;
-pub const SYS_sendmmsg: ::c_long = 345;
-pub const SYS_setns: ::c_long = 346;
-pub const SYS_process_vm_readv: ::c_long = 347;
-pub const SYS_process_vm_writev: ::c_long = 348;
-pub const SYS_kcmp: ::c_long = 349;
-pub const SYS_finit_module: ::c_long = 350;
-pub const SYS_sched_setattr: ::c_long = 351;
-pub const SYS_sched_getattr: ::c_long = 352;
-pub const SYS_renameat2: ::c_long = 353;
-pub const SYS_seccomp: ::c_long = 354;
-pub const SYS_getrandom: ::c_long = 355;
-pub const SYS_memfd_create: ::c_long = 356;
-pub const SYS_bpf: ::c_long = 357;
-pub const SYS_execveat: ::c_long = 358;
-pub const SYS_socket: ::c_long = 359;
-pub const SYS_socketpair: ::c_long = 360;
-pub const SYS_bind: ::c_long = 361;
-pub const SYS_connect: ::c_long = 362;
-pub const SYS_listen: ::c_long = 363;
-pub const SYS_accept4: ::c_long = 364;
-pub const SYS_getsockopt: ::c_long = 365;
-pub const SYS_setsockopt: ::c_long = 366;
-pub const SYS_getsockname: ::c_long = 367;
-pub const SYS_getpeername: ::c_long = 368;
-pub const SYS_sendto: ::c_long = 369;
-pub const SYS_sendmsg: ::c_long = 370;
-pub const SYS_recvfrom: ::c_long = 371;
-pub const SYS_recvmsg: ::c_long = 372;
-pub const SYS_shutdown: ::c_long = 373;
-pub const SYS_userfaultfd: ::c_long = 374;
-pub const SYS_membarrier: ::c_long = 375;
-pub const SYS_mlock2: ::c_long = 376;
-pub const SYS_copy_file_range: ::c_long = 377;
-pub const SYS_preadv2: ::c_long = 378;
-pub const SYS_pwritev2: ::c_long = 379;
-pub const SYS_pkey_mprotect: ::c_long = 380;
-pub const SYS_pkey_alloc: ::c_long = 381;
-pub const SYS_pkey_free: ::c_long = 382;
-
-// offsets in user_regs_structs, from sys/reg.h
-pub const EBX: ::c_int = 0;
-pub const ECX: ::c_int = 1;
-pub const EDX: ::c_int = 2;
-pub const ESI: ::c_int = 3;
-pub const EDI: ::c_int = 4;
-pub const EBP: ::c_int = 5;
-pub const EAX: ::c_int = 6;
-pub const DS: ::c_int = 7;
-pub const ES: ::c_int = 8;
-pub const FS: ::c_int = 9;
-pub const GS: ::c_int = 10;
-pub const ORIG_EAX: ::c_int = 11;
-pub const EIP: ::c_int = 12;
-pub const CS: ::c_int = 13;
-pub const EFL: ::c_int = 14;
-pub const UESP: ::c_int = 15;
-pub const SS: ::c_int = 16;
diff --git a/libc/src/unix/notbsd/android/b64/aarch64.rs b/libc/src/unix/notbsd/android/b64/aarch64.rs
deleted file mode 100644
index cb1c81b..0000000
--- a/libc/src/unix/notbsd/android/b64/aarch64.rs
+++ /dev/null
@@ -1,325 +0,0 @@
-pub type c_char = u8;
-pub type wchar_t = u32;
-
-s! {
- pub struct stat {
- pub st_dev: ::dev_t,
- pub st_ino: ::ino_t,
- pub st_mode: ::c_uint,
- pub st_nlink: ::c_uint,
- pub st_uid: ::uid_t,
- pub st_gid: ::gid_t,
- pub st_rdev: ::dev_t,
- __pad1: ::c_ulong,
- pub st_size: ::off64_t,
- pub st_blksize: ::c_int,
- __pad2: ::c_int,
- pub st_blocks: ::c_long,
- 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,
- __unused4: ::c_uint,
- __unused5: ::c_uint,
- }
-
- pub struct stat64 {
- pub st_dev: ::dev_t,
- pub st_ino: ::ino_t,
- pub st_mode: ::c_uint,
- pub st_nlink: ::c_uint,
- pub st_uid: ::uid_t,
- pub st_gid: ::gid_t,
- pub st_rdev: ::dev_t,
- __pad1: ::c_ulong,
- pub st_size: ::off64_t,
- pub st_blksize: ::c_int,
- __pad2: ::c_int,
- pub st_blocks: ::c_long,
- 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,
- __unused4: ::c_uint,
- __unused5: ::c_uint,
- }
-}
-
-pub const O_DIRECT: ::c_int = 0x10000;
-pub const O_DIRECTORY: ::c_int = 0x4000;
-pub const O_NOFOLLOW: ::c_int = 0x8000;
-pub const O_LARGEFILE: ::c_int = 0o400000;
-
-pub const SIGSTKSZ: ::size_t = 16384;
-pub const MINSIGSTKSZ: ::size_t = 5120;
-
-pub const SYS_io_setup: ::c_long = 0;
-pub const SYS_io_destroy: ::c_long = 1;
-pub const SYS_io_submit: ::c_long = 2;
-pub const SYS_io_cancel: ::c_long = 3;
-pub const SYS_io_getevents: ::c_long = 4;
-pub const SYS_setxattr: ::c_long = 5;
-pub const SYS_lsetxattr: ::c_long = 6;
-pub const SYS_fsetxattr: ::c_long = 7;
-pub const SYS_getxattr: ::c_long = 8;
-pub const SYS_lgetxattr: ::c_long = 9;
-pub const SYS_fgetxattr: ::c_long = 10;
-pub const SYS_listxattr: ::c_long = 11;
-pub const SYS_llistxattr: ::c_long = 12;
-pub const SYS_flistxattr: ::c_long = 13;
-pub const SYS_removexattr: ::c_long = 14;
-pub const SYS_lremovexattr: ::c_long = 15;
-pub const SYS_fremovexattr: ::c_long = 16;
-pub const SYS_getcwd: ::c_long = 17;
-pub const SYS_lookup_dcookie: ::c_long = 18;
-pub const SYS_eventfd2: ::c_long = 19;
-pub const SYS_epoll_create1: ::c_long = 20;
-pub const SYS_epoll_ctl: ::c_long = 21;
-pub const SYS_epoll_pwait: ::c_long = 22;
-pub const SYS_dup: ::c_long = 23;
-pub const SYS_dup3: ::c_long = 24;
-pub const SYS_inotify_init1: ::c_long = 26;
-pub const SYS_inotify_add_watch: ::c_long = 27;
-pub const SYS_inotify_rm_watch: ::c_long = 28;
-pub const SYS_ioctl: ::c_long = 29;
-pub const SYS_ioprio_set: ::c_long = 30;
-pub const SYS_ioprio_get: ::c_long = 31;
-pub const SYS_flock: ::c_long = 32;
-pub const SYS_mknodat: ::c_long = 33;
-pub const SYS_mkdirat: ::c_long = 34;
-pub const SYS_unlinkat: ::c_long = 35;
-pub const SYS_symlinkat: ::c_long = 36;
-pub const SYS_linkat: ::c_long = 37;
-pub const SYS_renameat: ::c_long = 38;
-pub const SYS_umount2: ::c_long = 39;
-pub const SYS_mount: ::c_long = 40;
-pub const SYS_pivot_root: ::c_long = 41;
-pub const SYS_nfsservctl: ::c_long = 42;
-pub const SYS_fallocate: ::c_long = 47;
-pub const SYS_faccessat: ::c_long = 48;
-pub const SYS_chdir: ::c_long = 49;
-pub const SYS_fchdir: ::c_long = 50;
-pub const SYS_chroot: ::c_long = 51;
-pub const SYS_fchmod: ::c_long = 52;
-pub const SYS_fchmodat: ::c_long = 53;
-pub const SYS_fchownat: ::c_long = 54;
-pub const SYS_fchown: ::c_long = 55;
-pub const SYS_openat: ::c_long = 56;
-pub const SYS_close: ::c_long = 57;
-pub const SYS_vhangup: ::c_long = 58;
-pub const SYS_pipe2: ::c_long = 59;
-pub const SYS_quotactl: ::c_long = 60;
-pub const SYS_getdents64: ::c_long = 61;
-pub const SYS_read: ::c_long = 63;
-pub const SYS_write: ::c_long = 64;
-pub const SYS_readv: ::c_long = 65;
-pub const SYS_writev: ::c_long = 66;
-pub const SYS_pread64: ::c_long = 67;
-pub const SYS_pwrite64: ::c_long = 68;
-pub const SYS_preadv: ::c_long = 69;
-pub const SYS_pwritev: ::c_long = 70;
-pub const SYS_pselect6: ::c_long = 72;
-pub const SYS_ppoll: ::c_long = 73;
-pub const SYS_signalfd4: ::c_long = 74;
-pub const SYS_vmsplice: ::c_long = 75;
-pub const SYS_splice: ::c_long = 76;
-pub const SYS_tee: ::c_long = 77;
-pub const SYS_readlinkat: ::c_long = 78;
-pub const SYS_sync: ::c_long = 81;
-pub const SYS_fsync: ::c_long = 82;
-pub const SYS_fdatasync: ::c_long = 83;
-pub const SYS_sync_file_range: ::c_long = 84;
-pub const SYS_timerfd_create: ::c_long = 85;
-pub const SYS_timerfd_settime: ::c_long = 86;
-pub const SYS_timerfd_gettime: ::c_long = 87;
-pub const SYS_utimensat: ::c_long = 88;
-pub const SYS_acct: ::c_long = 89;
-pub const SYS_capget: ::c_long = 90;
-pub const SYS_capset: ::c_long = 91;
-pub const SYS_personality: ::c_long = 92;
-pub const SYS_exit: ::c_long = 93;
-pub const SYS_exit_group: ::c_long = 94;
-pub const SYS_waitid: ::c_long = 95;
-pub const SYS_set_tid_address: ::c_long = 96;
-pub const SYS_unshare: ::c_long = 97;
-pub const SYS_futex: ::c_long = 98;
-pub const SYS_set_robust_list: ::c_long = 99;
-pub const SYS_get_robust_list: ::c_long = 100;
-pub const SYS_nanosleep: ::c_long = 101;
-pub const SYS_getitimer: ::c_long = 102;
-pub const SYS_setitimer: ::c_long = 103;
-pub const SYS_kexec_load: ::c_long = 104;
-pub const SYS_init_module: ::c_long = 105;
-pub const SYS_delete_module: ::c_long = 106;
-pub const SYS_timer_create: ::c_long = 107;
-pub const SYS_timer_gettime: ::c_long = 108;
-pub const SYS_timer_getoverrun: ::c_long = 109;
-pub const SYS_timer_settime: ::c_long = 110;
-pub const SYS_timer_delete: ::c_long = 111;
-pub const SYS_clock_settime: ::c_long = 112;
-pub const SYS_clock_gettime: ::c_long = 113;
-pub const SYS_clock_getres: ::c_long = 114;
-pub const SYS_clock_nanosleep: ::c_long = 115;
-pub const SYS_syslog: ::c_long = 116;
-pub const SYS_ptrace: ::c_long = 117;
-pub const SYS_sched_setparam: ::c_long = 118;
-pub const SYS_sched_setscheduler: ::c_long = 119;
-pub const SYS_sched_getscheduler: ::c_long = 120;
-pub const SYS_sched_getparam: ::c_long = 121;
-pub const SYS_sched_setaffinity: ::c_long = 122;
-pub const SYS_sched_getaffinity: ::c_long = 123;
-pub const SYS_sched_yield: ::c_long = 124;
-pub const SYS_sched_get_priority_max: ::c_long = 125;
-pub const SYS_sched_get_priority_min: ::c_long = 126;
-pub const SYS_sched_rr_get_interval: ::c_long = 127;
-pub const SYS_restart_syscall: ::c_long = 128;
-pub const SYS_kill: ::c_long = 129;
-pub const SYS_tkill: ::c_long = 130;
-pub const SYS_tgkill: ::c_long = 131;
-pub const SYS_sigaltstack: ::c_long = 132;
-pub const SYS_rt_sigsuspend: ::c_long = 133;
-pub const SYS_rt_sigaction: ::c_long = 134;
-pub const SYS_rt_sigprocmask: ::c_long = 135;
-pub const SYS_rt_sigpending: ::c_long = 136;
-pub const SYS_rt_sigtimedwait: ::c_long = 137;
-pub const SYS_rt_sigqueueinfo: ::c_long = 138;
-pub const SYS_rt_sigreturn: ::c_long = 139;
-pub const SYS_setpriority: ::c_long = 140;
-pub const SYS_getpriority: ::c_long = 141;
-pub const SYS_reboot: ::c_long = 142;
-pub const SYS_setregid: ::c_long = 143;
-pub const SYS_setgid: ::c_long = 144;
-pub const SYS_setreuid: ::c_long = 145;
-pub const SYS_setuid: ::c_long = 146;
-pub const SYS_setresuid: ::c_long = 147;
-pub const SYS_getresuid: ::c_long = 148;
-pub const SYS_setresgid: ::c_long = 149;
-pub const SYS_getresgid: ::c_long = 150;
-pub const SYS_setfsuid: ::c_long = 151;
-pub const SYS_setfsgid: ::c_long = 152;
-pub const SYS_times: ::c_long = 153;
-pub const SYS_setpgid: ::c_long = 154;
-pub const SYS_getpgid: ::c_long = 155;
-pub const SYS_getsid: ::c_long = 156;
-pub const SYS_setsid: ::c_long = 157;
-pub const SYS_getgroups: ::c_long = 158;
-pub const SYS_setgroups: ::c_long = 159;
-pub const SYS_uname: ::c_long = 160;
-pub const SYS_sethostname: ::c_long = 161;
-pub const SYS_setdomainname: ::c_long = 162;
-pub const SYS_getrlimit: ::c_long = 163;
-pub const SYS_setrlimit: ::c_long = 164;
-pub const SYS_getrusage: ::c_long = 165;
-pub const SYS_umask: ::c_long = 166;
-pub const SYS_prctl: ::c_long = 167;
-pub const SYS_getcpu: ::c_long = 168;
-pub const SYS_gettimeofday: ::c_long = 169;
-pub const SYS_settimeofday: ::c_long = 170;
-pub const SYS_adjtimex: ::c_long = 171;
-pub const SYS_getpid: ::c_long = 172;
-pub const SYS_getppid: ::c_long = 173;
-pub const SYS_getuid: ::c_long = 174;
-pub const SYS_geteuid: ::c_long = 175;
-pub const SYS_getgid: ::c_long = 176;
-pub const SYS_getegid: ::c_long = 177;
-pub const SYS_gettid: ::c_long = 178;
-pub const SYS_sysinfo: ::c_long = 179;
-pub const SYS_mq_open: ::c_long = 180;
-pub const SYS_mq_unlink: ::c_long = 181;
-pub const SYS_mq_timedsend: ::c_long = 182;
-pub const SYS_mq_timedreceive: ::c_long = 183;
-pub const SYS_mq_notify: ::c_long = 184;
-pub const SYS_mq_getsetattr: ::c_long = 185;
-pub const SYS_msgget: ::c_long = 186;
-pub const SYS_msgctl: ::c_long = 187;
-pub const SYS_msgrcv: ::c_long = 188;
-pub const SYS_msgsnd: ::c_long = 189;
-pub const SYS_semget: ::c_long = 190;
-pub const SYS_semctl: ::c_long = 191;
-pub const SYS_semtimedop: ::c_long = 192;
-pub const SYS_semop: ::c_long = 193;
-pub const SYS_shmget: ::c_long = 194;
-pub const SYS_shmctl: ::c_long = 195;
-pub const SYS_shmat: ::c_long = 196;
-pub const SYS_shmdt: ::c_long = 197;
-pub const SYS_socket: ::c_long = 198;
-pub const SYS_socketpair: ::c_long = 199;
-pub const SYS_bind: ::c_long = 200;
-pub const SYS_listen: ::c_long = 201;
-pub const SYS_accept: ::c_long = 202;
-pub const SYS_connect: ::c_long = 203;
-pub const SYS_getsockname: ::c_long = 204;
-pub const SYS_getpeername: ::c_long = 205;
-pub const SYS_sendto: ::c_long = 206;
-pub const SYS_recvfrom: ::c_long = 207;
-pub const SYS_setsockopt: ::c_long = 208;
-pub const SYS_getsockopt: ::c_long = 209;
-pub const SYS_shutdown: ::c_long = 210;
-pub const SYS_sendmsg: ::c_long = 211;
-pub const SYS_recvmsg: ::c_long = 212;
-pub const SYS_readahead: ::c_long = 213;
-pub const SYS_brk: ::c_long = 214;
-pub const SYS_munmap: ::c_long = 215;
-pub const SYS_mremap: ::c_long = 216;
-pub const SYS_add_key: ::c_long = 217;
-pub const SYS_request_key: ::c_long = 218;
-pub const SYS_keyctl: ::c_long = 219;
-pub const SYS_clone: ::c_long = 220;
-pub const SYS_execve: ::c_long = 221;
-pub const SYS_swapon: ::c_long = 224;
-pub const SYS_swapoff: ::c_long = 225;
-pub const SYS_mprotect: ::c_long = 226;
-pub const SYS_msync: ::c_long = 227;
-pub const SYS_mlock: ::c_long = 228;
-pub const SYS_munlock: ::c_long = 229;
-pub const SYS_mlockall: ::c_long = 230;
-pub const SYS_munlockall: ::c_long = 231;
-pub const SYS_mincore: ::c_long = 232;
-pub const SYS_madvise: ::c_long = 233;
-pub const SYS_remap_file_pages: ::c_long = 234;
-pub const SYS_mbind: ::c_long = 235;
-pub const SYS_get_mempolicy: ::c_long = 236;
-pub const SYS_set_mempolicy: ::c_long = 237;
-pub const SYS_migrate_pages: ::c_long = 238;
-pub const SYS_move_pages: ::c_long = 239;
-pub const SYS_rt_tgsigqueueinfo: ::c_long = 240;
-pub const SYS_perf_event_open: ::c_long = 241;
-pub const SYS_accept4: ::c_long = 242;
-pub const SYS_recvmmsg: ::c_long = 243;
-pub const SYS_arch_specific_syscall: ::c_long = 244;
-pub const SYS_wait4: ::c_long = 260;
-pub const SYS_prlimit64: ::c_long = 261;
-pub const SYS_fanotify_init: ::c_long = 262;
-pub const SYS_fanotify_mark: ::c_long = 263;
-pub const SYS_name_to_handle_at: ::c_long = 264;
-pub const SYS_open_by_handle_at: ::c_long = 265;
-pub const SYS_clock_adjtime: ::c_long = 266;
-pub const SYS_syncfs: ::c_long = 267;
-pub const SYS_setns: ::c_long = 268;
-pub const SYS_sendmmsg: ::c_long = 269;
-pub const SYS_process_vm_readv: ::c_long = 270;
-pub const SYS_process_vm_writev: ::c_long = 271;
-pub const SYS_kcmp: ::c_long = 272;
-pub const SYS_finit_module: ::c_long = 273;
-pub const SYS_sched_setattr: ::c_long = 274;
-pub const SYS_sched_getattr: ::c_long = 275;
-pub const SYS_renameat2: ::c_long = 276;
-pub const SYS_seccomp: ::c_long = 277;
-pub const SYS_getrandom: ::c_long = 278;
-pub const SYS_memfd_create: ::c_long = 279;
-pub const SYS_bpf: ::c_long = 280;
-pub const SYS_execveat: ::c_long = 281;
-pub const SYS_userfaultfd: ::c_long = 282;
-pub const SYS_membarrier: ::c_long = 283;
-pub const SYS_mlock2: ::c_long = 284;
-pub const SYS_copy_file_range: ::c_long = 285;
-pub const SYS_preadv2: ::c_long = 286;
-pub const SYS_pwritev2: ::c_long = 287;
-pub const SYS_pkey_mprotect: ::c_long = 288;
-pub const SYS_pkey_alloc: ::c_long = 289;
-pub const SYS_pkey_free: ::c_long = 290;
-pub const SYS_syscalls: ::c_long = 292;
diff --git a/libc/src/unix/notbsd/android/b64/mod.rs b/libc/src/unix/notbsd/android/b64/mod.rs
deleted file mode 100644
index d9759bd..0000000
--- a/libc/src/unix/notbsd/android/b64/mod.rs
+++ /dev/null
@@ -1,281 +0,0 @@
-// The following definitions are correct for aarch64 and x86_64,
-// but may be wrong for mips64
-
-pub type c_long = i64;
-pub type c_ulong = u64;
-pub type mode_t = u32;
-pub type off64_t = i64;
-pub type socklen_t = u32;
-
-s! {
- pub struct sigset_t {
- __val: [::c_ulong; 1],
- }
-
- pub struct sigaction {
- pub sa_flags: ::c_int,
- pub sa_sigaction: ::sighandler_t,
- pub sa_mask: ::sigset_t,
- pub sa_restorer: ::Option<extern fn()>,
- }
-
- pub struct rlimit64 {
- pub rlim_cur: ::c_ulonglong,
- pub rlim_max: ::c_ulonglong,
- }
-
- pub struct pthread_attr_t {
- pub flags: u32,
- pub stack_base: *mut ::c_void,
- pub stack_size: ::size_t,
- pub guard_size: ::size_t,
- pub sched_policy: i32,
- pub sched_priority: i32,
- __reserved: [::c_char; 16],
- }
-
- pub struct passwd {
- 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 statfs {
- pub f_type: u64,
- pub f_bsize: u64,
- pub f_blocks: u64,
- pub f_bfree: u64,
- pub f_bavail: u64,
- pub f_files: u64,
- pub f_ffree: u64,
- pub f_fsid: ::__fsid_t,
- pub f_namelen: u64,
- pub f_frsize: u64,
- pub f_flags: u64,
- pub f_spare: [u64; 4],
- }
-
- pub struct sysinfo {
- pub uptime: ::c_long,
- pub loads: [::c_ulong; 3],
- pub totalram: ::c_ulong,
- pub freeram: ::c_ulong,
- pub sharedram: ::c_ulong,
- pub bufferram: ::c_ulong,
- pub totalswap: ::c_ulong,
- pub freeswap: ::c_ulong,
- pub procs: ::c_ushort,
- pub pad: ::c_ushort,
- pub totalhigh: ::c_ulong,
- pub freehigh: ::c_ulong,
- pub mem_unit: ::c_uint,
- pub _f: [::c_char; 0],
- }
-
- pub struct statfs64 {
- pub f_type: u64,
- pub f_bsize: u64,
- pub f_blocks: u64,
- pub f_bfree: u64,
- pub f_bavail: u64,
- pub f_files: u64,
- pub f_ffree: u64,
- f_fsid: [u32; 2],
- pub f_namelen: u64,
- pub f_frsize: u64,
- pub f_flags: u64,
- pub f_spare: [u64; 4],
- }
-
- pub struct statvfs64 {
- pub f_bsize: ::c_ulong,
- pub f_frsize: ::c_ulong,
- pub f_blocks: u64,
- pub f_bfree: u64,
- pub f_bavail: u64,
- pub f_files: u64,
- pub f_ffree: u64,
- pub f_favail: u64,
- pub f_fsid: ::c_ulong,
- pub f_flag: ::c_ulong,
- pub f_namemax: ::c_ulong,
- __f_spare: [::c_int; 6],
- }
-}
-
-s_no_extra_traits!{
- pub struct pthread_mutex_t {
- value: ::c_int,
- __reserved: [::c_char; 36],
- }
-
- pub struct pthread_cond_t {
- value: ::c_int,
- __reserved: [::c_char; 44],
- }
-
- pub struct pthread_rwlock_t {
- numLocks: ::c_int,
- writerThreadId: ::c_int,
- pendingReaders: ::c_int,
- pendingWriters: ::c_int,
- attr: i32,
- __reserved: [::c_char; 36],
- }
-}
-
-cfg_if! {
- if #[cfg(feature = "extra_traits")] {
- impl PartialEq for pthread_mutex_t {
- fn eq(&self, other: &pthread_mutex_t) -> bool {
- self.value == other.value
- && self
- .__reserved
- .iter()
- .zip(other.__reserved.iter())
- .all(|(a,b)| a == b)
- }
- }
-
- impl Eq for pthread_mutex_t {}
-
- impl ::fmt::Debug for pthread_mutex_t {
- fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
- f.debug_struct("pthread_mutex_t")
- .field("value", &self.value)
- // FIXME: .field("__reserved", &self.__reserved)
- .finish()
- }
- }
-
- impl ::hash::Hash for pthread_mutex_t {
- fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
- self.value.hash(state);
- self.__reserved.hash(state);
- }
- }
-
- impl PartialEq for pthread_cond_t {
- fn eq(&self, other: &pthread_cond_t) -> bool {
- self.value == other.value
- && self
- .__reserved
- .iter()
- .zip(other.__reserved.iter())
- .all(|(a,b)| a == b)
- }
- }
-
- impl Eq for pthread_cond_t {}
-
- impl ::fmt::Debug for pthread_cond_t {
- fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
- f.debug_struct("pthread_cond_t")
- .field("value", &self.value)
- // FIXME: .field("__reserved", &self.__reserved)
- .finish()
- }
- }
-
- impl ::hash::Hash for pthread_cond_t {
- fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
- self.value.hash(state);
- self.__reserved.hash(state);
- }
- }
-
- impl PartialEq for pthread_rwlock_t {
- fn eq(&self, other: &pthread_rwlock_t) -> bool {
- self.numLocks == other.numLocks
- && self.writerThreadId == other.writerThreadId
- && self.pendingReaders == other.pendingReaders
- && self.pendingWriters == other.pendingWriters
- && self.attr == other.attr
- && self
- .__reserved
- .iter()
- .zip(other.__reserved.iter())
- .all(|(a,b)| a == b)
- }
- }
-
- impl Eq for pthread_rwlock_t {}
-
- impl ::fmt::Debug for pthread_rwlock_t {
- fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
- f.debug_struct("pthread_rwlock_t")
- .field("numLocks", &self.numLocks)
- .field("writerThreadId", &self.writerThreadId)
- .field("pendingReaders", &self.pendingReaders)
- .field("pendingWriters", &self.pendingWriters)
- .field("attr", &self.attr)
- // FIXME: .field("__reserved", &self.__reserved)
- .finish()
- }
- }
-
- impl ::hash::Hash for pthread_rwlock_t {
- fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
- self.numLocks.hash(state);
- self.writerThreadId.hash(state);
- self.pendingReaders.hash(state);
- self.pendingWriters.hash(state);
- self.attr.hash(state);
- self.__reserved.hash(state);
- }
- }
- }
-}
-
-// These constants must be of the same type of sigaction.sa_flags
-pub const SA_NOCLDSTOP: ::c_int = 0x00000001;
-pub const SA_NOCLDWAIT: ::c_int = 0x00000002;
-pub const SA_NODEFER: ::c_int = 0x40000000;
-pub const SA_ONSTACK: ::c_int = 0x08000000;
-pub const SA_RESETHAND: ::c_int = 0x80000000;
-pub const SA_RESTART: ::c_int = 0x10000000;
-pub const SA_SIGINFO: ::c_int = 0x00000004;
-
-pub const RTLD_GLOBAL: ::c_int = 0x00100;
-pub const RTLD_NOW: ::c_int = 2;
-pub const RTLD_DEFAULT: *mut ::c_void = 0i64 as *mut ::c_void;
-
-pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t {
- value: 0,
- __reserved: [0; 36],
-};
-pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = pthread_cond_t {
- value: 0,
- __reserved: [0; 44],
-};
-pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = pthread_rwlock_t {
- numLocks: 0,
- writerThreadId: 0,
- pendingReaders: 0,
- pendingWriters: 0,
- attr: 0,
- __reserved: [0; 36],
-};
-pub const PTHREAD_STACK_MIN: ::size_t = 4096 * 4;
-pub const CPU_SETSIZE: ::size_t = 1024;
-pub const __CPU_BITS: ::size_t = 64;
-
-pub const UT_LINESIZE: usize = 32;
-pub const UT_NAMESIZE: usize = 32;
-pub const UT_HOSTSIZE: usize = 256;
-
-cfg_if! {
- if #[cfg(target_arch = "x86_64")] {
- mod x86_64;
- pub use self::x86_64::*;
- } else if #[cfg(target_arch = "aarch64")] {
- mod aarch64;
- pub use self::aarch64::*;
- } else {
- // Unknown target_arch
- }
-}
diff --git a/libc/src/unix/notbsd/android/b64/x86_64.rs b/libc/src/unix/notbsd/android/b64/x86_64.rs
deleted file mode 100644
index 2ab6080..0000000
--- a/libc/src/unix/notbsd/android/b64/x86_64.rs
+++ /dev/null
@@ -1,420 +0,0 @@
-pub type c_char = i8;
-pub type wchar_t = i32;
-
-s! {
- pub struct stat {
- pub st_dev: ::dev_t,
- pub st_ino: ::ino_t,
- pub st_nlink: ::c_ulong,
- pub st_mode: ::c_uint,
- pub st_uid: ::uid_t,
- pub st_gid: ::gid_t,
- pub st_rdev: ::dev_t,
- pub st_size: ::off64_t,
- pub st_blksize: ::c_long,
- pub st_blocks: ::c_long,
- pub st_atime: ::c_long,
- pub st_atime_nsec: ::c_long,
- pub st_mtime: ::c_long,
- pub st_mtime_nsec: ::c_long,
- pub st_ctime: ::c_long,
- pub st_ctime_nsec: ::c_long,
- __unused: [::c_long; 3],
- }
-
- pub struct stat64 {
- pub st_dev: ::dev_t,
- pub st_ino: ::ino_t,
- pub st_nlink: ::c_ulong,
- pub st_mode: ::c_uint,
- pub st_uid: ::uid_t,
- pub st_gid: ::gid_t,
- pub st_rdev: ::dev_t,
- pub st_size: ::off64_t,
- pub st_blksize: ::c_long,
- pub st_blocks: ::c_long,
- pub st_atime: ::c_long,
- pub st_atime_nsec: ::c_long,
- pub st_mtime: ::c_long,
- pub st_mtime_nsec: ::c_long,
- pub st_ctime: ::c_long,
- pub st_ctime_nsec: ::c_long,
- __unused: [::c_long; 3],
- }
-}
-
-pub const O_DIRECT: ::c_int = 0x4000;
-pub const O_DIRECTORY: ::c_int = 0x10000;
-pub const O_NOFOLLOW: ::c_int = 0x20000;
-pub const O_LARGEFILE: ::c_int = 0o0100000;
-
-pub const SIGSTKSZ: ::size_t = 8192;
-pub const MINSIGSTKSZ: ::size_t = 2048;
-
-pub const MAP_32BIT: ::c_int = 0x40;
-
-// Syscall table
-
-pub const SYS_read: ::c_long = 0;
-pub const SYS_write: ::c_long = 1;
-pub const SYS_open: ::c_long = 2;
-pub const SYS_close: ::c_long = 3;
-pub const SYS_stat: ::c_long = 4;
-pub const SYS_fstat: ::c_long = 5;
-pub const SYS_lstat: ::c_long = 6;
-pub const SYS_poll: ::c_long = 7;
-pub const SYS_lseek: ::c_long = 8;
-pub const SYS_mmap: ::c_long = 9;
-pub const SYS_mprotect: ::c_long = 10;
-pub const SYS_munmap: ::c_long = 11;
-pub const SYS_brk: ::c_long = 12;
-pub const SYS_rt_sigaction: ::c_long = 13;
-pub const SYS_rt_sigprocmask: ::c_long = 14;
-pub const SYS_rt_sigreturn: ::c_long = 15;
-pub const SYS_ioctl: ::c_long = 16;
-pub const SYS_pread64: ::c_long = 17;
-pub const SYS_pwrite64: ::c_long = 18;
-pub const SYS_readv: ::c_long = 19;
-pub const SYS_writev: ::c_long = 20;
-pub const SYS_access: ::c_long = 21;
-pub const SYS_pipe: ::c_long = 22;
-pub const SYS_select: ::c_long = 23;
-pub const SYS_sched_yield: ::c_long = 24;
-pub const SYS_mremap: ::c_long = 25;
-pub const SYS_msync: ::c_long = 26;
-pub const SYS_mincore: ::c_long = 27;
-pub const SYS_madvise: ::c_long = 28;
-pub const SYS_shmget: ::c_long = 29;
-pub const SYS_shmat: ::c_long = 30;
-pub const SYS_shmctl: ::c_long = 31;
-pub const SYS_dup: ::c_long = 32;
-pub const SYS_dup2: ::c_long = 33;
-pub const SYS_pause: ::c_long = 34;
-pub const SYS_nanosleep: ::c_long = 35;
-pub const SYS_getitimer: ::c_long = 36;
-pub const SYS_alarm: ::c_long = 37;
-pub const SYS_setitimer: ::c_long = 38;
-pub const SYS_getpid: ::c_long = 39;
-pub const SYS_sendfile: ::c_long = 40;
-pub const SYS_socket: ::c_long = 41;
-pub const SYS_connect: ::c_long = 42;
-pub const SYS_accept: ::c_long = 43;
-pub const SYS_sendto: ::c_long = 44;
-pub const SYS_recvfrom: ::c_long = 45;
-pub const SYS_sendmsg: ::c_long = 46;
-pub const SYS_recvmsg: ::c_long = 47;
-pub const SYS_shutdown: ::c_long = 48;
-pub const SYS_bind: ::c_long = 49;
-pub const SYS_listen: ::c_long = 50;
-pub const SYS_getsockname: ::c_long = 51;
-pub const SYS_getpeername: ::c_long = 52;
-pub const SYS_socketpair: ::c_long = 53;
-pub const SYS_setsockopt: ::c_long = 54;
-pub const SYS_getsockopt: ::c_long = 55;
-pub const SYS_clone: ::c_long = 56;
-pub const SYS_fork: ::c_long = 57;
-pub const SYS_vfork: ::c_long = 58;
-pub const SYS_execve: ::c_long = 59;
-pub const SYS_exit: ::c_long = 60;
-pub const SYS_wait4: ::c_long = 61;
-pub const SYS_kill: ::c_long = 62;
-pub const SYS_uname: ::c_long = 63;
-pub const SYS_semget: ::c_long = 64;
-pub const SYS_semop: ::c_long = 65;
-pub const SYS_semctl: ::c_long = 66;
-pub const SYS_shmdt: ::c_long = 67;
-pub const SYS_msgget: ::c_long = 68;
-pub const SYS_msgsnd: ::c_long = 69;
-pub const SYS_msgrcv: ::c_long = 70;
-pub const SYS_msgctl: ::c_long = 71;
-pub const SYS_fcntl: ::c_long = 72;
-pub const SYS_flock: ::c_long = 73;
-pub const SYS_fsync: ::c_long = 74;
-pub const SYS_fdatasync: ::c_long = 75;
-pub const SYS_truncate: ::c_long = 76;
-pub const SYS_ftruncate: ::c_long = 77;
-pub const SYS_getdents: ::c_long = 78;
-pub const SYS_getcwd: ::c_long = 79;
-pub const SYS_chdir: ::c_long = 80;
-pub const SYS_fchdir: ::c_long = 81;
-pub const SYS_rename: ::c_long = 82;
-pub const SYS_mkdir: ::c_long = 83;
-pub const SYS_rmdir: ::c_long = 84;
-pub const SYS_creat: ::c_long = 85;
-pub const SYS_link: ::c_long = 86;
-pub const SYS_unlink: ::c_long = 87;
-pub const SYS_symlink: ::c_long = 88;
-pub const SYS_readlink: ::c_long = 89;
-pub const SYS_chmod: ::c_long = 90;
-pub const SYS_fchmod: ::c_long = 91;
-pub const SYS_chown: ::c_long = 92;
-pub const SYS_fchown: ::c_long = 93;
-pub const SYS_lchown: ::c_long = 94;
-pub const SYS_umask: ::c_long = 95;
-pub const SYS_gettimeofday: ::c_long = 96;
-pub const SYS_getrlimit: ::c_long = 97;
-pub const SYS_getrusage: ::c_long = 98;
-pub const SYS_sysinfo: ::c_long = 99;
-pub const SYS_times: ::c_long = 100;
-pub const SYS_ptrace: ::c_long = 101;
-pub const SYS_getuid: ::c_long = 102;
-pub const SYS_syslog: ::c_long = 103;
-pub const SYS_getgid: ::c_long = 104;
-pub const SYS_setuid: ::c_long = 105;
-pub const SYS_setgid: ::c_long = 106;
-pub const SYS_geteuid: ::c_long = 107;
-pub const SYS_getegid: ::c_long = 108;
-pub const SYS_setpgid: ::c_long = 109;
-pub const SYS_getppid: ::c_long = 110;
-pub const SYS_getpgrp: ::c_long = 111;
-pub const SYS_setsid: ::c_long = 112;
-pub const SYS_setreuid: ::c_long = 113;
-pub const SYS_setregid: ::c_long = 114;
-pub const SYS_getgroups: ::c_long = 115;
-pub const SYS_setgroups: ::c_long = 116;
-pub const SYS_setresuid: ::c_long = 117;
-pub const SYS_getresuid: ::c_long = 118;
-pub const SYS_setresgid: ::c_long = 119;
-pub const SYS_getresgid: ::c_long = 120;
-pub const SYS_getpgid: ::c_long = 121;
-pub const SYS_setfsuid: ::c_long = 122;
-pub const SYS_setfsgid: ::c_long = 123;
-pub const SYS_getsid: ::c_long = 124;
-pub const SYS_capget: ::c_long = 125;
-pub const SYS_capset: ::c_long = 126;
-pub const SYS_rt_sigpending: ::c_long = 127;
-pub const SYS_rt_sigtimedwait: ::c_long = 128;
-pub const SYS_rt_sigqueueinfo: ::c_long = 129;
-pub const SYS_rt_sigsuspend: ::c_long = 130;
-pub const SYS_sigaltstack: ::c_long = 131;
-pub const SYS_utime: ::c_long = 132;
-pub const SYS_mknod: ::c_long = 133;
-pub const SYS_uselib: ::c_long = 134;
-pub const SYS_personality: ::c_long = 135;
-pub const SYS_ustat: ::c_long = 136;
-pub const SYS_statfs: ::c_long = 137;
-pub const SYS_fstatfs: ::c_long = 138;
-pub const SYS_sysfs: ::c_long = 139;
-pub const SYS_getpriority: ::c_long = 140;
-pub const SYS_setpriority: ::c_long = 141;
-pub const SYS_sched_setparam: ::c_long = 142;
-pub const SYS_sched_getparam: ::c_long = 143;
-pub const SYS_sched_setscheduler: ::c_long = 144;
-pub const SYS_sched_getscheduler: ::c_long = 145;
-pub const SYS_sched_get_priority_max: ::c_long = 146;
-pub const SYS_sched_get_priority_min: ::c_long = 147;
-pub const SYS_sched_rr_get_interval: ::c_long = 148;
-pub const SYS_mlock: ::c_long = 149;
-pub const SYS_munlock: ::c_long = 150;
-pub const SYS_mlockall: ::c_long = 151;
-pub const SYS_munlockall: ::c_long = 152;
-pub const SYS_vhangup: ::c_long = 153;
-pub const SYS_modify_ldt: ::c_long = 154;
-pub const SYS_pivot_root: ::c_long = 155;
-// FIXME: SYS__sysctl is in the NDK sources but for some reason is
-// not available in the tests
-// pub const SYS__sysctl: ::c_long = 156;
-pub const SYS_prctl: ::c_long = 157;
-pub const SYS_arch_prctl: ::c_long = 158;
-pub const SYS_adjtimex: ::c_long = 159;
-pub const SYS_setrlimit: ::c_long = 160;
-pub const SYS_chroot: ::c_long = 161;
-pub const SYS_sync: ::c_long = 162;
-pub const SYS_acct: ::c_long = 163;
-pub const SYS_settimeofday: ::c_long = 164;
-pub const SYS_mount: ::c_long = 165;
-pub const SYS_umount2: ::c_long = 166;
-pub const SYS_swapon: ::c_long = 167;
-pub const SYS_swapoff: ::c_long = 168;
-pub const SYS_reboot: ::c_long = 169;
-pub const SYS_sethostname: ::c_long = 170;
-pub const SYS_setdomainname: ::c_long = 171;
-pub const SYS_iopl: ::c_long = 172;
-pub const SYS_ioperm: ::c_long = 173;
-pub const SYS_create_module: ::c_long = 174;
-pub const SYS_init_module: ::c_long = 175;
-pub const SYS_delete_module: ::c_long = 176;
-pub const SYS_get_kernel_syms: ::c_long = 177;
-pub const SYS_query_module: ::c_long = 178;
-pub const SYS_quotactl: ::c_long = 179;
-pub const SYS_nfsservctl: ::c_long = 180;
-pub const SYS_getpmsg: ::c_long = 181;
-pub const SYS_putpmsg: ::c_long = 182;
-pub const SYS_afs_syscall: ::c_long = 183;
-pub const SYS_tuxcall: ::c_long = 184;
-pub const SYS_security: ::c_long = 185;
-pub const SYS_gettid: ::c_long = 186;
-pub const SYS_readahead: ::c_long = 187;
-pub const SYS_setxattr: ::c_long = 188;
-pub const SYS_lsetxattr: ::c_long = 189;
-pub const SYS_fsetxattr: ::c_long = 190;
-pub const SYS_getxattr: ::c_long = 191;
-pub const SYS_lgetxattr: ::c_long = 192;
-pub const SYS_fgetxattr: ::c_long = 193;
-pub const SYS_listxattr: ::c_long = 194;
-pub const SYS_llistxattr: ::c_long = 195;
-pub const SYS_flistxattr: ::c_long = 196;
-pub const SYS_removexattr: ::c_long = 197;
-pub const SYS_lremovexattr: ::c_long = 198;
-pub const SYS_fremovexattr: ::c_long = 199;
-pub const SYS_tkill: ::c_long = 200;
-pub const SYS_time: ::c_long = 201;
-pub const SYS_futex: ::c_long = 202;
-pub const SYS_sched_setaffinity: ::c_long = 203;
-pub const SYS_sched_getaffinity: ::c_long = 204;
-pub const SYS_set_thread_area: ::c_long = 205;
-pub const SYS_io_setup: ::c_long = 206;
-pub const SYS_io_destroy: ::c_long = 207;
-pub const SYS_io_getevents: ::c_long = 208;
-pub const SYS_io_submit: ::c_long = 209;
-pub const SYS_io_cancel: ::c_long = 210;
-pub const SYS_get_thread_area: ::c_long = 211;
-pub const SYS_lookup_dcookie: ::c_long = 212;
-pub const SYS_epoll_create: ::c_long = 213;
-pub const SYS_epoll_ctl_old: ::c_long = 214;
-pub const SYS_epoll_wait_old: ::c_long = 215;
-pub const SYS_remap_file_pages: ::c_long = 216;
-pub const SYS_getdents64: ::c_long = 217;
-pub const SYS_set_tid_address: ::c_long = 218;
-pub const SYS_restart_syscall: ::c_long = 219;
-pub const SYS_semtimedop: ::c_long = 220;
-pub const SYS_fadvise64: ::c_long = 221;
-pub const SYS_timer_create: ::c_long = 222;
-pub const SYS_timer_settime: ::c_long = 223;
-pub const SYS_timer_gettime: ::c_long = 224;
-pub const SYS_timer_getoverrun: ::c_long = 225;
-pub const SYS_timer_delete: ::c_long = 226;
-pub const SYS_clock_settime: ::c_long = 227;
-pub const SYS_clock_gettime: ::c_long = 228;
-pub const SYS_clock_getres: ::c_long = 229;
-pub const SYS_clock_nanosleep: ::c_long = 230;
-pub const SYS_exit_group: ::c_long = 231;
-pub const SYS_epoll_wait: ::c_long = 232;
-pub const SYS_epoll_ctl: ::c_long = 233;
-pub const SYS_tgkill: ::c_long = 234;
-pub const SYS_utimes: ::c_long = 235;
-pub const SYS_vserver: ::c_long = 236;
-pub const SYS_mbind: ::c_long = 237;
-pub const SYS_set_mempolicy: ::c_long = 238;
-pub const SYS_get_mempolicy: ::c_long = 239;
-pub const SYS_mq_open: ::c_long = 240;
-pub const SYS_mq_unlink: ::c_long = 241;
-pub const SYS_mq_timedsend: ::c_long = 242;
-pub const SYS_mq_timedreceive: ::c_long = 243;
-pub const SYS_mq_notify: ::c_long = 244;
-pub const SYS_mq_getsetattr: ::c_long = 245;
-pub const SYS_kexec_load: ::c_long = 246;
-pub const SYS_waitid: ::c_long = 247;
-pub const SYS_add_key: ::c_long = 248;
-pub const SYS_request_key: ::c_long = 249;
-pub const SYS_keyctl: ::c_long = 250;
-pub const SYS_ioprio_set: ::c_long = 251;
-pub const SYS_ioprio_get: ::c_long = 252;
-pub const SYS_inotify_init: ::c_long = 253;
-pub const SYS_inotify_add_watch: ::c_long = 254;
-pub const SYS_inotify_rm_watch: ::c_long = 255;
-pub const SYS_migrate_pages: ::c_long = 256;
-pub const SYS_openat: ::c_long = 257;
-pub const SYS_mkdirat: ::c_long = 258;
-pub const SYS_mknodat: ::c_long = 259;
-pub const SYS_fchownat: ::c_long = 260;
-pub const SYS_futimesat: ::c_long = 261;
-pub const SYS_newfstatat: ::c_long = 262;
-pub const SYS_unlinkat: ::c_long = 263;
-pub const SYS_renameat: ::c_long = 264;
-pub const SYS_linkat: ::c_long = 265;
-pub const SYS_symlinkat: ::c_long = 266;
-pub const SYS_readlinkat: ::c_long = 267;
-pub const SYS_fchmodat: ::c_long = 268;
-pub const SYS_faccessat: ::c_long = 269;
-pub const SYS_pselect6: ::c_long = 270;
-pub const SYS_ppoll: ::c_long = 271;
-pub const SYS_unshare: ::c_long = 272;
-pub const SYS_set_robust_list: ::c_long = 273;
-pub const SYS_get_robust_list: ::c_long = 274;
-pub const SYS_splice: ::c_long = 275;
-pub const SYS_tee: ::c_long = 276;
-pub const SYS_sync_file_range: ::c_long = 277;
-pub const SYS_vmsplice: ::c_long = 278;
-pub const SYS_move_pages: ::c_long = 279;
-pub const SYS_utimensat: ::c_long = 280;
-pub const SYS_epoll_pwait: ::c_long = 281;
-pub const SYS_signalfd: ::c_long = 282;
-pub const SYS_timerfd_create: ::c_long = 283;
-pub const SYS_eventfd: ::c_long = 284;
-pub const SYS_fallocate: ::c_long = 285;
-pub const SYS_timerfd_settime: ::c_long = 286;
-pub const SYS_timerfd_gettime: ::c_long = 287;
-pub const SYS_accept4: ::c_long = 288;
-pub const SYS_signalfd4: ::c_long = 289;
-pub const SYS_eventfd2: ::c_long = 290;
-pub const SYS_epoll_create1: ::c_long = 291;
-pub const SYS_dup3: ::c_long = 292;
-pub const SYS_pipe2: ::c_long = 293;
-pub const SYS_inotify_init1: ::c_long = 294;
-pub const SYS_preadv: ::c_long = 295;
-pub const SYS_pwritev: ::c_long = 296;
-pub const SYS_rt_tgsigqueueinfo: ::c_long = 297;
-pub const SYS_perf_event_open: ::c_long = 298;
-pub const SYS_recvmmsg: ::c_long = 299;
-pub const SYS_fanotify_init: ::c_long = 300;
-pub const SYS_fanotify_mark: ::c_long = 301;
-pub const SYS_prlimit64: ::c_long = 302;
-pub const SYS_name_to_handle_at: ::c_long = 303;
-pub const SYS_open_by_handle_at: ::c_long = 304;
-pub const SYS_clock_adjtime: ::c_long = 305;
-pub const SYS_syncfs: ::c_long = 306;
-pub const SYS_sendmmsg: ::c_long = 307;
-pub const SYS_setns: ::c_long = 308;
-pub const SYS_getcpu: ::c_long = 309;
-pub const SYS_process_vm_readv: ::c_long = 310;
-pub const SYS_process_vm_writev: ::c_long = 311;
-pub const SYS_kcmp: ::c_long = 312;
-pub const SYS_finit_module: ::c_long = 313;
-pub const SYS_sched_setattr: ::c_long = 314;
-pub const SYS_sched_getattr: ::c_long = 315;
-pub const SYS_renameat2: ::c_long = 316;
-pub const SYS_seccomp: ::c_long = 317;
-pub const SYS_getrandom: ::c_long = 318;
-pub const SYS_memfd_create: ::c_long = 319;
-pub const SYS_kexec_file_load: ::c_long = 320;
-pub const SYS_bpf: ::c_long = 321;
-pub const SYS_execveat: ::c_long = 322;
-pub const SYS_userfaultfd: ::c_long = 323;
-pub const SYS_membarrier: ::c_long = 324;
-pub const SYS_mlock2: ::c_long = 325;
-pub const SYS_copy_file_range: ::c_long = 326;
-pub const SYS_preadv2: ::c_long = 327;
-pub const SYS_pwritev2: ::c_long = 328;
-pub const SYS_pkey_mprotect: ::c_long = 329;
-pub const SYS_pkey_alloc: ::c_long = 330;
-pub const SYS_pkey_free: ::c_long = 331;
-
-// offsets in user_regs_structs, from sys/reg.h
-pub const R15: ::c_int = 0;
-pub const R14: ::c_int = 1;
-pub const R13: ::c_int = 2;
-pub const R12: ::c_int = 3;
-pub const RBP: ::c_int = 4;
-pub const RBX: ::c_int = 5;
-pub const R11: ::c_int = 6;
-pub const R10: ::c_int = 7;
-pub const R9: ::c_int = 8;
-pub const R8: ::c_int = 9;
-pub const RAX: ::c_int = 10;
-pub const RCX: ::c_int = 11;
-pub const RDX: ::c_int = 12;
-pub const RSI: ::c_int = 13;
-pub const RDI: ::c_int = 14;
-pub const ORIG_RAX: ::c_int = 15;
-pub const RIP: ::c_int = 16;
-pub const CS: ::c_int = 17;
-pub const EFLAGS: ::c_int = 18;
-pub const RSP: ::c_int = 19;
-pub const SS: ::c_int = 20;
-pub const FS_BASE: ::c_int = 21;
-pub const GS_BASE: ::c_int = 22;
-pub const DS: ::c_int = 23;
-pub const ES: ::c_int = 24;
-pub const FS: ::c_int = 25;
-pub const GS: ::c_int = 26;
diff --git a/libc/src/unix/notbsd/android/mod.rs b/libc/src/unix/notbsd/android/mod.rs
deleted file mode 100644
index f4fb83d..0000000
--- a/libc/src/unix/notbsd/android/mod.rs
+++ /dev/null
@@ -1,2209 +0,0 @@
-//! Android-specific definitions for linux-like values
-
-pub type clock_t = ::c_long;
-pub type time_t = ::c_long;
-pub type suseconds_t = ::c_long;
-pub type off_t = ::c_long;
-pub type blkcnt_t = ::c_ulong;
-pub type blksize_t = ::c_ulong;
-pub type nlink_t = u32;
-pub type useconds_t = u32;
-pub type pthread_t = ::c_long;
-pub type pthread_mutexattr_t = ::c_long;
-pub type pthread_rwlockattr_t = ::c_long;
-pub type pthread_condattr_t = ::c_long;
-pub type pthread_key_t = ::c_int;
-pub type fsfilcnt_t = ::c_ulong;
-pub type fsblkcnt_t = ::c_ulong;
-pub type nfds_t = ::c_uint;
-pub type rlim_t = ::c_ulong;
-pub type dev_t = ::c_ulong;
-pub type ino_t = ::c_ulong;
-pub type __CPU_BITTYPE = ::c_ulong;
-pub type idtype_t = ::c_int;
-pub type loff_t = ::c_longlong;
-
-s! {
- pub struct stack_t {
- pub ss_sp: *mut ::c_void,
- pub ss_flags: ::c_int,
- pub ss_size: ::size_t
- }
-
- pub struct __fsid_t {
- __val: [::c_int; 2],
- }
-
- pub struct msghdr {
- pub msg_name: *mut ::c_void,
- pub msg_namelen: ::socklen_t,
- pub msg_iov: *mut ::iovec,
- pub msg_iovlen: ::size_t,
- pub msg_control: *mut ::c_void,
- pub msg_controllen: ::size_t,
- pub msg_flags: ::c_int,
- }
-
- pub struct cmsghdr {
- pub cmsg_len: ::size_t,
- pub cmsg_level: ::c_int,
- pub cmsg_type: ::c_int,
- }
-
- pub struct termios {
- pub c_iflag: ::tcflag_t,
- pub c_oflag: ::tcflag_t,
- pub c_cflag: ::tcflag_t,
- pub c_lflag: ::tcflag_t,
- pub c_line: ::cc_t,
- pub c_cc: [::cc_t; ::NCCS],
- }
-
- 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_line: ::cc_t,
- pub c_cc: [::cc_t; 19],
- pub c_ispeed: ::speed_t,
- pub c_ospeed: ::speed_t,
- }
-
- pub struct flock {
- pub l_type: ::c_short,
- pub l_whence: ::c_short,
- pub l_start: ::off_t,
- pub l_len: ::off_t,
- pub l_pid: ::pid_t,
- }
-
- pub struct cpu_set_t {
- #[cfg(target_pointer_width = "64")]
- __bits: [__CPU_BITTYPE; 16],
- #[cfg(target_pointer_width = "32")]
- __bits: [__CPU_BITTYPE; 1],
- }
-
- pub struct sem_t {
- count: ::c_uint,
- #[cfg(target_pointer_width = "64")]
- __reserved: [::c_int; 3],
- }
-
- pub struct exit_status {
- pub e_termination: ::c_short,
- pub e_exit: ::c_short,
- }
-
- 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,
- #[cfg(target_pointer_width = "64")]
- __f_reserved: [u32; 6],
- }
-
- pub struct signalfd_siginfo {
- pub ssi_signo: u32,
- pub ssi_errno: i32,
- pub ssi_code: i32,
- pub ssi_pid: u32,
- pub ssi_uid: u32,
- pub ssi_fd: i32,
- pub ssi_tid: u32,
- pub ssi_band: u32,
- pub ssi_overrun: u32,
- pub ssi_trapno: u32,
- pub ssi_status: i32,
- pub ssi_int: i32,
- pub ssi_ptr: ::c_ulonglong,
- pub ssi_utime: ::c_ulonglong,
- pub ssi_stime: ::c_ulonglong,
- pub ssi_addr: ::c_ulonglong,
- pub ssi_addr_lsb: u16,
- _pad2: u16,
- pub ssi_syscall: i32,
- pub ssi_call_addr: u64,
- pub ssi_arch: u32,
- _pad: [u8; 28],
- }
-
- pub struct ucred {
- pub pid: ::pid_t,
- 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 struct inotify_event {
- pub wd: ::c_int,
- pub mask: u32,
- pub cookie: u32,
- pub len: u32
- }
-}
-
-s_no_extra_traits!{
- pub struct sockaddr_nl {
- pub nl_family: ::sa_family_t,
- nl_pad: ::c_ushort,
- pub nl_pid: u32,
- pub nl_groups: u32
- }
-
- pub struct dirent {
- pub d_ino: u64,
- pub d_off: i64,
- pub d_reclen: ::c_ushort,
- pub d_type: ::c_uchar,
- pub d_name: [::c_char; 256],
- }
-
- pub struct dirent64 {
- pub d_ino: u64,
- pub d_off: i64,
- pub d_reclen: ::c_ushort,
- pub d_type: ::c_uchar,
- pub d_name: [::c_char; 256],
- }
-
- 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 lastlog {
- ll_time: ::time_t,
- ll_line: [::c_char; UT_LINESIZE],
- ll_host: [::c_char; UT_HOSTSIZE],
- }
-
- pub struct utmp {
- pub ut_type: ::c_short,
- pub ut_pid: ::pid_t,
- pub ut_line: [::c_char; UT_LINESIZE],
- pub ut_id: [::c_char; 4],
- pub ut_user: [::c_char; UT_NAMESIZE],
- pub ut_host: [::c_char; UT_HOSTSIZE],
- pub ut_exit: exit_status,
- pub ut_session: ::c_long,
- pub ut_tv: ::timeval,
- pub ut_addr_v6: [i32; 4],
- unused: [::c_char; 20],
- }
-
- pub struct sockaddr_alg {
- pub salg_family: ::sa_family_t,
- pub salg_type: [::c_uchar; 14],
- pub salg_feat: u32,
- pub salg_mask: u32,
- pub salg_name: [::c_uchar; 64],
- }
-
- pub struct af_alg_iv {
- pub ivlen: u32,
- pub iv: [::c_uchar; 0],
- }
-}
-
-cfg_if! {
- if #[cfg(feature = "extra_traits")] {
- impl PartialEq for sockaddr_nl {
- fn eq(&self, other: &sockaddr_nl) -> bool {
- self.nl_family == other.nl_family &&
- self.nl_pid == other.nl_pid &&
- self.nl_groups == other.nl_groups
- }
- }
- impl Eq for sockaddr_nl {}
- impl ::fmt::Debug for sockaddr_nl {
- fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
- f.debug_struct("sockaddr_nl")
- .field("nl_family", &self.nl_family)
- .field("nl_pid", &self.nl_pid)
- .field("nl_groups", &self.nl_groups)
- .finish()
- }
- }
- impl ::hash::Hash for sockaddr_nl {
- fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
- self.nl_family.hash(state);
- self.nl_pid.hash(state);
- self.nl_groups.hash(state);
- }
- }
-
- impl PartialEq for dirent {
- fn eq(&self, other: &dirent) -> bool {
- self.d_ino == other.d_ino
- && self.d_off == other.d_off
- && self.d_reclen == other.d_reclen
- && self.d_type == other.d_type
- && self
- .d_name
- .iter()
- .zip(other.d_name.iter())
- .all(|(a,b)| a == b)
- }
- }
-
- impl Eq for dirent {}
-
- impl ::fmt::Debug for dirent {
- fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
- f.debug_struct("dirent")
- .field("d_ino", &self.d_ino)
- .field("d_off", &self.d_off)
- .field("d_reclen", &self.d_reclen)
- .field("d_type", &self.d_type)
- // FIXME: .field("d_name", &self.d_name)
- .finish()
- }
- }
-
- impl ::hash::Hash for dirent {
- fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
- self.d_ino.hash(state);
- self.d_off.hash(state);
- self.d_reclen.hash(state);
- self.d_type.hash(state);
- self.d_name.hash(state);
- }
- }
-
- impl PartialEq for dirent64 {
- fn eq(&self, other: &dirent64) -> bool {
- self.d_ino == other.d_ino
- && self.d_off == other.d_off
- && self.d_reclen == other.d_reclen
- && self.d_type == other.d_type
- && self
- .d_name
- .iter()
- .zip(other.d_name.iter())
- .all(|(a,b)| a == b)
- }
- }
-
- impl Eq for dirent64 {}
-
- impl ::fmt::Debug for dirent64 {
- fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
- f.debug_struct("dirent64")
- .field("d_ino", &self.d_ino)
- .field("d_off", &self.d_off)
- .field("d_reclen", &self.d_reclen)
- .field("d_type", &self.d_type)
- // FIXME: .field("d_name", &self.d_name)
- .finish()
- }
- }
-
- impl ::hash::Hash for dirent64 {
- fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
- self.d_ino.hash(state);
- self.d_off.hash(state);
- self.d_reclen.hash(state);
- self.d_type.hash(state);
- self.d_name.hash(state);
- }
- }
-
- impl PartialEq for siginfo_t {
- fn eq(&self, other: &siginfo_t) -> bool {
- self.si_signo == other.si_signo
- && self.si_errno == other.si_errno
- && self.si_code == other.si_code
- // Ignore _pad
- // Ignore _align
- }
- }
-
- impl Eq for siginfo_t {}
-
- impl ::fmt::Debug for siginfo_t {
- fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
- f.debug_struct("siginfo_t")
- .field("si_signo", &self.si_signo)
- .field("si_errno", &self.si_errno)
- .field("si_code", &self.si_code)
- // Ignore _pad
- // Ignore _align
- .finish()
- }
- }
-
- impl ::hash::Hash for siginfo_t {
- fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
- self.si_signo.hash(state);
- self.si_errno.hash(state);
- self.si_code.hash(state);
- // Ignore _pad
- // Ignore _align
- }
- }
-
- impl PartialEq for lastlog {
- fn eq(&self, other: &lastlog) -> bool {
- self.ll_time == other.ll_time
- && self
- .ll_line
- .iter()
- .zip(other.ll_line.iter())
- .all(|(a,b)| a == b)
- && self
- .ll_host
- .iter()
- .zip(other.ll_host.iter())
- .all(|(a,b)| a == b)
- }
- }
-
- impl Eq for lastlog {}
-
- impl ::fmt::Debug for lastlog {
- fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
- f.debug_struct("lastlog")
- .field("ll_time", &self.ll_time)
- .field("ll_line", &self.ll_line)
- // FIXME: .field("ll_host", &self.ll_host)
- .finish()
- }
- }
-
- impl ::hash::Hash for lastlog {
- fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
- self.ll_time.hash(state);
- self.ll_line.hash(state);
- self.ll_host.hash(state);
- }
- }
-
- impl PartialEq for utmp {
- fn eq(&self, other: &utmp) -> bool {
- self.ut_type == other.ut_type
- && self.ut_pid == other.ut_pid
- && self
- .ut_line
- .iter()
- .zip(other.ut_line.iter())
- .all(|(a,b)| a == b)
- && self.ut_id == other.ut_id
- && self
- .ut_user
- .iter()
- .zip(other.ut_user.iter())
- .all(|(a,b)| a == b)
- && self
- .ut_host
- .iter()
- .zip(other.ut_host.iter())
- .all(|(a,b)| a == b)
- && self.ut_exit == other.ut_exit
- && self.ut_session == other.ut_session
- && self.ut_tv == other.ut_tv
- && self.ut_addr_v6 == other.ut_addr_v6
- && self.unused == other.unused
- }
- }
-
- impl Eq for utmp {}
-
- impl ::fmt::Debug for utmp {
- fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
- f.debug_struct("utmp")
- .field("ut_type", &self.ut_type)
- .field("ut_pid", &self.ut_pid)
- .field("ut_line", &self.ut_line)
- .field("ut_id", &self.ut_id)
- .field("ut_user", &self.ut_user)
- // FIXME: .field("ut_host", &self.ut_host)
- .field("ut_exit", &self.ut_exit)
- .field("ut_session", &self.ut_session)
- .field("ut_tv", &self.ut_tv)
- .field("ut_addr_v6", &self.ut_addr_v6)
- .field("unused", &self.unused)
- .finish()
- }
- }
-
- impl ::hash::Hash for utmp {
- fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
- self.ut_type.hash(state);
- self.ut_pid.hash(state);
- self.ut_line.hash(state);
- self.ut_id.hash(state);
- self.ut_user.hash(state);
- self.ut_host.hash(state);
- self.ut_exit.hash(state);
- self.ut_session.hash(state);
- self.ut_tv.hash(state);
- self.ut_addr_v6.hash(state);
- self.unused.hash(state);
- }
- }
-
- impl PartialEq for sockaddr_alg {
- fn eq(&self, other: &sockaddr_alg) -> bool {
- self.salg_family == other.salg_family
- && self
- .salg_type
- .iter()
- .zip(other.salg_type.iter())
- .all(|(a, b)| a == b)
- && self.salg_feat == other.salg_feat
- && self.salg_mask == other.salg_mask
- && self
- .salg_name
- .iter()
- .zip(other.salg_name.iter())
- .all(|(a, b)| a == b)
- }
- }
-
- impl Eq for sockaddr_alg {}
-
- impl ::fmt::Debug for sockaddr_alg {
- fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
- f.debug_struct("sockaddr_alg")
- .field("salg_family", &self.salg_family)
- .field("salg_type", &self.salg_type)
- .field("salg_feat", &self.salg_feat)
- .field("salg_mask", &self.salg_mask)
- .field("salg_name", &&self.salg_name[..])
- .finish()
- }
- }
-
- impl ::hash::Hash for sockaddr_alg {
- fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
- self.salg_family.hash(state);
- self.salg_type.hash(state);
- self.salg_feat.hash(state);
- self.salg_mask.hash(state);
- self.salg_name.hash(state);
- }
- }
-
- impl af_alg_iv {
- fn as_slice(&self) -> &[u8] {
- unsafe {
- ::core::slice::from_raw_parts(
- self.iv.as_ptr(),
- self.ivlen as usize
- )
- }
- }
- }
-
- impl PartialEq for af_alg_iv {
- fn eq(&self, other: &af_alg_iv) -> bool {
- *self.as_slice() == *other.as_slice()
- }
- }
-
- impl Eq for af_alg_iv {}
-
- impl ::fmt::Debug for af_alg_iv {
- fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
- f.debug_struct("af_alg_iv")
- .field("iv", &self.as_slice())
- .finish()
- }
- }
-
- impl ::hash::Hash for af_alg_iv {
- fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
- self.as_slice().hash(state);
- }
- }
- }
-}
-
-pub const MADV_SOFT_OFFLINE: ::c_int = 101;
-pub const MS_NOUSER: ::c_ulong = 0xffffffff80000000;
-pub const MS_RMT_MASK: ::c_ulong = 0x02800051;
-
-pub const O_TRUNC: ::c_int = 512;
-pub const O_CLOEXEC: ::c_int = 0x80000;
-pub const O_PATH: ::c_int = 0o10000000;
-pub const O_NOATIME: ::c_int = 0o1000000;
-
-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 EDOTDOT: ::c_int = 73;
-
-pub const EPOLL_CLOEXEC: ::c_int = 0x80000;
-pub const EPOLLONESHOT: ::c_int = 0x40000000;
-pub const EPOLLRDHUP: ::c_int = 0x00002000;
-pub const EPOLLWAKEUP: ::c_int = 0x20000000;
-
-pub const EFD_CLOEXEC: ::c_int = 0x80000;
-
-pub const USER_PROCESS: ::c_short = 7;
-
-pub const FALLOC_FL_COLLAPSE_RANGE: ::c_int = 0x08;
-
-pub const BUFSIZ: ::c_uint = 1024;
-pub const FILENAME_MAX: ::c_uint = 4096;
-pub const FOPEN_MAX: ::c_uint = 20;
-pub const POSIX_FADV_DONTNEED: ::c_int = 4;
-pub const POSIX_FADV_NOREUSE: ::c_int = 5;
-pub const L_tmpnam: ::c_uint = 4096;
-pub const TMP_MAX: ::c_uint = 308915776;
-pub const _PC_LINK_MAX: ::c_int = 1;
-pub const _PC_MAX_CANON: ::c_int = 2;
-pub const _PC_MAX_INPUT: ::c_int = 3;
-pub const _PC_NAME_MAX: ::c_int = 4;
-pub const _PC_PATH_MAX: ::c_int = 5;
-pub const _PC_PIPE_BUF: ::c_int = 6;
-pub const _PC_2_SYMLINKS: ::c_int = 7;
-pub const _PC_ALLOC_SIZE_MIN: ::c_int = 8;
-pub const _PC_REC_INCR_XFER_SIZE: ::c_int = 9;
-pub const _PC_REC_MAX_XFER_SIZE: ::c_int = 10;
-pub const _PC_REC_MIN_XFER_SIZE: ::c_int = 11;
-pub const _PC_REC_XFER_ALIGN: ::c_int = 12;
-pub const _PC_SYMLINK_MAX: ::c_int = 13;
-pub const _PC_CHOWN_RESTRICTED: ::c_int = 14;
-pub const _PC_NO_TRUNC: ::c_int = 15;
-pub const _PC_VDISABLE: ::c_int = 16;
-pub const _PC_ASYNC_IO: ::c_int = 17;
-pub const _PC_PRIO_IO: ::c_int = 18;
-pub const _PC_SYNC_IO: ::c_int = 19;
-
-pub const FIONBIO: ::c_int = 0x5421;
-
-pub const _SC_ARG_MAX: ::c_int = 0;
-pub const _SC_BC_BASE_MAX: ::c_int = 1;
-pub const _SC_BC_DIM_MAX: ::c_int = 2;
-pub const _SC_BC_SCALE_MAX: ::c_int = 3;
-pub const _SC_BC_STRING_MAX: ::c_int = 4;
-pub const _SC_CHILD_MAX: ::c_int = 5;
-pub const _SC_CLK_TCK: ::c_int = 6;
-pub const _SC_COLL_WEIGHTS_MAX: ::c_int = 7;
-pub const _SC_EXPR_NEST_MAX: ::c_int = 8;
-pub const _SC_LINE_MAX: ::c_int = 9;
-pub const _SC_NGROUPS_MAX: ::c_int = 10;
-pub const _SC_OPEN_MAX: ::c_int = 11;
-pub const _SC_PASS_MAX: ::c_int = 12;
-pub const _SC_2_C_BIND: ::c_int = 13;
-pub const _SC_2_C_DEV: ::c_int = 14;
-pub const _SC_2_C_VERSION: ::c_int = 15;
-pub const _SC_2_CHAR_TERM: ::c_int = 16;
-pub const _SC_2_FORT_DEV: ::c_int = 17;
-pub const _SC_2_FORT_RUN: ::c_int = 18;
-pub const _SC_2_LOCALEDEF: ::c_int = 19;
-pub const _SC_2_SW_DEV: ::c_int = 20;
-pub const _SC_2_UPE: ::c_int = 21;
-pub const _SC_2_VERSION: ::c_int = 22;
-pub const _SC_JOB_CONTROL: ::c_int = 23;
-pub const _SC_SAVED_IDS: ::c_int = 24;
-pub const _SC_VERSION: ::c_int = 25;
-pub const _SC_RE_DUP_MAX: ::c_int = 26;
-pub const _SC_STREAM_MAX: ::c_int = 27;
-pub const _SC_TZNAME_MAX: ::c_int = 28;
-pub const _SC_XOPEN_CRYPT: ::c_int = 29;
-pub const _SC_XOPEN_ENH_I18N: ::c_int = 30;
-pub const _SC_XOPEN_SHM: ::c_int = 31;
-pub const _SC_XOPEN_VERSION: ::c_int = 32;
-pub const _SC_XOPEN_XCU_VERSION: ::c_int = 33;
-pub const _SC_XOPEN_REALTIME: ::c_int = 34;
-pub const _SC_XOPEN_REALTIME_THREADS: ::c_int = 35;
-pub const _SC_XOPEN_LEGACY: ::c_int = 36;
-pub const _SC_ATEXIT_MAX: ::c_int = 37;
-pub const _SC_IOV_MAX: ::c_int = 38;
-pub const _SC_PAGESIZE: ::c_int = 39;
-pub const _SC_PAGE_SIZE: ::c_int = 40;
-pub const _SC_XOPEN_UNIX: ::c_int = 41;
-pub const _SC_XBS5_ILP32_OFF32: ::c_int = 42;
-pub const _SC_XBS5_ILP32_OFFBIG: ::c_int = 43;
-pub const _SC_XBS5_LP64_OFF64: ::c_int = 44;
-pub const _SC_XBS5_LPBIG_OFFBIG: ::c_int = 45;
-pub const _SC_AIO_LISTIO_MAX: ::c_int = 46;
-pub const _SC_AIO_MAX: ::c_int = 47;
-pub const _SC_AIO_PRIO_DELTA_MAX: ::c_int = 48;
-pub const _SC_DELAYTIMER_MAX: ::c_int = 49;
-pub const _SC_MQ_OPEN_MAX: ::c_int = 50;
-pub const _SC_MQ_PRIO_MAX: ::c_int = 51;
-pub const _SC_RTSIG_MAX: ::c_int = 52;
-pub const _SC_SEM_NSEMS_MAX: ::c_int = 53;
-pub const _SC_SEM_VALUE_MAX: ::c_int = 54;
-pub const _SC_SIGQUEUE_MAX: ::c_int = 55;
-pub const _SC_TIMER_MAX: ::c_int = 56;
-pub const _SC_ASYNCHRONOUS_IO: ::c_int = 57;
-pub const _SC_FSYNC: ::c_int = 58;
-pub const _SC_MAPPED_FILES: ::c_int = 59;
-pub const _SC_MEMLOCK: ::c_int = 60;
-pub const _SC_MEMLOCK_RANGE: ::c_int = 61;
-pub const _SC_MEMORY_PROTECTION: ::c_int = 62;
-pub const _SC_MESSAGE_PASSING: ::c_int = 63;
-pub const _SC_PRIORITIZED_IO: ::c_int = 64;
-pub const _SC_PRIORITY_SCHEDULING: ::c_int = 65;
-pub const _SC_REALTIME_SIGNALS: ::c_int = 66;
-pub const _SC_SEMAPHORES: ::c_int = 67;
-pub const _SC_SHARED_MEMORY_OBJECTS: ::c_int = 68;
-pub const _SC_SYNCHRONIZED_IO: ::c_int = 69;
-pub const _SC_TIMERS: ::c_int = 70;
-pub const _SC_GETGR_R_SIZE_MAX: ::c_int = 71;
-pub const _SC_GETPW_R_SIZE_MAX: ::c_int = 72;
-pub const _SC_LOGIN_NAME_MAX: ::c_int = 73;
-pub const _SC_THREAD_DESTRUCTOR_ITERATIONS: ::c_int = 74;
-pub const _SC_THREAD_KEYS_MAX: ::c_int = 75;
-pub const _SC_THREAD_STACK_MIN: ::c_int = 76;
-pub const _SC_THREAD_THREADS_MAX: ::c_int = 77;
-pub const _SC_TTY_NAME_MAX: ::c_int = 78;
-pub const _SC_THREADS: ::c_int = 79;
-pub const _SC_THREAD_ATTR_STACKADDR: ::c_int = 80;
-pub const _SC_THREAD_ATTR_STACKSIZE: ::c_int = 81;
-pub const _SC_THREAD_PRIORITY_SCHEDULING: ::c_int = 82;
-pub const _SC_THREAD_PRIO_INHERIT: ::c_int = 83;
-pub const _SC_THREAD_PRIO_PROTECT: ::c_int = 84;
-pub const _SC_THREAD_SAFE_FUNCTIONS: ::c_int = 85;
-pub const _SC_NPROCESSORS_CONF: ::c_int = 96;
-pub const _SC_NPROCESSORS_ONLN: ::c_int = 97;
-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;
-pub const PTHREAD_MUTEX_DEFAULT: ::c_int = PTHREAD_MUTEX_NORMAL;
-
-pub const FIOCLEX: ::c_int = 0x5451;
-
-pub const SIGCHLD: ::c_int = 17;
-pub const SIGBUS: ::c_int = 7;
-pub const SIGUSR1: ::c_int = 10;
-pub const SIGUSR2: ::c_int = 12;
-pub const SIGCONT: ::c_int = 18;
-pub const SIGSTOP: ::c_int = 19;
-pub const SIGTSTP: ::c_int = 20;
-pub const SIGURG: ::c_int = 23;
-pub const SIGIO: ::c_int = 29;
-pub const SIGSYS: ::c_int = 31;
-pub const SIGSTKFLT: ::c_int = 16;
-#[deprecated(
- since = "0.2.55",
- note = "Use SIGSYS instead"
-)]
-pub const SIGUNUSED: ::c_int = 31;
-pub const 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 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 RUSAGE_CHILDREN: ::c_int = -1;
-
-pub const LC_PAPER: ::c_int = 7;
-pub const LC_NAME: ::c_int = 8;
-pub const LC_ADDRESS: ::c_int = 9;
-pub const LC_TELEPHONE: ::c_int = 10;
-pub const LC_MEASUREMENT: ::c_int = 11;
-pub const LC_IDENTIFICATION: ::c_int = 12;
-pub const LC_PAPER_MASK: ::c_int = (1 << LC_PAPER);
-pub const LC_NAME_MASK: ::c_int = (1 << LC_NAME);
-pub const LC_ADDRESS_MASK: ::c_int = (1 << LC_ADDRESS);
-pub const LC_TELEPHONE_MASK: ::c_int = (1 << LC_TELEPHONE);
-pub const LC_MEASUREMENT_MASK: ::c_int = (1 << LC_MEASUREMENT);
-pub const LC_IDENTIFICATION_MASK: ::c_int = (1 << LC_IDENTIFICATION);
-pub const LC_ALL_MASK: ::c_int = ::LC_CTYPE_MASK
- | ::LC_NUMERIC_MASK
- | ::LC_TIME_MASK
- | ::LC_COLLATE_MASK
- | ::LC_MONETARY_MASK
- | ::LC_MESSAGES_MASK
- | LC_PAPER_MASK
- | LC_NAME_MASK
- | LC_ADDRESS_MASK
- | LC_TELEPHONE_MASK
- | LC_MEASUREMENT_MASK
- | LC_IDENTIFICATION_MASK;
-
-pub const MAP_ANON: ::c_int = 0x0020;
-pub const MAP_ANONYMOUS: ::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 = 0x02000;
-pub const MAP_NORESERVE: ::c_int = 0x04000;
-pub const MAP_POPULATE: ::c_int = 0x08000;
-pub const MAP_NONBLOCK: ::c_int = 0x010000;
-pub const MAP_STACK: ::c_int = 0x020000;
-
-pub const EDEADLK: ::c_int = 35;
-pub const ENAMETOOLONG: ::c_int = 36;
-pub const ENOLCK: ::c_int = 37;
-pub const ENOSYS: ::c_int = 38;
-pub const ENOTEMPTY: ::c_int = 39;
-pub const ELOOP: ::c_int = 40;
-pub const ENOMSG: ::c_int = 42;
-pub const EIDRM: ::c_int = 43;
-pub const ECHRNG: ::c_int = 44;
-pub const EL2NSYNC: ::c_int = 45;
-pub const EL3HLT: ::c_int = 46;
-pub const EL3RST: ::c_int = 47;
-pub const ELNRNG: ::c_int = 48;
-pub const EUNATCH: ::c_int = 49;
-pub const ENOCSI: ::c_int = 50;
-pub const EL2HLT: ::c_int = 51;
-pub const EBADE: ::c_int = 52;
-pub const EBADR: ::c_int = 53;
-pub const EXFULL: ::c_int = 54;
-pub const ENOANO: ::c_int = 55;
-pub const EBADRQC: ::c_int = 56;
-pub const EBADSLT: ::c_int = 57;
-
-pub const EMULTIHOP: ::c_int = 72;
-pub const 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 SOCK_STREAM: ::c_int = 1;
-pub const SOCK_DGRAM: ::c_int = 2;
-pub const SOCK_SEQPACKET: ::c_int = 5;
-pub const SOCK_DCCP: ::c_int = 6;
-pub const SOCK_PACKET: ::c_int = 10;
-
-pub const SOL_SOCKET: ::c_int = 1;
-pub const SOL_SCTP: ::c_int = 132;
-pub const SOL_IPX: ::c_int = 256;
-pub const SOL_AX25: ::c_int = 257;
-pub const SOL_ATALK: ::c_int = 258;
-pub const SOL_NETROM: ::c_int = 259;
-pub const SOL_ROSE: ::c_int = 260;
-
-#[doc(hidden)]
-#[deprecated(
- since = "0.2.55",
- note = "If you are using this report to: \
- https://github.com/rust-lang/libc/issues/665"
-)]
-pub const AF_MAX: ::c_int = 43;
-#[doc(hidden)]
-#[deprecated(
- since = "0.2.55",
- note = "If you are using this report to: \
- https://github.com/rust-lang/libc/issues/665"
-)]
-#[allow(deprecated)]
-pub const PF_MAX: ::c_int = AF_MAX;
-
-/* DCCP socket options */
-pub const DCCP_SOCKOPT_PACKET_SIZE: ::c_int = 1;
-pub const DCCP_SOCKOPT_SERVICE: ::c_int = 2;
-pub const DCCP_SOCKOPT_CHANGE_L: ::c_int = 3;
-pub const DCCP_SOCKOPT_CHANGE_R: ::c_int = 4;
-pub const DCCP_SOCKOPT_GET_CUR_MPS: ::c_int = 5;
-pub const DCCP_SOCKOPT_SERVER_TIMEWAIT: ::c_int = 6;
-pub const DCCP_SOCKOPT_SEND_CSCOV: ::c_int = 10;
-pub const DCCP_SOCKOPT_RECV_CSCOV: ::c_int = 11;
-pub const DCCP_SOCKOPT_AVAILABLE_CCIDS: ::c_int = 12;
-pub const DCCP_SOCKOPT_CCID: ::c_int = 13;
-pub const DCCP_SOCKOPT_TX_CCID: ::c_int = 14;
-pub const DCCP_SOCKOPT_RX_CCID: ::c_int = 15;
-pub const DCCP_SOCKOPT_QPOLICY_ID: ::c_int = 16;
-pub const DCCP_SOCKOPT_QPOLICY_TXQLEN: ::c_int = 17;
-pub const DCCP_SOCKOPT_CCID_RX_INFO: ::c_int = 128;
-pub const DCCP_SOCKOPT_CCID_TX_INFO: ::c_int = 192;
-
-/// maximum number of services provided on the same listening port
-pub const DCCP_SERVICE_LIST_MAX_LEN: ::c_int = 32;
-
-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_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_BINDTODEVICE: ::c_int = 25;
-pub const SO_TIMESTAMP: ::c_int = 29;
-pub const SO_ACCEPTCONN: ::c_int = 30;
-pub const SO_SNDBUFFORCE: ::c_int = 32;
-pub const SO_RCVBUFFORCE: ::c_int = 33;
-pub const SO_MARK: ::c_int = 36;
-pub const SO_PROTOCOL: ::c_int = 38;
-pub const SO_DOMAIN: ::c_int = 39;
-pub const SO_RXQ_OVFL: ::c_int = 40;
-pub const SO_PEEK_OFF: ::c_int = 42;
-pub const SO_BUSY_POLL: ::c_int = 46;
-
-pub const IPTOS_ECN_NOTECT: u8 = 0x00;
-
-pub const O_ACCMODE: ::c_int = 3;
-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 = 0x101000;
-pub const O_ASYNC: ::c_int = 0x2000;
-pub const O_NDELAY: ::c_int = 0x800;
-pub const O_DSYNC: ::c_int = 4096;
-
-pub const NI_MAXHOST: ::size_t = 1025;
-
-pub const NCCS: usize = 19;
-pub const TCSBRKP: ::c_int = 0x5425;
-pub const TCSANOW: ::c_int = 0;
-pub const TCSADRAIN: ::c_int = 0x1;
-pub const TCSAFLUSH: ::c_int = 0x2;
-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 EXTPROC: ::tcflag_t = 0o200000;
-
-pub const ADFS_SUPER_MAGIC: ::c_long = 0x0000adf5;
-pub const AFFS_SUPER_MAGIC: ::c_long = 0x0000adff;
-pub const CODA_SUPER_MAGIC: ::c_long = 0x73757245;
-pub const CRAMFS_MAGIC: ::c_long = 0x28cd3d45;
-pub const EFS_SUPER_MAGIC: ::c_long = 0x00414a53;
-pub const EXT2_SUPER_MAGIC: ::c_long = 0x0000ef53;
-pub const EXT3_SUPER_MAGIC: ::c_long = 0x0000ef53;
-pub const EXT4_SUPER_MAGIC: ::c_long = 0x0000ef53;
-pub const HPFS_SUPER_MAGIC: ::c_long = 0xf995e849;
-pub const HUGETLBFS_MAGIC: ::c_long = 0x958458f6;
-pub const ISOFS_SUPER_MAGIC: ::c_long = 0x00009660;
-pub const JFFS2_SUPER_MAGIC: ::c_long = 0x000072b6;
-pub const MINIX_SUPER_MAGIC: ::c_long = 0x0000137f;
-pub const MINIX_SUPER_MAGIC2: ::c_long = 0x0000138f;
-pub const MINIX2_SUPER_MAGIC: ::c_long = 0x00002468;
-pub const MINIX2_SUPER_MAGIC2: ::c_long = 0x00002478;
-pub const MSDOS_SUPER_MAGIC: ::c_long = 0x00004d44;
-pub const NCP_SUPER_MAGIC: ::c_long = 0x0000564c;
-pub const NFS_SUPER_MAGIC: ::c_long = 0x00006969;
-pub const OPENPROM_SUPER_MAGIC: ::c_long = 0x00009fa1;
-pub const PROC_SUPER_MAGIC: ::c_long = 0x00009fa0;
-pub const QNX4_SUPER_MAGIC: ::c_long = 0x0000002f;
-pub const REISERFS_SUPER_MAGIC: ::c_long = 0x52654973;
-pub const SMB_SUPER_MAGIC: ::c_long = 0x0000517b;
-pub const TMPFS_MAGIC: ::c_long = 0x01021994;
-pub const USBDEVICE_SUPER_MAGIC: ::c_long = 0x00009fa2;
-
-pub const MAP_HUGETLB: ::c_int = 0x040000;
-
-pub const PTRACE_TRACEME: ::c_int = 0;
-pub const PTRACE_PEEKTEXT: ::c_int = 1;
-pub const PTRACE_PEEKDATA: ::c_int = 2;
-pub const PTRACE_PEEKUSER: ::c_int = 3;
-pub const PTRACE_POKETEXT: ::c_int = 4;
-pub const PTRACE_POKEDATA: ::c_int = 5;
-pub const PTRACE_POKEUSER: ::c_int = 6;
-pub const PTRACE_CONT: ::c_int = 7;
-pub const PTRACE_KILL: ::c_int = 8;
-pub const PTRACE_SINGLESTEP: ::c_int = 9;
-pub const PTRACE_ATTACH: ::c_int = 16;
-pub const PTRACE_DETACH: ::c_int = 17;
-pub const PTRACE_SYSCALL: ::c_int = 24;
-pub const PTRACE_SETOPTIONS: ::c_int = 0x4200;
-pub const PTRACE_GETEVENTMSG: ::c_int = 0x4201;
-pub const PTRACE_GETSIGINFO: ::c_int = 0x4202;
-pub const PTRACE_SETSIGINFO: ::c_int = 0x4203;
-
-pub const EFD_NONBLOCK: ::c_int = 0x800;
-
-pub const F_GETLK: ::c_int = 5;
-pub const F_GETOWN: ::c_int = 9;
-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 RLIMIT_CPU: ::c_int = 0;
-pub const RLIMIT_FSIZE: ::c_int = 1;
-pub const RLIMIT_DATA: ::c_int = 2;
-pub const RLIMIT_STACK: ::c_int = 3;
-pub const RLIMIT_CORE: ::c_int = 4;
-pub const RLIMIT_LOCKS: ::c_int = 10;
-pub const RLIMIT_SIGPENDING: ::c_int = 11;
-pub const RLIMIT_MSGQUEUE: ::c_int = 12;
-pub const RLIMIT_NICE: ::c_int = 13;
-pub const RLIMIT_RTPRIO: ::c_int = 14;
-
-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 TIOCINQ: ::c_int = 0x541B;
-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 ST_RDONLY: ::c_ulong = 1;
-pub const ST_NOSUID: ::c_ulong = 2;
-pub const ST_NODEV: ::c_ulong = 4;
-pub const ST_NOEXEC: ::c_ulong = 8;
-pub const ST_SYNCHRONOUS: ::c_ulong = 16;
-pub const ST_MANDLOCK: ::c_ulong = 64;
-pub const ST_NOATIME: ::c_ulong = 1024;
-pub const ST_NODIRATIME: ::c_ulong = 2048;
-pub const ST_RELATIME: ::c_ulong = 4096;
-
-pub const RTLD_NOLOAD: ::c_int = 0x4;
-
-pub const SEM_FAILED: *mut sem_t = 0 as *mut sem_t;
-
-pub const LINUX_REBOOT_MAGIC1: ::c_int = 0xfee1dead;
-pub const LINUX_REBOOT_MAGIC2: ::c_int = 672274793;
-pub const LINUX_REBOOT_MAGIC2A: ::c_int = 85072278;
-pub const LINUX_REBOOT_MAGIC2B: ::c_int = 369367448;
-pub const LINUX_REBOOT_MAGIC2C: ::c_int = 537993216;
-
-pub const LINUX_REBOOT_CMD_RESTART: ::c_int = 0x01234567;
-pub const LINUX_REBOOT_CMD_HALT: ::c_int = 0xCDEF0123;
-pub const LINUX_REBOOT_CMD_CAD_ON: ::c_int = 0x89ABCDEF;
-pub const LINUX_REBOOT_CMD_CAD_OFF: ::c_int = 0x00000000;
-pub const LINUX_REBOOT_CMD_POWER_OFF: ::c_int = 0x4321FEDC;
-pub const LINUX_REBOOT_CMD_RESTART2: ::c_int = 0xA1B2C3D4;
-pub const LINUX_REBOOT_CMD_SW_SUSPEND: ::c_int = 0xD000FCE2;
-pub const LINUX_REBOOT_CMD_KEXEC: ::c_int = 0x45584543;
-
-pub const MCL_CURRENT: ::c_int = 0x0001;
-pub const MCL_FUTURE: ::c_int = 0x0002;
-
-pub const CBAUD: ::tcflag_t = 0o0010017;
-pub const TAB1: ::tcflag_t = 0x00000800;
-pub const TAB2: ::tcflag_t = 0x00001000;
-pub const TAB3: ::tcflag_t = 0x00001800;
-pub const CR1: ::tcflag_t = 0x00000200;
-pub const CR2: ::tcflag_t = 0x00000400;
-pub const CR3: ::tcflag_t = 0x00000600;
-pub const FF1: ::tcflag_t = 0x00008000;
-pub const BS1: ::tcflag_t = 0x00002000;
-pub const VT1: ::tcflag_t = 0x00004000;
-pub const VWERASE: usize = 14;
-pub const VREPRINT: usize = 12;
-pub const VSUSP: usize = 10;
-pub const VSTART: usize = 8;
-pub const VSTOP: usize = 9;
-pub const VDISCARD: usize = 13;
-pub const VTIME: usize = 5;
-pub const IXON: ::tcflag_t = 0x00000400;
-pub const IXOFF: ::tcflag_t = 0x00001000;
-pub const ONLCR: ::tcflag_t = 0x4;
-pub const CSIZE: ::tcflag_t = 0x00000030;
-pub const CS6: ::tcflag_t = 0x00000010;
-pub const CS7: ::tcflag_t = 0x00000020;
-pub const CS8: ::tcflag_t = 0x00000030;
-pub const CSTOPB: ::tcflag_t = 0x00000040;
-pub const CREAD: ::tcflag_t = 0x00000080;
-pub const PARENB: ::tcflag_t = 0x00000100;
-pub const PARODD: ::tcflag_t = 0x00000200;
-pub const HUPCL: ::tcflag_t = 0x00000400;
-pub const CLOCAL: ::tcflag_t = 0x00000800;
-pub const ECHOKE: ::tcflag_t = 0x00000800;
-pub const ECHOE: ::tcflag_t = 0x00000010;
-pub const ECHOK: ::tcflag_t = 0x00000020;
-pub const ECHONL: ::tcflag_t = 0x00000040;
-pub const ECHOPRT: ::tcflag_t = 0x00000400;
-pub const ECHOCTL: ::tcflag_t = 0x00000200;
-pub const ISIG: ::tcflag_t = 0x00000001;
-pub const ICANON: ::tcflag_t = 0x00000002;
-pub const PENDIN: ::tcflag_t = 0x00004000;
-pub const NOFLSH: ::tcflag_t = 0x00000080;
-pub const VSWTC: usize = 7;
-pub const OLCUC: ::tcflag_t = 0o000002;
-pub const NLDLY: ::tcflag_t = 0o000400;
-pub const CRDLY: ::tcflag_t = 0o003000;
-pub const TABDLY: ::tcflag_t = 0o014000;
-pub const BSDLY: ::tcflag_t = 0o020000;
-pub const FFDLY: ::tcflag_t = 0o100000;
-pub const VTDLY: ::tcflag_t = 0o040000;
-pub const XTABS: ::tcflag_t = 0o014000;
-
-pub const B0: ::speed_t = 0o000000;
-pub const B50: ::speed_t = 0o000001;
-pub const B75: ::speed_t = 0o000002;
-pub const B110: ::speed_t = 0o000003;
-pub const B134: ::speed_t = 0o000004;
-pub const B150: ::speed_t = 0o000005;
-pub const B200: ::speed_t = 0o000006;
-pub const B300: ::speed_t = 0o000007;
-pub const B600: ::speed_t = 0o000010;
-pub const B1200: ::speed_t = 0o000011;
-pub const B1800: ::speed_t = 0o000012;
-pub const B2400: ::speed_t = 0o000013;
-pub const B4800: ::speed_t = 0o000014;
-pub const B9600: ::speed_t = 0o000015;
-pub const B19200: ::speed_t = 0o000016;
-pub const B38400: ::speed_t = 0o000017;
-pub const EXTA: ::speed_t = B19200;
-pub const EXTB: ::speed_t = B38400;
-pub const BOTHER: ::speed_t = 0o010000;
-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 EAI_AGAIN: ::c_int = 2;
-pub const EAI_BADFLAGS: ::c_int = 3;
-pub const EAI_FAIL: ::c_int = 4;
-pub const EAI_FAMILY: ::c_int = 5;
-pub const EAI_MEMORY: ::c_int = 6;
-pub const EAI_NODATA: ::c_int = 7;
-pub const EAI_NONAME: ::c_int = 8;
-pub const EAI_SERVICE: ::c_int = 9;
-pub const EAI_SOCKTYPE: ::c_int = 10;
-pub const EAI_SYSTEM: ::c_int = 11;
-pub const EAI_OVERFLOW: ::c_int = 14;
-
-pub const NETLINK_ROUTE: ::c_int = 0;
-pub const NETLINK_UNUSED: ::c_int = 1;
-pub const NETLINK_USERSOCK: ::c_int = 2;
-pub const NETLINK_FIREWALL: ::c_int = 3;
-pub const NETLINK_SOCK_DIAG: ::c_int = 4;
-pub const NETLINK_NFLOG: ::c_int = 5;
-pub const NETLINK_XFRM: ::c_int = 6;
-pub const NETLINK_SELINUX: ::c_int = 7;
-pub const NETLINK_ISCSI: ::c_int = 8;
-pub const NETLINK_AUDIT: ::c_int = 9;
-pub const NETLINK_FIB_LOOKUP: ::c_int = 10;
-pub const NETLINK_CONNECTOR: ::c_int = 11;
-pub const NETLINK_NETFILTER: ::c_int = 12;
-pub const NETLINK_IP6_FW: ::c_int = 13;
-pub const NETLINK_DNRTMSG: ::c_int = 14;
-pub const NETLINK_KOBJECT_UEVENT: ::c_int = 15;
-pub const NETLINK_GENERIC: ::c_int = 16;
-pub const NETLINK_SCSITRANSPORT: ::c_int = 18;
-pub const NETLINK_ECRYPTFS: ::c_int = 19;
-pub const NETLINK_RDMA: ::c_int = 20;
-pub const NETLINK_CRYPTO: ::c_int = 21;
-pub const NETLINK_INET_DIAG: ::c_int = NETLINK_SOCK_DIAG;
-
-pub const MAX_LINKS: ::c_int = 32;
-
-pub const NLM_F_REQUEST: ::c_int = 1;
-pub const NLM_F_MULTI: ::c_int = 2;
-pub const NLM_F_ACK: ::c_int = 4;
-pub const NLM_F_ECHO: ::c_int = 8;
-pub const NLM_F_DUMP_INTR: ::c_int = 16;
-
-pub const NLM_F_ROOT: ::c_int = 0x100;
-pub const NLM_F_MATCH: ::c_int = 0x200;
-pub const NLM_F_ATOMIC: ::c_int = 0x400;
-pub const NLM_F_DUMP: ::c_int = NLM_F_ROOT | NLM_F_MATCH;
-
-pub const NLM_F_REPLACE: ::c_int = 0x100;
-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 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;
-pub const NETLINK_BROADCAST_ERROR: ::c_int = 4;
-pub const NETLINK_NO_ENOBUFS: ::c_int = 5;
-pub const NETLINK_RX_RING: ::c_int = 6;
-pub const NETLINK_TX_RING: ::c_int = 7;
-
-pub const GRND_NONBLOCK: ::c_uint = 0x0001;
-pub const GRND_RANDOM: ::c_uint = 0x0002;
-
-pub const SECCOMP_MODE_DISABLED: ::c_uint = 0;
-pub const SECCOMP_MODE_STRICT: ::c_uint = 1;
-pub const SECCOMP_MODE_FILTER: ::c_uint = 2;
-
-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;
-pub const CBAUDEX: ::tcflag_t = 0o010000;
-
-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 POLLWRNORM: ::c_short = 0x100;
-pub const POLLWRBAND: ::c_short = 0x200;
-
-pub const SFD_CLOEXEC: ::c_int = O_CLOEXEC;
-pub const SFD_NONBLOCK: ::c_int = O_NONBLOCK;
-
-pub const SOCK_NONBLOCK: ::c_int = O_NONBLOCK;
-
-pub const SO_ORIGINAL_DST: ::c_int = 80;
-pub const IP_ORIGDSTADDR : ::c_int = 20;
-pub const IP_RECVORIGDSTADDR : ::c_int = IP_ORIGDSTADDR;
-pub const IPV6_ORIGDSTADDR : ::c_int = 74;
-pub const IPV6_RECVORIGDSTADDR : ::c_int = IPV6_ORIGDSTADDR;
-pub const IPV6_FLOWINFO: ::c_int = 11;
-pub const IPV6_FLOWLABEL_MGR: ::c_int = 32;
-pub const IPV6_FLOWINFO_SEND: ::c_int = 33;
-pub const IPV6_FLOWINFO_FLOWLABEL: ::c_int = 0x000fffff;
-pub const IPV6_FLOWINFO_PRIORITY: ::c_int = 0x0ff00000;
-pub const IUTF8: ::tcflag_t = 0x00004000;
-pub const CMSPAR: ::tcflag_t = 0o10000000000;
-pub const O_TMPFILE: ::c_int = 0o20000000 | O_DIRECTORY;
-
-pub const MFD_CLOEXEC: ::c_uint = 0x0001;
-pub const MFD_ALLOW_SEALING: ::c_uint = 0x0002;
-pub const MFD_HUGETLB: ::c_uint = 0x0004;
-
-// 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 = 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;
-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 = 25;
-
-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;
-
-#[deprecated(
- since = "0.2.55",
- note = "ENOATTR is not available on Android; use ENODATA instead"
-)]
-pub const ENOATTR: ::c_int = ::ENODATA;
-
-// linux/if_alg.h
-pub const ALG_SET_KEY: ::c_int = 1;
-pub const ALG_SET_IV: ::c_int = 2;
-pub const ALG_SET_OP: ::c_int = 3;
-pub const ALG_SET_AEAD_ASSOCLEN: ::c_int = 4;
-pub const ALG_SET_AEAD_AUTHSIZE: ::c_int = 5;
-
-pub const ALG_OP_DECRYPT: ::c_int = 0;
-pub const ALG_OP_ENCRYPT: ::c_int = 1;
-
-// uapi/linux/inotify.h
-pub const IN_ACCESS: u32 = 0x0000_0001;
-pub const IN_MODIFY: u32 = 0x0000_0002;
-pub const IN_ATTRIB: u32 = 0x0000_0004;
-pub const IN_CLOSE_WRITE: u32 = 0x0000_0008;
-pub const IN_CLOSE_NOWRITE: u32 = 0x0000_0010;
-pub const IN_CLOSE: u32 = (IN_CLOSE_WRITE | IN_CLOSE_NOWRITE);
-pub const IN_OPEN: u32 = 0x0000_0020;
-pub const IN_MOVED_FROM: u32 = 0x0000_0040;
-pub const IN_MOVED_TO: u32 = 0x0000_0080;
-pub const IN_MOVE: u32 = (IN_MOVED_FROM | IN_MOVED_TO);
-pub const IN_CREATE: u32 = 0x0000_0100;
-pub const IN_DELETE: u32 = 0x0000_0200;
-pub const IN_DELETE_SELF: u32 = 0x0000_0400;
-pub const IN_MOVE_SELF: u32 = 0x0000_0800;
-pub const IN_UNMOUNT: u32 = 0x0000_2000;
-pub const IN_Q_OVERFLOW: u32 = 0x0000_4000;
-pub const IN_IGNORED: u32 = 0x0000_8000;
-pub const IN_ONLYDIR: u32 = 0x0100_0000;
-pub const IN_DONT_FOLLOW: u32 = 0x0200_0000;
-// pub const IN_EXCL_UNLINK: u32 = 0x0400_0000;
-
-// pub const IN_MASK_CREATE: u32 = 0x1000_0000;
-// pub const IN_MASK_ADD: u32 = 0x2000_0000;
-pub const IN_ISDIR: u32 = 0x4000_0000;
-pub const IN_ONESHOT: u32 = 0x8000_0000;
-
-pub const IN_ALL_EVENTS: u32 = (
- IN_ACCESS | IN_MODIFY | IN_ATTRIB | IN_CLOSE_WRITE |
- IN_CLOSE_NOWRITE | IN_OPEN | IN_MOVED_FROM |
- IN_MOVED_TO | IN_DELETE | IN_CREATE | IN_DELETE_SELF |
- IN_MOVE_SELF
-);
-
-pub const IN_CLOEXEC: ::c_int = O_CLOEXEC;
-pub const IN_NONBLOCK: ::c_int = O_NONBLOCK;
-
-pub const FUTEX_WAIT: ::c_int = 0;
-pub const FUTEX_WAKE: ::c_int = 1;
-pub const FUTEX_FD: ::c_int = 2;
-pub const FUTEX_REQUEUE: ::c_int = 3;
-pub const FUTEX_CMP_REQUEUE: ::c_int = 4;
-pub const FUTEX_WAKE_OP: ::c_int = 5;
-pub const FUTEX_LOCK_PI: ::c_int = 6;
-pub const FUTEX_UNLOCK_PI: ::c_int = 7;
-pub const FUTEX_TRYLOCK_PI: ::c_int = 8;
-pub const FUTEX_WAIT_BITSET: ::c_int = 9;
-pub const FUTEX_WAKE_BITSET: ::c_int = 10;
-pub const FUTEX_WAIT_REQUEUE_PI: ::c_int = 11;
-pub const FUTEX_CMP_REQUEUE_PI: ::c_int = 12;
-
-pub const FUTEX_PRIVATE_FLAG: ::c_int = 128;
-pub const FUTEX_CLOCK_REALTIME: ::c_int = 256;
-pub const FUTEX_CMD_MASK: ::c_int =
- !(FUTEX_PRIVATE_FLAG | FUTEX_CLOCK_REALTIME);
-
-f! {
- pub fn CMSG_NXTHDR(mhdr: *const msghdr,
- cmsg: *const cmsghdr) -> *mut cmsghdr {
- let next = (cmsg as usize
- + super::CMSG_ALIGN((*cmsg).cmsg_len as usize))
- as *mut cmsghdr;
- let max = (*mhdr).msg_control as usize
- + (*mhdr).msg_controllen as usize;
- if (next.offset(1)) as usize > max {
- 0 as *mut cmsghdr
- } else {
- next as *mut cmsghdr
- }
- }
-
- pub fn CPU_ZERO(cpuset: &mut cpu_set_t) -> () {
- for slot in cpuset.__bits.iter_mut() {
- *slot = 0;
- }
- }
-
- pub fn CPU_SET(cpu: usize, cpuset: &mut cpu_set_t) -> () {
- let size_in___bits = 8 * ::mem::size_of_val(&cpuset.__bits[0]);
- let (idx, offset) = (cpu / size_in___bits, cpu % size_in___bits);
- cpuset.__bits[idx] |= 1 << offset;
- ()
- }
-
- pub fn CPU_CLR(cpu: usize, cpuset: &mut cpu_set_t) -> () {
- let size_in___bits = 8 * ::mem::size_of_val(&cpuset.__bits[0]);
- let (idx, offset) = (cpu / size_in___bits, cpu % size_in___bits);
- cpuset.__bits[idx] &= !(1 << offset);
- ()
- }
-
- pub fn CPU_ISSET(cpu: usize, cpuset: &cpu_set_t) -> bool {
- let size_in___bits = 8 * ::mem::size_of_val(&cpuset.__bits[0]);
- let (idx, offset) = (cpu / size_in___bits, cpu % size_in___bits);
- 0 != (cpuset.__bits[idx] & (1 << offset))
- }
-
- pub fn CPU_EQUAL(set1: &cpu_set_t, set2: &cpu_set_t) -> bool {
- set1.__bits == set2.__bits
- }
- pub fn major(dev: ::dev_t) -> ::c_int {
- ((dev >> 8) & 0xfff) as ::c_int
- }
- pub fn minor(dev: ::dev_t) -> ::c_int {
- ((dev & 0xff) | ((dev >> 12) & 0xfff00)) as ::c_int
- }
- pub fn makedev(ma: ::c_int, mi: ::c_int) -> ::dev_t {
- let ma = ma as ::dev_t;
- 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 {
- pub fn getrlimit64(resource: ::c_int,
- rlim: *mut rlimit64) -> ::c_int;
- pub fn setrlimit64(resource: ::c_int,
- rlim: *const rlimit64) -> ::c_int;
- pub fn getrlimit(resource: ::c_int, rlim: *mut ::rlimit) -> ::c_int;
- pub fn setrlimit(resource: ::c_int, rlim: *const ::rlimit) -> ::c_int;
- pub fn strerror_r(errnum: ::c_int, buf: *mut c_char,
- buflen: ::size_t) -> ::c_int;
-
- pub fn gettimeofday(tp: *mut ::timeval,
- tz: *mut ::timezone) -> ::c_int;
- pub fn madvise(addr: *mut ::c_void, len: ::size_t, advice: ::c_int)
- -> ::c_int;
- pub fn ioctl(fd: ::c_int, request: ::c_int, ...) -> ::c_int;
- pub fn msync(addr: *mut ::c_void, len: ::size_t,
- flags: ::c_int) -> ::c_int;
- pub fn mprotect(addr: *mut ::c_void, len: ::size_t, prot: ::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;
- pub fn getnameinfo(sa: *const ::sockaddr,
- salen: ::socklen_t,
- host: *mut ::c_char,
- hostlen: ::size_t,
- serv: *mut ::c_char,
- sevlen: ::size_t,
- flags: ::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 __sched_cpualloc(count: ::size_t) -> *mut ::cpu_set_t;
- pub fn __sched_cpufree(set: *mut ::cpu_set_t);
- pub fn __sched_cpucount(setsize: ::size_t,
- set: *const cpu_set_t) -> ::c_int;
- pub fn sched_getcpu() -> ::c_int;
-
- pub fn utmpname(name: *const ::c_char) -> ::c_int;
- pub fn setutent();
- pub fn getutent() -> *mut utmp;
-
- pub fn posix_fallocate(fd: ::c_int, offset: ::off_t,
- len: ::off_t) -> ::c_int;
- pub fn signalfd(fd: ::c_int, mask: *const ::sigset_t, flags: ::c_int)
- -> ::c_int;
- pub fn syscall(num: ::c_long, ...) -> ::c_long;
- pub fn sched_getaffinity(pid: ::pid_t,
- cpusetsize: ::size_t,
- cpuset: *mut cpu_set_t) -> ::c_int;
- pub fn sched_setaffinity(pid: ::pid_t,
- cpusetsize: ::size_t,
- cpuset: *const cpu_set_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;
- pub fn pthread_getschedparam(native: ::pthread_t,
- policy: *mut ::c_int,
- param: *mut ::sched_param) -> ::c_int;
- pub fn unshare(flags: ::c_int) -> ::c_int;
- pub fn umount(target: *const ::c_char) -> ::c_int;
- pub fn sched_get_priority_max(policy: ::c_int) -> ::c_int;
- pub fn tee(fd_in: ::c_int,
- fd_out: ::c_int,
- len: ::size_t,
- flags: ::c_uint) -> ::ssize_t;
- pub fn settimeofday(tv: *const ::timeval, tz: *const ::timezone) -> ::c_int;
- pub fn splice(fd_in: ::c_int,
- off_in: *mut ::loff_t,
- fd_out: ::c_int,
- off_out: *mut ::loff_t,
- len: ::size_t,
- flags: ::c_uint) -> ::ssize_t;
- pub fn eventfd(init: ::c_uint, flags: ::c_int) -> ::c_int;
- 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;
- pub fn vmsplice(fd: ::c_int,
- iov: *const ::iovec,
- nr_segs: ::size_t,
- flags: ::c_uint) -> ::ssize_t;
- pub fn mount(src: *const ::c_char,
- target: *const ::c_char,
- fstype: *const ::c_char,
- flags: ::c_ulong,
- data: *const ::c_void) -> ::c_int;
- pub fn personality(persona: ::c_uint) -> ::c_int;
- pub fn prctl(option: ::c_int, ...) -> ::c_int;
- pub fn sched_getparam(pid: ::pid_t, param: *mut ::sched_param) -> ::c_int;
- pub fn ppoll(fds: *mut ::pollfd,
- nfds: nfds_t,
- timeout: *const ::timespec,
- sigmask: *const sigset_t) -> ::c_int;
- pub fn pthread_mutex_timedlock(lock: *mut pthread_mutex_t,
- abstime: *const ::timespec) -> ::c_int;
- pub fn clone(cb: extern fn(*mut ::c_void) -> ::c_int,
- child_stack: *mut ::c_void,
- flags: ::c_int,
- arg: *mut ::c_void, ...) -> ::c_int;
- pub fn sched_getscheduler(pid: ::pid_t) -> ::c_int;
- pub fn clock_nanosleep(clk_id: ::clockid_t,
- flags: ::c_int,
- rqtp: *const ::timespec,
- rmtp: *mut ::timespec) -> ::c_int;
- pub fn pthread_attr_getguardsize(attr: *const ::pthread_attr_t,
- guardsize: *mut ::size_t) -> ::c_int;
- pub fn sethostname(name: *const ::c_char, len: ::size_t) -> ::c_int;
- pub fn sched_get_priority_min(policy: ::c_int) -> ::c_int;
- pub fn pthread_condattr_getpshared(attr: *const pthread_condattr_t,
- pshared: *mut ::c_int) -> ::c_int;
- pub fn sysinfo(info: *mut ::sysinfo) -> ::c_int;
- pub fn umount2(target: *const ::c_char, flags: ::c_int) -> ::c_int;
- pub fn pthread_setschedparam(native: ::pthread_t,
- policy: ::c_int,
- param: *const ::sched_param) -> ::c_int;
- pub fn swapon(path: *const ::c_char, swapflags: ::c_int) -> ::c_int;
- pub fn sched_setscheduler(pid: ::pid_t,
- policy: ::c_int,
- param: *const ::sched_param) -> ::c_int;
- pub fn sendfile(out_fd: ::c_int,
- in_fd: ::c_int,
- offset: *mut off_t,
- count: ::size_t) -> ::ssize_t;
- pub fn setfsgid(gid: ::gid_t) -> ::c_int;
- pub fn setfsuid(uid: ::uid_t) -> ::c_int;
- pub fn sigsuspend(mask: *const ::sigset_t) -> ::c_int;
- #[cfg_attr(target_os = "solaris", link_name = "__posix_getgrgid_r")]
- pub fn getgrgid_r(gid: ::gid_t,
- grp: *mut ::group,
- buf: *mut ::c_char,
- buflen: ::size_t,
- result: *mut *mut ::group) -> ::c_int;
- #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
- link_name = "sigaltstack$UNIX2003")]
- #[cfg_attr(target_os = "netbsd", link_name = "__sigaltstack14")]
- pub fn sigaltstack(ss: *const stack_t,
- oss: *mut stack_t) -> ::c_int;
- pub fn sem_close(sem: *mut sem_t) -> ::c_int;
- #[cfg_attr(target_os = "solaris", link_name = "__posix_getgrnam_r")]
- pub fn getgrnam_r(name: *const ::c_char,
- grp: *mut ::group,
- buf: *mut ::c_char,
- buflen: ::size_t,
- result: *mut *mut ::group) -> ::c_int;
- #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
- link_name = "pthread_sigmask$UNIX2003")]
- pub fn pthread_sigmask(how: ::c_int, set: *const sigset_t,
- oldset: *mut sigset_t) -> ::c_int;
- pub fn sem_open(name: *const ::c_char, oflag: ::c_int, ...) -> *mut sem_t;
- pub fn getgrnam(name: *const ::c_char) -> *mut ::group;
- pub fn pthread_kill(thread: ::pthread_t, sig: ::c_int) -> ::c_int;
- pub fn sem_unlink(name: *const ::c_char) -> ::c_int;
- pub fn daemon(nochdir: ::c_int, noclose: ::c_int) -> ::c_int;
- #[cfg_attr(target_os = "netbsd", link_name = "__getpwnam_r50")]
- #[cfg_attr(target_os = "solaris", link_name = "__posix_getpwnam_r")]
- pub fn getpwnam_r(name: *const ::c_char,
- pwd: *mut passwd,
- buf: *mut ::c_char,
- buflen: ::size_t,
- result: *mut *mut passwd) -> ::c_int;
- #[cfg_attr(target_os = "netbsd", link_name = "__getpwuid_r50")]
- #[cfg_attr(target_os = "solaris", link_name = "__posix_getpwuid_r")]
- pub fn getpwuid_r(uid: ::uid_t,
- pwd: *mut passwd,
- buf: *mut ::c_char,
- buflen: ::size_t,
- result: *mut *mut passwd) -> ::c_int;
- #[cfg_attr(all(target_os = "macos", target_arch ="x86"),
- link_name = "sigwait$UNIX2003")]
- #[cfg_attr(target_os = "solaris", link_name = "__posix_sigwait")]
- pub fn sigwait(set: *const sigset_t,
- sig: *mut ::c_int) -> ::c_int;
- pub fn pthread_atfork(prepare: ::Option<unsafe extern fn()>,
- parent: ::Option<unsafe extern fn()>,
- child: ::Option<unsafe extern fn()>) -> ::c_int;
- pub fn getgrgid(gid: ::gid_t) -> *mut ::group;
- pub fn getgrouplist(user: *const ::c_char,
- group: ::gid_t,
- groups: *mut ::gid_t,
- ngroups: *mut ::c_int) -> ::c_int;
- pub fn initgroups(user: *const ::c_char, group: ::gid_t) -> ::c_int;
- pub fn pthread_mutexattr_getpshared(attr: *const pthread_mutexattr_t,
- pshared: *mut ::c_int) -> ::c_int;
- #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
- link_name = "popen$UNIX2003")]
- pub fn popen(command: *const c_char,
- mode: *const c_char) -> *mut ::FILE;
- pub fn faccessat(dirfd: ::c_int, pathname: *const ::c_char,
- mode: ::c_int, flags: ::c_int) -> ::c_int;
- pub fn pthread_create(native: *mut ::pthread_t,
- attr: *const ::pthread_attr_t,
- f: extern fn(*mut ::c_void) -> *mut ::c_void,
- value: *mut ::c_void) -> ::c_int;
- pub fn __errno() -> *mut ::c_int;
- pub fn inotify_rm_watch(fd: ::c_int, wd: u32) -> ::c_int;
- pub fn sendmmsg(sockfd: ::c_int, msgvec: *const ::mmsghdr, vlen: ::c_uint,
- flags: ::c_int) -> ::c_int;
- pub fn recvmmsg(sockfd: ::c_int, msgvec: *mut ::mmsghdr, vlen: ::c_uint,
- flags: ::c_int, timeout: *const ::timespec) -> ::c_int;
- pub fn inotify_init() -> ::c_int;
- pub fn inotify_init1(flags: ::c_int) -> ::c_int;
- pub fn inotify_add_watch(fd: ::c_int,
- path: *const ::c_char,
- mask: u32) -> ::c_int;
-}
-
-cfg_if! {
- if #[cfg(target_pointer_width = "32")] {
- mod b32;
- pub use self::b32::*;
- } else if #[cfg(target_pointer_width = "64")] {
- mod b64;
- pub use self::b64::*;
- } else {
- // Unknown target_pointer_width
- }
-}
diff --git a/libc/src/unix/notbsd/emscripten/align.rs b/libc/src/unix/notbsd/emscripten/align.rs
deleted file mode 100644
index 26a49b2..0000000
--- a/libc/src/unix/notbsd/emscripten/align.rs
+++ /dev/null
@@ -1,66 +0,0 @@
-macro_rules! expand_align {
- () => {
- s! {
- #[repr(align(4))]
- pub struct pthread_mutex_t {
- size: [u8; ::__SIZEOF_PTHREAD_MUTEX_T],
- }
-
- #[repr(align(4))]
- pub struct pthread_rwlock_t {
- size: [u8; ::__SIZEOF_PTHREAD_RWLOCK_T],
- }
-
- #[repr(align(4))]
- pub struct pthread_mutexattr_t {
- size: [u8; ::__SIZEOF_PTHREAD_MUTEXATTR_T],
- }
-
- #[repr(align(4))]
- pub struct pthread_rwlockattr_t {
- size: [u8; ::__SIZEOF_PTHREAD_RWLOCKATTR_T],
- }
-
- #[repr(align(4))]
- pub struct pthread_condattr_t {
- size: [u8; ::__SIZEOF_PTHREAD_CONDATTR_T],
- }
- }
-
- s_no_extra_traits! {
- #[cfg_attr(target_pointer_width = "32",
- repr(align(4)))]
- #[cfg_attr(target_pointer_width = "64",
- repr(align(8)))]
- pub struct pthread_cond_t {
- size: [u8; ::__SIZEOF_PTHREAD_COND_T],
- }
- }
-
- cfg_if! {
- if #[cfg(feature = "extra_traits")] {
- impl PartialEq for pthread_cond_t {
- fn eq(&self, other: &pthread_cond_t) -> bool {
- self.size
- .iter()
- .zip(other.size.iter())
- .all(|(a,b)| a == b)
- }
- }
- impl Eq for pthread_cond_t {}
- impl ::fmt::Debug for pthread_cond_t {
- fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
- f.debug_struct("pthread_cond_t")
- // FIXME: .field("size", &self.size)
- .finish()
- }
- }
- impl ::hash::Hash for pthread_cond_t {
- fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
- self.size.hash(state);
- }
- }
- }
- }
- }
-}
diff --git a/libc/src/unix/notbsd/emscripten/mod.rs b/libc/src/unix/notbsd/emscripten/mod.rs
deleted file mode 100644
index ba13d8e..0000000
--- a/libc/src/unix/notbsd/emscripten/mod.rs
+++ /dev/null
@@ -1,1866 +0,0 @@
-pub type c_char = i8;
-pub type wchar_t = i32;
-pub type useconds_t = u32;
-pub type dev_t = u32;
-pub type socklen_t = u32;
-pub type pthread_t = c_ulong;
-pub type mode_t = u32;
-pub type ino64_t = u32;
-pub type off64_t = i32;
-pub type blkcnt64_t = i32;
-pub type rlim64_t = u64;
-pub type shmatt_t = ::c_ulong;
-pub type mqd_t = ::c_int;
-pub type msgqnum_t = ::c_ulong;
-pub type msglen_t = ::c_ulong;
-pub type nfds_t = ::c_ulong;
-pub type nl_item = ::c_int;
-pub type idtype_t = ::c_uint;
-pub type loff_t = i32;
-pub type pthread_key_t = ::c_uint;
-
-pub type clock_t = c_long;
-pub type time_t = c_long;
-pub type suseconds_t = c_long;
-pub type ino_t = u32;
-pub type off_t = i32;
-pub type blkcnt_t = i32;
-
-pub type blksize_t = c_long;
-pub type fsblkcnt_t = u32;
-pub type fsfilcnt_t = u32;
-pub type rlim_t = ::c_ulonglong;
-pub type c_long = i32;
-pub type c_ulong = u32;
-pub type nlink_t = u32;
-
-#[cfg_attr(feature = "extra_traits", derive(Debug))]
-pub enum fpos64_t {} // TODO: fill this out with a struct
-impl ::Copy for fpos64_t {}
-impl ::Clone for fpos64_t {
- fn clone(&self) -> fpos64_t { *self }
-}
-
-s! {
- pub struct rlimit64 {
- pub rlim_cur: rlim64_t,
- pub rlim_max: rlim64_t,
- }
-
- pub struct glob_t {
- pub gl_pathc: ::size_t,
- pub gl_pathv: *mut *mut c_char,
- pub gl_offs: ::size_t,
- pub gl_flags: ::c_int,
-
- __unused1: *mut ::c_void,
- __unused2: *mut ::c_void,
- __unused3: *mut ::c_void,
- __unused4: *mut ::c_void,
- __unused5: *mut ::c_void,
- }
-
- pub struct passwd {
- 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 spwd {
- pub sp_namp: *mut ::c_char,
- pub sp_pwdp: *mut ::c_char,
- pub sp_lstchg: ::c_long,
- pub sp_min: ::c_long,
- pub sp_max: ::c_long,
- pub sp_warn: ::c_long,
- pub sp_inact: ::c_long,
- pub sp_expire: ::c_long,
- 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,
- 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 dqblk {
- pub dqb_bhardlimit: u64,
- pub dqb_bsoftlimit: u64,
- pub dqb_curspace: u64,
- pub dqb_ihardlimit: u64,
- pub dqb_isoftlimit: u64,
- pub dqb_curinodes: u64,
- pub dqb_btime: u64,
- pub dqb_itime: u64,
- pub dqb_valid: u32,
- }
-
- pub struct signalfd_siginfo {
- pub ssi_signo: u32,
- pub ssi_errno: i32,
- pub ssi_code: i32,
- pub ssi_pid: u32,
- pub ssi_uid: u32,
- pub ssi_fd: i32,
- pub ssi_tid: u32,
- pub ssi_band: u32,
- pub ssi_overrun: u32,
- pub ssi_trapno: u32,
- pub ssi_status: i32,
- pub ssi_int: i32,
- pub ssi_ptr: u64,
- pub ssi_utime: u64,
- pub ssi_stime: u64,
- pub ssi_addr: u64,
- pub ssi_addr_lsb: u16,
- _pad2: u16,
- pub ssi_syscall: i32,
- pub ssi_call_addr: u64,
- pub ssi_arch: u32,
- _pad: [u8; 28],
- }
-
- pub struct fsid_t {
- __val: [::c_int; 2],
- }
-
- pub struct cpu_set_t {
- bits: [u32; 32],
- }
-
- pub struct if_nameindex {
- pub if_index: ::c_uint,
- pub if_name: *mut ::c_char,
- }
-
- // System V IPC
- pub struct msginfo {
- pub msgpool: ::c_int,
- pub msgmap: ::c_int,
- pub msgmax: ::c_int,
- pub msgmnb: ::c_int,
- pub msgmni: ::c_int,
- pub msgssz: ::c_int,
- pub msgtql: ::c_int,
- pub msgseg: ::c_ushort,
- }
-
- pub struct sembuf {
- pub sem_num: ::c_ushort,
- pub sem_op: ::c_short,
- pub sem_flg: ::c_short,
- }
-
- pub struct aiocb {
- pub aio_fildes: ::c_int,
- pub aio_lio_opcode: ::c_int,
- pub aio_reqprio: ::c_int,
- pub aio_buf: *mut ::c_void,
- pub aio_nbytes: ::size_t,
- pub aio_sigevent: ::sigevent,
- __td: *mut ::c_void,
- __lock: [::c_int; 2],
- __err: ::c_int,
- __ret: ::ssize_t,
- pub aio_offset: off_t,
- __next: *mut ::c_void,
- __prev: *mut ::c_void,
- __dummy4: [::c_char; 24],
- }
-
- pub struct sigaction {
- pub sa_sigaction: ::sighandler_t,
- pub sa_mask: ::sigset_t,
- pub sa_flags: ::c_int,
- pub sa_restorer: ::Option<extern fn()>,
- }
-
- pub struct 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 termios {
- pub c_iflag: ::tcflag_t,
- pub c_oflag: ::tcflag_t,
- pub c_cflag: ::tcflag_t,
- pub c_lflag: ::tcflag_t,
- pub c_line: ::cc_t,
- pub c_cc: [::cc_t; ::NCCS],
- pub __c_ispeed: ::speed_t,
- pub __c_ospeed: ::speed_t,
- }
-
- pub struct flock {
- pub l_type: ::c_short,
- pub l_whence: ::c_short,
- pub l_start: ::off_t,
- pub l_len: ::off_t,
- pub l_pid: ::pid_t,
- }
-
- pub struct pthread_attr_t {
- __size: [u32; 11]
- }
-
- pub struct sigset_t {
- __val: [::c_ulong; 32],
- }
-
- pub struct msghdr {
- pub msg_name: *mut ::c_void,
- pub msg_namelen: ::socklen_t,
- pub msg_iov: *mut ::iovec,
- pub msg_iovlen: ::c_int,
- pub msg_control: *mut ::c_void,
- pub msg_controllen: ::socklen_t,
- pub msg_flags: ::c_int,
- }
-
- pub struct cmsghdr {
- pub cmsg_len: ::socklen_t,
- pub cmsg_level: ::c_int,
- pub cmsg_type: ::c_int,
- }
-
- pub struct sem_t {
- __val: [::c_int; 4],
- }
- pub struct stat {
- pub st_dev: ::dev_t,
- __st_dev_padding: ::c_int,
- __st_ino_truncated: ::c_long,
- pub st_mode: ::mode_t,
- pub st_nlink: ::nlink_t,
- pub st_uid: ::uid_t,
- pub st_gid: ::gid_t,
- pub st_rdev: ::dev_t,
- __st_rdev_padding: ::c_int,
- 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,
- pub st_ino: ::ino_t,
- }
-
- pub struct stat64 {
- pub st_dev: ::dev_t,
- __st_dev_padding: ::c_int,
- __st_ino_truncated: ::c_long,
- pub st_mode: ::mode_t,
- pub st_nlink: ::nlink_t,
- pub st_uid: ::uid_t,
- pub st_gid: ::gid_t,
- pub st_rdev: ::dev_t,
- __st_rdev_padding: ::c_int,
- 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,
- pub st_ino: ::ino_t,
- }
-
- pub struct stack_t {
- pub ss_sp: *mut ::c_void,
- pub ss_flags: ::c_int,
- pub ss_size: ::size_t
- }
-
- pub struct shmid_ds {
- pub shm_perm: ::ipc_perm,
- pub shm_segsz: ::size_t,
- pub shm_atime: ::time_t,
- __unused1: ::c_int,
- pub shm_dtime: ::time_t,
- __unused2: ::c_int,
- pub shm_ctime: ::time_t,
- __unused3: ::c_int,
- 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,
- pub msg_stime: ::time_t,
- __unused1: ::c_int,
- pub msg_rtime: ::time_t,
- __unused2: ::c_int,
- pub msg_ctime: ::time_t,
- __unused3: ::c_int,
- __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: u32,
- pub f_bfree: u32,
- pub f_bavail: u32,
- pub f_files: u32,
- pub f_ffree: u32,
- pub f_favail: u32,
- 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 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],
- }
-}
-
-s_no_extra_traits! {
- pub struct dirent {
- pub d_ino: ::ino_t,
- pub d_off: ::off_t,
- pub d_reclen: ::c_ushort,
- pub d_type: ::c_uchar,
- pub d_name: [::c_char; 256],
- }
-
- pub struct dirent64 {
- pub d_ino: ::ino64_t,
- pub d_off: ::off64_t,
- pub d_reclen: ::c_ushort,
- pub d_type: ::c_uchar,
- pub d_name: [::c_char; 256],
- }
-
- pub struct sysinfo {
- pub uptime: ::c_ulong,
- pub loads: [::c_ulong; 3],
- pub totalram: ::c_ulong,
- pub freeram: ::c_ulong,
- pub sharedram: ::c_ulong,
- pub bufferram: ::c_ulong,
- pub totalswap: ::c_ulong,
- pub freeswap: ::c_ulong,
- pub procs: ::c_ushort,
- pub pad: ::c_ushort,
- pub totalhigh: ::c_ulong,
- pub freehigh: ::c_ulong,
- pub mem_unit: ::c_uint,
- pub __reserved: [::c_char; 256],
- }
-
- pub struct mq_attr {
- pub mq_flags: ::c_long,
- pub mq_maxmsg: ::c_long,
- pub mq_msgsize: ::c_long,
- pub mq_curmsgs: ::c_long,
- pad: [::c_long; 4]
- }
-}
-
-cfg_if! {
- if #[cfg(feature = "extra_traits")] {
- impl PartialEq for dirent {
- fn eq(&self, other: &dirent) -> bool {
- self.d_ino == other.d_ino
- && self.d_off == other.d_off
- && self.d_reclen == other.d_reclen
- && self.d_type == other.d_type
- && self
- .d_name
- .iter()
- .zip(other.d_name.iter())
- .all(|(a,b)| a == b)
- }
- }
- impl Eq for dirent {}
- impl ::fmt::Debug for dirent {
- fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
- f.debug_struct("dirent")
- .field("d_ino", &self.d_ino)
- .field("d_off", &self.d_off)
- .field("d_reclen", &self.d_reclen)
- .field("d_type", &self.d_type)
- // FIXME: .field("d_name", &self.d_name)
- .finish()
- }
- }
- impl ::hash::Hash for dirent {
- fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
- self.d_ino.hash(state);
- self.d_off.hash(state);
- self.d_reclen.hash(state);
- self.d_type.hash(state);
- self.d_name.hash(state);
- }
- }
-
- impl PartialEq for dirent64 {
- fn eq(&self, other: &dirent64) -> bool {
- self.d_ino == other.d_ino
- && self.d_off == other.d_off
- && self.d_reclen == other.d_reclen
- && self.d_type == other.d_type
- && self
- .d_name
- .iter()
- .zip(other.d_name.iter())
- .all(|(a,b)| a == b)
- }
- }
- impl Eq for dirent64 {}
- impl ::fmt::Debug for dirent64 {
- fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
- f.debug_struct("dirent64")
- .field("d_ino", &self.d_ino)
- .field("d_off", &self.d_off)
- .field("d_reclen", &self.d_reclen)
- .field("d_type", &self.d_type)
- // FIXME: .field("d_name", &self.d_name)
- .finish()
- }
- }
- impl ::hash::Hash for dirent64 {
- fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
- self.d_ino.hash(state);
- self.d_off.hash(state);
- self.d_reclen.hash(state);
- self.d_type.hash(state);
- self.d_name.hash(state);
- }
- }
-
- impl PartialEq for sysinfo {
- fn eq(&self, other: &sysinfo) -> bool {
- self.uptime == other.uptime
- && self.loads == other.loads
- && self.totalram == other.totalram
- && self.freeram == other.freeram
- && self.sharedram == other.sharedram
- && self.bufferram == other.bufferram
- && self.totalswap == other.totalswap
- && self.freeswap == other.freeswap
- && self.procs == other.procs
- && self.pad == other.pad
- && self.totalhigh == other.totalhigh
- && self.freehigh == other.freehigh
- && self.mem_unit == other.mem_unit
- && self
- .__reserved
- .iter()
- .zip(other.__reserved.iter())
- .all(|(a,b)| a == b)
- }
- }
- impl Eq for sysinfo {}
- impl ::fmt::Debug for sysinfo {
- fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
- f.debug_struct("sysinfo")
- .field("uptime", &self.uptime)
- .field("loads", &self.loads)
- .field("totalram", &self.totalram)
- .field("freeram", &self.freeram)
- .field("sharedram", &self.sharedram)
- .field("bufferram", &self.bufferram)
- .field("totalswap", &self.totalswap)
- .field("freeswap", &self.freeswap)
- .field("procs", &self.procs)
- .field("pad", &self.pad)
- .field("totalhigh", &self.totalhigh)
- .field("freehigh", &self.freehigh)
- .field("mem_unit", &self.mem_unit)
- // FIXME: .field("__reserved", &self.__reserved)
- .finish()
- }
- }
- impl ::hash::Hash for sysinfo {
- fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
- self.uptime.hash(state);
- self.loads.hash(state);
- self.totalram.hash(state);
- self.freeram.hash(state);
- self.sharedram.hash(state);
- self.bufferram.hash(state);
- self.totalswap.hash(state);
- self.freeswap.hash(state);
- self.procs.hash(state);
- self.pad.hash(state);
- self.totalhigh.hash(state);
- self.freehigh.hash(state);
- self.mem_unit.hash(state);
- self.__reserved.hash(state);
- }
- }
-
- impl PartialEq for mq_attr {
- fn eq(&self, other: &mq_attr) -> bool {
- self.mq_flags == other.mq_flags &&
- self.mq_maxmsg == other.mq_maxmsg &&
- self.mq_msgsize == other.mq_msgsize &&
- self.mq_curmsgs == other.mq_curmsgs
- }
- }
- impl Eq for mq_attr {}
- impl ::fmt::Debug for mq_attr {
- fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
- f.debug_struct("mq_attr")
- .field("mq_flags", &self.mq_flags)
- .field("mq_maxmsg", &self.mq_maxmsg)
- .field("mq_msgsize", &self.mq_msgsize)
- .field("mq_curmsgs", &self.mq_curmsgs)
- .finish()
- }
- }
- impl ::hash::Hash for mq_attr {
- fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
- self.mq_flags.hash(state);
- self.mq_maxmsg.hash(state);
- self.mq_msgsize.hash(state);
- self.mq_curmsgs.hash(state);
- }
- }
- }
-}
-
-pub const MADV_SOFT_OFFLINE: ::c_int = 101;
-pub const MS_NOUSER: ::c_ulong = 0x80000000;
-pub const MS_RMT_MASK: ::c_ulong = 0x02800051;
-
-pub const ABDAY_1: ::nl_item = 0x20000;
-pub const ABDAY_2: ::nl_item = 0x20001;
-pub const ABDAY_3: ::nl_item = 0x20002;
-pub const ABDAY_4: ::nl_item = 0x20003;
-pub const ABDAY_5: ::nl_item = 0x20004;
-pub const ABDAY_6: ::nl_item = 0x20005;
-pub const ABDAY_7: ::nl_item = 0x20006;
-
-pub const DAY_1: ::nl_item = 0x20007;
-pub const DAY_2: ::nl_item = 0x20008;
-pub const DAY_3: ::nl_item = 0x20009;
-pub const DAY_4: ::nl_item = 0x2000A;
-pub const DAY_5: ::nl_item = 0x2000B;
-pub const DAY_6: ::nl_item = 0x2000C;
-pub const DAY_7: ::nl_item = 0x2000D;
-
-pub const ABMON_1: ::nl_item = 0x2000E;
-pub const ABMON_2: ::nl_item = 0x2000F;
-pub const ABMON_3: ::nl_item = 0x20010;
-pub const ABMON_4: ::nl_item = 0x20011;
-pub const ABMON_5: ::nl_item = 0x20012;
-pub const ABMON_6: ::nl_item = 0x20013;
-pub const ABMON_7: ::nl_item = 0x20014;
-pub const ABMON_8: ::nl_item = 0x20015;
-pub const ABMON_9: ::nl_item = 0x20016;
-pub const ABMON_10: ::nl_item = 0x20017;
-pub const ABMON_11: ::nl_item = 0x20018;
-pub const ABMON_12: ::nl_item = 0x20019;
-
-pub const MON_1: ::nl_item = 0x2001A;
-pub const MON_2: ::nl_item = 0x2001B;
-pub const MON_3: ::nl_item = 0x2001C;
-pub const MON_4: ::nl_item = 0x2001D;
-pub const MON_5: ::nl_item = 0x2001E;
-pub const MON_6: ::nl_item = 0x2001F;
-pub const MON_7: ::nl_item = 0x20020;
-pub const MON_8: ::nl_item = 0x20021;
-pub const MON_9: ::nl_item = 0x20022;
-pub const MON_10: ::nl_item = 0x20023;
-pub const MON_11: ::nl_item = 0x20024;
-pub const MON_12: ::nl_item = 0x20025;
-
-pub const AM_STR: ::nl_item = 0x20026;
-pub const PM_STR: ::nl_item = 0x20027;
-
-pub const D_T_FMT: ::nl_item = 0x20028;
-pub const D_FMT: ::nl_item = 0x20029;
-pub const T_FMT: ::nl_item = 0x2002A;
-pub const T_FMT_AMPM: ::nl_item = 0x2002B;
-
-pub const ERA: ::nl_item = 0x2002C;
-pub const ERA_D_FMT: ::nl_item = 0x2002E;
-pub const ALT_DIGITS: ::nl_item = 0x2002F;
-pub const ERA_D_T_FMT: ::nl_item = 0x20030;
-pub const ERA_T_FMT: ::nl_item = 0x20031;
-
-pub const CODESET: ::nl_item = 14;
-
-pub const CRNCYSTR: ::nl_item = 0x4000F;
-
-pub const RUSAGE_THREAD: ::c_int = 1;
-pub const RUSAGE_CHILDREN: ::c_int = -1;
-
-pub const RADIXCHAR: ::nl_item = 0x10000;
-pub const THOUSEP: ::nl_item = 0x10001;
-
-pub const YESEXPR: ::nl_item = 0x50000;
-pub const NOEXPR: ::nl_item = 0x50001;
-pub const YESSTR: ::nl_item = 0x50002;
-pub const NOSTR: ::nl_item = 0x50003;
-
-pub const FILENAME_MAX: ::c_uint = 4096;
-pub const L_tmpnam: ::c_uint = 20;
-pub const _PC_LINK_MAX: ::c_int = 0;
-pub const _PC_MAX_CANON: ::c_int = 1;
-pub const _PC_MAX_INPUT: ::c_int = 2;
-pub const _PC_NAME_MAX: ::c_int = 3;
-pub const _PC_PATH_MAX: ::c_int = 4;
-pub const _PC_PIPE_BUF: ::c_int = 5;
-pub const _PC_CHOWN_RESTRICTED: ::c_int = 6;
-pub const _PC_NO_TRUNC: ::c_int = 7;
-pub const _PC_VDISABLE: ::c_int = 8;
-pub const _PC_SYNC_IO: ::c_int = 9;
-pub const _PC_ASYNC_IO: ::c_int = 10;
-pub const _PC_PRIO_IO: ::c_int = 11;
-pub const _PC_SOCK_MAXBUF: ::c_int = 12;
-pub const _PC_FILESIZEBITS: ::c_int = 13;
-pub const _PC_REC_INCR_XFER_SIZE: ::c_int = 14;
-pub const _PC_REC_MAX_XFER_SIZE: ::c_int = 15;
-pub const _PC_REC_MIN_XFER_SIZE: ::c_int = 16;
-pub const _PC_REC_XFER_ALIGN: ::c_int = 17;
-pub const _PC_ALLOC_SIZE_MIN: ::c_int = 18;
-pub const _PC_SYMLINK_MAX: ::c_int = 19;
-pub const _PC_2_SYMLINKS: ::c_int = 20;
-
-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_STREAM_MAX: ::c_int = 5;
-pub const _SC_TZNAME_MAX: ::c_int = 6;
-pub const _SC_JOB_CONTROL: ::c_int = 7;
-pub const _SC_SAVED_IDS: ::c_int = 8;
-pub const _SC_REALTIME_SIGNALS: ::c_int = 9;
-pub const _SC_PRIORITY_SCHEDULING: ::c_int = 10;
-pub const _SC_TIMERS: ::c_int = 11;
-pub const _SC_ASYNCHRONOUS_IO: ::c_int = 12;
-pub const _SC_PRIORITIZED_IO: ::c_int = 13;
-pub const _SC_SYNCHRONIZED_IO: ::c_int = 14;
-pub const _SC_FSYNC: ::c_int = 15;
-pub const _SC_MAPPED_FILES: ::c_int = 16;
-pub const _SC_MEMLOCK: ::c_int = 17;
-pub const _SC_MEMLOCK_RANGE: ::c_int = 18;
-pub const _SC_MEMORY_PROTECTION: ::c_int = 19;
-pub const _SC_MESSAGE_PASSING: ::c_int = 20;
-pub const _SC_SEMAPHORES: ::c_int = 21;
-pub const _SC_SHARED_MEMORY_OBJECTS: ::c_int = 22;
-pub const _SC_AIO_LISTIO_MAX: ::c_int = 23;
-pub const _SC_AIO_MAX: ::c_int = 24;
-pub const _SC_AIO_PRIO_DELTA_MAX: ::c_int = 25;
-pub const _SC_DELAYTIMER_MAX: ::c_int = 26;
-pub const _SC_MQ_OPEN_MAX: ::c_int = 27;
-pub const _SC_MQ_PRIO_MAX: ::c_int = 28;
-pub const _SC_VERSION: ::c_int = 29;
-pub const _SC_PAGESIZE: ::c_int = 30;
-pub const _SC_PAGE_SIZE: ::c_int = _SC_PAGESIZE;
-pub const _SC_RTSIG_MAX: ::c_int = 31;
-pub const _SC_SEM_NSEMS_MAX: ::c_int = 32;
-pub const _SC_SEM_VALUE_MAX: ::c_int = 33;
-pub const _SC_SIGQUEUE_MAX: ::c_int = 34;
-pub const _SC_TIMER_MAX: ::c_int = 35;
-pub const _SC_BC_BASE_MAX: ::c_int = 36;
-pub const _SC_BC_DIM_MAX: ::c_int = 37;
-pub const _SC_BC_SCALE_MAX: ::c_int = 38;
-pub const _SC_BC_STRING_MAX: ::c_int = 39;
-pub const _SC_COLL_WEIGHTS_MAX: ::c_int = 40;
-pub const _SC_EXPR_NEST_MAX: ::c_int = 42;
-pub const _SC_LINE_MAX: ::c_int = 43;
-pub const _SC_RE_DUP_MAX: ::c_int = 44;
-pub const _SC_2_VERSION: ::c_int = 46;
-pub const _SC_2_C_BIND: ::c_int = 47;
-pub const _SC_2_C_DEV: ::c_int = 48;
-pub const _SC_2_FORT_DEV: ::c_int = 49;
-pub const _SC_2_FORT_RUN: ::c_int = 50;
-pub const _SC_2_SW_DEV: ::c_int = 51;
-pub const _SC_2_LOCALEDEF: ::c_int = 52;
-pub const _SC_UIO_MAXIOV: ::c_int = 60;
-pub const _SC_IOV_MAX: ::c_int = 60;
-pub const _SC_THREADS: ::c_int = 67;
-pub const _SC_THREAD_SAFE_FUNCTIONS: ::c_int = 68;
-pub const _SC_GETGR_R_SIZE_MAX: ::c_int = 69;
-pub const _SC_GETPW_R_SIZE_MAX: ::c_int = 70;
-pub const _SC_LOGIN_NAME_MAX: ::c_int = 71;
-pub const _SC_TTY_NAME_MAX: ::c_int = 72;
-pub const _SC_THREAD_DESTRUCTOR_ITERATIONS: ::c_int = 73;
-pub const _SC_THREAD_KEYS_MAX: ::c_int = 74;
-pub const _SC_THREAD_STACK_MIN: ::c_int = 75;
-pub const _SC_THREAD_THREADS_MAX: ::c_int = 76;
-pub const _SC_THREAD_ATTR_STACKADDR: ::c_int = 77;
-pub const _SC_THREAD_ATTR_STACKSIZE: ::c_int = 78;
-pub const _SC_THREAD_PRIORITY_SCHEDULING: ::c_int = 79;
-pub const _SC_THREAD_PRIO_INHERIT: ::c_int = 80;
-pub const _SC_THREAD_PRIO_PROTECT: ::c_int = 81;
-pub const _SC_THREAD_PROCESS_SHARED: ::c_int = 82;
-pub const _SC_NPROCESSORS_CONF: ::c_int = 83;
-pub const _SC_NPROCESSORS_ONLN: ::c_int = 84;
-pub const _SC_PHYS_PAGES: ::c_int = 85;
-pub const _SC_AVPHYS_PAGES: ::c_int = 86;
-pub const _SC_ATEXIT_MAX: ::c_int = 87;
-pub const _SC_PASS_MAX: ::c_int = 88;
-pub const _SC_XOPEN_VERSION: ::c_int = 89;
-pub const _SC_XOPEN_XCU_VERSION: ::c_int = 90;
-pub const _SC_XOPEN_UNIX: ::c_int = 91;
-pub const _SC_XOPEN_CRYPT: ::c_int = 92;
-pub const _SC_XOPEN_ENH_I18N: ::c_int = 93;
-pub const _SC_XOPEN_SHM: ::c_int = 94;
-pub const _SC_2_CHAR_TERM: ::c_int = 95;
-pub const _SC_2_UPE: ::c_int = 97;
-pub const _SC_XOPEN_XPG2: ::c_int = 98;
-pub const _SC_XOPEN_XPG3: ::c_int = 99;
-pub const _SC_XOPEN_XPG4: ::c_int = 100;
-pub const _SC_NZERO: ::c_int = 109;
-pub const _SC_XBS5_ILP32_OFF32: ::c_int = 125;
-pub const _SC_XBS5_ILP32_OFFBIG: ::c_int = 126;
-pub const _SC_XBS5_LP64_OFF64: ::c_int = 127;
-pub const _SC_XBS5_LPBIG_OFFBIG: ::c_int = 128;
-pub const _SC_XOPEN_LEGACY: ::c_int = 129;
-pub const _SC_XOPEN_REALTIME: ::c_int = 130;
-pub const _SC_XOPEN_REALTIME_THREADS: ::c_int = 131;
-pub const _SC_ADVISORY_INFO: ::c_int = 132;
-pub const _SC_BARRIERS: ::c_int = 133;
-pub const _SC_CLOCK_SELECTION: ::c_int = 137;
-pub const _SC_CPUTIME: ::c_int = 138;
-pub const _SC_THREAD_CPUTIME: ::c_int = 139;
-pub const _SC_MONOTONIC_CLOCK: ::c_int = 149;
-pub const _SC_READER_WRITER_LOCKS: ::c_int = 153;
-pub const _SC_SPIN_LOCKS: ::c_int = 154;
-pub const _SC_REGEXP: ::c_int = 155;
-pub const _SC_SHELL: ::c_int = 157;
-pub const _SC_SPAWN: ::c_int = 159;
-pub const _SC_SPORADIC_SERVER: ::c_int = 160;
-pub const _SC_THREAD_SPORADIC_SERVER: ::c_int = 161;
-pub const _SC_TIMEOUTS: ::c_int = 164;
-pub const _SC_TYPED_MEMORY_OBJECTS: ::c_int = 165;
-pub const _SC_2_PBS: ::c_int = 168;
-pub const _SC_2_PBS_ACCOUNTING: ::c_int = 169;
-pub const _SC_2_PBS_LOCATE: ::c_int = 170;
-pub const _SC_2_PBS_MESSAGE: ::c_int = 171;
-pub const _SC_2_PBS_TRACK: ::c_int = 172;
-pub const _SC_SYMLOOP_MAX: ::c_int = 173;
-pub const _SC_STREAMS: ::c_int = 174;
-pub const _SC_2_PBS_CHECKPOINT: ::c_int = 175;
-pub const _SC_V6_ILP32_OFF32: ::c_int = 176;
-pub const _SC_V6_ILP32_OFFBIG: ::c_int = 177;
-pub const _SC_V6_LP64_OFF64: ::c_int = 178;
-pub const _SC_V6_LPBIG_OFFBIG: ::c_int = 179;
-pub const _SC_HOST_NAME_MAX: ::c_int = 180;
-pub const _SC_TRACE: ::c_int = 181;
-pub const _SC_TRACE_EVENT_FILTER: ::c_int = 182;
-pub const _SC_TRACE_INHERIT: ::c_int = 183;
-pub const _SC_TRACE_LOG: ::c_int = 184;
-pub const _SC_IPV6: ::c_int = 235;
-pub const _SC_RAW_SOCKETS: ::c_int = 236;
-pub const _SC_V7_ILP32_OFF32: ::c_int = 237;
-pub const _SC_V7_ILP32_OFFBIG: ::c_int = 238;
-pub const _SC_V7_LP64_OFF64: ::c_int = 239;
-pub const _SC_V7_LPBIG_OFFBIG: ::c_int = 240;
-pub const _SC_SS_REPL_MAX: ::c_int = 241;
-pub const _SC_TRACE_EVENT_NAME_MAX: ::c_int = 242;
-pub const _SC_TRACE_NAME_MAX: ::c_int = 243;
-pub const _SC_TRACE_SYS_MAX: ::c_int = 244;
-pub const _SC_TRACE_USER_EVENT_MAX: ::c_int = 245;
-pub const _SC_XOPEN_STREAMS: ::c_int = 246;
-pub const _SC_THREAD_ROBUST_PRIO_INHERIT: ::c_int = 247;
-pub const _SC_THREAD_ROBUST_PRIO_PROTECT: ::c_int = 248;
-
-pub const RLIM_SAVED_MAX: ::rlim_t = RLIM_INFINITY;
-pub const RLIM_SAVED_CUR: ::rlim_t = RLIM_INFINITY;
-
-pub const GLOB_ERR: ::c_int = 1 << 0;
-pub const GLOB_MARK: ::c_int = 1 << 1;
-pub const GLOB_NOSORT: ::c_int = 1 << 2;
-pub const GLOB_DOOFFS: ::c_int = 1 << 3;
-pub const GLOB_NOCHECK: ::c_int = 1 << 4;
-pub const GLOB_APPEND: ::c_int = 1 << 5;
-pub const GLOB_NOESCAPE: ::c_int = 1 << 6;
-
-pub const GLOB_NOSPACE: ::c_int = 1;
-pub const GLOB_ABORTED: ::c_int = 2;
-pub const GLOB_NOMATCH: ::c_int = 3;
-
-pub const POSIX_MADV_NORMAL: ::c_int = 0;
-pub const POSIX_MADV_RANDOM: ::c_int = 1;
-pub const POSIX_MADV_SEQUENTIAL: ::c_int = 2;
-pub const POSIX_MADV_WILLNEED: ::c_int = 3;
-
-pub const S_IEXEC: mode_t = 64;
-pub const S_IWRITE: mode_t = 128;
-pub const S_IREAD: mode_t = 256;
-
-pub const F_LOCK: ::c_int = 1;
-pub const F_TEST: ::c_int = 3;
-pub const F_TLOCK: ::c_int = 2;
-pub const F_ULOCK: ::c_int = 0;
-
-pub const ST_RDONLY: ::c_ulong = 1;
-pub const ST_NOSUID: ::c_ulong = 2;
-pub const ST_NODEV: ::c_ulong = 4;
-pub const ST_NOEXEC: ::c_ulong = 8;
-pub const ST_SYNCHRONOUS: ::c_ulong = 16;
-pub const ST_MANDLOCK: ::c_ulong = 64;
-pub const ST_WRITE: ::c_ulong = 128;
-pub const ST_APPEND: ::c_ulong = 256;
-pub const ST_IMMUTABLE: ::c_ulong = 512;
-pub const ST_NOATIME: ::c_ulong = 1024;
-pub const ST_NODIRATIME: ::c_ulong = 2048;
-
-pub const RTLD_NEXT: *mut ::c_void = -1i64 as *mut ::c_void;
-pub const RTLD_DEFAULT: *mut ::c_void = 0i64 as *mut ::c_void;
-pub const RTLD_NODELETE: ::c_int = 0x1000;
-pub const RTLD_NOW: ::c_int = 0x2;
-
-pub const TCP_MD5SIG: ::c_int = 14;
-
-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;
-pub const PTHREAD_MUTEX_DEFAULT: ::c_int = PTHREAD_MUTEX_NORMAL;
-pub const PTHREAD_PROCESS_PRIVATE: ::c_int = 0;
-pub const PTHREAD_PROCESS_SHARED: ::c_int = 1;
-pub const __SIZEOF_PTHREAD_COND_T: usize = 48;
-
-pub const SCHED_OTHER: ::c_int = 0;
-pub const SCHED_FIFO: ::c_int = 1;
-pub const SCHED_RR: ::c_int = 2;
-pub const SCHED_BATCH: ::c_int = 3;
-pub const SCHED_IDLE: ::c_int = 5;
-
-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;
-#[doc(hidden)]
-#[deprecated(
- since = "0.2.55",
- note = "If you are using this report to: \
- https://github.com/rust-lang/libc/issues/665"
-)]
-pub const AF_MAX: ::c_int = 42;
-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;
-#[doc(hidden)]
-#[allow(deprecated)]
-#[deprecated(
- since = "0.2.55",
- note = "If you are using this report to: \
- https://github.com/rust-lang/libc/issues/665"
-)]
-pub const PF_MAX: ::c_int = AF_MAX;
-
-// System V IPC
-pub const IPC_PRIVATE: ::key_t = 0;
-
-pub const IPC_CREAT: ::c_int = 0o1000;
-pub const IPC_EXCL: ::c_int = 0o2000;
-pub const IPC_NOWAIT: ::c_int = 0o4000;
-
-pub const IPC_RMID: ::c_int = 0;
-pub const IPC_SET: ::c_int = 1;
-pub const IPC_STAT: ::c_int = 2;
-pub const IPC_INFO: ::c_int = 3;
-pub const MSG_STAT: ::c_int = 11;
-pub const MSG_INFO: ::c_int = 12;
-
-pub const MSG_NOERROR: ::c_int = 0o10000;
-pub const MSG_EXCEPT: ::c_int = 0o20000;
-
-pub const SHM_R: ::c_int = 0o400;
-pub const SHM_W: ::c_int = 0o200;
-
-pub const SHM_RDONLY: ::c_int = 0o10000;
-pub const SHM_RND: ::c_int = 0o20000;
-pub const SHM_REMAP: ::c_int = 0o40000;
-pub const SHM_EXEC: ::c_int = 0o100000;
-
-pub const SHM_LOCK: ::c_int = 11;
-pub const SHM_UNLOCK: ::c_int = 12;
-
-pub const SHM_HUGETLB: ::c_int = 0o4000;
-pub const SHM_NORESERVE: ::c_int = 0o10000;
-
-pub const EPOLLRDHUP: ::c_int = 0x2000;
-pub const EPOLLEXCLUSIVE: ::c_int = 0x10000000;
-pub const EPOLLONESHOT: ::c_int = 0x40000000;
-
-pub const QFMT_VFS_OLD: ::c_int = 1;
-pub const QFMT_VFS_V0: ::c_int = 2;
-
-pub const EFD_SEMAPHORE: ::c_int = 0x1;
-
-pub const LOG_NFACILITIES: ::c_int = 24;
-
-pub const SEM_FAILED: *mut ::sem_t = 0 as *mut sem_t;
-
-pub const RB_AUTOBOOT: ::c_int = 0x01234567u32 as i32;
-pub const RB_HALT_SYSTEM: ::c_int = 0xcdef0123u32 as i32;
-pub const RB_ENABLE_CAD: ::c_int = 0x89abcdefu32 as i32;
-pub const RB_DISABLE_CAD: ::c_int = 0x00000000u32 as i32;
-pub const RB_POWER_OFF: ::c_int = 0x4321fedcu32 as i32;
-pub const RB_SW_SUSPEND: ::c_int = 0xd000fce2u32 as i32;
-pub const RB_KEXEC: ::c_int = 0x45584543u32 as i32;
-
-pub const AI_PASSIVE: ::c_int = 0x0001;
-pub const AI_CANONNAME: ::c_int = 0x0002;
-pub const AI_NUMERICHOST: ::c_int = 0x0004;
-pub const AI_V4MAPPED: ::c_int = 0x0008;
-pub const AI_ALL: ::c_int = 0x0010;
-pub const AI_ADDRCONFIG: ::c_int = 0x0020;
-
-pub const AI_NUMERICSERV: ::c_int = 0x0400;
-
-pub const EAI_BADFLAGS: ::c_int = -1;
-pub const EAI_NONAME: ::c_int = -2;
-pub const EAI_AGAIN: ::c_int = -3;
-pub const EAI_FAIL: ::c_int = -4;
-pub const EAI_FAMILY: ::c_int = -6;
-pub const EAI_SOCKTYPE: ::c_int = -7;
-pub const EAI_SERVICE: ::c_int = -8;
-pub const EAI_MEMORY: ::c_int = -10;
-pub const EAI_OVERFLOW: ::c_int = -12;
-
-pub const NI_NUMERICHOST: ::c_int = 1;
-pub const NI_NUMERICSERV: ::c_int = 2;
-pub const NI_NOFQDN: ::c_int = 4;
-pub const NI_NAMEREQD: ::c_int = 8;
-pub const NI_DGRAM: ::c_int = 16;
-
-pub const SYNC_FILE_RANGE_WAIT_BEFORE: ::c_uint = 1;
-pub const SYNC_FILE_RANGE_WRITE: ::c_uint = 2;
-pub const SYNC_FILE_RANGE_WAIT_AFTER: ::c_uint = 4;
-
-pub const EAI_SYSTEM: ::c_int = -11;
-
-pub const AIO_CANCELED: ::c_int = 0;
-pub const AIO_NOTCANCELED: ::c_int = 1;
-pub const AIO_ALLDONE: ::c_int = 2;
-pub const LIO_READ: ::c_int = 0;
-pub const LIO_WRITE: ::c_int = 1;
-pub const LIO_NOP: ::c_int = 2;
-pub const LIO_WAIT: ::c_int = 0;
-pub const LIO_NOWAIT: ::c_int = 1;
-
-pub const MREMAP_MAYMOVE: ::c_int = 1;
-pub const MREMAP_FIXED: ::c_int = 2;
-
-pub const PR_SET_PDEATHSIG: ::c_int = 1;
-pub const PR_GET_PDEATHSIG: ::c_int = 2;
-
-pub const PR_GET_DUMPABLE: ::c_int = 3;
-pub const PR_SET_DUMPABLE: ::c_int = 4;
-
-pub const PR_GET_UNALIGN: ::c_int = 5;
-pub const PR_SET_UNALIGN: ::c_int = 6;
-pub const PR_UNALIGN_NOPRINT: ::c_int = 1;
-pub const PR_UNALIGN_SIGBUS: ::c_int = 2;
-
-pub const PR_GET_KEEPCAPS: ::c_int = 7;
-pub const PR_SET_KEEPCAPS: ::c_int = 8;
-
-pub const PR_GET_FPEMU: ::c_int = 9;
-pub const PR_SET_FPEMU: ::c_int = 10;
-pub const PR_FPEMU_NOPRINT: ::c_int = 1;
-pub const PR_FPEMU_SIGFPE: ::c_int = 2;
-
-pub const PR_GET_FPEXC: ::c_int = 11;
-pub const PR_SET_FPEXC: ::c_int = 12;
-pub const PR_FP_EXC_SW_ENABLE: ::c_int = 0x80;
-pub const PR_FP_EXC_DIV: ::c_int = 0x010000;
-pub const PR_FP_EXC_OVF: ::c_int = 0x020000;
-pub const PR_FP_EXC_UND: ::c_int = 0x040000;
-pub const PR_FP_EXC_RES: ::c_int = 0x080000;
-pub const PR_FP_EXC_INV: ::c_int = 0x100000;
-pub const PR_FP_EXC_DISABLED: ::c_int = 0;
-pub const PR_FP_EXC_NONRECOV: ::c_int = 1;
-pub const PR_FP_EXC_ASYNC: ::c_int = 2;
-pub const PR_FP_EXC_PRECISE: ::c_int = 3;
-
-pub const PR_GET_TIMING: ::c_int = 13;
-pub const PR_SET_TIMING: ::c_int = 14;
-pub const PR_TIMING_STATISTICAL: ::c_int = 0;
-pub const PR_TIMING_TIMESTAMP: ::c_int = 1;
-
-pub const PR_SET_NAME: ::c_int = 15;
-pub const PR_GET_NAME: ::c_int = 16;
-
-pub const PR_GET_ENDIAN: ::c_int = 19;
-pub const PR_SET_ENDIAN: ::c_int = 20;
-pub const PR_ENDIAN_BIG: ::c_int = 0;
-pub const PR_ENDIAN_LITTLE: ::c_int = 1;
-pub const PR_ENDIAN_PPC_LITTLE: ::c_int = 2;
-
-pub const PR_GET_SECCOMP: ::c_int = 21;
-pub const PR_SET_SECCOMP: ::c_int = 22;
-
-pub const PR_CAPBSET_READ: ::c_int = 23;
-pub const PR_CAPBSET_DROP: ::c_int = 24;
-
-pub const PR_GET_TSC: ::c_int = 25;
-pub const PR_SET_TSC: ::c_int = 26;
-pub const PR_TSC_ENABLE: ::c_int = 1;
-pub const PR_TSC_SIGSEGV: ::c_int = 2;
-
-pub const PR_GET_SECUREBITS: ::c_int = 27;
-pub const PR_SET_SECUREBITS: ::c_int = 28;
-
-pub const PR_SET_TIMERSLACK: ::c_int = 29;
-pub const PR_GET_TIMERSLACK: ::c_int = 30;
-
-pub const PR_TASK_PERF_EVENTS_DISABLE: ::c_int = 31;
-pub const PR_TASK_PERF_EVENTS_ENABLE: ::c_int = 32;
-
-pub const PR_MCE_KILL: ::c_int = 33;
-pub const PR_MCE_KILL_CLEAR: ::c_int = 0;
-pub const PR_MCE_KILL_SET: ::c_int = 1;
-
-pub const PR_MCE_KILL_LATE: ::c_int = 0;
-pub const PR_MCE_KILL_EARLY: ::c_int = 1;
-pub const PR_MCE_KILL_DEFAULT: ::c_int = 2;
-
-pub const PR_MCE_KILL_GET: ::c_int = 34;
-
-pub const PR_SET_MM: ::c_int = 35;
-pub const PR_SET_MM_START_CODE: ::c_int = 1;
-pub const PR_SET_MM_END_CODE: ::c_int = 2;
-pub const PR_SET_MM_START_DATA: ::c_int = 3;
-pub const PR_SET_MM_END_DATA: ::c_int = 4;
-pub const PR_SET_MM_START_STACK: ::c_int = 5;
-pub const PR_SET_MM_START_BRK: ::c_int = 6;
-pub const PR_SET_MM_BRK: ::c_int = 7;
-pub const PR_SET_MM_ARG_START: ::c_int = 8;
-pub const PR_SET_MM_ARG_END: ::c_int = 9;
-pub const PR_SET_MM_ENV_START: ::c_int = 10;
-pub const PR_SET_MM_ENV_END: ::c_int = 11;
-pub const PR_SET_MM_AUXV: ::c_int = 12;
-pub const PR_SET_MM_EXE_FILE: ::c_int = 13;
-pub const PR_SET_MM_MAP: ::c_int = 14;
-pub const PR_SET_MM_MAP_SIZE: ::c_int = 15;
-
-pub const PR_SET_PTRACER: ::c_int = 0x59616d61;
-
-pub const PR_SET_CHILD_SUBREAPER: ::c_int = 36;
-pub const PR_GET_CHILD_SUBREAPER: ::c_int = 37;
-
-pub const PR_SET_NO_NEW_PRIVS: ::c_int = 38;
-pub const PR_GET_NO_NEW_PRIVS: ::c_int = 39;
-
-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 PR_MPX_ENABLE_MANAGEMENT: ::c_int = 43;
-pub const PR_MPX_DISABLE_MANAGEMENT: ::c_int = 44;
-
-pub const PR_SET_FP_MODE: ::c_int = 45;
-pub const PR_GET_FP_MODE: ::c_int = 46;
-pub const PR_FP_MODE_FR: ::c_int = 1 << 0;
-pub const PR_FP_MODE_FRE: ::c_int = 1 << 1;
-
-pub const PR_CAP_AMBIENT: ::c_int = 47;
-pub const PR_CAP_AMBIENT_IS_SET: ::c_int = 1;
-pub const PR_CAP_AMBIENT_RAISE: ::c_int = 2;
-pub const PR_CAP_AMBIENT_LOWER: ::c_int = 3;
-pub const PR_CAP_AMBIENT_CLEAR_ALL: ::c_int = 4;
-
-pub const ITIMER_REAL: ::c_int = 0;
-pub const ITIMER_VIRTUAL: ::c_int = 1;
-pub const ITIMER_PROF: ::c_int = 2;
-
-pub const XATTR_CREATE: ::c_int = 0x1;
-pub const XATTR_REPLACE: ::c_int = 0x2;
-
-pub const _POSIX_VDISABLE: ::cc_t = 0;
-
-pub const FALLOC_FL_KEEP_SIZE: ::c_int = 0x01;
-pub const FALLOC_FL_PUNCH_HOLE: ::c_int = 0x02;
-
-// On Linux, libc doesn't define this constant, libattr does instead.
-// We still define it for Linux as it's defined by libc on other platforms,
-// and it's mentioned in the man pages for getxattr and setxattr.
-pub const SFD_CLOEXEC: ::c_int = 0x080000;
-
-pub const NCCS: usize = 32;
-
-pub const O_TRUNC: ::c_int = 512;
-pub const O_NOATIME: ::c_int = 0o1000000;
-pub const O_CLOEXEC: ::c_int = 0x80000;
-
-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 EDOTDOT: ::c_int = 73;
-
-pub const SA_NODEFER: ::c_int = 0x40000000;
-pub const SA_RESETHAND: ::c_int = 0x80000000;
-pub const SA_RESTART: ::c_int = 0x10000000;
-pub const SA_NOCLDSTOP: ::c_int = 0x00000001;
-
-pub const EPOLL_CLOEXEC: ::c_int = 0x80000;
-
-pub const EFD_CLOEXEC: ::c_int = 0x80000;
-
-pub const BUFSIZ: ::c_uint = 1024;
-pub const TMP_MAX: ::c_uint = 10000;
-pub const FOPEN_MAX: ::c_uint = 1000;
-pub const O_PATH: ::c_int = 0o10000000;
-pub const O_EXEC: ::c_int = 0o10000000;
-pub const O_SEARCH: ::c_int = 0o10000000;
-pub const O_ACCMODE: ::c_int = 0o10000003;
-pub const O_NDELAY: ::c_int = O_NONBLOCK;
-pub const NI_MAXHOST: ::socklen_t = 255;
-pub const PTHREAD_STACK_MIN: ::size_t = 2048;
-pub const POSIX_FADV_DONTNEED: ::c_int = 4;
-pub const POSIX_FADV_NOREUSE: ::c_int = 5;
-
-pub const POSIX_MADV_DONTNEED: ::c_int = 0;
-
-pub const RLIM_INFINITY: ::rlim_t = !0;
-pub const RLIMIT_NLIMITS: ::c_int = 15;
-
-pub const MAP_ANONYMOUS: ::c_int = MAP_ANON;
-
-pub const TCP_THIN_LINEAR_TIMEOUTS: ::c_int = 16;
-pub const TCP_THIN_DUPACK: ::c_int = 17;
-pub const TCP_USER_TIMEOUT: ::c_int = 18;
-pub const TCP_REPAIR: ::c_int = 19;
-pub const TCP_REPAIR_QUEUE: ::c_int = 20;
-pub const TCP_QUEUE_SEQ: ::c_int = 21;
-pub const TCP_REPAIR_OPTIONS: ::c_int = 22;
-pub const TCP_FASTOPEN: ::c_int = 23;
-pub const TCP_TIMESTAMP: ::c_int = 24;
-
-#[doc(hidden)]
-#[deprecated(
- since = "0.2.55",
- note = "Use SIGSYS instead"
-)]
-pub const SIGUNUSED: ::c_int = ::SIGSYS;
-
-pub const __SIZEOF_PTHREAD_CONDATTR_T: usize = 4;
-pub const __SIZEOF_PTHREAD_MUTEXATTR_T: usize = 4;
-pub const __SIZEOF_PTHREAD_RWLOCKATTR_T: usize = 8;
-
-pub const CPU_SETSIZE: ::c_int = 128;
-
-pub const QFMT_VFS_V1: ::c_int = 4;
-
-pub const PTRACE_TRACEME: ::c_int = 0;
-pub const PTRACE_PEEKTEXT: ::c_int = 1;
-pub const PTRACE_PEEKDATA: ::c_int = 2;
-pub const PTRACE_PEEKUSER: ::c_int = 3;
-pub const PTRACE_POKETEXT: ::c_int = 4;
-pub const PTRACE_POKEDATA: ::c_int = 5;
-pub const PTRACE_POKEUSER: ::c_int = 6;
-pub const PTRACE_CONT: ::c_int = 7;
-pub const PTRACE_KILL: ::c_int = 8;
-pub const PTRACE_SINGLESTEP: ::c_int = 9;
-pub const PTRACE_ATTACH: ::c_int = 16;
-pub const PTRACE_DETACH: ::c_int = 17;
-pub const PTRACE_SYSCALL: ::c_int = 24;
-pub const PTRACE_SETOPTIONS: ::c_int = 0x4200;
-pub const PTRACE_GETEVENTMSG: ::c_int = 0x4201;
-pub const PTRACE_GETSIGINFO: ::c_int = 0x4202;
-pub const PTRACE_SETSIGINFO: ::c_int = 0x4203;
-pub const PTRACE_GETREGSET: ::c_int = 0x4204;
-pub const PTRACE_SETREGSET: ::c_int = 0x4205;
-pub const PTRACE_SEIZE: ::c_int = 0x4206;
-pub const PTRACE_INTERRUPT: ::c_int = 0x4207;
-pub const PTRACE_LISTEN: ::c_int = 0x4208;
-pub const PTRACE_PEEKSIGINFO: ::c_int = 0x4209;
-
-pub const EPOLLWAKEUP: ::c_int = 0x20000000;
-
-pub const PTRACE_GETFPREGS: ::c_uint = 14;
-pub const PTRACE_SETFPREGS: ::c_uint = 15;
-pub const PTRACE_GETFPXREGS: ::c_uint = 18;
-pub const PTRACE_SETFPXREGS: ::c_uint = 19;
-pub const PTRACE_GETREGS: ::c_uint = 12;
-pub const PTRACE_SETREGS: ::c_uint = 13;
-
-pub const EFD_NONBLOCK: ::c_int = ::O_NONBLOCK;
-
-pub const SFD_NONBLOCK: ::c_int = ::O_NONBLOCK;
-
-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;
-
-// TODO(#247) Temporarily musl-specific (available since musl 0.9.12 / Linux
-// kernel 3.10). See also notbsd/mod.rs
-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 SIGSTKSZ: ::size_t = 8192;
-pub const MINSIGSTKSZ: ::size_t = 2048;
-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 CBAUDEX: ::tcflag_t = 0o010000;
-pub const VSWTC: usize = 7;
-pub const OLCUC: ::tcflag_t = 0o000002;
-pub const NLDLY: ::tcflag_t = 0o000400;
-pub const CRDLY: ::tcflag_t = 0o003000;
-pub const TABDLY: ::tcflag_t = 0o014000;
-pub const BSDLY: ::tcflag_t = 0o020000;
-pub const FFDLY: ::tcflag_t = 0o100000;
-pub const VTDLY: ::tcflag_t = 0o040000;
-pub const XTABS: ::tcflag_t = 0o014000;
-
-pub const B0: ::speed_t = 0o000000;
-pub const B50: ::speed_t = 0o000001;
-pub const B75: ::speed_t = 0o000002;
-pub const B110: ::speed_t = 0o000003;
-pub const B134: ::speed_t = 0o000004;
-pub const B150: ::speed_t = 0o000005;
-pub const B200: ::speed_t = 0o000006;
-pub const B300: ::speed_t = 0o000007;
-pub const B600: ::speed_t = 0o000010;
-pub const B1200: ::speed_t = 0o000011;
-pub const B1800: ::speed_t = 0o000012;
-pub const B2400: ::speed_t = 0o000013;
-pub const B4800: ::speed_t = 0o000014;
-pub const B9600: ::speed_t = 0o000015;
-pub const B19200: ::speed_t = 0o000016;
-pub const B38400: ::speed_t = 0o000017;
-pub const 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;
-pub const SO_MARK: ::c_int = 36;
-pub const SO_RXQ_OVFL: ::c_int = 40;
-pub const SO_PEEK_OFF: ::c_int = 42;
-pub const SO_BUSY_POLL: ::c_int = 46;
-
-pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 32;
-pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 28;
-
-pub const O_DIRECT: ::c_int = 0x4000;
-pub const O_DIRECTORY: ::c_int = 0x10000;
-pub const O_NOFOLLOW: ::c_int = 0x20000;
-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;
-pub const RLIMIT_NPROC: ::c_int = 6;
-pub const RLIMIT_MEMLOCK: ::c_int = 8;
-pub const RLIMIT_CPU: ::c_int = 0;
-pub const RLIMIT_FSIZE: ::c_int = 1;
-pub const RLIMIT_DATA: ::c_int = 2;
-pub const RLIMIT_STACK: ::c_int = 3;
-pub const RLIMIT_CORE: ::c_int = 4;
-pub const RLIMIT_LOCKS: ::c_int = 10;
-pub const RLIMIT_SIGPENDING: ::c_int = 11;
-pub const RLIMIT_MSGQUEUE: ::c_int = 12;
-pub const RLIMIT_NICE: ::c_int = 13;
-pub const RLIMIT_RTPRIO: ::c_int = 14;
-
-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 = 0x02000;
-pub const MAP_NORESERVE: ::c_int = 0x04000;
-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 = EDEADLK;
-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_LINGER: ::c_int = 13;
-pub const SO_REUSEPORT: ::c_int = 15;
-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 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 = 0x00010000;
-
-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 = 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 SYS_gettid: ::c_long = 224; // Valid for arm (32-bit) and x86 (32-bit)
-
-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;
-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 CMSG_NXTHDR(mhdr: *const msghdr,
- cmsg: *const cmsghdr) -> *mut cmsghdr {
- if ((*cmsg).cmsg_len as usize) < ::mem::size_of::<cmsghdr>() {
- return 0 as *mut cmsghdr;
- };
- let next = (cmsg as usize +
- super::CMSG_ALIGN((*cmsg).cmsg_len as usize))
- as *mut cmsghdr;
- let max = (*mhdr).msg_control as usize
- + (*mhdr).msg_controllen as usize;
- if (next.offset(1)) as usize > max {
- 0 as *mut cmsghdr
- } else {
- next as *mut cmsghdr
- }
- }
-
- pub fn CPU_ZERO(cpuset: &mut cpu_set_t) -> () {
- for slot in cpuset.bits.iter_mut() {
- *slot = 0;
- }
- }
-
- pub fn CPU_SET(cpu: usize, cpuset: &mut cpu_set_t) -> () {
- let size_in_bits
- = 8 * ::mem::size_of_val(&cpuset.bits[0]); // 32, 64 etc
- let (idx, offset) = (cpu / size_in_bits, cpu % size_in_bits);
- cpuset.bits[idx] |= 1 << offset;
- ()
- }
-
- pub fn CPU_CLR(cpu: usize, cpuset: &mut cpu_set_t) -> () {
- let size_in_bits
- = 8 * ::mem::size_of_val(&cpuset.bits[0]); // 32, 64 etc
- let (idx, offset) = (cpu / size_in_bits, cpu % size_in_bits);
- cpuset.bits[idx] &= !(1 << offset);
- ()
- }
-
- pub fn CPU_ISSET(cpu: usize, cpuset: &cpu_set_t) -> bool {
- let size_in_bits = 8 * ::mem::size_of_val(&cpuset.bits[0]);
- let (idx, offset) = (cpu / size_in_bits, cpu % size_in_bits);
- 0 != (cpuset.bits[idx] & (1 << offset))
- }
-
- pub fn CPU_EQUAL(set1: &cpu_set_t, set2: &cpu_set_t) -> bool {
- set1.bits == set2.bits
- }
-
- pub fn major(dev: ::dev_t) -> ::c_uint {
- // see
- // https://github.com/kripken/emscripten/blob/
- // master/system/include/libc/sys/sysmacros.h
- let mut major = 0;
- major |= (dev & 0x00000fff) >> 8;
- major |= (dev & 0xfffff000) >> 31 >> 1;
- major as ::c_uint
- }
-
- pub fn minor(dev: ::dev_t) -> ::c_uint {
- // see
- // https://github.com/kripken/emscripten/blob/
- // master/system/include/libc/sys/sysmacros.h
- let mut minor = 0;
- minor |= (dev & 0x000000ff) >> 0;
- minor |= (dev & 0xffffff00) >> 12;
- minor as ::c_uint
- }
-
- pub fn makedev(major: ::c_uint, minor: ::c_uint) -> ::dev_t {
- let major = major as ::dev_t;
- let minor = minor as ::dev_t;
- let mut dev = 0;
- dev |= (major & 0x00000fff) << 8;
- dev |= (major & 0xfffff000) << 31 << 1;
- dev |= (minor & 0x000000ff) << 0;
- dev |= (minor & 0xffffff00) << 12;
- dev
- }
-}
-
-extern {
- pub fn getrlimit64(resource: ::c_int,
- rlim: *mut rlimit64) -> ::c_int;
- pub fn setrlimit64(resource: ::c_int,
- rlim: *const rlimit64) -> ::c_int;
- pub fn getrlimit(resource: ::c_int, rlim: *mut ::rlimit) -> ::c_int;
- pub fn setrlimit(resource: ::c_int, rlim: *const ::rlimit) -> ::c_int;
- pub fn strerror_r(errnum: ::c_int, buf: *mut c_char,
- buflen: ::size_t) -> ::c_int;
-
- 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 gettimeofday(tp: *mut ::timeval,
- tz: *mut ::c_void) -> ::c_int;
-
- pub fn setpwent();
- pub fn endpwent();
- pub fn getpwent() -> *mut passwd;
-
- pub fn shm_open(name: *const c_char, oflag: ::c_int,
- mode: mode_t) -> ::c_int;
-
- pub fn mprotect(addr: *mut ::c_void, len: ::size_t, prot: ::c_int)
- -> ::c_int;
- pub fn __errno_location() -> *mut ::c_int;
-
- pub fn fopen64(filename: *const c_char,
- mode: *const c_char) -> *mut ::FILE;
- pub fn freopen64(filename: *const c_char, mode: *const c_char,
- file: *mut ::FILE) -> *mut ::FILE;
- pub fn tmpfile64() -> *mut ::FILE;
- pub fn fgetpos64(stream: *mut ::FILE, ptr: *mut fpos64_t) -> ::c_int;
- pub fn fsetpos64(stream: *mut ::FILE, ptr: *const fpos64_t) -> ::c_int;
- pub fn fseeko64(stream: *mut ::FILE,
- offset: ::off64_t,
- whence: ::c_int) -> ::c_int;
- pub fn ftello64(stream: *mut ::FILE) -> ::off64_t;
- pub fn posix_fallocate(fd: ::c_int, offset: ::off_t,
- len: ::off_t) -> ::c_int;
- pub fn pwritev(fd: ::c_int,
- iov: *const ::iovec,
- iovcnt: ::c_int,
- offset: ::off_t) -> ::ssize_t;
- pub fn preadv(fd: ::c_int,
- iov: *const ::iovec,
- iovcnt: ::c_int,
- offset: ::off_t) -> ::ssize_t;
- pub fn dup3(oldfd: ::c_int, newfd: ::c_int, flags: ::c_int) -> ::c_int;
- pub fn mkostemp(template: *mut ::c_char, flags: ::c_int) -> ::c_int;
- pub fn mkostemps(template: *mut ::c_char,
- suffixlen: ::c_int,
- flags: ::c_int) -> ::c_int;
- pub fn nl_langinfo_l(item: ::nl_item, locale: ::locale_t) -> *mut ::c_char;
- pub fn getnameinfo(sa: *const ::sockaddr,
- salen: ::socklen_t,
- host: *mut ::c_char,
- hostlen: ::socklen_t,
- serv: *mut ::c_char,
- sevlen: ::socklen_t,
- flags: ::c_int) -> ::c_int;
- pub fn getloadavg(loadavg: *mut ::c_double, nelem: ::c_int) -> ::c_int;
-
- // Not available now on Android
- pub fn mkfifoat(dirfd: ::c_int, pathname: *const ::c_char,
- mode: ::mode_t) -> ::c_int;
- pub fn if_nameindex() -> *mut if_nameindex;
- pub fn if_freenameindex(ptr: *mut if_nameindex);
-
- pub fn mremap(addr: *mut ::c_void,
- len: ::size_t,
- new_len: ::size_t,
- flags: ::c_int,
- ...) -> *mut ::c_void;
-
- 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;
- pub fn globfree(pglob: *mut ::glob_t);
-
- pub fn posix_madvise(addr: *mut ::c_void, len: ::size_t, advice: ::c_int)
- -> ::c_int;
-
- pub fn shm_unlink(name: *const ::c_char) -> ::c_int;
-
- pub fn seekdir(dirp: *mut ::DIR, loc: ::c_long);
-
- pub fn telldir(dirp: *mut ::DIR) -> ::c_long;
- pub fn madvise(addr: *mut ::c_void, len: ::size_t, advice: ::c_int)
- -> ::c_int;
-
- pub fn msync(addr: *mut ::c_void, len: ::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;
- pub fn mkstemps(template: *mut ::c_char, suffixlen: ::c_int) -> ::c_int;
- pub fn nl_langinfo(item: ::nl_item) -> *mut ::c_char;
-
- 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,
- flags: ::c_uint) -> ::c_int;
- pub fn recvmmsg(sockfd: ::c_int, msgvec: *mut ::mmsghdr, vlen: ::c_uint,
- flags: ::c_uint, timeout: *mut ::timespec) -> ::c_int;
- pub fn sync();
- pub fn ioctl(fd: ::c_int, request: ::c_int, ...) -> ::c_int;
- 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_create(native: *mut ::pthread_t,
- attr: *const ::pthread_attr_t,
- f: extern fn(*mut ::c_void) -> *mut ::c_void,
- value: *mut ::c_void) -> ::c_int;
-}
-
-cfg_if! {
- if #[cfg(libc_align)] {
- #[macro_use]
- mod align;
- } else {
- #[macro_use]
- mod no_align;
- }
-}
-expand_align!();
diff --git a/libc/src/unix/notbsd/emscripten/no_align.rs b/libc/src/unix/notbsd/emscripten/no_align.rs
deleted file mode 100644
index ece4dff..0000000
--- a/libc/src/unix/notbsd/emscripten/no_align.rs
+++ /dev/null
@@ -1,63 +0,0 @@
-macro_rules! expand_align {
- () => {
- s! {
- pub struct pthread_mutex_t {
- __align: [::c_long; 0],
- size: [u8; ::__SIZEOF_PTHREAD_MUTEX_T],
- }
-
- pub struct pthread_rwlock_t {
- __align: [::c_long; 0],
- size: [u8; ::__SIZEOF_PTHREAD_RWLOCK_T],
- }
-
- pub struct pthread_mutexattr_t {
- __align: [::c_int; 0],
- size: [u8; ::__SIZEOF_PTHREAD_MUTEXATTR_T],
- }
-
- pub struct pthread_rwlockattr_t {
- __align: [::c_int; 0],
- size: [u8; ::__SIZEOF_PTHREAD_RWLOCKATTR_T],
- }
-
- pub struct pthread_condattr_t {
- __align: [::c_int; 0],
- size: [u8; ::__SIZEOF_PTHREAD_CONDATTR_T],
- }
- }
-
- s_no_extra_traits! {
- pub struct pthread_cond_t {
- __align: [*const ::c_void; 0],
- size: [u8; ::__SIZEOF_PTHREAD_COND_T],
- }
- }
-
- cfg_if! {
- if #[cfg(feature = "extra_traits")] {
- impl PartialEq for pthread_cond_t {
- fn eq(&self, other: &pthread_cond_t) -> bool {
- self.size
- .iter()
- .zip(other.size.iter())
- .all(|(a,b)| a == b)
- }
- }
- impl Eq for pthread_cond_t {}
- impl ::fmt::Debug for pthread_cond_t {
- fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
- f.debug_struct("pthread_cond_t")
- // FIXME: .field("size", &self.size)
- .finish()
- }
- }
- impl ::hash::Hash for pthread_cond_t {
- fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
- self.size.hash(state);
- }
- }
- }
- }
- }
-}
diff --git a/libc/src/unix/notbsd/linux/align.rs b/libc/src/unix/notbsd/linux/align.rs
deleted file mode 100644
index 0ff4649..0000000
--- a/libc/src/unix/notbsd/linux/align.rs
+++ /dev/null
@@ -1,98 +0,0 @@
-macro_rules! expand_align {
- () => {
- s! {
- #[cfg_attr(any(target_pointer_width = "32",
- target_arch = "x86_64",
- target_arch = "powerpc64",
- target_arch = "mips64",
- target_arch = "s390x",
- target_arch = "sparc64",
- target_arch = "aarch64"),
- repr(align(4)))]
- #[cfg_attr(not(any(target_pointer_width = "32",
- target_arch = "x86_64",
- target_arch = "powerpc64",
- target_arch = "mips64",
- target_arch = "s390x",
- target_arch = "sparc64",
- target_arch = "aarch64")),
- repr(align(8)))]
- pub struct pthread_mutexattr_t {
- #[doc(hidden)]
- size: [u8; ::__SIZEOF_PTHREAD_MUTEXATTR_T],
- }
-
- #[cfg_attr(any(target_env = "musl", target_pointer_width = "32"),
- repr(align(4)))]
- #[cfg_attr(all(not(target_env = "musl"),
- target_pointer_width = "64"),
- repr(align(8)))]
- pub struct pthread_rwlockattr_t {
- #[doc(hidden)]
- size: [u8; ::__SIZEOF_PTHREAD_RWLOCKATTR_T],
- }
-
- #[repr(align(4))]
- pub struct pthread_condattr_t {
- #[doc(hidden)]
- size: [u8; ::__SIZEOF_PTHREAD_CONDATTR_T],
- }
- }
-
- s_no_extra_traits! {
- #[cfg_attr(all(target_env = "musl",
- target_pointer_width = "32"),
- repr(align(4)))]
- #[cfg_attr(all(target_env = "musl",
- target_pointer_width = "64"),
- repr(align(8)))]
- #[cfg_attr(all(not(target_env = "musl"),
- target_arch = "x86"),
- repr(align(4)))]
- #[cfg_attr(all(not(target_env = "musl"),
- not(target_arch = "x86")),
- repr(align(8)))]
- pub struct pthread_cond_t {
- #[doc(hidden)]
- size: [u8; ::__SIZEOF_PTHREAD_COND_T],
- }
-
- #[cfg_attr(all(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(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 {
- #[doc(hidden)]
- size: [u8; ::__SIZEOF_PTHREAD_MUTEX_T],
- }
-
- #[cfg_attr(all(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(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 {
- size: [u8; ::__SIZEOF_PTHREAD_RWLOCK_T],
- }
- }
- }
-}
diff --git a/libc/src/unix/notbsd/linux/mips/align.rs b/libc/src/unix/notbsd/linux/mips/align.rs
deleted file mode 100644
index 4a0e074..0000000
--- a/libc/src/unix/notbsd/linux/mips/align.rs
+++ /dev/null
@@ -1,13 +0,0 @@
-s! {
- // FIXME this is actually a union
- #[cfg_attr(target_pointer_width = "32",
- repr(align(4)))]
- #[cfg_attr(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],
- }
-}
diff --git a/libc/src/unix/notbsd/linux/mips/mips32.rs b/libc/src/unix/notbsd/linux/mips/mips32.rs
deleted file mode 100644
index d9d5589..0000000
--- a/libc/src/unix/notbsd/linux/mips/mips32.rs
+++ /dev/null
@@ -1,695 +0,0 @@
-use pthread_mutex_t;
-
-pub type c_char = i8;
-pub type c_long = i32;
-pub type c_ulong = u32;
-pub type clock_t = i32;
-pub type time_t = i32;
-pub type suseconds_t = i32;
-pub type wchar_t = i32;
-pub type off_t = i32;
-pub type ino_t = u32;
-pub type blkcnt_t = i32;
-pub type blksize_t = i32;
-pub type nlink_t = u32;
-pub type __u64 = ::c_ulonglong;
-
-s! {
- pub struct aiocb {
- pub aio_fildes: ::c_int,
- pub aio_lio_opcode: ::c_int,
- pub aio_reqprio: ::c_int,
- pub aio_buf: *mut ::c_void,
- pub aio_nbytes: ::size_t,
- pub aio_sigevent: ::sigevent,
- __next_prio: *mut aiocb,
- __abs_prio: ::c_int,
- __policy: ::c_int,
- __error_code: ::c_int,
- __return_value: ::ssize_t,
- pub aio_offset: off_t,
- __unused1: [::c_char; 4],
- __glibc_reserved: [::c_char; 32]
- }
-
- pub struct stat {
- pub st_dev: ::c_ulong,
- st_pad1: [::c_long; 3],
- pub st_ino: ::ino_t,
- pub st_mode: ::mode_t,
- pub st_nlink: ::nlink_t,
- pub st_uid: ::uid_t,
- pub st_gid: ::gid_t,
- pub st_rdev: ::c_ulong,
- pub st_pad2: [::c_long; 2],
- pub st_size: ::off_t,
- st_pad3: ::c_long,
- 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,
- st_pad5: [::c_long; 14],
- }
-
- pub struct stat64 {
- pub st_dev: ::c_ulong,
- st_pad1: [::c_long; 3],
- pub st_ino: ::ino64_t,
- pub st_mode: ::mode_t,
- pub st_nlink: ::nlink_t,
- pub st_uid: ::uid_t,
- pub st_gid: ::gid_t,
- pub st_rdev: ::c_ulong,
- st_pad2: [::c_long; 2],
- pub st_size: ::off64_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,
- st_pad3: ::c_long,
- pub st_blocks: ::blkcnt64_t,
- st_pad5: [::c_long; 14],
- }
-
- pub struct statfs64 {
- pub f_type: ::c_long,
- pub f_bsize: ::c_long,
- pub f_frsize: ::c_long,
- pub f_blocks: u64,
- pub f_bfree: u64,
- pub f_files: u64,
- pub f_ffree: u64,
- pub f_bavail: u64,
- pub f_fsid: ::fsid_t,
- pub f_namelen: ::c_long,
- pub f_flags: ::c_long,
- 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,
- pub f_blocks: u64,
- pub f_bfree: u64,
- pub f_bavail: u64,
- pub f_files: u64,
- pub f_ffree: u64,
- pub f_favail: u64,
- pub f_fsid: ::c_ulong,
- __f_unused: ::c_int,
- pub f_flag: ::c_ulong,
- pub f_namemax: ::c_ulong,
- __f_spare: [::c_int; 6],
- }
-
- pub struct pthread_attr_t {
- __size: [u32; 9]
- }
-
- pub struct sigaction {
- pub sa_flags: ::c_int,
- pub sa_sigaction: ::sighandler_t,
- pub sa_mask: sigset_t,
- pub sa_restorer: ::Option<extern fn()>,
- _resv: [::c_int; 1],
- }
-
- pub struct stack_t {
- pub ss_sp: *mut ::c_void,
- pub ss_size: ::size_t,
- pub ss_flags: ::c_int,
- }
-
- pub struct sigset_t {
- __val: [::c_ulong; 32],
- }
-
- pub struct siginfo_t {
- pub si_signo: ::c_int,
- pub si_code: ::c_int,
- pub si_errno: ::c_int,
- pub _pad: [::c_int; 29],
- }
-
- pub struct ipc_perm {
- pub __key: ::key_t,
- pub uid: ::uid_t,
- pub gid: ::gid_t,
- pub cuid: ::uid_t,
- pub cgid: ::gid_t,
- pub mode: ::c_uint,
- pub __seq: ::c_ushort,
- __pad1: ::c_ushort,
- __unused1: ::c_ulong,
- __unused2: ::c_ulong
- }
-
- pub struct shmid_ds {
- pub shm_perm: ::ipc_perm,
- pub shm_segsz: ::size_t,
- pub shm_atime: ::time_t,
- pub shm_dtime: ::time_t,
- pub shm_ctime: ::time_t,
- pub shm_cpid: ::pid_t,
- pub shm_lpid: ::pid_t,
- pub shm_nattch: ::shmatt_t,
- __unused4: ::c_ulong,
- __unused5: ::c_ulong
- }
-
- pub struct msqid_ds {
- pub msg_perm: ::ipc_perm,
- #[cfg(target_endian = "big")]
- __glibc_reserved1: ::c_ulong,
- pub msg_stime: ::time_t,
- #[cfg(target_endian = "little")]
- __glibc_reserved1: ::c_ulong,
- #[cfg(target_endian = "big")]
- __glibc_reserved2: ::c_ulong,
- pub msg_rtime: ::time_t,
- #[cfg(target_endian = "little")]
- __glibc_reserved2: ::c_ulong,
- #[cfg(target_endian = "big")]
- __glibc_reserved3: ::c_ulong,
- pub msg_ctime: ::time_t,
- #[cfg(target_endian = "little")]
- __glibc_reserved3: ::c_ulong,
- __msg_cbytes: ::c_ulong,
- pub msg_qnum: ::msgqnum_t,
- pub msg_qbytes: ::msglen_t,
- pub msg_lspid: ::pid_t,
- pub msg_lrpid: ::pid_t,
- __glibc_reserved4: ::c_ulong,
- __glibc_reserved5: ::c_ulong,
- }
-
- pub struct statfs {
- pub f_type: ::c_long,
- pub f_bsize: ::c_long,
- pub f_frsize: ::c_long,
- pub f_blocks: ::fsblkcnt_t,
- pub f_bfree: ::fsblkcnt_t,
- pub f_files: ::fsblkcnt_t,
- pub f_ffree: ::fsblkcnt_t,
- pub f_bavail: ::fsblkcnt_t,
- pub f_fsid: ::fsid_t,
-
- pub f_namelen: ::c_long,
- f_spare: [::c_long; 6],
- }
-
- pub struct msghdr {
- pub msg_name: *mut ::c_void,
- pub msg_namelen: ::socklen_t,
- pub msg_iov: *mut ::iovec,
- pub msg_iovlen: ::size_t,
- pub msg_control: *mut ::c_void,
- pub msg_controllen: ::size_t,
- pub msg_flags: ::c_int,
- }
-
- pub struct cmsghdr {
- pub cmsg_len: ::size_t,
- pub cmsg_level: ::c_int,
- pub cmsg_type: ::c_int,
- }
-
- pub struct termios {
- pub c_iflag: ::tcflag_t,
- pub c_oflag: ::tcflag_t,
- pub c_cflag: ::tcflag_t,
- pub c_lflag: ::tcflag_t,
- pub c_line: ::cc_t,
- pub c_cc: [::cc_t; ::NCCS],
- }
-
- pub struct flock {
- pub l_type: ::c_short,
- pub l_whence: ::c_short,
- pub l_start: ::off_t,
- pub l_len: ::off_t,
- pub l_sysid: ::c_long,
- pub l_pid: ::pid_t,
- pad: [::c_long; 4],
- }
-
- pub struct sysinfo {
- pub uptime: ::c_long,
- pub loads: [::c_ulong; 3],
- pub totalram: ::c_ulong,
- pub freeram: ::c_ulong,
- pub sharedram: ::c_ulong,
- pub bufferram: ::c_ulong,
- pub totalswap: ::c_ulong,
- pub freeswap: ::c_ulong,
- pub procs: ::c_ushort,
- pub pad: ::c_ushort,
- pub totalhigh: ::c_ulong,
- pub freehigh: ::c_ulong,
- pub mem_unit: ::c_uint,
- pub _f: [::c_char; 8],
- }
-}
-
-pub const __SIZEOF_PTHREAD_CONDATTR_T: usize = 4;
-pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 24;
-pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 32;
-pub const __SIZEOF_PTHREAD_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;
-
-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_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_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_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_symlink: ::c_long = 4000 + 83;
-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_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_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_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;
diff --git a/libc/src/unix/notbsd/linux/mips/mips64.rs b/libc/src/unix/notbsd/linux/mips/mips64.rs
deleted file mode 100644
index f480e50..0000000
--- a/libc/src/unix/notbsd/linux/mips/mips64.rs
+++ /dev/null
@@ -1,645 +0,0 @@
-use pthread_mutex_t;
-
-pub type blkcnt_t = i64;
-pub type blksize_t = i64;
-pub type c_char = i8;
-pub type c_long = i64;
-pub type c_ulong = u64;
-pub type ino_t = u64;
-pub type nlink_t = u64;
-pub type off_t = i64;
-pub type suseconds_t = i64;
-pub type time_t = i64;
-pub type wchar_t = i32;
-pub type clock_t = i64;
-pub type __u64 = ::c_ulong;
-
-s! {
- pub struct aiocb {
- pub aio_fildes: ::c_int,
- pub aio_lio_opcode: ::c_int,
- pub aio_reqprio: ::c_int,
- pub aio_buf: *mut ::c_void,
- pub aio_nbytes: ::size_t,
- pub aio_sigevent: ::sigevent,
- __next_prio: *mut aiocb,
- __abs_prio: ::c_int,
- __policy: ::c_int,
- __error_code: ::c_int,
- __return_value: ::ssize_t,
- pub aio_offset: off_t,
- __glibc_reserved: [::c_char; 32]
- }
-
- pub struct stat {
- pub st_dev: ::c_ulong,
- st_pad1: [::c_long; 2],
- 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: ::c_ulong,
- st_pad2: [::c_ulong; 1],
- pub st_size: ::off_t,
- st_pad3: ::c_long,
- 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,
- st_pad4: ::c_long,
- pub st_blocks: ::blkcnt_t,
- st_pad5: [::c_long; 7],
- }
-
- pub struct stat64 {
- pub st_dev: ::c_ulong,
- st_pad1: [::c_long; 2],
- pub st_ino: ::ino64_t,
- pub st_mode: ::mode_t,
- pub st_nlink: ::nlink_t,
- pub st_uid: ::uid_t,
- pub st_gid: ::gid_t,
- pub st_rdev: ::c_ulong,
- st_pad2: [::c_long; 2],
- pub st_size: ::off64_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,
- st_pad3: ::c_long,
- pub st_blocks: ::blkcnt64_t,
- st_pad5: [::c_long; 7],
- }
-
- pub struct statfs64 {
- pub f_type: ::c_long,
- pub f_bsize: ::c_long,
- pub f_frsize: ::c_long,
- pub f_blocks: u64,
- pub f_bfree: u64,
- pub f_files: u64,
- pub f_ffree: u64,
- pub f_bavail: u64,
- pub f_fsid: ::fsid_t,
- pub f_namelen: ::c_long,
- pub f_flags: ::c_long,
- 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,
- pub f_blocks: u64,
- pub f_bfree: u64,
- pub f_bavail: u64,
- pub f_files: u64,
- pub f_ffree: u64,
- pub f_favail: u64,
- pub f_fsid: ::c_ulong,
- pub f_flag: ::c_ulong,
- pub f_namemax: ::c_ulong,
- __f_spare: [::c_int; 6],
- }
-
- pub struct pthread_attr_t {
- __size: [::c_ulong; 7]
- }
-
- pub struct sigaction {
- pub sa_flags: ::c_int,
- pub sa_sigaction: ::sighandler_t,
- pub sa_mask: sigset_t,
- pub sa_restorer: ::Option<extern fn()>,
- }
-
- pub struct stack_t {
- pub ss_sp: *mut ::c_void,
- pub ss_size: ::size_t,
- pub ss_flags: ::c_int,
- }
-
- pub struct sigset_t {
- __size: [::c_ulong; 16],
- }
-
- pub struct siginfo_t {
- pub si_signo: ::c_int,
- pub si_code: ::c_int,
- pub si_errno: ::c_int,
- _pad: ::c_int,
- _pad2: [::c_long; 14],
- }
-
- pub struct ipc_perm {
- pub __key: ::key_t,
- pub uid: ::uid_t,
- pub gid: ::gid_t,
- pub cuid: ::uid_t,
- pub cgid: ::gid_t,
- pub mode: ::c_uint,
- pub __seq: ::c_ushort,
- __pad1: ::c_ushort,
- __unused1: ::c_ulong,
- __unused2: ::c_ulong
- }
-
- pub struct shmid_ds {
- pub shm_perm: ::ipc_perm,
- pub shm_segsz: ::size_t,
- pub shm_atime: ::time_t,
- pub shm_dtime: ::time_t,
- pub shm_ctime: ::time_t,
- pub shm_cpid: ::pid_t,
- pub shm_lpid: ::pid_t,
- pub shm_nattch: ::shmatt_t,
- __unused4: ::c_ulong,
- __unused5: ::c_ulong
- }
-
- pub struct msqid_ds {
- pub msg_perm: ::ipc_perm,
- pub msg_stime: ::time_t,
- pub msg_rtime: ::time_t,
- 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,
- __glibc_reserved4: ::c_ulong,
- __glibc_reserved5: ::c_ulong,
- }
-
- pub struct statfs {
- pub f_type: ::c_long,
- pub f_bsize: ::c_long,
- pub f_frsize: ::c_long,
- pub f_blocks: ::fsblkcnt_t,
- pub f_bfree: ::fsblkcnt_t,
- pub f_files: ::fsblkcnt_t,
- pub f_ffree: ::fsblkcnt_t,
- pub f_bavail: ::fsblkcnt_t,
- pub f_fsid: ::fsid_t,
-
- pub f_namelen: ::c_long,
- f_spare: [::c_long; 6],
- }
-
- pub struct msghdr {
- pub msg_name: *mut ::c_void,
- pub msg_namelen: ::socklen_t,
- pub msg_iov: *mut ::iovec,
- pub msg_iovlen: ::size_t,
- pub msg_control: *mut ::c_void,
- pub msg_controllen: ::size_t,
- pub msg_flags: ::c_int,
- }
-
- pub struct cmsghdr {
- pub cmsg_len: ::size_t,
- pub cmsg_level: ::c_int,
- pub cmsg_type: ::c_int,
- }
-
- pub struct termios {
- pub c_iflag: ::tcflag_t,
- pub c_oflag: ::tcflag_t,
- pub c_cflag: ::tcflag_t,
- pub c_lflag: ::tcflag_t,
- pub c_line: ::cc_t,
- pub c_cc: [::cc_t; ::NCCS],
- }
-
- pub struct flock {
- pub l_type: ::c_short,
- pub l_whence: ::c_short,
- pub l_start: ::off_t,
- pub l_len: ::off_t,
- pub l_pid: ::pid_t,
- }
-
- pub struct sysinfo {
- pub uptime: ::c_long,
- pub loads: [::c_ulong; 3],
- pub totalram: ::c_ulong,
- pub freeram: ::c_ulong,
- pub sharedram: ::c_ulong,
- pub bufferram: ::c_ulong,
- pub totalswap: ::c_ulong,
- pub freeswap: ::c_ulong,
- pub procs: ::c_ushort,
- pub pad: ::c_ushort,
- pub totalhigh: ::c_ulong,
- pub freehigh: ::c_ulong,
- pub mem_unit: ::c_uint,
- pub _f: [::c_char; 0],
- }
-}
-
-pub const __SIZEOF_PTHREAD_CONDATTR_T: usize = 4;
-pub const __SIZEOF_PTHREAD_MUTEXATTR_T: usize = 4;
-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;
-
-pub const SYS_read: ::c_long = 5000 + 0;
-pub const SYS_write: ::c_long = 5000 + 1;
-pub const SYS_open: ::c_long = 5000 + 2;
-pub const SYS_close: ::c_long = 5000 + 3;
-pub const SYS_stat: ::c_long = 5000 + 4;
-pub const SYS_fstat: ::c_long = 5000 + 5;
-pub const SYS_lstat: ::c_long = 5000 + 6;
-pub const SYS_poll: ::c_long = 5000 + 7;
-pub const SYS_lseek: ::c_long = 5000 + 8;
-pub const SYS_mmap: ::c_long = 5000 + 9;
-pub const SYS_mprotect: ::c_long = 5000 + 10;
-pub const SYS_munmap: ::c_long = 5000 + 11;
-pub const SYS_brk: ::c_long = 5000 + 12;
-pub const SYS_rt_sigaction: ::c_long = 5000 + 13;
-pub const SYS_rt_sigprocmask: ::c_long = 5000 + 14;
-pub const SYS_ioctl: ::c_long = 5000 + 15;
-pub const SYS_pread64: ::c_long = 5000 + 16;
-pub const SYS_pwrite64: ::c_long = 5000 + 17;
-pub const SYS_readv: ::c_long = 5000 + 18;
-pub const SYS_writev: ::c_long = 5000 + 19;
-pub const SYS_access: ::c_long = 5000 + 20;
-pub const SYS_pipe: ::c_long = 5000 + 21;
-pub const SYS__newselect: ::c_long = 5000 + 22;
-pub const SYS_sched_yield: ::c_long = 5000 + 23;
-pub const SYS_mremap: ::c_long = 5000 + 24;
-pub const SYS_msync: ::c_long = 5000 + 25;
-pub const SYS_mincore: ::c_long = 5000 + 26;
-pub const SYS_madvise: ::c_long = 5000 + 27;
-pub const SYS_shmget: ::c_long = 5000 + 28;
-pub const SYS_shmat: ::c_long = 5000 + 29;
-pub const SYS_shmctl: ::c_long = 5000 + 30;
-pub const SYS_dup: ::c_long = 5000 + 31;
-pub const SYS_dup2: ::c_long = 5000 + 32;
-pub const SYS_pause: ::c_long = 5000 + 33;
-pub const SYS_nanosleep: ::c_long = 5000 + 34;
-pub const SYS_getitimer: ::c_long = 5000 + 35;
-pub const SYS_setitimer: ::c_long = 5000 + 36;
-pub const SYS_alarm: ::c_long = 5000 + 37;
-pub const SYS_getpid: ::c_long = 5000 + 38;
-pub const SYS_sendfile: ::c_long = 5000 + 39;
-pub const SYS_socket: ::c_long = 5000 + 40;
-pub const SYS_connect: ::c_long = 5000 + 41;
-pub const SYS_accept: ::c_long = 5000 + 42;
-pub const SYS_sendto: ::c_long = 5000 + 43;
-pub const SYS_recvfrom: ::c_long = 5000 + 44;
-pub const SYS_sendmsg: ::c_long = 5000 + 45;
-pub const SYS_recvmsg: ::c_long = 5000 + 46;
-pub const SYS_shutdown: ::c_long = 5000 + 47;
-pub const SYS_bind: ::c_long = 5000 + 48;
-pub const SYS_listen: ::c_long = 5000 + 49;
-pub const SYS_getsockname: ::c_long = 5000 + 50;
-pub const SYS_getpeername: ::c_long = 5000 + 51;
-pub const SYS_socketpair: ::c_long = 5000 + 52;
-pub const SYS_setsockopt: ::c_long = 5000 + 53;
-pub const SYS_getsockopt: ::c_long = 5000 + 54;
-pub const SYS_clone: ::c_long = 5000 + 55;
-pub const SYS_fork: ::c_long = 5000 + 56;
-pub const SYS_execve: ::c_long = 5000 + 57;
-pub const SYS_exit: ::c_long = 5000 + 58;
-pub const SYS_wait4: ::c_long = 5000 + 59;
-pub const SYS_kill: ::c_long = 5000 + 60;
-pub const SYS_uname: ::c_long = 5000 + 61;
-pub const SYS_semget: ::c_long = 5000 + 62;
-pub const SYS_semop: ::c_long = 5000 + 63;
-pub const SYS_semctl: ::c_long = 5000 + 64;
-pub const SYS_shmdt: ::c_long = 5000 + 65;
-pub const SYS_msgget: ::c_long = 5000 + 66;
-pub const SYS_msgsnd: ::c_long = 5000 + 67;
-pub const SYS_msgrcv: ::c_long = 5000 + 68;
-pub const SYS_msgctl: ::c_long = 5000 + 69;
-pub const SYS_fcntl: ::c_long = 5000 + 70;
-pub const SYS_flock: ::c_long = 5000 + 71;
-pub const SYS_fsync: ::c_long = 5000 + 72;
-pub const SYS_fdatasync: ::c_long = 5000 + 73;
-pub const SYS_truncate: ::c_long = 5000 + 74;
-pub const SYS_ftruncate: ::c_long = 5000 + 75;
-pub const SYS_getdents: ::c_long = 5000 + 76;
-pub const SYS_getcwd: ::c_long = 5000 + 77;
-pub const SYS_chdir: ::c_long = 5000 + 78;
-pub const SYS_fchdir: ::c_long = 5000 + 79;
-pub const SYS_rename: ::c_long = 5000 + 80;
-pub const SYS_mkdir: ::c_long = 5000 + 81;
-pub const SYS_rmdir: ::c_long = 5000 + 82;
-pub const SYS_creat: ::c_long = 5000 + 83;
-pub const SYS_link: ::c_long = 5000 + 84;
-pub const SYS_unlink: ::c_long = 5000 + 85;
-pub const SYS_symlink: ::c_long = 5000 + 86;
-pub const SYS_readlink: ::c_long = 5000 + 87;
-pub const SYS_chmod: ::c_long = 5000 + 88;
-pub const SYS_fchmod: ::c_long = 5000 + 89;
-pub const SYS_chown: ::c_long = 5000 + 90;
-pub const SYS_fchown: ::c_long = 5000 + 91;
-pub const SYS_lchown: ::c_long = 5000 + 92;
-pub const SYS_umask: ::c_long = 5000 + 93;
-pub const SYS_gettimeofday: ::c_long = 5000 + 94;
-pub const SYS_getrlimit: ::c_long = 5000 + 95;
-pub const SYS_getrusage: ::c_long = 5000 + 96;
-pub const SYS_sysinfo: ::c_long = 5000 + 97;
-pub const SYS_times: ::c_long = 5000 + 98;
-pub const SYS_ptrace: ::c_long = 5000 + 99;
-pub const SYS_getuid: ::c_long = 5000 + 100;
-pub const SYS_syslog: ::c_long = 5000 + 101;
-pub const SYS_getgid: ::c_long = 5000 + 102;
-pub const SYS_setuid: ::c_long = 5000 + 103;
-pub const SYS_setgid: ::c_long = 5000 + 104;
-pub const SYS_geteuid: ::c_long = 5000 + 105;
-pub const SYS_getegid: ::c_long = 5000 + 106;
-pub const SYS_setpgid: ::c_long = 5000 + 107;
-pub const SYS_getppid: ::c_long = 5000 + 108;
-pub const SYS_getpgrp: ::c_long = 5000 + 109;
-pub const SYS_setsid: ::c_long = 5000 + 110;
-pub const SYS_setreuid: ::c_long = 5000 + 111;
-pub const SYS_setregid: ::c_long = 5000 + 112;
-pub const SYS_getgroups: ::c_long = 5000 + 113;
-pub const SYS_setgroups: ::c_long = 5000 + 114;
-pub const SYS_setresuid: ::c_long = 5000 + 115;
-pub const SYS_getresuid: ::c_long = 5000 + 116;
-pub const SYS_setresgid: ::c_long = 5000 + 117;
-pub const SYS_getresgid: ::c_long = 5000 + 118;
-pub const SYS_getpgid: ::c_long = 5000 + 119;
-pub const SYS_setfsuid: ::c_long = 5000 + 120;
-pub const SYS_setfsgid: ::c_long = 5000 + 121;
-pub const SYS_getsid: ::c_long = 5000 + 122;
-pub const SYS_capget: ::c_long = 5000 + 123;
-pub const SYS_capset: ::c_long = 5000 + 124;
-pub const SYS_rt_sigpending: ::c_long = 5000 + 125;
-pub const SYS_rt_sigtimedwait: ::c_long = 5000 + 126;
-pub const SYS_rt_sigqueueinfo: ::c_long = 5000 + 127;
-pub const SYS_rt_sigsuspend: ::c_long = 5000 + 128;
-pub const SYS_sigaltstack: ::c_long = 5000 + 129;
-pub const SYS_utime: ::c_long = 5000 + 130;
-pub const SYS_mknod: ::c_long = 5000 + 131;
-pub const SYS_personality: ::c_long = 5000 + 132;
-pub const SYS_ustat: ::c_long = 5000 + 133;
-pub const SYS_statfs: ::c_long = 5000 + 134;
-pub const SYS_fstatfs: ::c_long = 5000 + 135;
-pub const SYS_sysfs: ::c_long = 5000 + 136;
-pub const SYS_getpriority: ::c_long = 5000 + 137;
-pub const SYS_setpriority: ::c_long = 5000 + 138;
-pub const SYS_sched_setparam: ::c_long = 5000 + 139;
-pub const SYS_sched_getparam: ::c_long = 5000 + 140;
-pub const SYS_sched_setscheduler: ::c_long = 5000 + 141;
-pub const SYS_sched_getscheduler: ::c_long = 5000 + 142;
-pub const SYS_sched_get_priority_max: ::c_long = 5000 + 143;
-pub const SYS_sched_get_priority_min: ::c_long = 5000 + 144;
-pub const SYS_sched_rr_get_interval: ::c_long = 5000 + 145;
-pub const SYS_mlock: ::c_long = 5000 + 146;
-pub const SYS_munlock: ::c_long = 5000 + 147;
-pub const SYS_mlockall: ::c_long = 5000 + 148;
-pub const SYS_munlockall: ::c_long = 5000 + 149;
-pub const SYS_vhangup: ::c_long = 5000 + 150;
-pub const SYS_pivot_root: ::c_long = 5000 + 151;
-pub const SYS__sysctl: ::c_long = 5000 + 152;
-pub const SYS_prctl: ::c_long = 5000 + 153;
-pub const SYS_adjtimex: ::c_long = 5000 + 154;
-pub const SYS_setrlimit: ::c_long = 5000 + 155;
-pub const SYS_chroot: ::c_long = 5000 + 156;
-pub const SYS_sync: ::c_long = 5000 + 157;
-pub const SYS_acct: ::c_long = 5000 + 158;
-pub const SYS_settimeofday: ::c_long = 5000 + 159;
-pub const SYS_mount: ::c_long = 5000 + 160;
-pub const SYS_umount2: ::c_long = 5000 + 161;
-pub const SYS_swapon: ::c_long = 5000 + 162;
-pub const SYS_swapoff: ::c_long = 5000 + 163;
-pub const SYS_reboot: ::c_long = 5000 + 164;
-pub const SYS_sethostname: ::c_long = 5000 + 165;
-pub const SYS_setdomainname: ::c_long = 5000 + 166;
-pub const SYS_create_module: ::c_long = 5000 + 167;
-pub const SYS_init_module: ::c_long = 5000 + 168;
-pub const SYS_delete_module: ::c_long = 5000 + 169;
-pub const SYS_get_kernel_syms: ::c_long = 5000 + 170;
-pub const SYS_query_module: ::c_long = 5000 + 171;
-pub const SYS_quotactl: ::c_long = 5000 + 172;
-pub const SYS_nfsservctl: ::c_long = 5000 + 173;
-pub const SYS_getpmsg: ::c_long = 5000 + 174;
-pub const SYS_putpmsg: ::c_long = 5000 + 175;
-pub const SYS_afs_syscall: ::c_long = 5000 + 176;
-pub const SYS_gettid: ::c_long = 5000 + 178;
-pub const SYS_readahead: ::c_long = 5000 + 179;
-pub const SYS_setxattr: ::c_long = 5000 + 180;
-pub const SYS_lsetxattr: ::c_long = 5000 + 181;
-pub const SYS_fsetxattr: ::c_long = 5000 + 182;
-pub const SYS_getxattr: ::c_long = 5000 + 183;
-pub const SYS_lgetxattr: ::c_long = 5000 + 184;
-pub const SYS_fgetxattr: ::c_long = 5000 + 185;
-pub const SYS_listxattr: ::c_long = 5000 + 186;
-pub const SYS_llistxattr: ::c_long = 5000 + 187;
-pub const SYS_flistxattr: ::c_long = 5000 + 188;
-pub const SYS_removexattr: ::c_long = 5000 + 189;
-pub const SYS_lremovexattr: ::c_long = 5000 + 190;
-pub const SYS_fremovexattr: ::c_long = 5000 + 191;
-pub const SYS_tkill: ::c_long = 5000 + 192;
-pub const SYS_futex: ::c_long = 5000 + 194;
-pub const SYS_sched_setaffinity: ::c_long = 5000 + 195;
-pub const SYS_sched_getaffinity: ::c_long = 5000 + 196;
-pub const SYS_cacheflush: ::c_long = 5000 + 197;
-pub const SYS_cachectl: ::c_long = 5000 + 198;
-pub const SYS_sysmips: ::c_long = 5000 + 199;
-pub const SYS_io_setup: ::c_long = 5000 + 200;
-pub const SYS_io_destroy: ::c_long = 5000 + 201;
-pub const SYS_io_getevents: ::c_long = 5000 + 202;
-pub const SYS_io_submit: ::c_long = 5000 + 203;
-pub const SYS_io_cancel: ::c_long = 5000 + 204;
-pub const SYS_exit_group: ::c_long = 5000 + 205;
-pub const SYS_lookup_dcookie: ::c_long = 5000 + 206;
-pub const SYS_epoll_create: ::c_long = 5000 + 207;
-pub const SYS_epoll_ctl: ::c_long = 5000 + 208;
-pub const SYS_epoll_wait: ::c_long = 5000 + 209;
-pub const SYS_remap_file_pages: ::c_long = 5000 + 210;
-pub const SYS_rt_sigreturn: ::c_long = 5000 + 211;
-pub const SYS_set_tid_address: ::c_long = 5000 + 212;
-pub const SYS_restart_syscall: ::c_long = 5000 + 213;
-pub const SYS_semtimedop: ::c_long = 5000 + 214;
-pub const SYS_fadvise64: ::c_long = 5000 + 215;
-pub const SYS_timer_create: ::c_long = 5000 + 216;
-pub const SYS_timer_settime: ::c_long = 5000 + 217;
-pub const SYS_timer_gettime: ::c_long = 5000 + 218;
-pub const SYS_timer_getoverrun: ::c_long = 5000 + 219;
-pub const SYS_timer_delete: ::c_long = 5000 + 220;
-pub const SYS_clock_settime: ::c_long = 5000 + 221;
-pub const SYS_clock_gettime: ::c_long = 5000 + 222;
-pub const SYS_clock_getres: ::c_long = 5000 + 223;
-pub const SYS_clock_nanosleep: ::c_long = 5000 + 224;
-pub const SYS_tgkill: ::c_long = 5000 + 225;
-pub const SYS_utimes: ::c_long = 5000 + 226;
-pub const SYS_mbind: ::c_long = 5000 + 227;
-pub const SYS_get_mempolicy: ::c_long = 5000 + 228;
-pub const SYS_set_mempolicy: ::c_long = 5000 + 229;
-pub const SYS_mq_open: ::c_long = 5000 + 230;
-pub const SYS_mq_unlink: ::c_long = 5000 + 231;
-pub const SYS_mq_timedsend: ::c_long = 5000 + 232;
-pub const SYS_mq_timedreceive: ::c_long = 5000 + 233;
-pub const SYS_mq_notify: ::c_long = 5000 + 234;
-pub const SYS_mq_getsetattr: ::c_long = 5000 + 235;
-pub const SYS_vserver: ::c_long = 5000 + 236;
-pub const SYS_waitid: ::c_long = 5000 + 237;
-/* pub const SYS_sys_setaltroot: ::c_long = 5000 + 238; */
-pub const SYS_add_key: ::c_long = 5000 + 239;
-pub const SYS_request_key: ::c_long = 5000 + 240;
-pub const SYS_keyctl: ::c_long = 5000 + 241;
-pub const SYS_set_thread_area: ::c_long = 5000 + 242;
-pub const SYS_inotify_init: ::c_long = 5000 + 243;
-pub const SYS_inotify_add_watch: ::c_long = 5000 + 244;
-pub const SYS_inotify_rm_watch: ::c_long = 5000 + 245;
-pub const SYS_migrate_pages: ::c_long = 5000 + 246;
-pub const SYS_openat: ::c_long = 5000 + 247;
-pub const SYS_mkdirat: ::c_long = 5000 + 248;
-pub const SYS_mknodat: ::c_long = 5000 + 249;
-pub const SYS_fchownat: ::c_long = 5000 + 250;
-pub const SYS_futimesat: ::c_long = 5000 + 251;
-pub const SYS_newfstatat: ::c_long = 5000 + 252;
-pub const SYS_unlinkat: ::c_long = 5000 + 253;
-pub const SYS_renameat: ::c_long = 5000 + 254;
-pub const SYS_linkat: ::c_long = 5000 + 255;
-pub const SYS_symlinkat: ::c_long = 5000 + 256;
-pub const SYS_readlinkat: ::c_long = 5000 + 257;
-pub const SYS_fchmodat: ::c_long = 5000 + 258;
-pub const SYS_faccessat: ::c_long = 5000 + 259;
-pub const SYS_pselect6: ::c_long = 5000 + 260;
-pub const SYS_ppoll: ::c_long = 5000 + 261;
-pub const SYS_unshare: ::c_long = 5000 + 262;
-pub const SYS_splice: ::c_long = 5000 + 263;
-pub const SYS_sync_file_range: ::c_long = 5000 + 264;
-pub const SYS_tee: ::c_long = 5000 + 265;
-pub const SYS_vmsplice: ::c_long = 5000 + 266;
-pub const SYS_move_pages: ::c_long = 5000 + 267;
-pub const SYS_set_robust_list: ::c_long = 5000 + 268;
-pub const SYS_get_robust_list: ::c_long = 5000 + 269;
-pub const SYS_kexec_load: ::c_long = 5000 + 270;
-pub const SYS_getcpu: ::c_long = 5000 + 271;
-pub const SYS_epoll_pwait: ::c_long = 5000 + 272;
-pub const SYS_ioprio_set: ::c_long = 5000 + 273;
-pub const SYS_ioprio_get: ::c_long = 5000 + 274;
-pub const SYS_utimensat: ::c_long = 5000 + 275;
-pub const SYS_signalfd: ::c_long = 5000 + 276;
-pub const SYS_timerfd: ::c_long = 5000 + 277;
-pub const SYS_eventfd: ::c_long = 5000 + 278;
-pub const SYS_fallocate: ::c_long = 5000 + 279;
-pub const SYS_timerfd_create: ::c_long = 5000 + 280;
-pub const SYS_timerfd_gettime: ::c_long = 5000 + 281;
-pub const SYS_timerfd_settime: ::c_long = 5000 + 282;
-pub const SYS_signalfd4: ::c_long = 5000 + 283;
-pub const SYS_eventfd2: ::c_long = 5000 + 284;
-pub const SYS_epoll_create1: ::c_long = 5000 + 285;
-pub const SYS_dup3: ::c_long = 5000 + 286;
-pub const SYS_pipe2: ::c_long = 5000 + 287;
-pub const SYS_inotify_init1: ::c_long = 5000 + 288;
-pub const SYS_preadv: ::c_long = 5000 + 289;
-pub const SYS_pwritev: ::c_long = 5000 + 290;
-pub const SYS_rt_tgsigqueueinfo: ::c_long = 5000 + 291;
-pub const SYS_perf_event_open: ::c_long = 5000 + 292;
-pub const SYS_accept4: ::c_long = 5000 + 293;
-pub const SYS_recvmmsg: ::c_long = 5000 + 294;
-pub const SYS_fanotify_init: ::c_long = 5000 + 295;
-pub const SYS_fanotify_mark: ::c_long = 5000 + 296;
-pub const SYS_prlimit64: ::c_long = 5000 + 297;
-pub const SYS_name_to_handle_at: ::c_long = 5000 + 298;
-pub const SYS_open_by_handle_at: ::c_long = 5000 + 299;
-pub const SYS_clock_adjtime: ::c_long = 5000 + 300;
-pub const SYS_syncfs: ::c_long = 5000 + 301;
-pub const SYS_sendmmsg: ::c_long = 5000 + 302;
-pub const SYS_setns: ::c_long = 5000 + 303;
-pub const SYS_process_vm_readv: ::c_long = 5000 + 304;
-pub const SYS_process_vm_writev: ::c_long = 5000 + 305;
-pub const SYS_kcmp: ::c_long = 5000 + 306;
-pub const SYS_finit_module: ::c_long = 5000 + 307;
-pub const SYS_getdents64: ::c_long = 5000 + 308;
-pub const SYS_sched_setattr: ::c_long = 5000 + 309;
-pub const SYS_sched_getattr: ::c_long = 5000 + 310;
-pub const SYS_renameat2: ::c_long = 5000 + 311;
-pub const SYS_seccomp: ::c_long = 5000 + 312;
-pub const SYS_getrandom: ::c_long = 5000 + 313;
-pub const SYS_memfd_create: ::c_long = 5000 + 314;
-pub const SYS_bpf: ::c_long = 5000 + 315;
-pub const SYS_execveat: ::c_long = 5000 + 316;
-pub const SYS_userfaultfd: ::c_long = 5000 + 317;
-pub const SYS_membarrier: ::c_long = 5000 + 318;
-pub const SYS_mlock2: ::c_long = 5000 + 319;
-pub const SYS_copy_file_range: ::c_long = 5000 + 320;
-pub const SYS_preadv2: ::c_long = 5000 + 321;
-pub const SYS_pwritev2: ::c_long = 5000 + 322;
-pub const SYS_pkey_mprotect: ::c_long = 5000 + 323;
-pub const SYS_pkey_alloc: ::c_long = 5000 + 324;
-pub const SYS_pkey_free: ::c_long = 5000 + 325;
diff --git a/libc/src/unix/notbsd/linux/mips/mod.rs b/libc/src/unix/notbsd/linux/mips/mod.rs
deleted file mode 100644
index 46c49ff..0000000
--- a/libc/src/unix/notbsd/linux/mips/mod.rs
+++ /dev/null
@@ -1,1008 +0,0 @@
-pub type pthread_t = c_ulong;
-pub type shmatt_t = ::c_ulong;
-pub type msgqnum_t = ::c_ulong;
-pub type msglen_t = ::c_ulong;
-pub type fsblkcnt_t = ::c_ulong;
-pub type fsfilcnt_t = ::c_ulong;
-pub type rlim_t = c_ulong;
-pub type __priority_which_t = ::c_uint;
-pub type __rlimit_resource_t = ::c_uint;
-
-s! {
- pub struct glob64_t {
- pub gl_pathc: ::size_t,
- pub gl_pathv: *mut *mut ::c_char,
- pub gl_offs: ::size_t,
- pub gl_flags: ::c_int,
-
- __unused1: *mut ::c_void,
- __unused2: *mut ::c_void,
- __unused3: *mut ::c_void,
- __unused4: *mut ::c_void,
- __unused5: *mut ::c_void,
- }
-
- 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_line: ::cc_t,
- pub c_cc: [::cc_t; 23],
- 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 MS_RMT_MASK: ::c_ulong = 0x02800051;
-
-pub const SFD_CLOEXEC: ::c_int = 0x080000;
-
-pub const NCCS: usize = 32;
-
-pub const O_TRUNC: ::c_int = 512;
-
-pub const O_NOATIME: ::c_int = 0o1000000;
-pub const O_CLOEXEC: ::c_int = 0x80000;
-pub const O_PATH: ::c_int = 0o10000000;
-pub const O_TMPFILE: ::c_int = 0o20000000 | O_DIRECTORY;
-
-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 EDOTDOT: ::c_int = 73;
-
-pub const SA_NODEFER: ::c_int = 0x40000000;
-pub const SA_RESETHAND: ::c_int = 0x80000000;
-pub const SA_RESTART: ::c_int = 0x10000000;
-pub const SA_NOCLDSTOP: ::c_int = 0x00000001;
-
-pub const EPOLL_CLOEXEC: ::c_int = 0x80000;
-
-pub const EFD_CLOEXEC: ::c_int = 0x80000;
-
-pub const BUFSIZ: ::c_uint = 8192;
-pub const TMP_MAX: ::c_uint = 238328;
-pub const FOPEN_MAX: ::c_uint = 16;
-pub const POSIX_FADV_DONTNEED: ::c_int = 4;
-pub const POSIX_FADV_NOREUSE: ::c_int = 5;
-pub const POSIX_MADV_DONTNEED: ::c_int = 4;
-pub const _SC_EQUIV_CLASS_MAX: ::c_int = 41;
-pub const _SC_CHARCLASS_NAME_MAX: ::c_int = 45;
-pub const _SC_PII: ::c_int = 53;
-pub const _SC_PII_XTI: ::c_int = 54;
-pub const _SC_PII_SOCKET: ::c_int = 55;
-pub const _SC_PII_INTERNET: ::c_int = 56;
-pub const _SC_PII_OSI: ::c_int = 57;
-pub const _SC_POLL: ::c_int = 58;
-pub const _SC_SELECT: ::c_int = 59;
-pub const _SC_PII_INTERNET_STREAM: ::c_int = 61;
-pub const _SC_PII_INTERNET_DGRAM: ::c_int = 62;
-pub const _SC_PII_OSI_COTS: ::c_int = 63;
-pub const _SC_PII_OSI_CLTS: ::c_int = 64;
-pub const _SC_PII_OSI_M: ::c_int = 65;
-pub const _SC_T_IOV_MAX: ::c_int = 66;
-pub const _SC_2_C_VERSION: ::c_int = 96;
-pub const _SC_CHAR_BIT: ::c_int = 101;
-pub const _SC_CHAR_MAX: ::c_int = 102;
-pub const _SC_CHAR_MIN: ::c_int = 103;
-pub const _SC_INT_MAX: ::c_int = 104;
-pub const _SC_INT_MIN: ::c_int = 105;
-pub const _SC_LONG_BIT: ::c_int = 106;
-pub const _SC_WORD_BIT: ::c_int = 107;
-pub const _SC_MB_LEN_MAX: ::c_int = 108;
-pub const _SC_SSIZE_MAX: ::c_int = 110;
-pub const _SC_SCHAR_MAX: ::c_int = 111;
-pub const _SC_SCHAR_MIN: ::c_int = 112;
-pub const _SC_SHRT_MAX: ::c_int = 113;
-pub const _SC_SHRT_MIN: ::c_int = 114;
-pub const _SC_UCHAR_MAX: ::c_int = 115;
-pub const _SC_UINT_MAX: ::c_int = 116;
-pub const _SC_ULONG_MAX: ::c_int = 117;
-pub const _SC_USHRT_MAX: ::c_int = 118;
-pub const _SC_NL_ARGMAX: ::c_int = 119;
-pub const _SC_NL_LANGMAX: ::c_int = 120;
-pub const _SC_NL_MSGMAX: ::c_int = 121;
-pub const _SC_NL_NMAX: ::c_int = 122;
-pub const _SC_NL_SETMAX: ::c_int = 123;
-pub const _SC_NL_TEXTMAX: ::c_int = 124;
-pub const _SC_BASE: ::c_int = 134;
-pub const _SC_C_LANG_SUPPORT: ::c_int = 135;
-pub const _SC_C_LANG_SUPPORT_R: ::c_int = 136;
-pub const _SC_DEVICE_IO: ::c_int = 140;
-pub const _SC_DEVICE_SPECIFIC: ::c_int = 141;
-pub const _SC_DEVICE_SPECIFIC_R: ::c_int = 142;
-pub const _SC_FD_MGMT: ::c_int = 143;
-pub const _SC_FIFO: ::c_int = 144;
-pub const _SC_PIPE: ::c_int = 145;
-pub const _SC_FILE_ATTRIBUTES: ::c_int = 146;
-pub const _SC_FILE_LOCKING: ::c_int = 147;
-pub const _SC_FILE_SYSTEM: ::c_int = 148;
-pub const _SC_MULTI_PROCESS: ::c_int = 150;
-pub const _SC_SINGLE_PROCESS: ::c_int = 151;
-pub const _SC_NETWORKING: ::c_int = 152;
-pub const _SC_REGEX_VERSION: ::c_int = 156;
-pub const _SC_SIGNALS: ::c_int = 158;
-pub const _SC_SYSTEM_DATABASE: ::c_int = 162;
-pub const _SC_SYSTEM_DATABASE_R: ::c_int = 163;
-pub const _SC_USER_GROUPS: ::c_int = 166;
-pub const _SC_USER_GROUPS_R: ::c_int = 167;
-pub const _SC_LEVEL1_ICACHE_SIZE: ::c_int = 185;
-pub const _SC_LEVEL1_ICACHE_ASSOC: ::c_int = 186;
-pub const _SC_LEVEL1_ICACHE_LINESIZE: ::c_int = 187;
-pub const _SC_LEVEL1_DCACHE_SIZE: ::c_int = 188;
-pub const _SC_LEVEL1_DCACHE_ASSOC: ::c_int = 189;
-pub const _SC_LEVEL1_DCACHE_LINESIZE: ::c_int = 190;
-pub const _SC_LEVEL2_CACHE_SIZE: ::c_int = 191;
-pub const _SC_LEVEL2_CACHE_ASSOC: ::c_int = 192;
-pub const _SC_LEVEL2_CACHE_LINESIZE: ::c_int = 193;
-pub const _SC_LEVEL3_CACHE_SIZE: ::c_int = 194;
-pub const _SC_LEVEL3_CACHE_ASSOC: ::c_int = 195;
-pub const _SC_LEVEL3_CACHE_LINESIZE: ::c_int = 196;
-pub const _SC_LEVEL4_CACHE_SIZE: ::c_int = 197;
-pub const _SC_LEVEL4_CACHE_ASSOC: ::c_int = 198;
-pub const _SC_LEVEL4_CACHE_LINESIZE: ::c_int = 199;
-pub const O_ACCMODE: ::c_int = 3;
-pub const O_DIRECT: ::c_int = 0x8000;
-pub const O_DIRECTORY: ::c_int = 0x10000;
-pub const O_NOFOLLOW: ::c_int = 0x20000;
-pub const ST_RELATIME: ::c_ulong = 4096;
-pub const NI_MAXHOST: ::socklen_t = 1025;
-
-pub const RLIMIT_NOFILE: ::c_int = 5;
-pub const RLIMIT_AS: ::c_int = 6;
-pub const RLIMIT_RSS: ::c_int = 7;
-pub const RLIMIT_NPROC: ::c_int = 8;
-pub const RLIMIT_MEMLOCK: ::c_int = 9;
-pub const RLIMIT_NLIMITS: ::c_int = 16;
-
-pub const O_APPEND: ::c_int = 8;
-pub const O_CREAT: ::c_int = 256;
-pub const O_EXCL: ::c_int = 1024;
-pub const O_NOCTTY: ::c_int = 2048;
-pub const O_NONBLOCK: ::c_int = 128;
-pub const O_SYNC: ::c_int = 0x4010;
-pub const O_RSYNC: ::c_int = 0x4010;
-pub const O_DSYNC: ::c_int = 0x10;
-pub const O_FSYNC: ::c_int = 0x4010;
-pub const O_ASYNC: ::c_int = 0x1000;
-pub const O_NDELAY: ::c_int = 0x80;
-
-pub const SOCK_NONBLOCK: ::c_int = 128;
-
-pub const EDEADLK: ::c_int = 45;
-pub const ENAMETOOLONG: ::c_int = 78;
-pub const ENOLCK: ::c_int = 46;
-pub const ENOSYS: ::c_int = 89;
-pub const ENOTEMPTY: ::c_int = 93;
-pub const ELOOP: ::c_int = 90;
-pub const ENOMSG: ::c_int = 35;
-pub const EIDRM: ::c_int = 36;
-pub const ECHRNG: ::c_int = 37;
-pub const EL2NSYNC: ::c_int = 38;
-pub const EL3HLT: ::c_int = 39;
-pub const EL3RST: ::c_int = 40;
-pub const ELNRNG: ::c_int = 41;
-pub const EUNATCH: ::c_int = 42;
-pub const ENOCSI: ::c_int = 43;
-pub const EL2HLT: ::c_int = 44;
-pub const EBADE: ::c_int = 50;
-pub const EBADR: ::c_int = 51;
-pub const EXFULL: ::c_int = 52;
-pub const ENOANO: ::c_int = 53;
-pub const EBADRQC: ::c_int = 54;
-pub const EBADSLT: ::c_int = 55;
-pub const EDEADLOCK: ::c_int = 56;
-pub const EMULTIHOP: ::c_int = 74;
-pub const EOVERFLOW: ::c_int = 79;
-pub const ENOTUNIQ: ::c_int = 80;
-pub const EBADFD: ::c_int = 81;
-pub const EBADMSG: ::c_int = 77;
-pub const EREMCHG: ::c_int = 82;
-pub const ELIBACC: ::c_int = 83;
-pub const ELIBBAD: ::c_int = 84;
-pub const ELIBSCN: ::c_int = 85;
-pub const ELIBMAX: ::c_int = 86;
-pub const ELIBEXEC: ::c_int = 87;
-pub const EILSEQ: ::c_int = 88;
-pub const ERESTART: ::c_int = 91;
-pub const ESTRPIPE: ::c_int = 92;
-pub const EUSERS: ::c_int = 94;
-pub const ENOTSOCK: ::c_int = 95;
-pub const EDESTADDRREQ: ::c_int = 96;
-pub const EMSGSIZE: ::c_int = 97;
-pub const EPROTOTYPE: ::c_int = 98;
-pub const ENOPROTOOPT: ::c_int = 99;
-pub const EPROTONOSUPPORT: ::c_int = 120;
-pub const ESOCKTNOSUPPORT: ::c_int = 121;
-pub const EOPNOTSUPP: ::c_int = 122;
-pub const ENOTSUP: ::c_int = EOPNOTSUPP;
-pub const EPFNOSUPPORT: ::c_int = 123;
-pub const EAFNOSUPPORT: ::c_int = 124;
-pub const EADDRINUSE: ::c_int = 125;
-pub const EADDRNOTAVAIL: ::c_int = 126;
-pub const ENETDOWN: ::c_int = 127;
-pub const ENETUNREACH: ::c_int = 128;
-pub const ENETRESET: ::c_int = 129;
-pub const ECONNABORTED: ::c_int = 130;
-pub const ECONNRESET: ::c_int = 131;
-pub const ENOBUFS: ::c_int = 132;
-pub const EISCONN: ::c_int = 133;
-pub const ENOTCONN: ::c_int = 134;
-pub const ESHUTDOWN: ::c_int = 143;
-pub const ETOOMANYREFS: ::c_int = 144;
-pub const ETIMEDOUT: ::c_int = 145;
-pub const ECONNREFUSED: ::c_int = 146;
-pub const EHOSTDOWN: ::c_int = 147;
-pub const EHOSTUNREACH: ::c_int = 148;
-pub const EALREADY: ::c_int = 149;
-pub const EINPROGRESS: ::c_int = 150;
-pub const ESTALE: ::c_int = 151;
-pub const EUCLEAN: ::c_int = 135;
-pub const ENOTNAM: ::c_int = 137;
-pub const ENAVAIL: ::c_int = 138;
-pub const EISNAM: ::c_int = 139;
-pub const EREMOTEIO: ::c_int = 140;
-pub const EDQUOT: ::c_int = 1133;
-pub const ENOMEDIUM: ::c_int = 159;
-pub const EMEDIUMTYPE: ::c_int = 160;
-pub const ECANCELED: ::c_int = 158;
-pub const ENOKEY: ::c_int = 161;
-pub const EKEYEXPIRED: ::c_int = 162;
-pub const EKEYREVOKED: ::c_int = 163;
-pub const EKEYREJECTED: ::c_int = 164;
-pub const EOWNERDEAD: ::c_int = 165;
-pub const ENOTRECOVERABLE: ::c_int = 166;
-pub const ERFKILL: ::c_int = 167;
-
-pub const LC_PAPER: ::c_int = 7;
-pub const LC_NAME: ::c_int = 8;
-pub const LC_ADDRESS: ::c_int = 9;
-pub const LC_TELEPHONE: ::c_int = 10;
-pub const LC_MEASUREMENT: ::c_int = 11;
-pub const LC_IDENTIFICATION: ::c_int = 12;
-pub const LC_PAPER_MASK: ::c_int = (1 << LC_PAPER);
-pub const LC_NAME_MASK: ::c_int = (1 << LC_NAME);
-pub const LC_ADDRESS_MASK: ::c_int = (1 << LC_ADDRESS);
-pub const LC_TELEPHONE_MASK: ::c_int = (1 << LC_TELEPHONE);
-pub const LC_MEASUREMENT_MASK: ::c_int = (1 << LC_MEASUREMENT);
-pub const LC_IDENTIFICATION_MASK: ::c_int = (1 << LC_IDENTIFICATION);
-pub const LC_ALL_MASK: ::c_int = ::LC_CTYPE_MASK
- | ::LC_NUMERIC_MASK
- | ::LC_TIME_MASK
- | ::LC_COLLATE_MASK
- | ::LC_MONETARY_MASK
- | ::LC_MESSAGES_MASK
- | LC_PAPER_MASK
- | LC_NAME_MASK
- | LC_ADDRESS_MASK
- | LC_TELEPHONE_MASK
- | LC_MEASUREMENT_MASK
- | LC_IDENTIFICATION_MASK;
-
-pub const MAP_NORESERVE: ::c_int = 0x400;
-pub const MAP_ANON: ::c_int = 0x800;
-pub const MAP_ANONYMOUS: ::c_int = 0x800;
-pub const MAP_GROWSDOWN: ::c_int = 0x1000;
-pub const MAP_DENYWRITE: ::c_int = 0x2000;
-pub const MAP_EXECUTABLE: ::c_int = 0x4000;
-pub const MAP_LOCKED: ::c_int = 0x8000;
-pub const MAP_POPULATE: ::c_int = 0x10000;
-pub const MAP_NONBLOCK: ::c_int = 0x20000;
-pub const MAP_STACK: ::c_int = 0x40000;
-pub const MAP_SHARED_VALIDATE: ::c_int = 0x3;
-pub const MAP_FIXED_NOREPLACE: ::c_int = 0x100000;
-
-pub const SOCK_STREAM: ::c_int = 2;
-pub const SOCK_DGRAM: ::c_int = 1;
-pub const SOCK_SEQPACKET: ::c_int = 5;
-pub const SOCK_DCCP: ::c_int = 6;
-pub const SOCK_PACKET: ::c_int = 10;
-
-pub const SOL_SOCKET: ::c_int = 0xffff;
-
-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_LINGER: ::c_int = 0x0080;
-pub const SO_OOBINLINE: ::c_int = 0x0100;
-pub const SO_REUSEPORT: ::c_int = 0x0200;
-pub const SO_TYPE: ::c_int = 0x1008;
-pub const SO_STYLE: ::c_int = SO_TYPE;
-pub const SO_ERROR: ::c_int = 0x1007;
-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_ACCEPTCONN: ::c_int = 0x1009;
-pub const SO_PROTOCOL: ::c_int = 0x1028;
-pub const SO_DOMAIN: ::c_int = 0x1029;
-pub const SO_NO_CHECK: ::c_int = 11;
-pub const SO_PRIORITY: ::c_int = 12;
-pub const SO_BSDCOMPAT: ::c_int = 14;
-pub const SO_PASSCRED: ::c_int = 17;
-pub const SO_PEERCRED: ::c_int = 18;
-pub const SO_SECURITY_AUTHENTICATION: ::c_int = 22;
-pub const SO_SECURITY_ENCRYPTION_TRANSPORT: ::c_int = 23;
-pub const SO_SECURITY_ENCRYPTION_NETWORK: ::c_int = 24;
-pub const SO_BINDTODEVICE: ::c_int = 25;
-pub const SO_ATTACH_FILTER: ::c_int = 26;
-pub const SO_DETACH_FILTER: ::c_int = 27;
-pub const SO_GET_FILTER: ::c_int = SO_ATTACH_FILTER;
-pub const SO_PEERNAME: ::c_int = 28;
-pub const SO_TIMESTAMP: ::c_int = 29;
-pub const SO_PEERSEC: ::c_int = 30;
-pub const SO_SNDBUFFORCE: ::c_int = 31;
-pub const SO_RCVBUFFORCE: ::c_int = 33;
-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_RXQ_OVFL: ::c_int = 40;
-pub const SO_WIFI_STATUS: ::c_int = 41;
-pub const SCM_WIFI_STATUS: ::c_int = SO_WIFI_STATUS;
-pub const SO_PEEK_OFF: ::c_int = 42;
-pub const SO_NOFCS: ::c_int = 43;
-pub const SO_LOCK_FILTER: ::c_int = 44;
-pub const SO_SELECT_ERR_QUEUE: ::c_int = 45;
-pub const SO_BUSY_POLL: ::c_int = 46;
-pub const SO_MAX_PACING_RATE: ::c_int = 47;
-pub const SO_BPF_EXTENSIONS: ::c_int = 48;
-pub const SO_INCOMING_CPU: ::c_int = 49;
-pub const SO_ATTACH_BPF: ::c_int = 50;
-pub const SO_DETACH_BPF: ::c_int = SO_DETACH_FILTER;
-
-/* DCCP socket options */
-pub const DCCP_SOCKOPT_PACKET_SIZE: ::c_int = 1;
-pub const DCCP_SOCKOPT_SERVICE: ::c_int = 2;
-pub const DCCP_SOCKOPT_CHANGE_L: ::c_int = 3;
-pub const DCCP_SOCKOPT_CHANGE_R: ::c_int = 4;
-pub const DCCP_SOCKOPT_GET_CUR_MPS: ::c_int = 5;
-pub const DCCP_SOCKOPT_SERVER_TIMEWAIT: ::c_int = 6;
-pub const DCCP_SOCKOPT_SEND_CSCOV: ::c_int = 10;
-pub const DCCP_SOCKOPT_RECV_CSCOV: ::c_int = 11;
-pub const DCCP_SOCKOPT_AVAILABLE_CCIDS: ::c_int = 12;
-pub const DCCP_SOCKOPT_CCID: ::c_int = 13;
-pub const DCCP_SOCKOPT_TX_CCID: ::c_int = 14;
-pub const DCCP_SOCKOPT_RX_CCID: ::c_int = 15;
-pub const DCCP_SOCKOPT_QPOLICY_ID: ::c_int = 16;
-pub const DCCP_SOCKOPT_QPOLICY_TXQLEN: ::c_int = 17;
-pub const DCCP_SOCKOPT_CCID_RX_INFO: ::c_int = 128;
-pub const DCCP_SOCKOPT_CCID_TX_INFO: ::c_int = 192;
-
-/// maximum number of services provided on the same listening port
-pub const DCCP_SERVICE_LIST_MAX_LEN: ::c_int = 32;
-
-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_NOCLDWAIT: ::c_int = 0x00010000;
-
-pub const SIGCHLD: ::c_int = 18;
-pub const SIGBUS: ::c_int = 10;
-pub const SIGTTIN: ::c_int = 26;
-pub const SIGTTOU: ::c_int = 27;
-pub const SIGXCPU: ::c_int = 30;
-pub const SIGXFSZ: ::c_int = 31;
-pub const SIGVTALRM: ::c_int = 28;
-pub const SIGPROF: ::c_int = 29;
-pub const SIGWINCH: ::c_int = 20;
-pub const SIGUSR1: ::c_int = 16;
-pub const SIGUSR2: ::c_int = 17;
-pub const SIGCONT: ::c_int = 25;
-pub const SIGSTOP: ::c_int = 23;
-pub const SIGTSTP: ::c_int = 24;
-pub const SIGURG: ::c_int = 21;
-pub const SIGIO: ::c_int = 22;
-pub const SIGSYS: ::c_int = 12;
-pub const SIGPOLL: ::c_int = 22;
-pub const SIGPWR: ::c_int = 19;
-pub const SIG_SETMASK: ::c_int = 3;
-pub const SIG_BLOCK: ::c_int = 0x1;
-pub const SIG_UNBLOCK: ::c_int = 0x2;
-
-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;
-pub const CODA_SUPER_MAGIC: ::c_long = 0x73757245;
-pub const CRAMFS_MAGIC: ::c_long = 0x28cd3d45;
-pub const EFS_SUPER_MAGIC: ::c_long = 0x00414a53;
-pub const EXT2_SUPER_MAGIC: ::c_long = 0x0000ef53;
-pub const EXT3_SUPER_MAGIC: ::c_long = 0x0000ef53;
-pub const EXT4_SUPER_MAGIC: ::c_long = 0x0000ef53;
-pub const HPFS_SUPER_MAGIC: ::c_long = 0xf995e849;
-pub const HUGETLBFS_MAGIC: ::c_long = 0x958458f6;
-pub const ISOFS_SUPER_MAGIC: ::c_long = 0x00009660;
-pub const JFFS2_SUPER_MAGIC: ::c_long = 0x000072b6;
-pub const MINIX_SUPER_MAGIC: ::c_long = 0x0000137f;
-pub const MINIX_SUPER_MAGIC2: ::c_long = 0x0000138f;
-pub const MINIX2_SUPER_MAGIC: ::c_long = 0x00002468;
-pub const MINIX2_SUPER_MAGIC2: ::c_long = 0x00002478;
-pub const MSDOS_SUPER_MAGIC: ::c_long = 0x00004d44;
-pub const NCP_SUPER_MAGIC: ::c_long = 0x0000564c;
-pub const NFS_SUPER_MAGIC: ::c_long = 0x00006969;
-pub const OPENPROM_SUPER_MAGIC: ::c_long = 0x00009fa1;
-pub const PROC_SUPER_MAGIC: ::c_long = 0x00009fa0;
-pub const QNX4_SUPER_MAGIC: ::c_long = 0x0000002f;
-pub const REISERFS_SUPER_MAGIC: ::c_long = 0x52654973;
-pub const SMB_SUPER_MAGIC: ::c_long = 0x0000517b;
-pub const TMPFS_MAGIC: ::c_long = 0x01021994;
-pub const USBDEVICE_SUPER_MAGIC: ::c_long = 0x00009fa2;
-
-pub const VEOF: usize = 16;
-pub const VEOL: usize = 17;
-pub const VEOL2: usize = 6;
-pub const VMIN: usize = 4;
-pub const IEXTEN: ::tcflag_t = 0x00000100;
-pub const TOSTOP: ::tcflag_t = 0x00008000;
-pub const FLUSHO: ::tcflag_t = 0x00002000;
-pub const EXTPROC: ::tcflag_t = 0o200000;
-pub const TCSANOW: ::c_int = 0x540e;
-pub const TCSADRAIN: ::c_int = 0x540f;
-pub const TCSAFLUSH: ::c_int = 0x5410;
-
-pub const CPU_SETSIZE: ::c_int = 0x400;
-
-pub const PTRACE_TRACEME: ::c_uint = 0;
-pub const PTRACE_PEEKTEXT: ::c_uint = 1;
-pub const PTRACE_PEEKDATA: ::c_uint = 2;
-pub const PTRACE_PEEKUSER: ::c_uint = 3;
-pub const PTRACE_POKETEXT: ::c_uint = 4;
-pub const PTRACE_POKEDATA: ::c_uint = 5;
-pub const PTRACE_POKEUSER: ::c_uint = 6;
-pub const PTRACE_CONT: ::c_uint = 7;
-pub const PTRACE_KILL: ::c_uint = 8;
-pub const PTRACE_SINGLESTEP: ::c_uint = 9;
-pub const PTRACE_ATTACH: ::c_uint = 16;
-pub const PTRACE_DETACH: ::c_uint = 17;
-pub const PTRACE_SYSCALL: ::c_uint = 24;
-pub const PTRACE_SETOPTIONS: ::c_uint = 0x4200;
-pub const PTRACE_GETEVENTMSG: ::c_uint = 0x4201;
-pub const PTRACE_GETSIGINFO: ::c_uint = 0x4202;
-pub const PTRACE_SETSIGINFO: ::c_uint = 0x4203;
-pub const PTRACE_GETFPREGS: ::c_uint = 14;
-pub const PTRACE_SETFPREGS: ::c_uint = 15;
-pub const PTRACE_GETFPXREGS: ::c_uint = 18;
-pub const PTRACE_SETFPXREGS: ::c_uint = 19;
-pub const PTRACE_GETREGS: ::c_uint = 12;
-pub const PTRACE_SETREGS: ::c_uint = 13;
-
-pub const MAP_HUGETLB: ::c_int = 0x080000;
-
-pub const EFD_NONBLOCK: ::c_int = 0x80;
-
-pub const F_RDLCK: ::c_int = 0;
-pub const F_WRLCK: ::c_int = 1;
-pub const F_UNLCK: ::c_int = 2;
-pub const F_GETLK: ::c_int = 14;
-pub const F_GETOWN: ::c_int = 23;
-pub const F_SETOWN: ::c_int = 24;
-pub const F_SETLK: ::c_int = 6;
-pub const F_SETLKW: ::c_int = 7;
-
-pub const SFD_NONBLOCK: ::c_int = 0x80;
-
-pub const TCGETS: ::c_ulong = 0x540d;
-pub const TCSETS: ::c_ulong = 0x540e;
-pub const TCSETSW: ::c_ulong = 0x540f;
-pub const TCSETSF: ::c_ulong = 0x5410;
-pub const TCGETA: ::c_ulong = 0x5401;
-pub const TCSETA: ::c_ulong = 0x5402;
-pub const TCSETAW: ::c_ulong = 0x5403;
-pub const TCSETAF: ::c_ulong = 0x5404;
-pub const TCSBRK: ::c_ulong = 0x5405;
-pub const TCXONC: ::c_ulong = 0x5406;
-pub const TCFLSH: ::c_ulong = 0x5407;
-pub const TIOCGSOFTCAR: ::c_ulong = 0x5481;
-pub const TIOCSSOFTCAR: ::c_ulong = 0x5482;
-pub const TIOCINQ: ::c_ulong = 0x467f;
-pub const TIOCLINUX: ::c_ulong = 0x5483;
-pub const TIOCGSERIAL: ::c_ulong = 0x5484;
-pub const TIOCEXCL: ::c_ulong = 0x740d;
-pub const TIOCNXCL: ::c_ulong = 0x740e;
-pub const TIOCSCTTY: ::c_ulong = 0x5480;
-pub const TIOCGPGRP: ::c_ulong = 0x40047477;
-pub const TIOCSPGRP: ::c_ulong = 0x80047476;
-pub const TIOCOUTQ: ::c_ulong = 0x7472;
-pub const TIOCSTI: ::c_ulong = 0x5472;
-pub const TIOCGWINSZ: ::c_ulong = 0x40087468;
-pub const TIOCSWINSZ: ::c_ulong = 0x80087467;
-pub const TIOCMGET: ::c_ulong = 0x741d;
-pub const TIOCMBIS: ::c_ulong = 0x741b;
-pub const TIOCMBIC: ::c_ulong = 0x741c;
-pub const TIOCMSET: ::c_ulong = 0x741a;
-pub const FIONREAD: ::c_ulong = 0x467f;
-pub const TIOCCONS: ::c_ulong = 0x80047478;
-
-pub const RTLD_DEEPBIND: ::c_int = 0x10;
-pub const RTLD_GLOBAL: ::c_int = 0x4;
-pub const RTLD_NOLOAD: ::c_int = 0x8;
-
-pub const LINUX_REBOOT_MAGIC1: ::c_int = 0xfee1dead;
-pub const LINUX_REBOOT_MAGIC2: ::c_int = 672274793;
-pub const LINUX_REBOOT_MAGIC2A: ::c_int = 85072278;
-pub const LINUX_REBOOT_MAGIC2B: ::c_int = 369367448;
-pub const LINUX_REBOOT_MAGIC2C: ::c_int = 537993216;
-
-pub const LINUX_REBOOT_CMD_RESTART: ::c_int = 0x01234567;
-pub const LINUX_REBOOT_CMD_HALT: ::c_int = 0xCDEF0123;
-pub const LINUX_REBOOT_CMD_CAD_ON: ::c_int = 0x89ABCDEF;
-pub const LINUX_REBOOT_CMD_CAD_OFF: ::c_int = 0x00000000;
-pub const LINUX_REBOOT_CMD_POWER_OFF: ::c_int = 0x4321FEDC;
-pub const LINUX_REBOOT_CMD_RESTART2: ::c_int = 0xA1B2C3D4;
-pub const LINUX_REBOOT_CMD_SW_SUSPEND: ::c_int = 0xD000FCE2;
-pub const LINUX_REBOOT_CMD_KEXEC: ::c_int = 0x45584543;
-
-pub const MCL_CURRENT: ::c_int = 0x0001;
-pub const MCL_FUTURE: ::c_int = 0x0002;
-
-pub const SIGSTKSZ: ::size_t = 8192;
-pub const MINSIGSTKSZ: ::size_t = 2048;
-pub const CBAUD: ::tcflag_t = 0o0010017;
-pub const TAB1: ::tcflag_t = 0x00000800;
-pub const TAB2: ::tcflag_t = 0x00001000;
-pub const TAB3: ::tcflag_t = 0x00001800;
-pub const CR1: ::tcflag_t = 0x00000200;
-pub const CR2: ::tcflag_t = 0x00000400;
-pub const CR3: ::tcflag_t = 0x00000600;
-pub const FF1: ::tcflag_t = 0x00008000;
-pub const BS1: ::tcflag_t = 0x00002000;
-pub const VT1: ::tcflag_t = 0x00004000;
-pub const VWERASE: usize = 14;
-pub const VREPRINT: usize = 12;
-pub const VSUSP: usize = 10;
-pub const VSTART: usize = 8;
-pub const VSTOP: usize = 9;
-pub const VDISCARD: usize = 13;
-pub const VTIME: usize = 5;
-pub const IXON: ::tcflag_t = 0x00000400;
-pub const IXOFF: ::tcflag_t = 0x00001000;
-pub const ONLCR: ::tcflag_t = 0x4;
-pub const CSIZE: ::tcflag_t = 0x00000030;
-pub const CS6: ::tcflag_t = 0x00000010;
-pub const CS7: ::tcflag_t = 0x00000020;
-pub const CS8: ::tcflag_t = 0x00000030;
-pub const CSTOPB: ::tcflag_t = 0x00000040;
-pub const CREAD: ::tcflag_t = 0x00000080;
-pub const PARENB: ::tcflag_t = 0x00000100;
-pub const PARODD: ::tcflag_t = 0x00000200;
-pub const HUPCL: ::tcflag_t = 0x00000400;
-pub const CLOCAL: ::tcflag_t = 0x00000800;
-pub const ECHOKE: ::tcflag_t = 0x00000800;
-pub const ECHOE: ::tcflag_t = 0x00000010;
-pub const ECHOK: ::tcflag_t = 0x00000020;
-pub const ECHONL: ::tcflag_t = 0x00000040;
-pub const ECHOPRT: ::tcflag_t = 0x00000400;
-pub const ECHOCTL: ::tcflag_t = 0x00000200;
-pub const ISIG: ::tcflag_t = 0x00000001;
-pub const ICANON: ::tcflag_t = 0x00000002;
-pub const PENDIN: ::tcflag_t = 0x00004000;
-pub const NOFLSH: ::tcflag_t = 0x00000080;
-pub const CIBAUD: ::tcflag_t = 0o02003600000;
-pub const CBAUDEX: ::tcflag_t = 0o010000;
-pub const VSWTC: usize = 7;
-pub const OLCUC: ::tcflag_t = 0o000002;
-pub const NLDLY: ::tcflag_t = 0o000400;
-pub const CRDLY: ::tcflag_t = 0o003000;
-pub const TABDLY: ::tcflag_t = 0o014000;
-pub const BSDLY: ::tcflag_t = 0o020000;
-pub const FFDLY: ::tcflag_t = 0o100000;
-pub const VTDLY: ::tcflag_t = 0o040000;
-pub const XTABS: ::tcflag_t = 0o014000;
-
-pub const B0: ::speed_t = 0o000000;
-pub const B50: ::speed_t = 0o000001;
-pub const B75: ::speed_t = 0o000002;
-pub const B110: ::speed_t = 0o000003;
-pub const B134: ::speed_t = 0o000004;
-pub const B150: ::speed_t = 0o000005;
-pub const B200: ::speed_t = 0o000006;
-pub const B300: ::speed_t = 0o000007;
-pub const B600: ::speed_t = 0o000010;
-pub const B1200: ::speed_t = 0o000011;
-pub const B1800: ::speed_t = 0o000012;
-pub const B2400: ::speed_t = 0o000013;
-pub const B4800: ::speed_t = 0o000014;
-pub const B9600: ::speed_t = 0o000015;
-pub const B19200: ::speed_t = 0o000016;
-pub const B38400: ::speed_t = 0o000017;
-pub const EXTA: ::speed_t = B19200;
-pub const EXTB: ::speed_t = B38400;
-pub const BOTHER: ::speed_t = 0o010000;
-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 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 = 0x010;
-pub const TIOCM_SR: ::c_int = 0x020;
-pub const TIOCM_CTS: ::c_int = 0x040;
-pub const TIOCM_CAR: ::c_int = 0x100;
-pub const TIOCM_CD: ::c_int = TIOCM_CAR;
-pub const TIOCM_RNG: ::c_int = 0x200;
-pub const TIOCM_RI: ::c_int = TIOCM_RNG;
-pub const TIOCM_DSR: ::c_int = 0x400;
-
-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 = 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;
-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 = 25;
-
-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 RLIMIT_CPU: ::__rlimit_resource_t = 0;
-pub const RLIMIT_FSIZE: ::__rlimit_resource_t = 1;
-pub const RLIMIT_DATA: ::__rlimit_resource_t = 2;
-pub const RLIMIT_STACK: ::__rlimit_resource_t = 3;
-pub const RLIMIT_CORE: ::__rlimit_resource_t = 4;
-pub const RLIMIT_LOCKS: ::__rlimit_resource_t = 10;
-pub const RLIMIT_SIGPENDING: ::__rlimit_resource_t = 11;
-pub const RLIMIT_MSGQUEUE: ::__rlimit_resource_t = 12;
-pub const RLIMIT_NICE: ::__rlimit_resource_t = 13;
-pub const RLIMIT_RTPRIO: ::__rlimit_resource_t = 14;
-
-#[doc(hidden)]
-#[deprecated(
- since = "0.2.55",
- note = "If you are using this report to: \
- https://github.com/rust-lang/libc/issues/665"
-)]
-pub const AF_MAX: ::c_int = 45;
-#[doc(hidden)]
-#[deprecated(
- since = "0.2.55",
- note = "If you are using this report to: \
- https://github.com/rust-lang/libc/issues/665"
-)]
-#[allow(deprecated)]
-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 sendmmsg(sockfd: ::c_int, msgvec: *mut ::mmsghdr, vlen: ::c_uint,
- flags: ::c_int) -> ::c_int;
- pub fn recvmmsg(sockfd: ::c_int, msgvec: *mut ::mmsghdr, vlen: ::c_uint,
- flags: ::c_int, timeout: *mut ::timespec) -> ::c_int;
-
- pub fn getrlimit64(resource: ::__rlimit_resource_t,
- rlim: *mut ::rlimit64) -> ::c_int;
- pub fn setrlimit64(resource: ::__rlimit_resource_t,
- rlim: *const ::rlimit64) -> ::c_int;
- pub fn getrlimit(resource: ::__rlimit_resource_t,
- rlim: *mut ::rlimit) -> ::c_int;
- pub fn setrlimit(resource: ::__rlimit_resource_t,
- rlim: *const ::rlimit) -> ::c_int;
- pub fn prlimit(pid: ::pid_t,
- resource: ::__rlimit_resource_t, new_limit: *const ::rlimit,
- old_limit: *mut ::rlimit) -> ::c_int;
- pub fn prlimit64(pid: ::pid_t,
- resource: ::__rlimit_resource_t,
- new_limit: *const ::rlimit64,
- old_limit: *mut ::rlimit64) -> ::c_int;
- pub fn sysctl(name: *mut ::c_int,
- namelen: ::c_int,
- oldp: *mut ::c_void,
- oldlenp: *mut ::size_t,
- newp: *mut ::c_void,
- newlen: ::size_t)
- -> ::c_int;
- pub fn ioctl(fd: ::c_int, request: ::c_ulong, ...) -> ::c_int;
- pub fn backtrace(buf: *mut *mut ::c_void,
- sz: ::c_int) -> ::c_int;
- pub fn glob64(pattern: *const ::c_char,
- flags: ::c_int,
- errfunc: ::Option<extern fn(epath: *const ::c_char,
- errno: ::c_int)
- -> ::c_int>,
- pglob: *mut glob64_t) -> ::c_int;
- pub fn globfree64(pglob: *mut glob64_t);
- pub fn ptrace(request: ::c_uint, ...) -> ::c_long;
- pub fn pthread_attr_getaffinity_np(attr: *const ::pthread_attr_t,
- cpusetsize: ::size_t,
- cpuset: *mut ::cpu_set_t) -> ::c_int;
- pub fn pthread_attr_setaffinity_np(attr: *mut ::pthread_attr_t,
- cpusetsize: ::size_t,
- cpuset: *const ::cpu_set_t) -> ::c_int;
- pub fn getpriority(which: ::__priority_which_t, who: ::id_t) -> ::c_int;
- pub fn setpriority(which: ::__priority_which_t, 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! {
- if #[cfg(target_arch = "mips")] {
- mod mips32;
- pub use self::mips32::*;
- } else if #[cfg(target_arch = "mips64")] {
- mod mips64;
- pub use self::mips64::*;
- } else {
- // Unknown target_arch
- }
-}
-
-cfg_if! {
- if #[cfg(libc_align)] {
- mod align;
- pub use self::align::*;
- } else {
- mod no_align;
- pub use self::no_align::*;
- }
-}
diff --git a/libc/src/unix/notbsd/linux/mips/no_align.rs b/libc/src/unix/notbsd/linux/mips/no_align.rs
deleted file mode 100644
index e32bf67..0000000
--- a/libc/src/unix/notbsd/linux/mips/no_align.rs
+++ /dev/null
@@ -1,10 +0,0 @@
-s! {
- // FIXME this is actually a union
- pub struct sem_t {
- #[cfg(target_pointer_width = "32")]
- __size: [::c_char; 16],
- #[cfg(target_pointer_width = "64")]
- __size: [::c_char; 32],
- __align: [::c_long; 0],
- }
-}
diff --git a/libc/src/unix/notbsd/linux/mod.rs b/libc/src/unix/notbsd/linux/mod.rs
deleted file mode 100644
index 3b7bc29..0000000
--- a/libc/src/unix/notbsd/linux/mod.rs
+++ /dev/null
@@ -1,2672 +0,0 @@
-//! Linux-specific definitions for linux-like values
-
-pub type useconds_t = u32;
-pub type dev_t = u64;
-pub type socklen_t = u32;
-pub type mode_t = u32;
-pub type ino64_t = u64;
-pub type off64_t = i64;
-pub type blkcnt64_t = i64;
-pub type rlim64_t = u64;
-pub type mqd_t = ::c_int;
-pub type nfds_t = ::c_ulong;
-pub type nl_item = ::c_int;
-pub type idtype_t = ::c_uint;
-pub type loff_t = ::c_longlong;
-pub type pthread_key_t = ::c_uint;
-
-pub type __u8 = ::c_uchar;
-pub type __u16 = ::c_ushort;
-pub type __s16 = ::c_short;
-pub type __u32 = ::c_uint;
-pub type __s32 = ::c_int;
-
-pub type Elf32_Half = u16;
-pub type Elf32_Word = u32;
-pub type Elf32_Off = u32;
-pub type Elf32_Addr = u32;
-
-pub type Elf64_Half = u16;
-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;
-
-#[cfg_attr(feature = "extra_traits", derive(Debug))]
-pub enum fpos64_t {} // TODO: fill this out with a struct
-impl ::Copy for fpos64_t {}
-impl ::Clone for fpos64_t {
- fn clone(&self) -> fpos64_t { *self }
-}
-
-s! {
- pub struct rlimit64 {
- pub rlim_cur: rlim64_t,
- pub rlim_max: rlim64_t,
- }
-
- pub struct glob_t {
- pub gl_pathc: ::size_t,
- pub gl_pathv: *mut *mut c_char,
- pub gl_offs: ::size_t,
- pub gl_flags: ::c_int,
-
- __unused1: *mut ::c_void,
- __unused2: *mut ::c_void,
- __unused3: *mut ::c_void,
- __unused4: *mut ::c_void,
- __unused5: *mut ::c_void,
- }
-
- pub struct passwd {
- 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 spwd {
- pub sp_namp: *mut ::c_char,
- pub sp_pwdp: *mut ::c_char,
- pub sp_lstchg: ::c_long,
- pub sp_min: ::c_long,
- pub sp_max: ::c_long,
- pub sp_warn: ::c_long,
- pub sp_inact: ::c_long,
- pub sp_expire: ::c_long,
- pub sp_flag: ::c_ulong,
- }
-
- pub struct dqblk {
- pub dqb_bhardlimit: u64,
- pub dqb_bsoftlimit: u64,
- pub dqb_curspace: u64,
- pub dqb_ihardlimit: u64,
- pub dqb_isoftlimit: u64,
- pub dqb_curinodes: u64,
- pub dqb_btime: u64,
- pub dqb_itime: u64,
- pub dqb_valid: u32,
- }
-
- pub struct signalfd_siginfo {
- pub ssi_signo: u32,
- pub ssi_errno: i32,
- pub ssi_code: i32,
- pub ssi_pid: u32,
- pub ssi_uid: u32,
- pub ssi_fd: i32,
- pub ssi_tid: u32,
- pub ssi_band: u32,
- pub ssi_overrun: u32,
- pub ssi_trapno: u32,
- pub ssi_status: i32,
- pub ssi_int: i32,
- pub ssi_ptr: u64,
- pub ssi_utime: u64,
- pub ssi_stime: u64,
- pub ssi_addr: u64,
- pub ssi_addr_lsb: u16,
- _pad2: u16,
- pub ssi_syscall: i32,
- pub ssi_call_addr: u64,
- pub ssi_arch: u32,
- _pad: [u8; 28],
- }
-
- pub struct itimerspec {
- pub it_interval: ::timespec,
- pub it_value: ::timespec,
- }
-
- pub struct fsid_t {
- __val: [::c_int; 2],
- }
-
- 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")))]
- bits: [u32; 32],
- #[cfg(not(all(target_pointer_width = "32",
- not(target_arch = "x86_64"))))]
- bits: [u64; 16],
- }
-
- pub struct if_nameindex {
- pub if_index: ::c_uint,
- pub if_name: *mut ::c_char,
- }
-
- // System V IPC
- pub struct msginfo {
- pub msgpool: ::c_int,
- pub msgmap: ::c_int,
- pub msgmax: ::c_int,
- pub msgmnb: ::c_int,
- pub msgmni: ::c_int,
- pub msgssz: ::c_int,
- pub msgtql: ::c_int,
- pub msgseg: ::c_ushort,
- }
-
- pub struct sembuf {
- pub sem_num: ::c_ushort,
- pub sem_op: ::c_short,
- pub sem_flg: ::c_short,
- }
-
- pub struct input_event {
- pub time: ::timeval,
- pub type_: ::__u16,
- pub code: ::__u16,
- pub value: ::__s32,
- }
-
- pub struct input_id {
- pub bustype: ::__u16,
- pub vendor: ::__u16,
- pub product: ::__u16,
- pub version: ::__u16,
- }
-
- pub struct input_absinfo {
- pub value: ::__s32,
- pub minimum: ::__s32,
- pub maximum: ::__s32,
- pub fuzz: ::__s32,
- pub flat: ::__s32,
- pub resolution: ::__s32,
- }
-
- pub struct input_keymap_entry {
- pub flags: ::__u8,
- pub len: ::__u8,
- pub index: ::__u16,
- pub keycode: ::__u32,
- pub scancode: [::__u8; 32],
- }
-
- pub struct input_mask {
- pub type_: ::__u32,
- pub codes_size: ::__u32,
- pub codes_ptr: ::__u64,
- }
-
- pub struct ff_replay {
- pub length: ::__u16,
- pub delay: ::__u16,
- }
-
- pub struct ff_trigger {
- pub button: ::__u16,
- pub interval: ::__u16,
- }
-
- pub struct ff_envelope {
- pub attack_length: ::__u16,
- pub attack_level: ::__u16,
- pub fade_length: ::__u16,
- pub fade_level: ::__u16,
- }
-
- pub struct ff_constant_effect {
- pub level: ::__s16,
- pub envelope: ff_envelope,
- }
-
- pub struct ff_ramp_effect {
- pub start_level: ::__s16,
- pub end_level: ::__s16,
- pub envelope: ff_envelope,
- }
-
- pub struct ff_condition_effect {
- pub right_saturation: ::__u16,
- pub left_saturation: ::__u16,
-
- pub right_coeff: ::__s16,
- pub left_coeff: ::__s16,
-
- pub deadband: ::__u16,
- pub center: ::__s16,
- }
-
- pub struct ff_periodic_effect {
- pub waveform: ::__u16,
- pub period: ::__u16,
- pub magnitude: ::__s16,
- pub offset: ::__s16,
- pub phase: ::__u16,
-
- pub envelope: ff_envelope,
-
- pub custom_len: ::__u32,
- pub custom_data: *mut ::__s16,
- }
-
- pub struct ff_rumble_effect {
- pub strong_magnitude: ::__u16,
- pub weak_magnitude: ::__u16,
- }
-
- pub struct ff_effect {
- pub type_: ::__u16,
- pub id: ::__s16,
- pub direction: ::__u16,
- pub trigger: ff_trigger,
- pub replay: ff_replay,
- // FIXME this is actually a union
- #[cfg(target_pointer_width = "64")]
- pub u: [u64; 4],
- #[cfg(target_pointer_width = "32")]
- pub u: [u32; 7],
- }
-
- pub struct dl_phdr_info {
- #[cfg(target_pointer_width = "64")]
- pub dlpi_addr: Elf64_Addr,
- #[cfg(target_pointer_width = "32")]
- pub dlpi_addr: Elf32_Addr,
-
- pub dlpi_name: *const ::c_char,
-
- #[cfg(target_pointer_width = "64")]
- pub dlpi_phdr: *const Elf64_Phdr,
- #[cfg(target_pointer_width = "32")]
- pub dlpi_phdr: *const Elf32_Phdr,
-
- #[cfg(target_pointer_width = "64")]
- pub dlpi_phnum: Elf64_Half,
- #[cfg(target_pointer_width = "32")]
- pub dlpi_phnum: Elf32_Half,
-
- pub dlpi_adds: ::c_ulonglong,
- pub dlpi_subs: ::c_ulonglong,
- pub dlpi_tls_modid: ::size_t,
- 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,
- pub p_vaddr: Elf32_Addr,
- pub p_paddr: Elf32_Addr,
- pub p_filesz: Elf32_Word,
- pub p_memsz: Elf32_Word,
- pub p_flags: Elf32_Word,
- pub p_align: Elf32_Word,
- }
-
- pub struct Elf64_Phdr {
- pub p_type: Elf64_Word,
- pub p_flags: Elf64_Word,
- pub p_offset: Elf64_Off,
- pub p_vaddr: Elf64_Addr,
- pub p_paddr: Elf64_Addr,
- pub p_filesz: Elf64_Xword,
- pub p_memsz: Elf64_Xword,
- 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,
- pub gid: ::gid_t,
- }
-
- pub struct mntent {
- pub mnt_fsname: *mut ::c_char,
- pub mnt_dir: *mut ::c_char,
- pub mnt_type: *mut ::c_char,
- pub mnt_opts: *mut ::c_char,
- 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 struct inotify_event {
- pub wd: ::c_int,
- pub mask: u32,
- pub cookie: u32,
- pub len: u32
- }
-}
-
-s_no_extra_traits!{
- pub struct sockaddr_nl {
- pub nl_family: ::sa_family_t,
- nl_pad: ::c_ushort,
- pub nl_pid: u32,
- pub nl_groups: u32
- }
-
- pub struct dirent {
- pub d_ino: ::ino_t,
- pub d_off: ::off_t,
- pub d_reclen: ::c_ushort,
- pub d_type: ::c_uchar,
- pub d_name: [::c_char; 256],
- }
-
- pub struct dirent64 {
- pub d_ino: ::ino64_t,
- pub d_off: ::off64_t,
- pub d_reclen: ::c_ushort,
- pub d_type: ::c_uchar,
- pub d_name: [::c_char; 256],
- }
-
- pub struct sockaddr_alg {
- pub salg_family: ::sa_family_t,
- pub salg_type: [::c_uchar; 14],
- pub salg_feat: u32,
- pub salg_mask: u32,
- pub salg_name: [::c_uchar; 64],
- }
-
- pub struct af_alg_iv {
- pub ivlen: u32,
- pub iv: [::c_uchar; 0],
- }
-
- // x32 compatibility
- // See https://sourceware.org/bugzilla/show_bug.cgi?id=21279
- pub struct mq_attr {
- #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
- pub mq_flags: i64,
- #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
- pub mq_maxmsg: i64,
- #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
- pub mq_msgsize: i64,
- #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
- pub mq_curmsgs: i64,
- #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
- pad: [i64; 4],
-
- #[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))]
- pub mq_flags: ::c_long,
- #[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))]
- pub mq_maxmsg: ::c_long,
- #[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))]
- pub mq_msgsize: ::c_long,
- #[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))]
- pub mq_curmsgs: ::c_long,
- #[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))]
- pad: [::c_long; 4],
- }
-}
-
-cfg_if! {
- if #[cfg(feature = "extra_traits")] {
- impl PartialEq for sockaddr_nl {
- fn eq(&self, other: &sockaddr_nl) -> bool {
- self.nl_family == other.nl_family &&
- self.nl_pid == other.nl_pid &&
- self.nl_groups == other.nl_groups
- }
- }
- impl Eq for sockaddr_nl {}
- impl ::fmt::Debug for sockaddr_nl {
- fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
- f.debug_struct("sockaddr_nl")
- .field("nl_family", &self.nl_family)
- .field("nl_pid", &self.nl_pid)
- .field("nl_groups", &self.nl_groups)
- .finish()
- }
- }
- impl ::hash::Hash for sockaddr_nl {
- fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
- self.nl_family.hash(state);
- self.nl_pid.hash(state);
- self.nl_groups.hash(state);
- }
- }
-
- impl PartialEq for dirent {
- fn eq(&self, other: &dirent) -> bool {
- self.d_ino == other.d_ino
- && self.d_off == other.d_off
- && self.d_reclen == other.d_reclen
- && self.d_type == other.d_type
- && self
- .d_name
- .iter()
- .zip(other.d_name.iter())
- .all(|(a,b)| a == b)
- }
- }
-
- impl Eq for dirent {}
-
- impl ::fmt::Debug for dirent {
- fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
- f.debug_struct("dirent")
- .field("d_ino", &self.d_ino)
- .field("d_off", &self.d_off)
- .field("d_reclen", &self.d_reclen)
- .field("d_type", &self.d_type)
- // FIXME: .field("d_name", &self.d_name)
- .finish()
- }
- }
-
- impl ::hash::Hash for dirent {
- fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
- self.d_ino.hash(state);
- self.d_off.hash(state);
- self.d_reclen.hash(state);
- self.d_type.hash(state);
- self.d_name.hash(state);
- }
- }
-
- impl PartialEq for dirent64 {
- fn eq(&self, other: &dirent64) -> bool {
- self.d_ino == other.d_ino
- && self.d_off == other.d_off
- && self.d_reclen == other.d_reclen
- && self.d_type == other.d_type
- && self
- .d_name
- .iter()
- .zip(other.d_name.iter())
- .all(|(a,b)| a == b)
- }
- }
-
- impl Eq for dirent64 {}
-
- impl ::fmt::Debug for dirent64 {
- fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
- f.debug_struct("dirent64")
- .field("d_ino", &self.d_ino)
- .field("d_off", &self.d_off)
- .field("d_reclen", &self.d_reclen)
- .field("d_type", &self.d_type)
- // FIXME: .field("d_name", &self.d_name)
- .finish()
- }
- }
-
- impl ::hash::Hash for dirent64 {
- fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
- self.d_ino.hash(state);
- self.d_off.hash(state);
- self.d_reclen.hash(state);
- self.d_type.hash(state);
- self.d_name.hash(state);
- }
- }
-
- impl PartialEq for pthread_cond_t {
- fn eq(&self, other: &pthread_cond_t) -> bool {
- self.size.iter().zip(other.size.iter()).all(|(a,b)| a == b)
- }
- }
-
- impl Eq for pthread_cond_t {}
-
- impl ::fmt::Debug for pthread_cond_t {
- fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
- f.debug_struct("pthread_cond_t")
- // FIXME: .field("size", &self.size)
- .finish()
- }
- }
-
- impl ::hash::Hash for pthread_cond_t {
- fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
- self.size.hash(state);
- }
- }
-
- impl PartialEq for pthread_mutex_t {
- fn eq(&self, other: &pthread_mutex_t) -> bool {
- self.size.iter().zip(other.size.iter()).all(|(a,b)| a == b)
- }
- }
-
- impl Eq for pthread_mutex_t {}
-
- impl ::fmt::Debug for pthread_mutex_t {
- fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
- f.debug_struct("pthread_mutex_t")
- // FIXME: .field("size", &self.size)
- .finish()
- }
- }
-
- impl ::hash::Hash for pthread_mutex_t {
- fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
- self.size.hash(state);
- }
- }
-
- impl PartialEq for pthread_rwlock_t {
- fn eq(&self, other: &pthread_rwlock_t) -> bool {
- self.size.iter().zip(other.size.iter()).all(|(a,b)| a == b)
- }
- }
-
- impl Eq for pthread_rwlock_t {}
-
- impl ::fmt::Debug for pthread_rwlock_t {
- fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
- f.debug_struct("pthread_rwlock_t")
- // FIXME: .field("size", &self.size)
- .finish()
- }
- }
-
- impl ::hash::Hash for pthread_rwlock_t {
- fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
- self.size.hash(state);
- }
- }
-
- impl PartialEq for sockaddr_alg {
- fn eq(&self, other: &sockaddr_alg) -> bool {
- self.salg_family == other.salg_family
- && self
- .salg_type
- .iter()
- .zip(other.salg_type.iter())
- .all(|(a, b)| a == b)
- && self.salg_feat == other.salg_feat
- && self.salg_mask == other.salg_mask
- && self
- .salg_name
- .iter()
- .zip(other.salg_name.iter())
- .all(|(a, b)| a == b)
- }
- }
-
- impl Eq for sockaddr_alg {}
-
- impl ::fmt::Debug for sockaddr_alg {
- fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
- f.debug_struct("sockaddr_alg")
- .field("salg_family", &self.salg_family)
- .field("salg_type", &self.salg_type)
- .field("salg_feat", &self.salg_feat)
- .field("salg_mask", &self.salg_mask)
- .field("salg_name", &&self.salg_name[..])
- .finish()
- }
- }
-
- impl ::hash::Hash for sockaddr_alg {
- fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
- self.salg_family.hash(state);
- self.salg_type.hash(state);
- self.salg_feat.hash(state);
- self.salg_mask.hash(state);
- self.salg_name.hash(state);
- }
- }
-
- impl af_alg_iv {
- fn as_slice(&self) -> &[u8] {
- unsafe {
- ::core::slice::from_raw_parts(
- self.iv.as_ptr(),
- self.ivlen as usize
- )
- }
- }
- }
-
- impl PartialEq for af_alg_iv {
- fn eq(&self, other: &af_alg_iv) -> bool {
- *self.as_slice() == *other.as_slice()
- }
- }
-
- impl Eq for af_alg_iv {}
-
- impl ::fmt::Debug for af_alg_iv {
- fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
- f.debug_struct("af_alg_iv")
- .field("iv", &self.as_slice())
- .finish()
- }
- }
-
- impl ::hash::Hash for af_alg_iv {
- fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
- self.as_slice().hash(state);
- }
- }
-
- impl PartialEq for mq_attr {
- fn eq(&self, other: &mq_attr) -> bool {
- self.mq_flags == other.mq_flags &&
- self.mq_maxmsg == other.mq_maxmsg &&
- self.mq_msgsize == other.mq_msgsize &&
- self.mq_curmsgs == other.mq_curmsgs
- }
- }
- impl Eq for mq_attr {}
- impl ::fmt::Debug for mq_attr {
- fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
- f.debug_struct("mq_attr")
- .field("mq_flags", &self.mq_flags)
- .field("mq_maxmsg", &self.mq_maxmsg)
- .field("mq_msgsize", &self.mq_msgsize)
- .field("mq_curmsgs", &self.mq_curmsgs)
- .finish()
- }
- }
- impl ::hash::Hash for mq_attr {
- fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
- self.mq_flags.hash(state);
- self.mq_maxmsg.hash(state);
- self.mq_msgsize.hash(state);
- self.mq_curmsgs.hash(state);
- }
- }
- }
-}
-
-pub const ABDAY_1: ::nl_item = 0x20000;
-pub const ABDAY_2: ::nl_item = 0x20001;
-pub const ABDAY_3: ::nl_item = 0x20002;
-pub const ABDAY_4: ::nl_item = 0x20003;
-pub const ABDAY_5: ::nl_item = 0x20004;
-pub const ABDAY_6: ::nl_item = 0x20005;
-pub const ABDAY_7: ::nl_item = 0x20006;
-
-pub const DAY_1: ::nl_item = 0x20007;
-pub const DAY_2: ::nl_item = 0x20008;
-pub const DAY_3: ::nl_item = 0x20009;
-pub const DAY_4: ::nl_item = 0x2000A;
-pub const DAY_5: ::nl_item = 0x2000B;
-pub const DAY_6: ::nl_item = 0x2000C;
-pub const DAY_7: ::nl_item = 0x2000D;
-
-pub const ABMON_1: ::nl_item = 0x2000E;
-pub const ABMON_2: ::nl_item = 0x2000F;
-pub const ABMON_3: ::nl_item = 0x20010;
-pub const ABMON_4: ::nl_item = 0x20011;
-pub const ABMON_5: ::nl_item = 0x20012;
-pub const ABMON_6: ::nl_item = 0x20013;
-pub const ABMON_7: ::nl_item = 0x20014;
-pub const ABMON_8: ::nl_item = 0x20015;
-pub const ABMON_9: ::nl_item = 0x20016;
-pub const ABMON_10: ::nl_item = 0x20017;
-pub const ABMON_11: ::nl_item = 0x20018;
-pub const ABMON_12: ::nl_item = 0x20019;
-
-pub const MON_1: ::nl_item = 0x2001A;
-pub const MON_2: ::nl_item = 0x2001B;
-pub const MON_3: ::nl_item = 0x2001C;
-pub const MON_4: ::nl_item = 0x2001D;
-pub const MON_5: ::nl_item = 0x2001E;
-pub const MON_6: ::nl_item = 0x2001F;
-pub const MON_7: ::nl_item = 0x20020;
-pub const MON_8: ::nl_item = 0x20021;
-pub const MON_9: ::nl_item = 0x20022;
-pub const MON_10: ::nl_item = 0x20023;
-pub const MON_11: ::nl_item = 0x20024;
-pub const MON_12: ::nl_item = 0x20025;
-
-pub const AM_STR: ::nl_item = 0x20026;
-pub const PM_STR: ::nl_item = 0x20027;
-
-pub const D_T_FMT: ::nl_item = 0x20028;
-pub const D_FMT: ::nl_item = 0x20029;
-pub const T_FMT: ::nl_item = 0x2002A;
-pub const T_FMT_AMPM: ::nl_item = 0x2002B;
-
-pub const ERA: ::nl_item = 0x2002C;
-pub const ERA_D_FMT: ::nl_item = 0x2002E;
-pub const ALT_DIGITS: ::nl_item = 0x2002F;
-pub const ERA_D_T_FMT: ::nl_item = 0x20030;
-pub const ERA_T_FMT: ::nl_item = 0x20031;
-
-pub const CODESET: ::nl_item = 14;
-
-pub const CRNCYSTR: ::nl_item = 0x4000F;
-
-pub const RUSAGE_THREAD: ::c_int = 1;
-pub const RUSAGE_CHILDREN: ::c_int = -1;
-
-pub const RADIXCHAR: ::nl_item = 0x10000;
-pub const THOUSEP: ::nl_item = 0x10001;
-
-pub const YESEXPR: ::nl_item = 0x50000;
-pub const NOEXPR: ::nl_item = 0x50001;
-pub const YESSTR: ::nl_item = 0x50002;
-pub const NOSTR: ::nl_item = 0x50003;
-
-pub const FILENAME_MAX: ::c_uint = 4096;
-pub const L_tmpnam: ::c_uint = 20;
-pub const _PC_LINK_MAX: ::c_int = 0;
-pub const _PC_MAX_CANON: ::c_int = 1;
-pub const _PC_MAX_INPUT: ::c_int = 2;
-pub const _PC_NAME_MAX: ::c_int = 3;
-pub const _PC_PATH_MAX: ::c_int = 4;
-pub const _PC_PIPE_BUF: ::c_int = 5;
-pub const _PC_CHOWN_RESTRICTED: ::c_int = 6;
-pub const _PC_NO_TRUNC: ::c_int = 7;
-pub const _PC_VDISABLE: ::c_int = 8;
-pub const _PC_SYNC_IO: ::c_int = 9;
-pub const _PC_ASYNC_IO: ::c_int = 10;
-pub const _PC_PRIO_IO: ::c_int = 11;
-pub const _PC_SOCK_MAXBUF: ::c_int = 12;
-pub const _PC_FILESIZEBITS: ::c_int = 13;
-pub const _PC_REC_INCR_XFER_SIZE: ::c_int = 14;
-pub const _PC_REC_MAX_XFER_SIZE: ::c_int = 15;
-pub const _PC_REC_MIN_XFER_SIZE: ::c_int = 16;
-pub const _PC_REC_XFER_ALIGN: ::c_int = 17;
-pub const _PC_ALLOC_SIZE_MIN: ::c_int = 18;
-pub const _PC_SYMLINK_MAX: ::c_int = 19;
-pub const _PC_2_SYMLINKS: ::c_int = 20;
-
-pub const MS_NOUSER: ::c_ulong = 0xffffffff80000000;
-
-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_STREAM_MAX: ::c_int = 5;
-pub const _SC_TZNAME_MAX: ::c_int = 6;
-pub const _SC_JOB_CONTROL: ::c_int = 7;
-pub const _SC_SAVED_IDS: ::c_int = 8;
-pub const _SC_REALTIME_SIGNALS: ::c_int = 9;
-pub const _SC_PRIORITY_SCHEDULING: ::c_int = 10;
-pub const _SC_TIMERS: ::c_int = 11;
-pub const _SC_ASYNCHRONOUS_IO: ::c_int = 12;
-pub const _SC_PRIORITIZED_IO: ::c_int = 13;
-pub const _SC_SYNCHRONIZED_IO: ::c_int = 14;
-pub const _SC_FSYNC: ::c_int = 15;
-pub const _SC_MAPPED_FILES: ::c_int = 16;
-pub const _SC_MEMLOCK: ::c_int = 17;
-pub const _SC_MEMLOCK_RANGE: ::c_int = 18;
-pub const _SC_MEMORY_PROTECTION: ::c_int = 19;
-pub const _SC_MESSAGE_PASSING: ::c_int = 20;
-pub const _SC_SEMAPHORES: ::c_int = 21;
-pub const _SC_SHARED_MEMORY_OBJECTS: ::c_int = 22;
-pub const _SC_AIO_LISTIO_MAX: ::c_int = 23;
-pub const _SC_AIO_MAX: ::c_int = 24;
-pub const _SC_AIO_PRIO_DELTA_MAX: ::c_int = 25;
-pub const _SC_DELAYTIMER_MAX: ::c_int = 26;
-pub const _SC_MQ_OPEN_MAX: ::c_int = 27;
-pub const _SC_MQ_PRIO_MAX: ::c_int = 28;
-pub const _SC_VERSION: ::c_int = 29;
-pub const _SC_PAGESIZE: ::c_int = 30;
-pub const _SC_PAGE_SIZE: ::c_int = _SC_PAGESIZE;
-pub const _SC_RTSIG_MAX: ::c_int = 31;
-pub const _SC_SEM_NSEMS_MAX: ::c_int = 32;
-pub const _SC_SEM_VALUE_MAX: ::c_int = 33;
-pub const _SC_SIGQUEUE_MAX: ::c_int = 34;
-pub const _SC_TIMER_MAX: ::c_int = 35;
-pub const _SC_BC_BASE_MAX: ::c_int = 36;
-pub const _SC_BC_DIM_MAX: ::c_int = 37;
-pub const _SC_BC_SCALE_MAX: ::c_int = 38;
-pub const _SC_BC_STRING_MAX: ::c_int = 39;
-pub const _SC_COLL_WEIGHTS_MAX: ::c_int = 40;
-pub const _SC_EXPR_NEST_MAX: ::c_int = 42;
-pub const _SC_LINE_MAX: ::c_int = 43;
-pub const _SC_RE_DUP_MAX: ::c_int = 44;
-pub const _SC_2_VERSION: ::c_int = 46;
-pub const _SC_2_C_BIND: ::c_int = 47;
-pub const _SC_2_C_DEV: ::c_int = 48;
-pub const _SC_2_FORT_DEV: ::c_int = 49;
-pub const _SC_2_FORT_RUN: ::c_int = 50;
-pub const _SC_2_SW_DEV: ::c_int = 51;
-pub const _SC_2_LOCALEDEF: ::c_int = 52;
-pub const _SC_UIO_MAXIOV: ::c_int = 60;
-pub const _SC_IOV_MAX: ::c_int = 60;
-pub const _SC_THREADS: ::c_int = 67;
-pub const _SC_THREAD_SAFE_FUNCTIONS: ::c_int = 68;
-pub const _SC_GETGR_R_SIZE_MAX: ::c_int = 69;
-pub const _SC_GETPW_R_SIZE_MAX: ::c_int = 70;
-pub const _SC_LOGIN_NAME_MAX: ::c_int = 71;
-pub const _SC_TTY_NAME_MAX: ::c_int = 72;
-pub const _SC_THREAD_DESTRUCTOR_ITERATIONS: ::c_int = 73;
-pub const _SC_THREAD_KEYS_MAX: ::c_int = 74;
-pub const _SC_THREAD_STACK_MIN: ::c_int = 75;
-pub const _SC_THREAD_THREADS_MAX: ::c_int = 76;
-pub const _SC_THREAD_ATTR_STACKADDR: ::c_int = 77;
-pub const _SC_THREAD_ATTR_STACKSIZE: ::c_int = 78;
-pub const _SC_THREAD_PRIORITY_SCHEDULING: ::c_int = 79;
-pub const _SC_THREAD_PRIO_INHERIT: ::c_int = 80;
-pub const _SC_THREAD_PRIO_PROTECT: ::c_int = 81;
-pub const _SC_THREAD_PROCESS_SHARED: ::c_int = 82;
-pub const _SC_NPROCESSORS_CONF: ::c_int = 83;
-pub const _SC_NPROCESSORS_ONLN: ::c_int = 84;
-pub const _SC_PHYS_PAGES: ::c_int = 85;
-pub const _SC_AVPHYS_PAGES: ::c_int = 86;
-pub const _SC_ATEXIT_MAX: ::c_int = 87;
-pub const _SC_PASS_MAX: ::c_int = 88;
-pub const _SC_XOPEN_VERSION: ::c_int = 89;
-pub const _SC_XOPEN_XCU_VERSION: ::c_int = 90;
-pub const _SC_XOPEN_UNIX: ::c_int = 91;
-pub const _SC_XOPEN_CRYPT: ::c_int = 92;
-pub const _SC_XOPEN_ENH_I18N: ::c_int = 93;
-pub const _SC_XOPEN_SHM: ::c_int = 94;
-pub const _SC_2_CHAR_TERM: ::c_int = 95;
-pub const _SC_2_UPE: ::c_int = 97;
-pub const _SC_XOPEN_XPG2: ::c_int = 98;
-pub const _SC_XOPEN_XPG3: ::c_int = 99;
-pub const _SC_XOPEN_XPG4: ::c_int = 100;
-pub const _SC_NZERO: ::c_int = 109;
-pub const _SC_XBS5_ILP32_OFF32: ::c_int = 125;
-pub const _SC_XBS5_ILP32_OFFBIG: ::c_int = 126;
-pub const _SC_XBS5_LP64_OFF64: ::c_int = 127;
-pub const _SC_XBS5_LPBIG_OFFBIG: ::c_int = 128;
-pub const _SC_XOPEN_LEGACY: ::c_int = 129;
-pub const _SC_XOPEN_REALTIME: ::c_int = 130;
-pub const _SC_XOPEN_REALTIME_THREADS: ::c_int = 131;
-pub const _SC_ADVISORY_INFO: ::c_int = 132;
-pub const _SC_BARRIERS: ::c_int = 133;
-pub const _SC_CLOCK_SELECTION: ::c_int = 137;
-pub const _SC_CPUTIME: ::c_int = 138;
-pub const _SC_THREAD_CPUTIME: ::c_int = 139;
-pub const _SC_MONOTONIC_CLOCK: ::c_int = 149;
-pub const _SC_READER_WRITER_LOCKS: ::c_int = 153;
-pub const _SC_SPIN_LOCKS: ::c_int = 154;
-pub const _SC_REGEXP: ::c_int = 155;
-pub const _SC_SHELL: ::c_int = 157;
-pub const _SC_SPAWN: ::c_int = 159;
-pub const _SC_SPORADIC_SERVER: ::c_int = 160;
-pub const _SC_THREAD_SPORADIC_SERVER: ::c_int = 161;
-pub const _SC_TIMEOUTS: ::c_int = 164;
-pub const _SC_TYPED_MEMORY_OBJECTS: ::c_int = 165;
-pub const _SC_2_PBS: ::c_int = 168;
-pub const _SC_2_PBS_ACCOUNTING: ::c_int = 169;
-pub const _SC_2_PBS_LOCATE: ::c_int = 170;
-pub const _SC_2_PBS_MESSAGE: ::c_int = 171;
-pub const _SC_2_PBS_TRACK: ::c_int = 172;
-pub const _SC_SYMLOOP_MAX: ::c_int = 173;
-pub const _SC_STREAMS: ::c_int = 174;
-pub const _SC_2_PBS_CHECKPOINT: ::c_int = 175;
-pub const _SC_V6_ILP32_OFF32: ::c_int = 176;
-pub const _SC_V6_ILP32_OFFBIG: ::c_int = 177;
-pub const _SC_V6_LP64_OFF64: ::c_int = 178;
-pub const _SC_V6_LPBIG_OFFBIG: ::c_int = 179;
-pub const _SC_HOST_NAME_MAX: ::c_int = 180;
-pub const _SC_TRACE: ::c_int = 181;
-pub const _SC_TRACE_EVENT_FILTER: ::c_int = 182;
-pub const _SC_TRACE_INHERIT: ::c_int = 183;
-pub const _SC_TRACE_LOG: ::c_int = 184;
-pub const _SC_IPV6: ::c_int = 235;
-pub const _SC_RAW_SOCKETS: ::c_int = 236;
-pub const _SC_V7_ILP32_OFF32: ::c_int = 237;
-pub const _SC_V7_ILP32_OFFBIG: ::c_int = 238;
-pub const _SC_V7_LP64_OFF64: ::c_int = 239;
-pub const _SC_V7_LPBIG_OFFBIG: ::c_int = 240;
-pub const _SC_SS_REPL_MAX: ::c_int = 241;
-pub const _SC_TRACE_EVENT_NAME_MAX: ::c_int = 242;
-pub const _SC_TRACE_NAME_MAX: ::c_int = 243;
-pub const _SC_TRACE_SYS_MAX: ::c_int = 244;
-pub const _SC_TRACE_USER_EVENT_MAX: ::c_int = 245;
-pub const _SC_XOPEN_STREAMS: ::c_int = 246;
-pub const _SC_THREAD_ROBUST_PRIO_INHERIT: ::c_int = 247;
-pub const _SC_THREAD_ROBUST_PRIO_PROTECT: ::c_int = 248;
-
-pub const RLIM_SAVED_MAX: ::rlim_t = RLIM_INFINITY;
-pub const RLIM_SAVED_CUR: ::rlim_t = RLIM_INFINITY;
-
-pub const GLOB_ERR: ::c_int = 1 << 0;
-pub const GLOB_MARK: ::c_int = 1 << 1;
-pub const GLOB_NOSORT: ::c_int = 1 << 2;
-pub const GLOB_DOOFFS: ::c_int = 1 << 3;
-pub const GLOB_NOCHECK: ::c_int = 1 << 4;
-pub const GLOB_APPEND: ::c_int = 1 << 5;
-pub const GLOB_NOESCAPE: ::c_int = 1 << 6;
-
-pub const GLOB_NOSPACE: ::c_int = 1;
-pub const GLOB_ABORTED: ::c_int = 2;
-pub const GLOB_NOMATCH: ::c_int = 3;
-
-pub const POSIX_MADV_NORMAL: ::c_int = 0;
-pub const POSIX_MADV_RANDOM: ::c_int = 1;
-pub const POSIX_MADV_SEQUENTIAL: ::c_int = 2;
-pub const POSIX_MADV_WILLNEED: ::c_int = 3;
-
-pub const S_IEXEC: mode_t = 64;
-pub const S_IWRITE: mode_t = 128;
-pub const S_IREAD: mode_t = 256;
-
-pub const F_LOCK: ::c_int = 1;
-pub const F_TEST: ::c_int = 3;
-pub const F_TLOCK: ::c_int = 2;
-pub const F_ULOCK: ::c_int = 0;
-
-pub const F_SEAL_FUTURE_WRITE: ::c_int = 0x0010;
-
-pub const IFF_LOWER_UP: ::c_int = 0x10000;
-pub const IFF_DORMANT: ::c_int = 0x20000;
-pub const IFF_ECHO: ::c_int = 0x40000;
-
-// linux/if_addr.h
-pub const IFA_UNSPEC: ::c_ushort = 0;
-pub const IFA_ADDRESS: ::c_ushort = 1;
-pub const IFA_LOCAL: ::c_ushort = 2;
-pub const IFA_LABEL: ::c_ushort = 3;
-pub const IFA_BROADCAST: ::c_ushort = 4;
-pub const IFA_ANYCAST: ::c_ushort = 5;
-pub const IFA_CACHEINFO: ::c_ushort = 6;
-pub const IFA_MULTICAST: ::c_ushort = 7;
-
-pub const IFA_F_SECONDARY: u32 = 0x01;
-pub const IFA_F_TEMPORARY: u32 = 0x01;
-pub const IFA_F_NODAD: u32 = 0x02;
-pub const IFA_F_OPTIMISTIC: u32 = 0x04;
-pub const IFA_F_DADFAILED: u32 = 0x08;
-pub const IFA_F_HOMEADDRESS: u32 = 0x10;
-pub const IFA_F_DEPRECATED: u32 = 0x20;
-pub const IFA_F_TENTATIVE: u32 = 0x40;
-pub const IFA_F_PERMANENT: u32 = 0x80;
-
-// linux/if_link.h
-pub const IFLA_UNSPEC: ::c_ushort = 0;
-pub const IFLA_ADDRESS: ::c_ushort = 1;
-pub const IFLA_BROADCAST: ::c_ushort = 2;
-pub const IFLA_IFNAME: ::c_ushort = 3;
-pub const IFLA_MTU: ::c_ushort = 4;
-pub const IFLA_LINK: ::c_ushort = 5;
-pub const IFLA_QDISC: ::c_ushort = 6;
-pub const IFLA_STATS: ::c_ushort = 7;
-
-// linux/if_tun.h
-pub const IFF_TUN: ::c_int = 0x0001;
-pub const IFF_TAP: ::c_int = 0x0002;
-pub const IFF_NO_PI: ::c_int = 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 as ::c_short;
-pub const TUN_TAP_DEV: ::c_short = ::IFF_TAP as ::c_short;
-pub const TUN_TYPE_MASK: ::c_short = 0x000f;
-// This flag has no real effect
-pub const IFF_ONE_QUEUE: ::c_int = 0x2000;
-pub const IFF_VNET_HDR: ::c_int = 0x4000;
-pub const IFF_TUN_EXCL: ::c_int = 0x8000;
-pub const IFF_MULTI_QUEUE: ::c_int = 0x0100;
-pub const IFF_ATTACH_QUEUE: ::c_int = 0x0200;
-pub const IFF_DETACH_QUEUE: ::c_int = 0x0400;
-// read-only flag
-pub const IFF_PERSIST: ::c_int = 0x0800;
-pub const IFF_NOFILTER: ::c_int = 0x1000;
-
-pub const ST_RDONLY: ::c_ulong = 1;
-pub const ST_NOSUID: ::c_ulong = 2;
-pub const ST_NODEV: ::c_ulong = 4;
-pub const ST_NOEXEC: ::c_ulong = 8;
-pub const ST_SYNCHRONOUS: ::c_ulong = 16;
-pub const ST_MANDLOCK: ::c_ulong = 64;
-pub const ST_WRITE: ::c_ulong = 128;
-pub const ST_APPEND: ::c_ulong = 256;
-pub const ST_IMMUTABLE: ::c_ulong = 512;
-pub const ST_NOATIME: ::c_ulong = 1024;
-pub const ST_NODIRATIME: ::c_ulong = 2048;
-
-pub const RTLD_NEXT: *mut ::c_void = -1i64 as *mut ::c_void;
-pub const RTLD_DEFAULT: *mut ::c_void = 0i64 as *mut ::c_void;
-pub const RTLD_NODELETE: ::c_int = 0x1000;
-pub const RTLD_NOW: ::c_int = 0x2;
-
-pub const TCP_MD5SIG: ::c_int = 14;
-
-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;
-pub const PTHREAD_MUTEX_DEFAULT: ::c_int = PTHREAD_MUTEX_NORMAL;
-pub const PTHREAD_PROCESS_PRIVATE: ::c_int = 0;
-pub const PTHREAD_PROCESS_SHARED: ::c_int = 1;
-pub const __SIZEOF_PTHREAD_COND_T: usize = 48;
-
-pub const RENAME_NOREPLACE: ::c_int = 1;
-pub const RENAME_EXCHANGE: ::c_int = 2;
-pub const RENAME_WHITEOUT: ::c_int = 4;
-
-pub const SCHED_OTHER: ::c_int = 0;
-pub const SCHED_FIFO: ::c_int = 1;
-pub const SCHED_RR: ::c_int = 2;
-pub const SCHED_BATCH: ::c_int = 3;
-pub const SCHED_IDLE: ::c_int = 5;
-
-// netinet/in.h
-// NOTE: These are in addition to the constants defined in src/unix/mod.rs
-
-// IPPROTO_IP defined in src/unix/mod.rs
-/// Hop-by-hop option header
-pub const IPPROTO_HOPOPTS: ::c_int = 0;
-// IPPROTO_ICMP defined in src/unix/mod.rs
-/// group mgmt protocol
-pub const IPPROTO_IGMP: ::c_int = 2;
-/// for compatibility
-pub const IPPROTO_IPIP: ::c_int = 4;
-// IPPROTO_TCP defined in src/unix/mod.rs
-/// exterior gateway protocol
-pub const IPPROTO_EGP: ::c_int = 8;
-/// pup
-pub const IPPROTO_PUP: ::c_int = 12;
-// IPPROTO_UDP defined in src/unix/mod.rs
-/// xns idp
-pub const IPPROTO_IDP: ::c_int = 22;
-/// tp-4 w/ class negotiation
-pub const IPPROTO_TP: ::c_int = 29;
-/// DCCP
-pub const IPPROTO_DCCP: ::c_int = 33;
-// IPPROTO_IPV6 defined in src/unix/mod.rs
-/// IP6 routing header
-pub const IPPROTO_ROUTING: ::c_int = 43;
-/// IP6 fragmentation header
-pub const IPPROTO_FRAGMENT: ::c_int = 44;
-/// resource reservation
-pub const IPPROTO_RSVP: ::c_int = 46;
-/// General Routing Encap.
-pub const IPPROTO_GRE: ::c_int = 47;
-/// IP6 Encap Sec. Payload
-pub const IPPROTO_ESP: ::c_int = 50;
-/// IP6 Auth Header
-pub const IPPROTO_AH: ::c_int = 51;
-// IPPROTO_ICMPV6 defined in src/unix/mod.rs
-/// IP6 no next header
-pub const IPPROTO_NONE: ::c_int = 59;
-/// IP6 destination option
-pub const IPPROTO_DSTOPTS: ::c_int = 60;
-pub const IPPROTO_MTP: ::c_int = 92;
-pub const IPPROTO_BEETPH: ::c_int = 94;
-/// encapsulation header
-pub const IPPROTO_ENCAP: ::c_int = 98;
-/// Protocol indep. multicast
-pub const IPPROTO_PIM: ::c_int = 103;
-/// IP Payload Comp. Protocol
-pub const IPPROTO_COMP: ::c_int = 108;
-/// SCTP
-pub const IPPROTO_SCTP: ::c_int = 132;
-pub const IPPROTO_MH: ::c_int = 135;
-pub const IPPROTO_UDPLITE: ::c_int = 136;
-pub const IPPROTO_MPLS: ::c_int = 137;
-/// raw IP packet
-pub const IPPROTO_RAW: ::c_int = 255;
-pub const IPPROTO_MAX: ::c_int = 256;
-
-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;
-
-pub const IPC_CREAT: ::c_int = 0o1000;
-pub const IPC_EXCL: ::c_int = 0o2000;
-pub const IPC_NOWAIT: ::c_int = 0o4000;
-
-pub const IPC_RMID: ::c_int = 0;
-pub const IPC_SET: ::c_int = 1;
-pub const IPC_STAT: ::c_int = 2;
-pub const IPC_INFO: ::c_int = 3;
-pub const MSG_STAT: ::c_int = 11;
-pub const MSG_INFO: ::c_int = 12;
-
-pub const MSG_NOERROR: ::c_int = 0o10000;
-pub const MSG_EXCEPT: ::c_int = 0o20000;
-pub const MSG_COPY: ::c_int = 0o40000;
-
-pub const SHM_R: ::c_int = 0o400;
-pub const SHM_W: ::c_int = 0o200;
-
-pub const SHM_RDONLY: ::c_int = 0o10000;
-pub const SHM_RND: ::c_int = 0o20000;
-pub const SHM_REMAP: ::c_int = 0o40000;
-pub const SHM_EXEC: ::c_int = 0o100000;
-
-pub const SHM_LOCK: ::c_int = 11;
-pub const SHM_UNLOCK: ::c_int = 12;
-
-pub const SHM_HUGETLB: ::c_int = 0o4000;
-pub const SHM_NORESERVE: ::c_int = 0o10000;
-
-pub const EPOLLRDHUP: ::c_int = 0x2000;
-pub const EPOLLEXCLUSIVE: ::c_int = 0x10000000;
-pub const EPOLLONESHOT: ::c_int = 0x40000000;
-
-pub const QFMT_VFS_OLD: ::c_int = 1;
-pub const QFMT_VFS_V0: ::c_int = 2;
-pub const QFMT_VFS_V1: ::c_int = 4;
-
-pub const EFD_SEMAPHORE: ::c_int = 0x1;
-
-pub const LOG_NFACILITIES: ::c_int = 24;
-
-pub const SEM_FAILED: *mut ::sem_t = 0 as *mut sem_t;
-
-pub const RB_AUTOBOOT: ::c_int = 0x01234567u32 as i32;
-pub const RB_HALT_SYSTEM: ::c_int = 0xcdef0123u32 as i32;
-pub const RB_ENABLE_CAD: ::c_int = 0x89abcdefu32 as i32;
-pub const RB_DISABLE_CAD: ::c_int = 0x00000000u32 as i32;
-pub const RB_POWER_OFF: ::c_int = 0x4321fedcu32 as i32;
-pub const RB_SW_SUSPEND: ::c_int = 0xd000fce2u32 as i32;
-pub const RB_KEXEC: ::c_int = 0x45584543u32 as i32;
-
-pub const AI_PASSIVE: ::c_int = 0x0001;
-pub const AI_CANONNAME: ::c_int = 0x0002;
-pub const AI_NUMERICHOST: ::c_int = 0x0004;
-pub const AI_V4MAPPED: ::c_int = 0x0008;
-pub const AI_ALL: ::c_int = 0x0010;
-pub const AI_ADDRCONFIG: ::c_int = 0x0020;
-
-pub const AI_NUMERICSERV: ::c_int = 0x0400;
-
-pub const EAI_BADFLAGS: ::c_int = -1;
-pub const EAI_NONAME: ::c_int = -2;
-pub const EAI_AGAIN: ::c_int = -3;
-pub const EAI_FAIL: ::c_int = -4;
-pub const EAI_NODATA: ::c_int = -5;
-pub const EAI_FAMILY: ::c_int = -6;
-pub const EAI_SOCKTYPE: ::c_int = -7;
-pub const EAI_SERVICE: ::c_int = -8;
-pub const EAI_MEMORY: ::c_int = -10;
-pub const EAI_SYSTEM: ::c_int = -11;
-pub const EAI_OVERFLOW: ::c_int = -12;
-
-pub const NI_NUMERICHOST: ::c_int = 1;
-pub const NI_NUMERICSERV: ::c_int = 2;
-pub const NI_NOFQDN: ::c_int = 4;
-pub const NI_NAMEREQD: ::c_int = 8;
-pub const NI_DGRAM: ::c_int = 16;
-
-pub const SYNC_FILE_RANGE_WAIT_BEFORE: ::c_uint = 1;
-pub const SYNC_FILE_RANGE_WRITE: ::c_uint = 2;
-pub const SYNC_FILE_RANGE_WAIT_AFTER: ::c_uint = 4;
-
-pub const AIO_CANCELED: ::c_int = 0;
-pub const AIO_NOTCANCELED: ::c_int = 1;
-pub const AIO_ALLDONE: ::c_int = 2;
-pub const LIO_READ: ::c_int = 0;
-pub const LIO_WRITE: ::c_int = 1;
-pub const LIO_NOP: ::c_int = 2;
-pub const LIO_WAIT: ::c_int = 0;
-pub const LIO_NOWAIT: ::c_int = 1;
-
-pub const MREMAP_MAYMOVE: ::c_int = 1;
-pub const MREMAP_FIXED: ::c_int = 2;
-
-pub const PR_SET_PDEATHSIG: ::c_int = 1;
-pub const PR_GET_PDEATHSIG: ::c_int = 2;
-
-pub const PR_GET_DUMPABLE: ::c_int = 3;
-pub const PR_SET_DUMPABLE: ::c_int = 4;
-
-pub const PR_GET_UNALIGN: ::c_int = 5;
-pub const PR_SET_UNALIGN: ::c_int = 6;
-pub const PR_UNALIGN_NOPRINT: ::c_int = 1;
-pub const PR_UNALIGN_SIGBUS: ::c_int = 2;
-
-pub const PR_GET_KEEPCAPS: ::c_int = 7;
-pub const PR_SET_KEEPCAPS: ::c_int = 8;
-
-pub const PR_GET_FPEMU: ::c_int = 9;
-pub const PR_SET_FPEMU: ::c_int = 10;
-pub const PR_FPEMU_NOPRINT: ::c_int = 1;
-pub const PR_FPEMU_SIGFPE: ::c_int = 2;
-
-pub const PR_GET_FPEXC: ::c_int = 11;
-pub const PR_SET_FPEXC: ::c_int = 12;
-pub const PR_FP_EXC_SW_ENABLE: ::c_int = 0x80;
-pub const PR_FP_EXC_DIV: ::c_int = 0x010000;
-pub const PR_FP_EXC_OVF: ::c_int = 0x020000;
-pub const PR_FP_EXC_UND: ::c_int = 0x040000;
-pub const PR_FP_EXC_RES: ::c_int = 0x080000;
-pub const PR_FP_EXC_INV: ::c_int = 0x100000;
-pub const PR_FP_EXC_DISABLED: ::c_int = 0;
-pub const PR_FP_EXC_NONRECOV: ::c_int = 1;
-pub const PR_FP_EXC_ASYNC: ::c_int = 2;
-pub const PR_FP_EXC_PRECISE: ::c_int = 3;
-
-pub const PR_GET_TIMING: ::c_int = 13;
-pub const PR_SET_TIMING: ::c_int = 14;
-pub const PR_TIMING_STATISTICAL: ::c_int = 0;
-pub const PR_TIMING_TIMESTAMP: ::c_int = 1;
-
-pub const PR_SET_NAME: ::c_int = 15;
-pub const PR_GET_NAME: ::c_int = 16;
-
-pub const PR_GET_ENDIAN: ::c_int = 19;
-pub const PR_SET_ENDIAN: ::c_int = 20;
-pub const PR_ENDIAN_BIG: ::c_int = 0;
-pub const PR_ENDIAN_LITTLE: ::c_int = 1;
-pub const PR_ENDIAN_PPC_LITTLE: ::c_int = 2;
-
-pub const PR_GET_SECCOMP: ::c_int = 21;
-pub const PR_SET_SECCOMP: ::c_int = 22;
-
-pub const PR_CAPBSET_READ: ::c_int = 23;
-pub const PR_CAPBSET_DROP: ::c_int = 24;
-
-pub const PR_GET_TSC: ::c_int = 25;
-pub const PR_SET_TSC: ::c_int = 26;
-pub const PR_TSC_ENABLE: ::c_int = 1;
-pub const PR_TSC_SIGSEGV: ::c_int = 2;
-
-pub const PR_GET_SECUREBITS: ::c_int = 27;
-pub const PR_SET_SECUREBITS: ::c_int = 28;
-
-pub const PR_SET_TIMERSLACK: ::c_int = 29;
-pub const PR_GET_TIMERSLACK: ::c_int = 30;
-
-pub const PR_TASK_PERF_EVENTS_DISABLE: ::c_int = 31;
-pub const PR_TASK_PERF_EVENTS_ENABLE: ::c_int = 32;
-
-pub const PR_MCE_KILL: ::c_int = 33;
-pub const PR_MCE_KILL_CLEAR: ::c_int = 0;
-pub const PR_MCE_KILL_SET: ::c_int = 1;
-
-pub const PR_MCE_KILL_LATE: ::c_int = 0;
-pub const PR_MCE_KILL_EARLY: ::c_int = 1;
-pub const PR_MCE_KILL_DEFAULT: ::c_int = 2;
-
-pub const PR_MCE_KILL_GET: ::c_int = 34;
-
-pub const PR_SET_MM: ::c_int = 35;
-pub const PR_SET_MM_START_CODE: ::c_int = 1;
-pub const PR_SET_MM_END_CODE: ::c_int = 2;
-pub const PR_SET_MM_START_DATA: ::c_int = 3;
-pub const PR_SET_MM_END_DATA: ::c_int = 4;
-pub const PR_SET_MM_START_STACK: ::c_int = 5;
-pub const PR_SET_MM_START_BRK: ::c_int = 6;
-pub const PR_SET_MM_BRK: ::c_int = 7;
-pub const PR_SET_MM_ARG_START: ::c_int = 8;
-pub const PR_SET_MM_ARG_END: ::c_int = 9;
-pub const PR_SET_MM_ENV_START: ::c_int = 10;
-pub const PR_SET_MM_ENV_END: ::c_int = 11;
-pub const PR_SET_MM_AUXV: ::c_int = 12;
-pub const PR_SET_MM_EXE_FILE: ::c_int = 13;
-pub const PR_SET_MM_MAP: ::c_int = 14;
-pub const PR_SET_MM_MAP_SIZE: ::c_int = 15;
-
-pub const PR_SET_PTRACER: ::c_int = 0x59616d61;
-
-pub const PR_SET_CHILD_SUBREAPER: ::c_int = 36;
-pub const PR_GET_CHILD_SUBREAPER: ::c_int = 37;
-
-pub const PR_SET_NO_NEW_PRIVS: ::c_int = 38;
-pub const PR_GET_NO_NEW_PRIVS: ::c_int = 39;
-
-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 PR_MPX_ENABLE_MANAGEMENT: ::c_int = 43;
-pub const PR_MPX_DISABLE_MANAGEMENT: ::c_int = 44;
-
-pub const PR_SET_FP_MODE: ::c_int = 45;
-pub const PR_GET_FP_MODE: ::c_int = 46;
-pub const PR_FP_MODE_FR: ::c_int = 1 << 0;
-pub const PR_FP_MODE_FRE: ::c_int = 1 << 1;
-
-pub const PR_CAP_AMBIENT: ::c_int = 47;
-pub const PR_CAP_AMBIENT_IS_SET: ::c_int = 1;
-pub const PR_CAP_AMBIENT_RAISE: ::c_int = 2;
-pub const PR_CAP_AMBIENT_LOWER: ::c_int = 3;
-pub const PR_CAP_AMBIENT_CLEAR_ALL: ::c_int = 4;
-
-pub const GRND_NONBLOCK: ::c_uint = 0x0001;
-pub const GRND_RANDOM: ::c_uint = 0x0002;
-
-pub const SECCOMP_MODE_DISABLED: ::c_uint = 0;
-pub const SECCOMP_MODE_STRICT: ::c_uint = 1;
-pub const SECCOMP_MODE_FILTER: ::c_uint = 2;
-
-pub const ITIMER_REAL: ::c_int = 0;
-pub const ITIMER_VIRTUAL: ::c_int = 1;
-pub const ITIMER_PROF: ::c_int = 2;
-
-pub const TFD_CLOEXEC: ::c_int = O_CLOEXEC;
-pub const TFD_NONBLOCK: ::c_int = O_NONBLOCK;
-pub const TFD_TIMER_ABSTIME: ::c_int = 1;
-
-pub const XATTR_CREATE: ::c_int = 0x1;
-pub const XATTR_REPLACE: ::c_int = 0x2;
-
-pub const _POSIX_VDISABLE: ::cc_t = 0;
-
-pub const FALLOC_FL_KEEP_SIZE: ::c_int = 0x01;
-pub const FALLOC_FL_PUNCH_HOLE: ::c_int = 0x02;
-pub const FALLOC_FL_COLLAPSE_RANGE: ::c_int = 0x08;
-pub const FALLOC_FL_ZERO_RANGE: ::c_int = 0x10;
-pub const FALLOC_FL_INSERT_RANGE: ::c_int = 0x20;
-pub const FALLOC_FL_UNSHARE_RANGE: ::c_int = 0x40;
-
-#[deprecated(
- since = "0.2.55",
- note = "ENOATTR is not available on Linux; use ENODATA instead"
-)]
-pub const ENOATTR: ::c_int = ::ENODATA;
-
-pub const SO_ORIGINAL_DST: ::c_int = 80;
-pub const IP_ORIGDSTADDR : ::c_int = 20;
-pub const IP_RECVORIGDSTADDR : ::c_int = IP_ORIGDSTADDR;
-pub const IPV6_ORIGDSTADDR : ::c_int = 74;
-pub const IPV6_RECVORIGDSTADDR : ::c_int = IPV6_ORIGDSTADDR;
-pub const IPV6_FLOWINFO: ::c_int = 11;
-pub const IPV6_FLOWLABEL_MGR: ::c_int = 32;
-pub const IPV6_FLOWINFO_SEND: ::c_int = 33;
-pub const IPV6_FLOWINFO_FLOWLABEL: ::c_int = 0x000fffff;
-pub const IPV6_FLOWINFO_PRIORITY: ::c_int = 0x0ff00000;
-pub const IUTF8: ::tcflag_t = 0x00004000;
-pub const CMSPAR: ::tcflag_t = 0o10000000000;
-
-pub const MFD_CLOEXEC: ::c_uint = 0x0001;
-pub const MFD_ALLOW_SEALING: ::c_uint = 0x0002;
-pub const MFD_HUGETLB: ::c_uint = 0x0004;
-
-// these are used in the p_type field of Elf32_Phdr and Elf64_Phdr, which has
-// the type Elf32Word and Elf64Word respectively. Luckily, both of those are u32
-// so we can use that type here to avoid having to cast.
-pub const PT_NULL: u32 = 0;
-pub const PT_LOAD: u32 = 1;
-pub const PT_DYNAMIC: u32 = 2;
-pub const PT_INTERP: u32 = 3;
-pub const PT_NOTE: u32 = 4;
-pub const PT_SHLIB: u32 = 5;
-pub const PT_PHDR: u32 = 6;
-pub const PT_TLS: u32 = 7;
-pub const PT_NUM: u32 = 8;
-pub const PT_LOOS: u32 = 0x60000000;
-pub const PT_GNU_EH_FRAME: u32 = 0x6474e550;
-pub const PT_GNU_STACK: u32 = 0x6474e551;
-pub const PT_GNU_RELRO: u32 = 0x6474e552;
-
-// 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;
-
-// These are the defined Ethernet Protocol ID's.
-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_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;
-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_PRP: ::c_int = 0x88FB;
-pub const ETH_P_FCOE: ::c_int = 0x8906;
-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_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;
-pub const ETH_P_AF_IUCV: ::c_int = 0xFBFB;
-
-pub const ETH_P_802_3_MIN: ::c_int = 0x0600;
-
-// Non DIX types. Won't clash for 1500 types.
-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_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 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 IPTOS_ECN_NOT_ECT: u8 = 0x00;
-
-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;
-
-// linux/neighbor.h
-pub const NUD_NONE: u16 = 0x00;
-pub const NUD_INCOMPLETE: u16 = 0x01;
-pub const NUD_REACHABLE: u16 = 0x02;
-pub const NUD_STALE: u16 = 0x04;
-pub const NUD_DELAY: u16 = 0x08;
-pub const NUD_PROBE: u16 = 0x10;
-pub const NUD_FAILED: u16 = 0x20;
-pub const NUD_NOARP: u16 = 0x40;
-pub const NUD_PERMANENT: u16 = 0x80;
-
-pub const NTF_USE: u8 = 0x01;
-pub const NTF_SELF: u8 = 0x02;
-pub const NTF_MASTER: u8 = 0x04;
-pub const NTF_PROXY: u8 = 0x08;
-pub const NTF_ROUTER: u8 = 0x80;
-
-pub const NDA_UNSPEC: ::c_ushort = 0;
-pub const NDA_DST: ::c_ushort = 1;
-pub const NDA_LLADDR: ::c_ushort = 2;
-pub const NDA_CACHEINFO: ::c_ushort = 3;
-pub const NDA_PROBES: ::c_ushort = 4;
-pub const NDA_VLAN: ::c_ushort = 5;
-pub const NDA_PORT: ::c_ushort = 6;
-pub const NDA_VNI: ::c_ushort = 7;
-pub const NDA_IFINDEX: ::c_ushort = 8;
-
-// linux/rtnetlink.h
-pub const TCA_UNSPEC: ::c_ushort = 0;
-pub const TCA_KIND: ::c_ushort = 1;
-pub const TCA_OPTIONS: ::c_ushort = 2;
-pub const TCA_STATS: ::c_ushort = 3;
-pub const TCA_XSTATS: ::c_ushort = 4;
-pub const TCA_RATE: ::c_ushort = 5;
-pub const TCA_FCNT: ::c_ushort = 6;
-pub const TCA_STATS2: ::c_ushort = 7;
-pub const TCA_STAB: ::c_ushort = 8;
-
-pub const RTM_F_NOTIFY: ::c_uint = 0x100;
-pub const RTM_F_CLONED: ::c_uint = 0x200;
-pub const RTM_F_EQUALIZE: ::c_uint = 0x400;
-pub const RTM_F_PREFIX: ::c_uint = 0x800;
-
-pub const RTA_UNSPEC: ::c_ushort = 0;
-pub const RTA_DST: ::c_ushort = 1;
-pub const RTA_SRC: ::c_ushort = 2;
-pub const RTA_IIF: ::c_ushort = 3;
-pub const RTA_OIF: ::c_ushort = 4;
-pub const RTA_GATEWAY: ::c_ushort = 5;
-pub const RTA_PRIORITY: ::c_ushort = 6;
-pub const RTA_PREFSRC: ::c_ushort = 7;
-pub const RTA_METRICS: ::c_ushort = 8;
-pub const RTA_MULTIPATH: ::c_ushort = 9;
-pub const RTA_PROTOINFO: ::c_ushort = 10; // No longer used
-pub const RTA_FLOW: ::c_ushort = 11;
-pub const RTA_CACHEINFO: ::c_ushort = 12;
-pub const RTA_SESSION: ::c_ushort = 13; // No longer used
-pub const RTA_MP_ALGO: ::c_ushort = 14; // No longer used
-pub const RTA_TABLE: ::c_ushort = 15;
-pub const RTA_MARK: ::c_ushort = 16;
-pub const RTA_MFC_STATS: ::c_ushort = 17;
-
-pub const RTN_UNSPEC: ::c_uchar = 0;
-pub const RTN_UNICAST: ::c_uchar = 1;
-pub const RTN_LOCAL: ::c_uchar = 2;
-pub const RTN_BROADCAST: ::c_uchar = 3;
-pub const RTN_ANYCAST: ::c_uchar = 4;
-pub const RTN_MULTICAST: ::c_uchar = 5;
-pub const RTN_BLACKHOLE: ::c_uchar = 6;
-pub const RTN_UNREACHABLE: ::c_uchar = 7;
-pub const RTN_PROHIBIT: ::c_uchar = 8;
-pub const RTN_THROW: ::c_uchar = 9;
-pub const RTN_NAT: ::c_uchar = 10;
-pub const RTN_XRESOLVE: ::c_uchar = 11;
-
-pub const RTPROT_UNSPEC: ::c_uchar = 0;
-pub const RTPROT_REDIRECT: ::c_uchar = 1;
-pub const RTPROT_KERNEL: ::c_uchar = 2;
-pub const RTPROT_BOOT: ::c_uchar = 3;
-pub const RTPROT_STATIC: ::c_uchar = 4;
-
-pub const RT_SCOPE_UNIVERSE: ::c_uchar = 0;
-pub const RT_SCOPE_SITE: ::c_uchar = 200;
-pub const RT_SCOPE_LINK: ::c_uchar = 253;
-pub const RT_SCOPE_HOST: ::c_uchar = 254;
-pub const RT_SCOPE_NOWHERE: ::c_uchar = 255;
-
-pub const RT_TABLE_UNSPEC: ::c_uchar = 0;
-pub const RT_TABLE_COMPAT: ::c_uchar = 252;
-pub const RT_TABLE_DEFAULT: ::c_uchar = 253;
-pub const RT_TABLE_MAIN: ::c_uchar = 254;
-pub const RT_TABLE_LOCAL: ::c_uchar = 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;
-
-// linux/if_alg.h
-pub const ALG_SET_KEY: ::c_int = 1;
-pub const ALG_SET_IV: ::c_int = 2;
-pub const ALG_SET_OP: ::c_int = 3;
-pub const ALG_SET_AEAD_ASSOCLEN: ::c_int = 4;
-pub const ALG_SET_AEAD_AUTHSIZE: ::c_int = 5;
-
-pub const ALG_OP_DECRYPT: ::c_int = 0;
-pub const ALG_OP_ENCRYPT: ::c_int = 1;
-
-// uapi/linux/inotify.h
-pub const IN_ACCESS: u32 = 0x0000_0001;
-pub const IN_MODIFY: u32 = 0x0000_0002;
-pub const IN_ATTRIB: u32 = 0x0000_0004;
-pub const IN_CLOSE_WRITE: u32 = 0x0000_0008;
-pub const IN_CLOSE_NOWRITE: u32 = 0x0000_0010;
-pub const IN_CLOSE: u32 = (IN_CLOSE_WRITE | IN_CLOSE_NOWRITE);
-pub const IN_OPEN: u32 = 0x0000_0020;
-pub const IN_MOVED_FROM: u32 = 0x0000_0040;
-pub const IN_MOVED_TO: u32 = 0x0000_0080;
-pub const IN_MOVE: u32 = (IN_MOVED_FROM | IN_MOVED_TO);
-pub const IN_CREATE: u32 = 0x0000_0100;
-pub const IN_DELETE: u32 = 0x0000_0200;
-pub const IN_DELETE_SELF: u32 = 0x0000_0400;
-pub const IN_MOVE_SELF: u32 = 0x0000_0800;
-pub const IN_UNMOUNT: u32 = 0x0000_2000;
-pub const IN_Q_OVERFLOW: u32 = 0x0000_4000;
-pub const IN_IGNORED: u32 = 0x0000_8000;
-pub const IN_ONLYDIR: u32 = 0x0100_0000;
-pub const IN_DONT_FOLLOW: u32 = 0x0200_0000;
-// pub const IN_EXCL_UNLINK: u32 = 0x0400_0000;
-
-// pub const IN_MASK_CREATE: u32 = 0x1000_0000;
-// pub const IN_MASK_ADD: u32 = 0x2000_0000;
-pub const IN_ISDIR: u32 = 0x4000_0000;
-pub const IN_ONESHOT: u32 = 0x8000_0000;
-
-pub const IN_ALL_EVENTS: u32 = (
- IN_ACCESS | IN_MODIFY | IN_ATTRIB | IN_CLOSE_WRITE |
- IN_CLOSE_NOWRITE | IN_OPEN | IN_MOVED_FROM |
- IN_MOVED_TO | IN_DELETE | IN_CREATE | IN_DELETE_SELF |
- IN_MOVE_SELF
-);
-
-pub const IN_CLOEXEC: ::c_int = O_CLOEXEC;
-pub const IN_NONBLOCK: ::c_int = O_NONBLOCK;
-
-pub const FUTEX_WAIT: ::c_int = 0;
-pub const FUTEX_WAKE: ::c_int = 1;
-pub const FUTEX_FD: ::c_int = 2;
-pub const FUTEX_REQUEUE: ::c_int = 3;
-pub const FUTEX_CMP_REQUEUE: ::c_int = 4;
-pub const FUTEX_WAKE_OP: ::c_int = 5;
-pub const FUTEX_LOCK_PI: ::c_int = 6;
-pub const FUTEX_UNLOCK_PI: ::c_int = 7;
-pub const FUTEX_TRYLOCK_PI: ::c_int = 8;
-pub const FUTEX_WAIT_BITSET: ::c_int = 9;
-pub const FUTEX_WAKE_BITSET: ::c_int = 10;
-pub const FUTEX_WAIT_REQUEUE_PI: ::c_int = 11;
-pub const FUTEX_CMP_REQUEUE_PI: ::c_int = 12;
-
-pub const FUTEX_PRIVATE_FLAG: ::c_int = 128;
-pub const FUTEX_CLOCK_REALTIME: ::c_int = 256;
-pub const FUTEX_CMD_MASK: ::c_int =
- !(FUTEX_PRIVATE_FLAG | FUTEX_CLOCK_REALTIME);
-
-f! {
- pub fn CMSG_NXTHDR(mhdr: *const msghdr,
- cmsg: *const cmsghdr) -> *mut cmsghdr {
- if ((*cmsg).cmsg_len as usize) < ::mem::size_of::<cmsghdr>() {
- return 0 as *mut cmsghdr;
- };
- let next = (cmsg as usize +
- super::CMSG_ALIGN((*cmsg).cmsg_len as usize))
- as *mut cmsghdr;
- let max = (*mhdr).msg_control as usize
- + (*mhdr).msg_controllen as usize;
- if (next.offset(1)) as usize > max ||
- next as usize + super::CMSG_ALIGN((*next).cmsg_len as usize) > max
- {
- 0 as *mut cmsghdr
- } else {
- next as *mut cmsghdr
- }
- }
-
- pub fn CPU_ZERO(cpuset: &mut cpu_set_t) -> () {
- for slot in cpuset.bits.iter_mut() {
- *slot = 0;
- }
- }
-
- pub fn CPU_SET(cpu: usize, cpuset: &mut cpu_set_t) -> () {
- let size_in_bits
- = 8 * ::mem::size_of_val(&cpuset.bits[0]); // 32, 64 etc
- let (idx, offset) = (cpu / size_in_bits, cpu % size_in_bits);
- cpuset.bits[idx] |= 1 << offset;
- ()
- }
-
- pub fn CPU_CLR(cpu: usize, cpuset: &mut cpu_set_t) -> () {
- let size_in_bits
- = 8 * ::mem::size_of_val(&cpuset.bits[0]); // 32, 64 etc
- let (idx, offset) = (cpu / size_in_bits, cpu % size_in_bits);
- cpuset.bits[idx] &= !(1 << offset);
- ()
- }
-
- pub fn CPU_ISSET(cpu: usize, cpuset: &cpu_set_t) -> bool {
- let size_in_bits = 8 * ::mem::size_of_val(&cpuset.bits[0]);
- let (idx, offset) = (cpu / size_in_bits, cpu % size_in_bits);
- 0 != (cpuset.bits[idx] & (1 << offset))
- }
-
- pub fn CPU_EQUAL(set1: &cpu_set_t, set2: &cpu_set_t) -> bool {
- set1.bits == set2.bits
- }
-
- pub fn major(dev: ::dev_t) -> ::c_uint {
- let mut major = 0;
- major |= (dev & 0x00000000000fff00) >> 8;
- major |= (dev & 0xfffff00000000000) >> 32;
- major as ::c_uint
- }
-
- pub fn minor(dev: ::dev_t) -> ::c_uint {
- let mut minor = 0;
- minor |= (dev & 0x00000000000000ff) >> 0;
- minor |= (dev & 0x00000ffffff00000) >> 12;
- minor as ::c_uint
- }
-
- pub fn makedev(major: ::c_uint, minor: ::c_uint) -> ::dev_t {
- let major = major as ::dev_t;
- let minor = minor as ::dev_t;
- let mut dev = 0;
- dev |= (major & 0x00000fff) << 8;
- dev |= (major & 0xfffff000) << 32;
- dev |= (minor & 0x000000ff) << 0;
- 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 {
- #[cfg_attr(not(target_env = "musl"),
- link_name = "__xpg_strerror_r")]
- pub fn strerror_r(errnum: ::c_int, buf: *mut c_char,
- buflen: ::size_t) -> ::c_int;
-
- 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;
- 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 lutimes(file: *const ::c_char, times: *const ::timeval) -> ::c_int;
-
- 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,
- mode: mode_t) -> ::c_int;
-
- // System V IPC
- pub fn shmget(key: ::key_t, size: ::size_t, shmflg: ::c_int) -> ::c_int;
- 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;
- pub fn shmctl(shmid: ::c_int,
- cmd: ::c_int,
- buf: *mut ::shmid_ds) -> ::c_int;
- pub fn ftok(pathname: *const ::c_char, proj_id: ::c_int) -> ::key_t;
- pub fn semget(key: ::key_t, nsems: ::c_int, semflag: ::c_int) -> ::c_int;
- pub fn semop(semid: ::c_int,
- sops: *mut ::sembuf, nsops: ::size_t) -> ::c_int;
- pub fn semctl(semid: ::c_int,
- semnum: ::c_int, cmd: ::c_int, ...) -> ::c_int;
- pub fn msgctl(msqid: ::c_int, cmd: ::c_int, buf: *mut msqid_ds) -> ::c_int;
- pub fn msgget(key: ::key_t, msgflg: ::c_int) -> ::c_int;
- pub fn msgrcv(msqid: ::c_int, msgp: *mut ::c_void, msgsz: ::size_t,
- msgtyp: ::c_long, msgflg: ::c_int) -> ::ssize_t;
- pub fn msgsnd(msqid: ::c_int, msgp: *const ::c_void, msgsz: ::size_t,
- msgflg: ::c_int) -> ::c_int;
-
- pub fn mprotect(addr: *mut ::c_void, len: ::size_t, prot: ::c_int)
- -> ::c_int;
- pub fn __errno_location() -> *mut ::c_int;
-
- pub fn fopen64(filename: *const c_char,
- mode: *const c_char) -> *mut ::FILE;
- pub fn freopen64(filename: *const c_char, mode: *const c_char,
- file: *mut ::FILE) -> *mut ::FILE;
- pub fn tmpfile64() -> *mut ::FILE;
- pub fn fgetpos64(stream: *mut ::FILE, ptr: *mut fpos64_t) -> ::c_int;
- pub fn fsetpos64(stream: *mut ::FILE, ptr: *const fpos64_t) -> ::c_int;
- pub fn fseeko64(stream: *mut ::FILE,
- offset: ::off64_t,
- whence: ::c_int) -> ::c_int;
- 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,
- value: *mut ::c_void, size: ::size_t) -> ::ssize_t;
- pub fn lgetxattr(path: *const c_char, name: *const c_char,
- value: *mut ::c_void, size: ::size_t) -> ::ssize_t;
- pub fn fgetxattr(filedes: ::c_int, name: *const c_char,
- value: *mut ::c_void, size: ::size_t) -> ::ssize_t;
- pub fn setxattr(path: *const c_char, name: *const c_char,
- value: *const ::c_void, size: ::size_t,
- flags: ::c_int) -> ::c_int;
- pub fn lsetxattr(path: *const c_char, name: *const c_char,
- value: *const ::c_void, size: ::size_t,
- flags: ::c_int) -> ::c_int;
- pub fn fsetxattr(filedes: ::c_int, name: *const c_char,
- value: *const ::c_void, size: ::size_t,
- flags: ::c_int) -> ::c_int;
- pub fn listxattr(path: *const c_char, list: *mut c_char,
- size: ::size_t) -> ::ssize_t;
- pub fn llistxattr(path: *const c_char, list: *mut c_char,
- size: ::size_t) -> ::ssize_t;
- pub fn flistxattr(filedes: ::c_int, list: *mut c_char,
- size: ::size_t) -> ::ssize_t;
- pub fn removexattr(path: *const c_char, name: *const c_char) -> ::c_int;
- pub fn lremovexattr(path: *const c_char, name: *const c_char) -> ::c_int;
- pub fn fremovexattr(filedes: ::c_int, name: *const c_char) -> ::c_int;
- pub fn signalfd(fd: ::c_int,
- mask: *const ::sigset_t,
- flags: ::c_int) -> ::c_int;
- pub fn timerfd_create(clockid: ::c_int, flags: ::c_int) -> ::c_int;
- pub fn timerfd_gettime(fd: ::c_int,
- curr_value: *mut itimerspec) -> ::c_int;
- pub fn timerfd_settime(fd: ::c_int,
- flags: ::c_int,
- new_value: *const itimerspec,
- old_value: *mut itimerspec) -> ::c_int;
- pub fn pwritev(fd: ::c_int,
- iov: *const ::iovec,
- iovcnt: ::c_int,
- offset: ::off_t) -> ::ssize_t;
- pub fn preadv(fd: ::c_int,
- iov: *const ::iovec,
- iovcnt: ::c_int,
- offset: ::off_t) -> ::ssize_t;
- pub fn quotactl(cmd: ::c_int,
- special: *const ::c_char,
- id: ::c_int,
- data: *mut ::c_char) -> ::c_int;
- pub fn mq_open(name: *const ::c_char, oflag: ::c_int, ...) -> ::mqd_t;
- pub fn mq_close(mqd: ::mqd_t) -> ::c_int;
- pub fn mq_unlink(name: *const ::c_char) -> ::c_int;
- pub fn mq_receive(mqd: ::mqd_t,
- msg_ptr: *mut ::c_char,
- msg_len: ::size_t,
- msq_prio: *mut ::c_uint) -> ::ssize_t;
- pub fn mq_send(mqd: ::mqd_t,
- msg_ptr: *const ::c_char,
- msg_len: ::size_t,
- msq_prio: ::c_uint) -> ::c_int;
- pub fn mq_getattr(mqd: ::mqd_t, attr: *mut ::mq_attr) -> ::c_int;
- pub fn mq_setattr(mqd: ::mqd_t,
- newattr: *const ::mq_attr,
- oldattr: *mut ::mq_attr) -> ::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 dup3(oldfd: ::c_int, newfd: ::c_int, flags: ::c_int) -> ::c_int;
- pub fn mkostemp(template: *mut ::c_char, flags: ::c_int) -> ::c_int;
- pub fn mkostemps(template: *mut ::c_char,
- suffixlen: ::c_int,
- flags: ::c_int) -> ::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 nl_langinfo_l(item: ::nl_item, locale: ::locale_t) -> *mut ::c_char;
- pub fn getnameinfo(sa: *const ::sockaddr,
- salen: ::socklen_t,
- host: *mut ::c_char,
- hostlen: ::socklen_t,
- serv: *mut ::c_char,
- sevlen: ::socklen_t,
- flags: ::c_int) -> ::c_int;
- pub fn pthread_setschedprio(native: ::pthread_t,
- priority: ::c_int) -> ::c_int;
- pub fn getloadavg(loadavg: *mut ::c_double, nelem: ::c_int) -> ::c_int;
- pub fn process_vm_readv(pid: ::pid_t,
- local_iov: *const ::iovec,
- liovcnt: ::c_ulong,
- remote_iov: *const ::iovec,
- riovcnt: ::c_ulong,
- flags: ::c_ulong) -> isize;
- pub fn process_vm_writev(pid: ::pid_t,
- local_iov: *const ::iovec,
- liovcnt: ::c_ulong,
- remote_iov: *const ::iovec,
- riovcnt: ::c_ulong,
- flags: ::c_ulong) -> isize;
- pub fn reboot(how_to: ::c_int) -> ::c_int;
- pub fn setfsgid(gid: ::gid_t) -> ::c_int;
- pub fn setfsuid(uid: ::uid_t) -> ::c_int;
-
- // Not available now on Android
- pub fn mkfifoat(dirfd: ::c_int, pathname: *const ::c_char,
- mode: ::mode_t) -> ::c_int;
- pub fn if_nameindex() -> *mut if_nameindex;
- pub fn if_freenameindex(ptr: *mut if_nameindex);
- pub fn sync_file_range(fd: ::c_int, offset: ::off64_t,
- nbytes: ::off64_t, flags: ::c_uint) -> ::c_int;
- pub fn mremap(addr: *mut ::c_void,
- len: ::size_t,
- new_len: ::size_t,
- flags: ::c_int,
- ...) -> *mut ::c_void;
-
- 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;
- pub fn globfree(pglob: *mut ::glob_t);
-
- pub fn posix_madvise(addr: *mut ::c_void, len: ::size_t, advice: ::c_int)
- -> ::c_int;
-
- pub fn shm_unlink(name: *const ::c_char) -> ::c_int;
-
- pub fn seekdir(dirp: *mut ::DIR, loc: ::c_long);
-
- pub fn telldir(dirp: *mut ::DIR) -> ::c_long;
- pub fn madvise(addr: *mut ::c_void, len: ::size_t, advice: ::c_int)
- -> ::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;
- pub fn mkstemps(template: *mut ::c_char, suffixlen: ::c_int) -> ::c_int;
- pub fn futimes(fd: ::c_int, times: *const ::timeval) -> ::c_int;
- pub fn nl_langinfo(item: ::nl_item) -> *mut ::c_char;
-
- 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;
- pub fn sync();
- pub fn syscall(num: ::c_long, ...) -> ::c_long;
- pub fn sched_getaffinity(pid: ::pid_t,
- cpusetsize: ::size_t,
- cpuset: *mut cpu_set_t) -> ::c_int;
- pub fn sched_setaffinity(pid: ::pid_t,
- cpusetsize: ::size_t,
- cpuset: *const cpu_set_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;
- pub fn pthread_getschedparam(native: ::pthread_t,
- policy: *mut ::c_int,
- param: *mut ::sched_param) -> ::c_int;
- pub fn unshare(flags: ::c_int) -> ::c_int;
- pub fn umount(target: *const ::c_char) -> ::c_int;
- pub fn sched_get_priority_max(policy: ::c_int) -> ::c_int;
- pub fn tee(fd_in: ::c_int,
- fd_out: ::c_int,
- len: ::size_t,
- flags: ::c_uint) -> ::ssize_t;
- pub fn settimeofday(tv: *const ::timeval, tz: *const ::timezone) -> ::c_int;
- pub fn splice(fd_in: ::c_int,
- off_in: *mut ::loff_t,
- fd_out: ::c_int,
- off_out: *mut ::loff_t,
- len: ::size_t,
- flags: ::c_uint) -> ::ssize_t;
- pub fn eventfd(init: ::c_uint, flags: ::c_int) -> ::c_int;
- 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;
- pub fn vmsplice(fd: ::c_int,
- iov: *const ::iovec,
- nr_segs: ::size_t,
- flags: ::c_uint) -> ::ssize_t;
- pub fn mount(src: *const ::c_char,
- target: *const ::c_char,
- fstype: *const ::c_char,
- flags: ::c_ulong,
- data: *const ::c_void) -> ::c_int;
- pub fn personality(persona: ::c_ulong) -> ::c_int;
- pub fn prctl(option: ::c_int, ...) -> ::c_int;
- pub fn sched_getparam(pid: ::pid_t, param: *mut ::sched_param) -> ::c_int;
- pub fn ppoll(fds: *mut ::pollfd,
- nfds: nfds_t,
- timeout: *const ::timespec,
- sigmask: *const sigset_t) -> ::c_int;
- pub fn pthread_mutex_timedlock(lock: *mut pthread_mutex_t,
- abstime: *const ::timespec) -> ::c_int;
- pub fn clone(cb: extern fn(*mut ::c_void) -> ::c_int,
- child_stack: *mut ::c_void,
- flags: ::c_int,
- arg: *mut ::c_void, ...) -> ::c_int;
- pub fn sched_getscheduler(pid: ::pid_t) -> ::c_int;
- pub fn clock_nanosleep(clk_id: ::clockid_t,
- flags: ::c_int,
- rqtp: *const ::timespec,
- rmtp: *mut ::timespec) -> ::c_int;
- pub fn pthread_attr_getguardsize(attr: *const ::pthread_attr_t,
- guardsize: *mut ::size_t) -> ::c_int;
- pub fn sethostname(name: *const ::c_char, len: ::size_t) -> ::c_int;
- pub fn sched_get_priority_min(policy: ::c_int) -> ::c_int;
- pub fn pthread_condattr_getpshared(attr: *const pthread_condattr_t,
- pshared: *mut ::c_int) -> ::c_int;
- pub fn sysinfo(info: *mut ::sysinfo) -> ::c_int;
- pub fn umount2(target: *const ::c_char, flags: ::c_int) -> ::c_int;
- pub fn pthread_setschedparam(native: ::pthread_t,
- policy: ::c_int,
- param: *const ::sched_param) -> ::c_int;
- pub fn swapon(path: *const ::c_char, swapflags: ::c_int) -> ::c_int;
- pub fn sched_setscheduler(pid: ::pid_t,
- policy: ::c_int,
- param: *const ::sched_param) -> ::c_int;
- pub fn sendfile(out_fd: ::c_int,
- in_fd: ::c_int,
- offset: *mut off_t,
- count: ::size_t) -> ::ssize_t;
- pub fn sigsuspend(mask: *const ::sigset_t) -> ::c_int;
- #[cfg_attr(target_os = "solaris", link_name = "__posix_getgrgid_r")]
- pub fn getgrgid_r(gid: ::gid_t,
- grp: *mut ::group,
- buf: *mut ::c_char,
- buflen: ::size_t,
- result: *mut *mut ::group) -> ::c_int;
- #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
- link_name = "sigaltstack$UNIX2003")]
- #[cfg_attr(target_os = "netbsd", link_name = "__sigaltstack14")]
- pub fn sigaltstack(ss: *const stack_t,
- oss: *mut stack_t) -> ::c_int;
- pub fn sem_close(sem: *mut sem_t) -> ::c_int;
- pub fn getdtablesize() -> ::c_int;
- #[cfg_attr(target_os = "solaris", link_name = "__posix_getgrnam_r")]
- pub fn getgrnam_r(name: *const ::c_char,
- grp: *mut ::group,
- buf: *mut ::c_char,
- buflen: ::size_t,
- result: *mut *mut ::group) -> ::c_int;
- pub fn initgroups(user: *const ::c_char, group: ::gid_t) -> ::c_int;
- #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
- link_name = "pthread_sigmask$UNIX2003")]
- pub fn pthread_sigmask(how: ::c_int, set: *const sigset_t,
- oldset: *mut sigset_t) -> ::c_int;
- pub fn sem_open(name: *const ::c_char, oflag: ::c_int, ...) -> *mut sem_t;
- pub fn getgrnam(name: *const ::c_char) -> *mut ::group;
- pub fn pthread_cancel(thread: ::pthread_t) -> ::c_int;
- pub fn pthread_kill(thread: ::pthread_t, sig: ::c_int) -> ::c_int;
- pub fn sem_unlink(name: *const ::c_char) -> ::c_int;
- pub fn daemon(nochdir: ::c_int, noclose: ::c_int) -> ::c_int;
- #[cfg_attr(target_os = "netbsd", link_name = "__getpwnam_r50")]
- #[cfg_attr(target_os = "solaris", link_name = "__posix_getpwnam_r")]
- pub fn getpwnam_r(name: *const ::c_char,
- pwd: *mut passwd,
- buf: *mut ::c_char,
- buflen: ::size_t,
- result: *mut *mut passwd) -> ::c_int;
- #[cfg_attr(target_os = "netbsd", link_name = "__getpwuid_r50")]
- #[cfg_attr(target_os = "solaris", link_name = "__posix_getpwuid_r")]
- pub fn getpwuid_r(uid: ::uid_t,
- pwd: *mut passwd,
- buf: *mut ::c_char,
- buflen: ::size_t,
- result: *mut *mut passwd) -> ::c_int;
- #[cfg_attr(all(target_os = "macos", target_arch ="x86"),
- link_name = "sigwait$UNIX2003")]
- #[cfg_attr(target_os = "solaris", link_name = "__posix_sigwait")]
- pub fn sigwait(set: *const sigset_t,
- sig: *mut ::c_int) -> ::c_int;
- pub fn pthread_atfork(prepare: ::Option<unsafe extern fn()>,
- parent: ::Option<unsafe extern fn()>,
- child: ::Option<unsafe extern fn()>) -> ::c_int;
- pub fn getgrgid(gid: ::gid_t) -> *mut ::group;
- pub fn getgrouplist(user: *const ::c_char,
- group: ::gid_t,
- groups: *mut ::gid_t,
- ngroups: *mut ::c_int) -> ::c_int;
- pub fn pthread_mutexattr_getpshared(attr: *const pthread_mutexattr_t,
- pshared: *mut ::c_int) -> ::c_int;
- #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
- link_name = "popen$UNIX2003")]
- pub fn popen(command: *const c_char,
- mode: *const c_char) -> *mut ::FILE;
- pub fn faccessat(dirfd: ::c_int, pathname: *const ::c_char,
- mode: ::c_int, flags: ::c_int) -> ::c_int;
- pub fn pthread_create(native: *mut ::pthread_t,
- attr: *const ::pthread_attr_t,
- f: extern fn(*mut ::c_void) -> *mut ::c_void,
- value: *mut ::c_void) -> ::c_int;
- pub fn dl_iterate_phdr(
- callback: ::Option<unsafe extern fn(
- info: *mut ::dl_phdr_info,
- size: ::size_t,
- data: *mut ::c_void
- ) -> ::c_int>,
- data: *mut ::c_void
- ) -> ::c_int;
-
- pub fn setmntent(filename: *const ::c_char,
- ty: *const ::c_char) -> *mut ::FILE;
- pub fn getmntent(stream: *mut ::FILE) -> *mut ::mntent;
- pub fn addmntent(stream: *mut ::FILE, mnt: *const ::mntent) -> ::c_int;
- 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;
- pub fn inotify_rm_watch(fd: ::c_int, wd: ::c_int) -> ::c_int;
- pub fn inotify_init() -> ::c_int;
- pub fn inotify_init1(flags: ::c_int) -> ::c_int;
- pub fn inotify_add_watch(fd: ::c_int,
- path: *const ::c_char,
- mask: u32) -> ::c_int;
-}
-
-cfg_if! {
- if #[cfg(target_env = "musl")] {
- mod musl;
- pub use self::musl::*;
- } else if #[cfg(any(target_arch = "mips",
- target_arch = "mips64"))] {
- mod mips;
- pub use self::mips::*;
- } else if #[cfg(any(target_arch = "s390x"))] {
- mod s390x;
- pub use self::s390x::*;
- } else {
- mod other;
- pub use self::other::*;
- }
-}
-
-cfg_if! {
- if #[cfg(libc_align)] {
- #[macro_use]
- mod align;
- } else {
- #[macro_use]
- mod no_align;
- }
-}
-expand_align!();
diff --git a/libc/src/unix/notbsd/linux/musl/b32/arm.rs b/libc/src/unix/notbsd/linux/musl/b32/arm.rs
deleted file mode 100644
index 7162fdf..0000000
--- a/libc/src/unix/notbsd/linux/musl/b32/arm.rs
+++ /dev/null
@@ -1,844 +0,0 @@
-pub type c_char = u8;
-pub type wchar_t = u32;
-
-s! {
- pub struct stat {
- pub st_dev: ::dev_t,
- __st_dev_padding: ::c_int,
- __st_ino_truncated: ::c_long,
- pub st_mode: ::mode_t,
- pub st_nlink: ::nlink_t,
- pub st_uid: ::uid_t,
- pub st_gid: ::gid_t,
- pub st_rdev: ::dev_t,
- __st_rdev_padding: ::c_int,
- 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,
- pub st_ino: ::ino_t,
- }
-
- pub struct stat64 {
- pub st_dev: ::dev_t,
- __st_dev_padding: ::c_int,
- __st_ino_truncated: ::c_long,
- pub st_mode: ::mode_t,
- pub st_nlink: ::nlink_t,
- pub st_uid: ::uid_t,
- pub st_gid: ::gid_t,
- pub st_rdev: ::dev_t,
- __st_rdev_padding: ::c_int,
- 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,
- pub st_ino: ::ino_t,
- }
-
- 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,
- __unused1: ::c_long,
- __unused2: ::c_long
- }
-
- pub struct shmid_ds {
- pub shm_perm: ::ipc_perm,
- pub shm_segsz: ::size_t,
- pub shm_atime: ::time_t,
- __unused1: ::c_int,
- pub shm_dtime: ::time_t,
- __unused2: ::c_int,
- pub shm_ctime: ::time_t,
- __unused3: ::c_int,
- 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,
- pub msg_stime: ::time_t,
- __unused1: ::c_int,
- pub msg_rtime: ::time_t,
- __unused2: ::c_int,
- pub msg_ctime: ::time_t,
- __unused3: ::c_int,
- __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,
- 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 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;
-pub const O_ASYNC: ::c_int = 0x2000;
-pub const O_LARGEFILE: ::c_int = 0o400000;
-
-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;
-pub const RLIMIT_NPROC: ::c_int = 6;
-pub const RLIMIT_MEMLOCK: ::c_int = 8;
-pub const RLIMIT_NLIMITS: ::c_int = 15;
-
-pub const MADV_SOFT_OFFLINE: ::c_int = 101;
-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;
-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 = 0x02000;
-pub const MAP_NORESERVE: ::c_int = 0x04000;
-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 = EDEADLK;
-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_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;
-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 = 0x00010000;
-
-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 = 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 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_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_mknod: ::c_long = 14;
-pub const SYS_chmod: ::c_long = 15;
-pub const SYS_lchown: ::c_long = 16;
-pub const SYS_lseek: ::c_long = 19;
-pub const SYS_getpid: ::c_long = 20;
-pub const SYS_mount: ::c_long = 21;
-pub const SYS_setuid: ::c_long = 23;
-pub const SYS_getuid: ::c_long = 24;
-pub const SYS_ptrace: ::c_long = 26;
-pub const SYS_pause: ::c_long = 29;
-pub const SYS_access: ::c_long = 33;
-pub const SYS_nice: ::c_long = 34;
-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_brk: ::c_long = 45;
-pub const SYS_setgid: ::c_long = 46;
-pub const SYS_getgid: ::c_long = 47;
-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_ioctl: ::c_long = 54;
-pub const SYS_fcntl: ::c_long = 55;
-pub const SYS_setpgid: ::c_long = 57;
-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_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_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_symlink: ::c_long = 83;
-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_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_statfs: ::c_long = 99;
-pub const SYS_fstatfs: ::c_long = 100;
-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_vhangup: ::c_long = 111;
-pub const SYS_wait4: ::c_long = 114;
-pub const SYS_swapoff: ::c_long = 115;
-pub const SYS_sysinfo: ::c_long = 116;
-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_adjtimex: ::c_long = 124;
-pub const SYS_mprotect: ::c_long = 125;
-pub const SYS_sigprocmask: ::c_long = 126;
-pub const SYS_init_module: ::c_long = 128;
-pub const SYS_delete_module: ::c_long = 129;
-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_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_poll: ::c_long = 168;
-pub const SYS_nfsservctl: ::c_long = 169;
-pub const SYS_setresgid: ::c_long = 170;
-pub const SYS_getresgid: ::c_long = 171;
-pub const SYS_prctl: ::c_long = 172;
-pub const SYS_rt_sigreturn: ::c_long = 173;
-pub const SYS_rt_sigaction: ::c_long = 174;
-pub const SYS_rt_sigprocmask: ::c_long = 175;
-pub const SYS_rt_sigpending: ::c_long = 176;
-pub const SYS_rt_sigtimedwait: ::c_long = 177;
-pub const SYS_rt_sigqueueinfo: ::c_long = 178;
-pub const SYS_rt_sigsuspend: ::c_long = 179;
-pub const SYS_pread64: ::c_long = 180;
-pub const SYS_pwrite64: ::c_long = 181;
-pub const SYS_chown: ::c_long = 182;
-pub const SYS_getcwd: ::c_long = 183;
-pub const SYS_capget: ::c_long = 184;
-pub const SYS_capset: ::c_long = 185;
-pub const SYS_sigaltstack: ::c_long = 186;
-pub const SYS_sendfile: ::c_long = 187;
-pub const SYS_vfork: ::c_long = 190;
-pub const SYS_ugetrlimit: ::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_lchown32: ::c_long = 198;
-pub const SYS_getuid32: ::c_long = 199;
-pub const SYS_getgid32: ::c_long = 200;
-pub const SYS_geteuid32: ::c_long = 201;
-pub const SYS_getegid32: ::c_long = 202;
-pub const SYS_setreuid32: ::c_long = 203;
-pub const SYS_setregid32: ::c_long = 204;
-pub const SYS_getgroups32: ::c_long = 205;
-pub const SYS_setgroups32: ::c_long = 206;
-pub const SYS_fchown32: ::c_long = 207;
-pub const SYS_setresuid32: ::c_long = 208;
-pub const SYS_getresuid32: ::c_long = 209;
-pub const SYS_setresgid32: ::c_long = 210;
-pub const SYS_getresgid32: ::c_long = 211;
-pub const SYS_chown32: ::c_long = 212;
-pub const SYS_setuid32: ::c_long = 213;
-pub const SYS_setgid32: ::c_long = 214;
-pub const SYS_setfsuid32: ::c_long = 215;
-pub const SYS_setfsgid32: ::c_long = 216;
-pub const SYS_getdents64: ::c_long = 217;
-pub const SYS_pivot_root: ::c_long = 218;
-pub const SYS_mincore: ::c_long = 219;
-pub const SYS_madvise: ::c_long = 220;
-pub const SYS_fcntl64: ::c_long = 221;
-pub const SYS_gettid: ::c_long = 224;
-pub const SYS_readahead: ::c_long = 225;
-pub const SYS_setxattr: ::c_long = 226;
-pub const SYS_lsetxattr: ::c_long = 227;
-pub const SYS_fsetxattr: ::c_long = 228;
-pub const SYS_getxattr: ::c_long = 229;
-pub const SYS_lgetxattr: ::c_long = 230;
-pub const SYS_fgetxattr: ::c_long = 231;
-pub const SYS_listxattr: ::c_long = 232;
-pub const SYS_llistxattr: ::c_long = 233;
-pub const SYS_flistxattr: ::c_long = 234;
-pub const SYS_removexattr: ::c_long = 235;
-pub const SYS_lremovexattr: ::c_long = 236;
-pub const SYS_fremovexattr: ::c_long = 237;
-pub const SYS_tkill: ::c_long = 238;
-pub const SYS_sendfile64: ::c_long = 239;
-pub const SYS_futex: ::c_long = 240;
-pub const SYS_sched_setaffinity: ::c_long = 241;
-pub const SYS_sched_getaffinity: ::c_long = 242;
-pub const SYS_io_setup: ::c_long = 243;
-pub const SYS_io_destroy: ::c_long = 244;
-pub const SYS_io_getevents: ::c_long = 245;
-pub const SYS_io_submit: ::c_long = 246;
-pub const SYS_io_cancel: ::c_long = 247;
-pub const SYS_exit_group: ::c_long = 248;
-pub const SYS_lookup_dcookie: ::c_long = 249;
-pub const SYS_epoll_create: ::c_long = 250;
-pub const SYS_epoll_ctl: ::c_long = 251;
-pub const SYS_epoll_wait: ::c_long = 252;
-pub const SYS_remap_file_pages: ::c_long = 253;
-pub const SYS_set_tid_address: ::c_long = 256;
-pub const SYS_timer_create: ::c_long = 257;
-pub const SYS_timer_settime: ::c_long = 258;
-pub const SYS_timer_gettime: ::c_long = 259;
-pub const SYS_timer_getoverrun: ::c_long = 260;
-pub const SYS_timer_delete: ::c_long = 261;
-pub const SYS_clock_settime: ::c_long = 262;
-pub const SYS_clock_gettime: ::c_long = 263;
-pub const SYS_clock_getres: ::c_long = 264;
-pub const SYS_clock_nanosleep: ::c_long = 265;
-pub const SYS_statfs64: ::c_long = 266;
-pub const SYS_fstatfs64: ::c_long = 267;
-pub const SYS_tgkill: ::c_long = 268;
-pub const SYS_utimes: ::c_long = 269;
-pub const SYS_pciconfig_iobase: ::c_long = 271;
-pub const SYS_pciconfig_read: ::c_long = 272;
-pub const SYS_pciconfig_write: ::c_long = 273;
-pub const SYS_mq_open: ::c_long = 274;
-pub const SYS_mq_unlink: ::c_long = 275;
-pub const SYS_mq_timedsend: ::c_long = 276;
-pub const SYS_mq_timedreceive: ::c_long = 277;
-pub const SYS_mq_notify: ::c_long = 278;
-pub const SYS_mq_getsetattr: ::c_long = 279;
-pub const SYS_waitid: ::c_long = 280;
-pub const SYS_socket: ::c_long = 281;
-pub const SYS_bind: ::c_long = 282;
-pub const SYS_connect: ::c_long = 283;
-pub const SYS_listen: ::c_long = 284;
-pub const SYS_accept: ::c_long = 285;
-pub const SYS_getsockname: ::c_long = 286;
-pub const SYS_getpeername: ::c_long = 287;
-pub const SYS_socketpair: ::c_long = 288;
-pub const SYS_send: ::c_long = 289;
-pub const SYS_sendto: ::c_long = 290;
-pub const SYS_recv: ::c_long = 291;
-pub const SYS_recvfrom: ::c_long = 292;
-pub const SYS_shutdown: ::c_long = 293;
-pub const SYS_setsockopt: ::c_long = 294;
-pub const SYS_getsockopt: ::c_long = 295;
-pub const SYS_sendmsg: ::c_long = 296;
-pub const SYS_recvmsg: ::c_long = 297;
-pub const SYS_semop: ::c_long = 298;
-pub const SYS_semget: ::c_long = 299;
-pub const SYS_semctl: ::c_long = 300;
-pub const SYS_msgsnd: ::c_long = 301;
-pub const SYS_msgrcv: ::c_long = 302;
-pub const SYS_msgget: ::c_long = 303;
-pub const SYS_msgctl: ::c_long = 304;
-pub const SYS_shmat: ::c_long = 305;
-pub const SYS_shmdt: ::c_long = 306;
-pub const SYS_shmget: ::c_long = 307;
-pub const SYS_shmctl: ::c_long = 308;
-pub const SYS_add_key: ::c_long = 309;
-pub const SYS_request_key: ::c_long = 310;
-pub const SYS_keyctl: ::c_long = 311;
-pub const SYS_semtimedop: ::c_long = 312;
-pub const SYS_vserver: ::c_long = 313;
-pub const SYS_ioprio_set: ::c_long = 314;
-pub const SYS_ioprio_get: ::c_long = 315;
-pub const SYS_inotify_init: ::c_long = 316;
-pub const SYS_inotify_add_watch: ::c_long = 317;
-pub const SYS_inotify_rm_watch: ::c_long = 318;
-pub const SYS_mbind: ::c_long = 319;
-pub const SYS_get_mempolicy: ::c_long = 320;
-pub const SYS_set_mempolicy: ::c_long = 321;
-pub const SYS_openat: ::c_long = 322;
-pub const SYS_mkdirat: ::c_long = 323;
-pub const SYS_mknodat: ::c_long = 324;
-pub const SYS_fchownat: ::c_long = 325;
-pub const SYS_futimesat: ::c_long = 326;
-pub const SYS_fstatat64: ::c_long = 327;
-pub const SYS_unlinkat: ::c_long = 328;
-pub const SYS_renameat: ::c_long = 329;
-pub const SYS_linkat: ::c_long = 330;
-pub const SYS_symlinkat: ::c_long = 331;
-pub const SYS_readlinkat: ::c_long = 332;
-pub const SYS_fchmodat: ::c_long = 333;
-pub const SYS_faccessat: ::c_long = 334;
-pub const SYS_pselect6: ::c_long = 335;
-pub const SYS_ppoll: ::c_long = 336;
-pub const SYS_unshare: ::c_long = 337;
-pub const SYS_set_robust_list: ::c_long = 338;
-pub const SYS_get_robust_list: ::c_long = 339;
-pub const SYS_splice: ::c_long = 340;
-pub const SYS_tee: ::c_long = 342;
-pub const SYS_vmsplice: ::c_long = 343;
-pub const SYS_move_pages: ::c_long = 344;
-pub const SYS_getcpu: ::c_long = 345;
-pub const SYS_epoll_pwait: ::c_long = 346;
-pub const SYS_kexec_load: ::c_long = 347;
-pub const SYS_utimensat: ::c_long = 348;
-pub const SYS_signalfd: ::c_long = 349;
-pub const SYS_timerfd_create: ::c_long = 350;
-pub const SYS_eventfd: ::c_long = 351;
-pub const SYS_fallocate: ::c_long = 352;
-pub const SYS_timerfd_settime: ::c_long = 353;
-pub const SYS_timerfd_gettime: ::c_long = 354;
-pub const SYS_signalfd4: ::c_long = 355;
-pub const SYS_eventfd2: ::c_long = 356;
-pub const SYS_epoll_create1: ::c_long = 357;
-pub const SYS_dup3: ::c_long = 358;
-pub const SYS_pipe2: ::c_long = 359;
-pub const SYS_inotify_init1: ::c_long = 360;
-pub const SYS_preadv: ::c_long = 361;
-pub const SYS_pwritev: ::c_long = 362;
-pub const SYS_rt_tgsigqueueinfo: ::c_long = 363;
-pub const SYS_perf_event_open: ::c_long = 364;
-pub const SYS_recvmmsg: ::c_long = 365;
-pub const SYS_accept4: ::c_long = 366;
-pub const SYS_fanotify_init: ::c_long = 367;
-pub const SYS_fanotify_mark: ::c_long = 368;
-pub const SYS_prlimit64: ::c_long = 369;
-pub const SYS_name_to_handle_at: ::c_long = 370;
-pub const SYS_open_by_handle_at: ::c_long = 371;
-pub const SYS_clock_adjtime: ::c_long = 372;
-pub const SYS_syncfs: ::c_long = 373;
-pub const SYS_sendmmsg: ::c_long = 374;
-pub const SYS_setns: ::c_long = 375;
-pub const SYS_process_vm_readv: ::c_long = 376;
-pub const SYS_process_vm_writev: ::c_long = 377;
-pub const SYS_kcmp: ::c_long = 378;
-pub const SYS_finit_module: ::c_long = 379;
-pub const SYS_sched_setattr: ::c_long = 380;
-pub const SYS_sched_getattr: ::c_long = 381;
-pub const SYS_renameat2: ::c_long = 382;
-pub const SYS_seccomp: ::c_long = 383;
-pub const SYS_getrandom: ::c_long = 384;
-pub const SYS_memfd_create: ::c_long = 385;
-pub const SYS_bpf: ::c_long = 386;
-pub const SYS_execveat: ::c_long = 387;
-pub const SYS_userfaultfd: ::c_long = 388;
-pub const SYS_membarrier: ::c_long = 389;
-pub const SYS_mlock2: ::c_long = 390;
-pub const SYS_copy_file_range: ::c_long = 391;
-pub const SYS_preadv2: ::c_long = 392;
-pub const SYS_pwritev2: ::c_long = 393;
-pub const SYS_pkey_mprotect: ::c_long = 394;
-pub const SYS_pkey_alloc: ::c_long = 395;
-pub const SYS_pkey_free: ::c_long = 396;
-
-#[doc(hidden)]
-#[deprecated(
- since = "0.2.55",
- note = "If you are using this report to: \
- https://github.com/rust-lang/libc/issues/665"
-)]
-pub const AF_MAX: ::c_int = 45;
-#[doc(hidden)]
-#[allow(deprecated)]
-#[deprecated(
- since = "0.2.55",
- note = "If you are using this report to: \
- https://github.com/rust-lang/libc/issues/665"
-)]
-pub const PF_MAX: ::c_int = AF_MAX;
diff --git a/libc/src/unix/notbsd/linux/musl/b32/mips.rs b/libc/src/unix/notbsd/linux/musl/b32/mips.rs
deleted file mode 100644
index fbecb49..0000000
--- a/libc/src/unix/notbsd/linux/musl/b32/mips.rs
+++ /dev/null
@@ -1,853 +0,0 @@
-pub type c_char = i8;
-pub type wchar_t = ::c_int;
-
-s! {
- pub struct stat {
- pub st_dev: ::dev_t,
- __st_padding1: [::c_long; 2],
- 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_padding2: [::c_long; 2],
- 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,
- __st_padding3: ::c_long,
- pub st_blocks: ::blkcnt_t,
- __st_padding4: [::c_long; 14],
- }
-
- pub struct stat64 {
- pub st_dev: ::dev_t,
- __st_padding1: [::c_long; 2],
- pub st_ino: ::ino64_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_padding2: [::c_long; 2],
- 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,
- __st_padding3: ::c_long,
- pub st_blocks: ::blkcnt64_t,
- __st_padding4: [::c_long; 14],
- }
-
- pub struct stack_t {
- pub ss_sp: *mut ::c_void,
- pub ss_size: ::size_t,
- 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,
- pub shm_atime: ::time_t,
- pub shm_dtime: ::time_t,
- pub shm_ctime: ::time_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,
- #[cfg(target_endian = "big")]
- __unused1: ::c_int,
- pub msg_stime: ::time_t,
- #[cfg(target_endian = "little")]
- __unused1: ::c_int,
- #[cfg(target_endian = "big")]
- __unused2: ::c_int,
- pub msg_rtime: ::time_t,
- #[cfg(target_endian = "little")]
- __unused2: ::c_int,
- #[cfg(target_endian = "big")]
- __unused3: ::c_int,
- pub msg_ctime: ::time_t,
- #[cfg(target_endian = "little")]
- __unused3: ::c_int,
- __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_frsize: ::c_ulong,
- pub f_blocks: ::fsblkcnt_t,
- pub f_bfree: ::fsblkcnt_t,
- pub f_files: ::fsfilcnt_t,
- pub f_ffree: ::fsfilcnt_t,
- pub f_bavail: ::fsblkcnt_t,
- pub f_fsid: ::fsid_t,
- pub f_namelen: ::c_ulong,
- pub f_flags: ::c_ulong,
- pub f_spare: [::c_ulong; 5],
- }
-
- pub struct siginfo_t {
- pub si_signo: ::c_int,
- pub si_code: ::c_int,
- pub si_errno: ::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_frsize: ::c_ulong,
- pub f_blocks: ::fsblkcnt_t,
- pub f_bfree: ::fsblkcnt_t,
- pub f_files: ::fsfilcnt_t,
- pub f_ffree: ::fsfilcnt_t,
- pub f_bavail: ::fsblkcnt_t,
- pub f_fsid: ::fsid_t,
- pub f_namelen: ::c_ulong,
- pub f_flags: ::c_ulong,
- pub f_spare: [::c_ulong; 5],
- }
-
- 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 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;
-pub const O_ASYNC: ::c_int = 0o10000;
-pub const O_LARGEFILE: ::c_int = 0x2000;
-
-pub const FIOCLEX: ::c_int = 0x6601;
-pub const FIONBIO: ::c_int = 0x667E;
-
-pub const RLIMIT_RSS: ::c_int = 7;
-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 = 15;
-
-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;
-pub const O_EXCL: ::c_int = 0o2000;
-pub const O_NOCTTY: ::c_int = 0o4000;
-pub const O_NONBLOCK: ::c_int = 0o200;
-pub const O_SYNC: ::c_int = 0o40020;
-pub const O_RSYNC: ::c_int = 0o40020;
-pub const O_DSYNC: ::c_int = 0o020;
-
-pub const SOCK_NONBLOCK: ::c_int = 0o200;
-
-pub const MAP_ANON: ::c_int = 0x800;
-pub const MAP_GROWSDOWN: ::c_int = 0x1000;
-pub const MAP_DENYWRITE: ::c_int = 0x2000;
-pub const MAP_EXECUTABLE: ::c_int = 0x4000;
-pub const MAP_LOCKED: ::c_int = 0x8000;
-pub const MAP_NORESERVE: ::c_int = 0x0400;
-pub const MAP_POPULATE: ::c_int = 0x10000;
-pub const MAP_NONBLOCK: ::c_int = 0x20000;
-pub const MAP_STACK: ::c_int = 0x40000;
-
-pub const EDEADLK: ::c_int = 45;
-pub const ENAMETOOLONG: ::c_int = 78;
-pub const ENOLCK: ::c_int = 46;
-pub const ENOSYS: ::c_int = 89;
-pub const ENOTEMPTY: ::c_int = 93;
-pub const ELOOP: ::c_int = 90;
-pub const ENOMSG: ::c_int = 35;
-pub const EIDRM: ::c_int = 36;
-pub const ECHRNG: ::c_int = 37;
-pub const EL2NSYNC: ::c_int = 38;
-pub const EL3HLT: ::c_int = 39;
-pub const EL3RST: ::c_int = 40;
-pub const ELNRNG: ::c_int = 41;
-pub const EUNATCH: ::c_int = 42;
-pub const ENOCSI: ::c_int = 43;
-pub const EL2HLT: ::c_int = 44;
-pub const EBADE: ::c_int = 50;
-pub const EBADR: ::c_int = 51;
-pub const EXFULL: ::c_int = 52;
-pub const ENOANO: ::c_int = 53;
-pub const EBADRQC: ::c_int = 54;
-pub const EBADSLT: ::c_int = 55;
-pub const EDEADLOCK: ::c_int = 56;
-pub const EMULTIHOP: ::c_int = 74;
-pub const EOVERFLOW: ::c_int = 79;
-pub const ENOTUNIQ: ::c_int = 80;
-pub const EBADFD: ::c_int = 81;
-pub const EBADMSG: ::c_int = 77;
-pub const EREMCHG: ::c_int = 82;
-pub const ELIBACC: ::c_int = 83;
-pub const ELIBBAD: ::c_int = 84;
-pub const ELIBSCN: ::c_int = 85;
-pub const ELIBMAX: ::c_int = 86;
-pub const ELIBEXEC: ::c_int = 87;
-pub const EILSEQ: ::c_int = 88;
-pub const ERESTART: ::c_int = 91;
-pub const ESTRPIPE: ::c_int = 92;
-pub const EUSERS: ::c_int = 94;
-pub const ENOTSOCK: ::c_int = 95;
-pub const EDESTADDRREQ: ::c_int = 96;
-pub const EMSGSIZE: ::c_int = 97;
-pub const EPROTOTYPE: ::c_int = 98;
-pub const ENOPROTOOPT: ::c_int = 99;
-pub const EPROTONOSUPPORT: ::c_int = 120;
-pub const ESOCKTNOSUPPORT: ::c_int = 121;
-pub const EOPNOTSUPP: ::c_int = 122;
-pub const ENOTSUP: ::c_int = EOPNOTSUPP;
-pub const EPFNOSUPPORT: ::c_int = 123;
-pub const EAFNOSUPPORT: ::c_int = 124;
-pub const EADDRINUSE: ::c_int = 125;
-pub const EADDRNOTAVAIL: ::c_int = 126;
-pub const ENETDOWN: ::c_int = 127;
-pub const ENETUNREACH: ::c_int = 128;
-pub const ENETRESET: ::c_int = 129;
-pub const ECONNABORTED: ::c_int = 130;
-pub const ECONNRESET: ::c_int = 131;
-pub const ENOBUFS: ::c_int = 132;
-pub const EISCONN: ::c_int = 133;
-pub const ENOTCONN: ::c_int = 134;
-pub const ESHUTDOWN: ::c_int = 143;
-pub const ETOOMANYREFS: ::c_int = 144;
-pub const ETIMEDOUT: ::c_int = 145;
-pub const ECONNREFUSED: ::c_int = 146;
-pub const EHOSTDOWN: ::c_int = 147;
-pub const EHOSTUNREACH: ::c_int = 148;
-pub const EALREADY: ::c_int = 149;
-pub const EINPROGRESS: ::c_int = 150;
-pub const ESTALE: ::c_int = 151;
-pub const EUCLEAN: ::c_int = 135;
-pub const ENOTNAM: ::c_int = 137;
-pub const ENAVAIL: ::c_int = 138;
-pub const EISNAM: ::c_int = 139;
-pub const EREMOTEIO: ::c_int = 140;
-pub const EDQUOT: ::c_int = 1133;
-pub const ENOMEDIUM: ::c_int = 159;
-pub const EMEDIUMTYPE: ::c_int = 160;
-pub const ECANCELED: ::c_int = 158;
-pub const ENOKEY: ::c_int = 161;
-pub const EKEYEXPIRED: ::c_int = 162;
-pub const EKEYREVOKED: ::c_int = 163;
-pub const EKEYREJECTED: ::c_int = 164;
-pub const EOWNERDEAD: ::c_int = 165;
-pub const ENOTRECOVERABLE: ::c_int = 166;
-pub const EHWPOISON: ::c_int = 168;
-pub const ERFKILL: ::c_int = 167;
-
-pub const SOCK_STREAM: ::c_int = 2;
-pub const SOCK_DGRAM: ::c_int = 1;
-pub const SOCK_SEQPACKET: ::c_int = 5;
-
-pub const SOL_SOCKET: ::c_int = 65535;
-
-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_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_RCVTIMEO: ::c_int = 0x1006;
-pub const SO_SNDTIMEO: ::c_int = 0x1005;
-pub const SO_ERROR: ::c_int = 0x1007;
-pub const SO_TYPE: ::c_int = 0x1008;
-pub const SO_ACCEPTCONN: ::c_int = 0x1009;
-pub const SO_PROTOCOL: ::c_int = 0x1028;
-pub const SO_DOMAIN: ::c_int = 0x1029;
-pub const SO_NO_CHECK: ::c_int = 11;
-pub const SO_PRIORITY: ::c_int = 12;
-pub const SO_BSDCOMPAT: ::c_int = 14;
-pub const SO_PASSCRED: ::c_int = 17;
-pub const SO_PEERCRED: ::c_int = 18;
-pub const SO_SNDBUFFORCE: ::c_int = 31;
-pub const SO_RCVBUFFORCE: ::c_int = 33;
-
-pub const SA_ONSTACK: ::c_int = 0x08000000;
-pub const SA_SIGINFO: ::c_int = 8;
-pub const SA_NOCLDWAIT: ::c_int = 0x10000;
-
-pub const SIGCHLD: ::c_int = 18;
-pub const SIGBUS: ::c_int = 10;
-pub const SIGTTIN: ::c_int = 26;
-pub const SIGTTOU: ::c_int = 27;
-pub const SIGXCPU: ::c_int = 30;
-pub const SIGXFSZ: ::c_int = 31;
-pub const SIGVTALRM: ::c_int = 28;
-pub const SIGPROF: ::c_int = 29;
-pub const SIGWINCH: ::c_int = 20;
-pub const SIGUSR1: ::c_int = 16;
-pub const SIGUSR2: ::c_int = 17;
-pub const SIGCONT: ::c_int = 25;
-pub const SIGSTOP: ::c_int = 23;
-pub const SIGTSTP: ::c_int = 24;
-pub const SIGURG: ::c_int = 21;
-pub const SIGIO: ::c_int = 22;
-pub const SIGSYS: ::c_int = 12;
-pub const SIGSTKFLT: ::c_int = 7;
-pub const SIGPOLL: ::c_int = ::SIGIO;
-pub const SIGPWR: ::c_int = 19;
-pub const SIG_SETMASK: ::c_int = 3;
-pub const SIG_BLOCK: ::c_int = 1;
-pub const SIG_UNBLOCK: ::c_int = 2;
-
-pub const EXTPROC: ::tcflag_t = 0o200000;
-
-pub const MAP_HUGETLB: ::c_int = 0x80000;
-
-pub const F_GETLK: ::c_int = 33;
-pub const F_GETOWN: ::c_int = 23;
-pub const F_SETLK: ::c_int = 34;
-pub const F_SETLKW: ::c_int = 35;
-pub const F_SETOWN: ::c_int = 24;
-
-pub const VEOF: usize = 16;
-pub const VEOL: usize = 17;
-pub const VEOL2: usize = 6;
-pub const VMIN: usize = 4;
-pub const IEXTEN: ::tcflag_t = 0o000400;
-pub const TOSTOP: ::tcflag_t = 0o100000;
-pub const FLUSHO: ::tcflag_t = 0o020000;
-
-pub const TCGETS: ::c_int = 0x540D;
-pub const TCSETS: ::c_int = 0x540E;
-pub const TCSETSW: ::c_int = 0x540F;
-pub const TCSETSF: ::c_int = 0x5410;
-pub const TCGETA: ::c_int = 0x5401;
-pub const TCSETA: ::c_int = 0x5402;
-pub const TCSETAW: ::c_int = 0x5403;
-pub const TCSETAF: ::c_int = 0x5404;
-pub const TCSBRK: ::c_int = 0x5405;
-pub const TCXONC: ::c_int = 0x5406;
-pub const TCFLSH: ::c_int = 0x5407;
-pub const TIOCGSOFTCAR: ::c_int = 0x5481;
-pub const TIOCSSOFTCAR: ::c_int = 0x5482;
-pub const TIOCLINUX: ::c_int = 0x5483;
-pub const TIOCGSERIAL: ::c_int = 0x5484;
-pub const TIOCEXCL: ::c_int = 0x740D;
-pub const TIOCNXCL: ::c_int = 0x740E;
-pub const TIOCSCTTY: ::c_int = 0x5480;
-pub const TIOCGPGRP: ::c_int = 0x40047477;
-pub const TIOCSPGRP: ::c_int = 0x80047476;
-pub const TIOCOUTQ: ::c_int = 0x7472;
-pub const TIOCSTI: ::c_int = 0x5472;
-pub const TIOCGWINSZ: ::c_int = 0x40087468;
-pub const TIOCSWINSZ: ::c_int = 0x80087467;
-pub const TIOCMGET: ::c_int = 0x741D;
-pub const TIOCMBIS: ::c_int = 0x741B;
-pub const TIOCMBIC: ::c_int = 0x741C;
-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;
-
-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 = 0x010;
-pub const TIOCM_SR: ::c_int = 0x020;
-pub const TIOCM_CTS: ::c_int = 0x040;
-pub const TIOCM_CAR: ::c_int = 0x100;
-pub const TIOCM_CD: ::c_int = TIOCM_CAR;
-pub const TIOCM_RNG: ::c_int = 0x200;
-pub const TIOCM_RI: ::c_int = TIOCM_RNG;
-pub const TIOCM_DSR: ::c_int = 0x400;
-
-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_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_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_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_symlink: ::c_long = 4000 + 83;
-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_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_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_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_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_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_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_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;
-
-#[doc(hidden)]
-#[deprecated(
- since = "0.2.55",
- note = "If you are using this report to: \
- https://github.com/rust-lang/libc/issues/665"
-)]
-pub const AF_MAX: ::c_int = 42;
-#[doc(hidden)]
-#[deprecated(
- since = "0.2.55",
- note = "If you are using this report to: \
- https://github.com/rust-lang/libc/issues/665"
-)]
-#[allow(deprecated)]
-pub const PF_MAX: ::c_int = AF_MAX;
diff --git a/libc/src/unix/notbsd/linux/musl/b32/mod.rs b/libc/src/unix/notbsd/linux/musl/b32/mod.rs
deleted file mode 100644
index 4128a8e..0000000
--- a/libc/src/unix/notbsd/linux/musl/b32/mod.rs
+++ /dev/null
@@ -1,62 +0,0 @@
-pub type c_long = i32;
-pub type c_ulong = u32;
-pub type nlink_t = u32;
-pub type blksize_t = ::c_long;
-pub type __u64 = ::c_ulonglong;
-
-s! {
- pub struct pthread_attr_t {
- __size: [u32; 9]
- }
-
- pub struct sigset_t {
- __val: [::c_ulong; 32],
- }
-
- pub struct msghdr {
- pub msg_name: *mut ::c_void,
- pub msg_namelen: ::socklen_t,
- pub msg_iov: *mut ::iovec,
- pub msg_iovlen: ::c_int,
- pub msg_control: *mut ::c_void,
- pub msg_controllen: ::socklen_t,
- pub msg_flags: ::c_int,
- }
-
- pub struct cmsghdr {
- pub cmsg_len: ::socklen_t,
- pub cmsg_level: ::c_int,
- pub cmsg_type: ::c_int,
- }
-
- pub struct sem_t {
- __val: [::c_int; 4],
- }
-}
-
-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;
- pub use self::x86::*;
- } else if #[cfg(any(target_arch = "mips"))] {
- mod mips;
- pub use self::mips::*;
- } 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
deleted file mode 100644
index eafd7a6..0000000
--- a/libc/src/unix/notbsd/linux/musl/b32/powerpc.rs
+++ /dev/null
@@ -1,870 +0,0 @@
-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 const MADV_SOFT_OFFLINE: ::c_int = 101;
-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)]
-#[deprecated(
- since = "0.2.55",
- note = "If you are using this report to: \
- https://github.com/rust-lang/libc/issues/665"
-)]
-pub const AF_MAX: ::c_int = 43;
-#[doc(hidden)]
-#[allow(deprecated)]
-#[deprecated(
- since = "0.2.55",
- note = "If you are using this report to: \
- https://github.com/rust-lang/libc/issues/665"
-)]
-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
deleted file mode 100644
index 3e8579a..0000000
--- a/libc/src/unix/notbsd/linux/musl/b32/x86.rs
+++ /dev/null
@@ -1,952 +0,0 @@
-pub type c_char = i8;
-pub type wchar_t = i32;
-
-s! {
- pub struct stat {
- pub st_dev: ::dev_t,
- __st_dev_padding: ::c_int,
- __st_ino_truncated: ::c_long,
- pub st_mode: ::mode_t,
- pub st_nlink: ::nlink_t,
- pub st_uid: ::uid_t,
- pub st_gid: ::gid_t,
- pub st_rdev: ::dev_t,
- __st_rdev_padding: ::c_int,
- 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,
- pub st_ino: ::ino_t,
- }
-
- pub struct stat64 {
- pub st_dev: ::dev_t,
- __st_dev_padding: ::c_int,
- __st_ino_truncated: ::c_long,
- pub st_mode: ::mode_t,
- pub st_nlink: ::nlink_t,
- pub st_uid: ::uid_t,
- pub st_gid: ::gid_t,
- pub st_rdev: ::dev_t,
- __st_rdev_padding: ::c_int,
- 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,
- pub st_ino: ::ino_t,
- }
-
- 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,
- __unused1: ::c_long,
- __unused2: ::c_long
- }
-
- pub struct shmid_ds {
- pub shm_perm: ::ipc_perm,
- pub shm_segsz: ::size_t,
- pub shm_atime: ::time_t,
- __unused1: ::c_int,
- pub shm_dtime: ::time_t,
- __unused2: ::c_int,
- pub shm_ctime: ::time_t,
- __unused3: ::c_int,
- 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,
- pub msg_stime: ::time_t,
- __unused1: ::c_int,
- pub msg_rtime: ::time_t,
- __unused2: ::c_int,
- pub msg_ctime: ::time_t,
- __unused3: ::c_int,
- __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 mcontext_t {
- __private: [u32; 22]
- }
-
- 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,
- pub f_fsid: ::c_ulong,
- __f_unused: ::c_int,
- pub f_flag: ::c_ulong,
- pub f_namemax: ::c_ulong,
- __f_spare: [::c_int; 6],
- }
-}
-
-s_no_extra_traits!{
- pub struct ucontext_t {
- pub uc_flags: ::c_ulong,
- pub uc_link: *mut ucontext_t,
- pub uc_stack: ::stack_t,
- pub uc_mcontext: mcontext_t,
- pub uc_sigmask: ::sigset_t,
- __private: [u8; 112],
- }
-}
-
-cfg_if! {
- if #[cfg(feature = "extra_traits")] {
- impl PartialEq for ucontext_t {
- fn eq(&self, other: &ucontext_t) -> bool {
- self.uc_flags == other.uc_flags
- && self.uc_link == other.uc_link
- && self.uc_stack == other.uc_stack
- && self.uc_mcontext == other.uc_mcontext
- && self.uc_sigmask == other.uc_sigmask
- && self
- .__private
- .iter()
- .zip(other.__private.iter())
- .all(|(a,b)| a == b)
- }
- }
-
- impl Eq for ucontext_t {}
-
- impl ::fmt::Debug for ucontext_t {
- fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
- f.debug_struct("ucontext_t")
- .field("uc_flags", &self.uc_flags)
- .field("uc_link", &self.uc_link)
- .field("uc_stack", &self.uc_stack)
- .field("uc_mcontext", &self.uc_mcontext)
- .field("uc_sigmask", &self.uc_sigmask)
- // Ignore __private field
- .finish()
- }
- }
-
- impl ::hash::Hash for ucontext_t {
- fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
- self.uc_flags.hash(state);
- self.uc_link.hash(state);
- self.uc_stack.hash(state);
- self.uc_mcontext.hash(state);
- self.uc_sigmask.hash(state);
- self.__private.hash(state);
- }
- }
- }
-}
-
-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;
-pub const O_ASYNC: ::c_int = 0x2000;
-pub const O_LARGEFILE: ::c_int = 0o0100000;
-
-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;
-pub const RLIMIT_NPROC: ::c_int = 6;
-pub const RLIMIT_MEMLOCK: ::c_int = 8;
-pub const RLIMIT_NLIMITS: ::c_int = 15;
-
-pub const MADV_SOFT_OFFLINE: ::c_int = 101;
-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;
-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 = 0x02000;
-pub const MAP_NORESERVE: ::c_int = 0x04000;
-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 = EDEADLK;
-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_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;
-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 = 0x00010000;
-
-pub const MAP_HUGETLB: ::c_int = 0x040000;
-pub const MAP_32BIT: ::c_int = 0x0040;
-
-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 = 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 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_vm86old: ::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_vm86: ::c_long = 166;
-pub const SYS_query_module: ::c_long = 167;
-pub const SYS_poll: ::c_long = 168;
-pub const SYS_nfsservctl: ::c_long = 169;
-pub const SYS_setresgid: ::c_long = 170;
-pub const SYS_getresgid: ::c_long = 171;
-pub const SYS_prctl: ::c_long = 172;
-pub const SYS_rt_sigreturn: ::c_long = 173;
-pub const SYS_rt_sigaction: ::c_long = 174;
-pub const SYS_rt_sigprocmask: ::c_long = 175;
-pub const SYS_rt_sigpending: ::c_long = 176;
-pub const SYS_rt_sigtimedwait: ::c_long = 177;
-pub const SYS_rt_sigqueueinfo: ::c_long = 178;
-pub const SYS_rt_sigsuspend: ::c_long = 179;
-pub const SYS_pread64: ::c_long = 180;
-pub const SYS_pwrite64: ::c_long = 181;
-pub const SYS_chown: ::c_long = 182;
-pub const SYS_getcwd: ::c_long = 183;
-pub const SYS_capget: ::c_long = 184;
-pub const SYS_capset: ::c_long = 185;
-pub const SYS_sigaltstack: ::c_long = 186;
-pub const SYS_sendfile: ::c_long = 187;
-pub const SYS_getpmsg: ::c_long = 188;
-pub const SYS_putpmsg: ::c_long = 189;
-pub const SYS_vfork: ::c_long = 190;
-pub const SYS_ugetrlimit: ::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_lchown32: ::c_long = 198;
-pub const SYS_getuid32: ::c_long = 199;
-pub const SYS_getgid32: ::c_long = 200;
-pub const SYS_geteuid32: ::c_long = 201;
-pub const SYS_getegid32: ::c_long = 202;
-pub const SYS_setreuid32: ::c_long = 203;
-pub const SYS_setregid32: ::c_long = 204;
-pub const SYS_getgroups32: ::c_long = 205;
-pub const SYS_setgroups32: ::c_long = 206;
-pub const SYS_fchown32: ::c_long = 207;
-pub const SYS_setresuid32: ::c_long = 208;
-pub const SYS_getresuid32: ::c_long = 209;
-pub const SYS_setresgid32: ::c_long = 210;
-pub const SYS_getresgid32: ::c_long = 211;
-pub const SYS_chown32: ::c_long = 212;
-pub const SYS_setuid32: ::c_long = 213;
-pub const SYS_setgid32: ::c_long = 214;
-pub const SYS_setfsuid32: ::c_long = 215;
-pub const SYS_setfsgid32: ::c_long = 216;
-pub const SYS_pivot_root: ::c_long = 217;
-pub const SYS_mincore: ::c_long = 218;
-pub const SYS_madvise: ::c_long = 219;
-pub const SYS_getdents64: ::c_long = 220;
-pub const SYS_fcntl64: ::c_long = 221;
-pub const SYS_gettid: ::c_long = 224;
-pub const SYS_readahead: ::c_long = 225;
-pub const SYS_setxattr: ::c_long = 226;
-pub const SYS_lsetxattr: ::c_long = 227;
-pub const SYS_fsetxattr: ::c_long = 228;
-pub const SYS_getxattr: ::c_long = 229;
-pub const SYS_lgetxattr: ::c_long = 230;
-pub const SYS_fgetxattr: ::c_long = 231;
-pub const SYS_listxattr: ::c_long = 232;
-pub const SYS_llistxattr: ::c_long = 233;
-pub const SYS_flistxattr: ::c_long = 234;
-pub const SYS_removexattr: ::c_long = 235;
-pub const SYS_lremovexattr: ::c_long = 236;
-pub const SYS_fremovexattr: ::c_long = 237;
-pub const SYS_tkill: ::c_long = 238;
-pub const SYS_sendfile64: ::c_long = 239;
-pub const SYS_futex: ::c_long = 240;
-pub const SYS_sched_setaffinity: ::c_long = 241;
-pub const SYS_sched_getaffinity: ::c_long = 242;
-pub const SYS_set_thread_area: ::c_long = 243;
-pub const SYS_get_thread_area: ::c_long = 244;
-pub const SYS_io_setup: ::c_long = 245;
-pub const SYS_io_destroy: ::c_long = 246;
-pub const SYS_io_getevents: ::c_long = 247;
-pub const SYS_io_submit: ::c_long = 248;
-pub const SYS_io_cancel: ::c_long = 249;
-pub const SYS_fadvise64: ::c_long = 250;
-pub const SYS_exit_group: ::c_long = 252;
-pub const SYS_lookup_dcookie: ::c_long = 253;
-pub const SYS_epoll_create: ::c_long = 254;
-pub const SYS_epoll_ctl: ::c_long = 255;
-pub const SYS_epoll_wait: ::c_long = 256;
-pub const SYS_remap_file_pages: ::c_long = 257;
-pub const SYS_set_tid_address: ::c_long = 258;
-pub const SYS_timer_create: ::c_long = 259;
-pub const SYS_timer_settime: ::c_long = 260;
-pub const SYS_timer_gettime: ::c_long = 261;
-pub const SYS_timer_getoverrun: ::c_long = 262;
-pub const SYS_timer_delete: ::c_long = 263;
-pub const SYS_clock_settime: ::c_long = 264;
-pub const SYS_clock_gettime: ::c_long = 265;
-pub const SYS_clock_getres: ::c_long = 266;
-pub const SYS_clock_nanosleep: ::c_long = 267;
-pub const SYS_statfs64: ::c_long = 268;
-pub const SYS_fstatfs64: ::c_long = 269;
-pub const SYS_tgkill: ::c_long = 270;
-pub const SYS_utimes: ::c_long = 271;
-pub const SYS_fadvise64_64: ::c_long = 272;
-pub const SYS_vserver: ::c_long = 273;
-pub const SYS_mbind: ::c_long = 274;
-pub const SYS_get_mempolicy: ::c_long = 275;
-pub const SYS_set_mempolicy: ::c_long = 276;
-pub const SYS_mq_open: ::c_long = 277;
-pub const SYS_mq_unlink: ::c_long = 278;
-pub const SYS_mq_timedsend: ::c_long = 279;
-pub const SYS_mq_timedreceive: ::c_long = 280;
-pub const SYS_mq_notify: ::c_long = 281;
-pub const SYS_mq_getsetattr: ::c_long = 282;
-pub const SYS_kexec_load: ::c_long = 283;
-pub const SYS_waitid: ::c_long = 284;
-pub const SYS_add_key: ::c_long = 286;
-pub const SYS_request_key: ::c_long = 287;
-pub const SYS_keyctl: ::c_long = 288;
-pub const SYS_ioprio_set: ::c_long = 289;
-pub const SYS_ioprio_get: ::c_long = 290;
-pub const SYS_inotify_init: ::c_long = 291;
-pub const SYS_inotify_add_watch: ::c_long = 292;
-pub const SYS_inotify_rm_watch: ::c_long = 293;
-pub const SYS_migrate_pages: ::c_long = 294;
-pub const SYS_openat: ::c_long = 295;
-pub const SYS_mkdirat: ::c_long = 296;
-pub const SYS_mknodat: ::c_long = 297;
-pub const SYS_fchownat: ::c_long = 298;
-pub const SYS_futimesat: ::c_long = 299;
-pub const SYS_fstatat64: ::c_long = 300;
-pub const SYS_unlinkat: ::c_long = 301;
-pub const SYS_renameat: ::c_long = 302;
-pub const SYS_linkat: ::c_long = 303;
-pub const SYS_symlinkat: ::c_long = 304;
-pub const SYS_readlinkat: ::c_long = 305;
-pub const SYS_fchmodat: ::c_long = 306;
-pub const SYS_faccessat: ::c_long = 307;
-pub const SYS_pselect6: ::c_long = 308;
-pub const SYS_ppoll: ::c_long = 309;
-pub const SYS_unshare: ::c_long = 310;
-pub const SYS_set_robust_list: ::c_long = 311;
-pub const SYS_get_robust_list: ::c_long = 312;
-pub const SYS_splice: ::c_long = 313;
-pub const SYS_sync_file_range: ::c_long = 314;
-pub const SYS_tee: ::c_long = 315;
-pub const SYS_vmsplice: ::c_long = 316;
-pub const SYS_move_pages: ::c_long = 317;
-pub const SYS_getcpu: ::c_long = 318;
-pub const SYS_epoll_pwait: ::c_long = 319;
-pub const SYS_utimensat: ::c_long = 320;
-pub const SYS_signalfd: ::c_long = 321;
-pub const SYS_timerfd_create: ::c_long = 322;
-pub const SYS_eventfd: ::c_long = 323;
-pub const SYS_fallocate: ::c_long = 324;
-pub const SYS_timerfd_settime: ::c_long = 325;
-pub const SYS_timerfd_gettime: ::c_long = 326;
-pub const SYS_signalfd4: ::c_long = 327;
-pub const SYS_eventfd2: ::c_long = 328;
-pub const SYS_epoll_create1: ::c_long = 329;
-pub const SYS_dup3: ::c_long = 330;
-pub const SYS_pipe2: ::c_long = 331;
-pub const SYS_inotify_init1: ::c_long = 332;
-pub const SYS_preadv: ::c_long = 333;
-pub const SYS_pwritev: ::c_long = 334;
-pub const SYS_rt_tgsigqueueinfo: ::c_long = 335;
-pub const SYS_perf_event_open: ::c_long = 336;
-pub const SYS_recvmmsg: ::c_long = 337;
-pub const SYS_fanotify_init: ::c_long = 338;
-pub const SYS_fanotify_mark: ::c_long = 339;
-pub const SYS_prlimit64: ::c_long = 340;
-pub const SYS_name_to_handle_at: ::c_long = 341;
-pub const SYS_open_by_handle_at: ::c_long = 342;
-pub const SYS_clock_adjtime: ::c_long = 343;
-pub const SYS_syncfs: ::c_long = 344;
-pub const SYS_sendmmsg: ::c_long = 345;
-pub const SYS_setns: ::c_long = 346;
-pub const SYS_process_vm_readv: ::c_long = 347;
-pub const SYS_process_vm_writev: ::c_long = 348;
-pub const SYS_kcmp: ::c_long = 349;
-pub const SYS_finit_module: ::c_long = 350;
-pub const SYS_sched_setattr: ::c_long = 351;
-pub const SYS_sched_getattr: ::c_long = 352;
-pub const SYS_renameat2: ::c_long = 353;
-pub const SYS_seccomp: ::c_long = 354;
-pub const SYS_getrandom: ::c_long = 355;
-pub const SYS_memfd_create: ::c_long = 356;
-pub const SYS_bpf: ::c_long = 357;
-pub const SYS_execveat: ::c_long = 358;
-pub const SYS_socket: ::c_long = 359;
-pub const SYS_socketpair: ::c_long = 360;
-pub const SYS_bind: ::c_long = 361;
-pub const SYS_connect: ::c_long = 362;
-pub const SYS_listen: ::c_long = 363;
-pub const SYS_accept4: ::c_long = 364;
-pub const SYS_getsockopt: ::c_long = 365;
-pub const SYS_setsockopt: ::c_long = 366;
-pub const SYS_getsockname: ::c_long = 367;
-pub const SYS_getpeername: ::c_long = 368;
-pub const SYS_sendto: ::c_long = 369;
-pub const SYS_sendmsg: ::c_long = 370;
-pub const SYS_recvfrom: ::c_long = 371;
-pub const SYS_recvmsg: ::c_long = 372;
-pub const SYS_shutdown: ::c_long = 373;
-pub const SYS_userfaultfd: ::c_long = 374;
-pub const SYS_membarrier: ::c_long = 375;
-pub const SYS_mlock2: ::c_long = 376;
-pub const SYS_copy_file_range: ::c_long = 377;
-pub const SYS_preadv2: ::c_long = 378;
-pub const SYS_pwritev2: ::c_long = 379;
-// FIXME syscalls 380-382 have been added in musl 1.16
-// See discussion https://github.com/rust-lang/libc/pull/699
-
-// offsets in user_regs_structs, from sys/reg.h
-pub const EBX: ::c_int = 0;
-pub const ECX: ::c_int = 1;
-pub const EDX: ::c_int = 2;
-pub const ESI: ::c_int = 3;
-pub const EDI: ::c_int = 4;
-pub const EBP: ::c_int = 5;
-pub const EAX: ::c_int = 6;
-pub const DS: ::c_int = 7;
-pub const ES: ::c_int = 8;
-pub const FS: ::c_int = 9;
-pub const GS: ::c_int = 10;
-pub const ORIG_EAX: ::c_int = 11;
-pub const EIP: ::c_int = 12;
-pub const CS: ::c_int = 13;
-pub const EFL: ::c_int = 14;
-pub const UESP: ::c_int = 15;
-pub const SS: ::c_int = 16;
-
-#[doc(hidden)]
-#[deprecated(
- since = "0.2.55",
- note = "If you are using this report to: \
- https://github.com/rust-lang/libc/issues/665"
-)]
-pub const AF_MAX: ::c_int = 45;
-#[doc(hidden)]
-#[allow(deprecated)]
-#[deprecated(
- since = "0.2.55",
- note = "If you are using this report to: \
- https://github.com/rust-lang/libc/issues/665"
-)]
-pub const PF_MAX: ::c_int = AF_MAX;
diff --git a/libc/src/unix/notbsd/linux/musl/b64/aarch64.rs b/libc/src/unix/notbsd/linux/musl/b64/aarch64.rs
deleted file mode 100644
index 16cb46d..0000000
--- a/libc/src/unix/notbsd/linux/musl/b64/aarch64.rs
+++ /dev/null
@@ -1,491 +0,0 @@
-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;
-
-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,
- __pad0: ::c_ulong,
- pub st_size: ::off_t,
- pub st_blksize: ::blksize_t,
- __pad1: ::c_int,
- 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_uint; 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,
- __pad0: ::c_ulong,
- pub st_size: ::off_t,
- pub st_blksize: ::blksize_t,
- __pad1: ::c_int,
- 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_uint; 2],
- }
-
- pub struct ipc_perm {
- pub __ipc_perm_key: ::key_t,
- pub uid: ::uid_t,
- pub gid: ::gid_t,
- pub cuid: ::uid_t,
- pub cgid: ::gid_t,
- pub mode: ::mode_t,
- pub __seq: ::c_ushort,
- __unused1: ::c_ulong,
- __unused2: ::c_ulong,
- }
-}
-
-pub const O_DIRECT: ::c_int = 0x10000;
-pub const O_DIRECTORY: ::c_int = 0x4000;
-pub const O_LARGEFILE: ::c_int = 0x20000;
-pub const O_NOFOLLOW: ::c_int = 0x8000;
-
-pub const MINSIGSTKSZ: ::size_t = 6144;
-pub const SIGSTKSZ: ::size_t = 12288;
-
-#[doc(hidden)]
-#[deprecated(
- since = "0.2.55",
- note = "If you are using this report to: \
- https://github.com/rust-lang/libc/issues/665"
-)]
-pub const PF_MAX: ::c_int = 45;
-#[doc(hidden)]
-#[deprecated(
- since = "0.2.55",
- note = "If you are using this report to: \
- https://github.com/rust-lang/libc/issues/665"
-)]
-#[allow(deprecated)]
-pub const AF_MAX: ::c_int = PF_MAX;
-
-pub const MADV_SOFT_OFFLINE: ::c_int = 101;
-pub const SYS_io_setup: ::c_long = 0;
-pub const SYS_io_destroy: ::c_long = 1;
-pub const SYS_io_submit: ::c_long = 2;
-pub const SYS_io_cancel: ::c_long = 3;
-pub const SYS_io_getevents: ::c_long = 4;
-pub const SYS_setxattr: ::c_long = 5;
-pub const SYS_lsetxattr: ::c_long = 6;
-pub const SYS_fsetxattr: ::c_long = 7;
-pub const SYS_getxattr: ::c_long = 8;
-pub const SYS_lgetxattr: ::c_long = 9;
-pub const SYS_fgetxattr: ::c_long = 10;
-pub const SYS_listxattr: ::c_long = 11;
-pub const SYS_llistxattr: ::c_long = 12;
-pub const SYS_flistxattr: ::c_long = 13;
-pub const SYS_removexattr: ::c_long = 14;
-pub const SYS_lremovexattr: ::c_long = 15;
-pub const SYS_fremovexattr: ::c_long = 16;
-pub const SYS_getcwd: ::c_long = 17;
-pub const SYS_lookup_dcookie: ::c_long = 18;
-pub const SYS_eventfd2: ::c_long = 19;
-pub const SYS_epoll_create1: ::c_long = 20;
-pub const SYS_epoll_ctl: ::c_long = 21;
-pub const SYS_epoll_pwait: ::c_long = 22;
-pub const SYS_dup: ::c_long = 23;
-pub const SYS_dup3: ::c_long = 24;
-pub const SYS_inotify_init1: ::c_long = 26;
-pub const SYS_inotify_add_watch: ::c_long = 27;
-pub const SYS_inotify_rm_watch: ::c_long = 28;
-pub const SYS_ioctl: ::c_long = 29;
-pub const SYS_ioprio_set: ::c_long = 30;
-pub const SYS_ioprio_get: ::c_long = 31;
-pub const SYS_flock: ::c_long = 32;
-pub const SYS_mknodat: ::c_long = 33;
-pub const SYS_mkdirat: ::c_long = 34;
-pub const SYS_unlinkat: ::c_long = 35;
-pub const SYS_symlinkat: ::c_long = 36;
-pub const SYS_linkat: ::c_long = 37;
-pub const SYS_renameat: ::c_long = 38;
-pub const SYS_umount2: ::c_long = 39;
-pub const SYS_mount: ::c_long = 40;
-pub const SYS_pivot_root: ::c_long = 41;
-pub const SYS_nfsservctl: ::c_long = 42;
-pub const SYS_fallocate: ::c_long = 47;
-pub const SYS_faccessat: ::c_long = 48;
-pub const SYS_chdir: ::c_long = 49;
-pub const SYS_fchdir: ::c_long = 50;
-pub const SYS_chroot: ::c_long = 51;
-pub const SYS_fchmod: ::c_long = 52;
-pub const SYS_fchmodat: ::c_long = 53;
-pub const SYS_fchownat: ::c_long = 54;
-pub const SYS_fchown: ::c_long = 55;
-pub const SYS_openat: ::c_long = 56;
-pub const SYS_close: ::c_long = 57;
-pub const SYS_vhangup: ::c_long = 58;
-pub const SYS_pipe2: ::c_long = 59;
-pub const SYS_quotactl: ::c_long = 60;
-pub const SYS_getdents64: ::c_long = 61;
-pub const SYS_read: ::c_long = 63;
-pub const SYS_write: ::c_long = 64;
-pub const SYS_readv: ::c_long = 65;
-pub const SYS_writev: ::c_long = 66;
-pub const SYS_pread64: ::c_long = 67;
-pub const SYS_pwrite64: ::c_long = 68;
-pub const SYS_preadv: ::c_long = 69;
-pub const SYS_pwritev: ::c_long = 70;
-pub const SYS_pselect6: ::c_long = 72;
-pub const SYS_ppoll: ::c_long = 73;
-pub const SYS_signalfd4: ::c_long = 74;
-pub const SYS_vmsplice: ::c_long = 75;
-pub const SYS_splice: ::c_long = 76;
-pub const SYS_tee: ::c_long = 77;
-pub const SYS_readlinkat: ::c_long = 78;
-pub const SYS_sync: ::c_long = 81;
-pub const SYS_fsync: ::c_long = 82;
-pub const SYS_fdatasync: ::c_long = 83;
-pub const SYS_sync_file_range: ::c_long = 84;
-pub const SYS_timerfd_create: ::c_long = 85;
-pub const SYS_timerfd_settime: ::c_long = 86;
-pub const SYS_timerfd_gettime: ::c_long = 87;
-pub const SYS_utimensat: ::c_long = 88;
-pub const SYS_acct: ::c_long = 89;
-pub const SYS_capget: ::c_long = 90;
-pub const SYS_capset: ::c_long = 91;
-pub const SYS_personality: ::c_long = 92;
-pub const SYS_exit: ::c_long = 93;
-pub const SYS_exit_group: ::c_long = 94;
-pub const SYS_waitid: ::c_long = 95;
-pub const SYS_set_tid_address: ::c_long = 96;
-pub const SYS_unshare: ::c_long = 97;
-pub const SYS_futex: ::c_long = 98;
-pub const SYS_set_robust_list: ::c_long = 99;
-pub const SYS_get_robust_list: ::c_long = 100;
-pub const SYS_nanosleep: ::c_long = 101;
-pub const SYS_getitimer: ::c_long = 102;
-pub const SYS_setitimer: ::c_long = 103;
-pub const SYS_kexec_load: ::c_long = 104;
-pub const SYS_init_module: ::c_long = 105;
-pub const SYS_delete_module: ::c_long = 106;
-pub const SYS_timer_create: ::c_long = 107;
-pub const SYS_timer_gettime: ::c_long = 108;
-pub const SYS_timer_getoverrun: ::c_long = 109;
-pub const SYS_timer_settime: ::c_long = 110;
-pub const SYS_timer_delete: ::c_long = 111;
-pub const SYS_clock_settime: ::c_long = 112;
-pub const SYS_clock_gettime: ::c_long = 113;
-pub const SYS_clock_getres: ::c_long = 114;
-pub const SYS_clock_nanosleep: ::c_long = 115;
-pub const SYS_syslog: ::c_long = 116;
-pub const SYS_ptrace: ::c_long = 117;
-pub const SYS_sched_setparam: ::c_long = 118;
-pub const SYS_sched_setscheduler: ::c_long = 119;
-pub const SYS_sched_getscheduler: ::c_long = 120;
-pub const SYS_sched_getparam: ::c_long = 121;
-pub const SYS_sched_setaffinity: ::c_long = 122;
-pub const SYS_sched_getaffinity: ::c_long = 123;
-pub const SYS_sched_yield: ::c_long = 124;
-pub const SYS_sched_get_priority_max: ::c_long = 125;
-pub const SYS_sched_get_priority_min: ::c_long = 126;
-pub const SYS_sched_rr_get_interval: ::c_long = 127;
-pub const SYS_restart_syscall: ::c_long = 128;
-pub const SYS_kill: ::c_long = 129;
-pub const SYS_tkill: ::c_long = 130;
-pub const SYS_tgkill: ::c_long = 131;
-pub const SYS_sigaltstack: ::c_long = 132;
-pub const SYS_rt_sigsuspend: ::c_long = 133;
-pub const SYS_rt_sigaction: ::c_long = 134;
-pub const SYS_rt_sigprocmask: ::c_long = 135;
-pub const SYS_rt_sigpending: ::c_long = 136;
-pub const SYS_rt_sigtimedwait: ::c_long = 137;
-pub const SYS_rt_sigqueueinfo: ::c_long = 138;
-pub const SYS_rt_sigreturn: ::c_long = 139;
-pub const SYS_setpriority: ::c_long = 140;
-pub const SYS_getpriority: ::c_long = 141;
-pub const SYS_reboot: ::c_long = 142;
-pub const SYS_setregid: ::c_long = 143;
-pub const SYS_setgid: ::c_long = 144;
-pub const SYS_setreuid: ::c_long = 145;
-pub const SYS_setuid: ::c_long = 146;
-pub const SYS_setresuid: ::c_long = 147;
-pub const SYS_getresuid: ::c_long = 148;
-pub const SYS_setresgid: ::c_long = 149;
-pub const SYS_getresgid: ::c_long = 150;
-pub const SYS_setfsuid: ::c_long = 151;
-pub const SYS_setfsgid: ::c_long = 152;
-pub const SYS_times: ::c_long = 153;
-pub const SYS_setpgid: ::c_long = 154;
-pub const SYS_getpgid: ::c_long = 155;
-pub const SYS_getsid: ::c_long = 156;
-pub const SYS_setsid: ::c_long = 157;
-pub const SYS_getgroups: ::c_long = 158;
-pub const SYS_setgroups: ::c_long = 159;
-pub const SYS_uname: ::c_long = 160;
-pub const SYS_sethostname: ::c_long = 161;
-pub const SYS_setdomainname: ::c_long = 162;
-pub const SYS_getrlimit: ::c_long = 163;
-pub const SYS_setrlimit: ::c_long = 164;
-pub const SYS_getrusage: ::c_long = 165;
-pub const SYS_umask: ::c_long = 166;
-pub const SYS_prctl: ::c_long = 167;
-pub const SYS_getcpu: ::c_long = 168;
-pub const SYS_gettimeofday: ::c_long = 169;
-pub const SYS_settimeofday: ::c_long = 170;
-pub const SYS_adjtimex: ::c_long = 171;
-pub const SYS_getpid: ::c_long = 172;
-pub const SYS_getppid: ::c_long = 173;
-pub const SYS_getuid: ::c_long = 174;
-pub const SYS_geteuid: ::c_long = 175;
-pub const SYS_getgid: ::c_long = 176;
-pub const SYS_getegid: ::c_long = 177;
-pub const SYS_gettid: ::c_long = 178;
-pub const SYS_sysinfo: ::c_long = 179;
-pub const SYS_mq_open: ::c_long = 180;
-pub const SYS_mq_unlink: ::c_long = 181;
-pub const SYS_mq_timedsend: ::c_long = 182;
-pub const SYS_mq_timedreceive: ::c_long = 183;
-pub const SYS_mq_notify: ::c_long = 184;
-pub const SYS_mq_getsetattr: ::c_long = 185;
-pub const SYS_msgget: ::c_long = 186;
-pub const SYS_msgctl: ::c_long = 187;
-pub const SYS_msgrcv: ::c_long = 188;
-pub const SYS_msgsnd: ::c_long = 189;
-pub const SYS_semget: ::c_long = 190;
-pub const SYS_semctl: ::c_long = 191;
-pub const SYS_semtimedop: ::c_long = 192;
-pub const SYS_semop: ::c_long = 193;
-pub const SYS_shmget: ::c_long = 194;
-pub const SYS_shmctl: ::c_long = 195;
-pub const SYS_shmat: ::c_long = 196;
-pub const SYS_shmdt: ::c_long = 197;
-pub const SYS_socket: ::c_long = 198;
-pub const SYS_socketpair: ::c_long = 199;
-pub const SYS_bind: ::c_long = 200;
-pub const SYS_listen: ::c_long = 201;
-pub const SYS_accept: ::c_long = 202;
-pub const SYS_connect: ::c_long = 203;
-pub const SYS_getsockname: ::c_long = 204;
-pub const SYS_getpeername: ::c_long = 205;
-pub const SYS_sendto: ::c_long = 206;
-pub const SYS_recvfrom: ::c_long = 207;
-pub const SYS_setsockopt: ::c_long = 208;
-pub const SYS_getsockopt: ::c_long = 209;
-pub const SYS_shutdown: ::c_long = 210;
-pub const SYS_sendmsg: ::c_long = 211;
-pub const SYS_recvmsg: ::c_long = 212;
-pub const SYS_readahead: ::c_long = 213;
-pub const SYS_brk: ::c_long = 214;
-pub const SYS_munmap: ::c_long = 215;
-pub const SYS_mremap: ::c_long = 216;
-pub const SYS_add_key: ::c_long = 217;
-pub const SYS_request_key: ::c_long = 218;
-pub const SYS_keyctl: ::c_long = 219;
-pub const SYS_clone: ::c_long = 220;
-pub const SYS_execve: ::c_long = 221;
-pub const SYS_swapon: ::c_long = 224;
-pub const SYS_swapoff: ::c_long = 225;
-pub const SYS_mprotect: ::c_long = 226;
-pub const SYS_msync: ::c_long = 227;
-pub const SYS_mlock: ::c_long = 228;
-pub const SYS_munlock: ::c_long = 229;
-pub const SYS_mlockall: ::c_long = 230;
-pub const SYS_munlockall: ::c_long = 231;
-pub const SYS_mincore: ::c_long = 232;
-pub const SYS_madvise: ::c_long = 233;
-pub const SYS_remap_file_pages: ::c_long = 234;
-pub const SYS_mbind: ::c_long = 235;
-pub const SYS_get_mempolicy: ::c_long = 236;
-pub const SYS_set_mempolicy: ::c_long = 237;
-pub const SYS_migrate_pages: ::c_long = 238;
-pub const SYS_move_pages: ::c_long = 239;
-pub const SYS_rt_tgsigqueueinfo: ::c_long = 240;
-pub const SYS_perf_event_open: ::c_long = 241;
-pub const SYS_accept4: ::c_long = 242;
-pub const SYS_recvmmsg: ::c_long = 243;
-pub const SYS_wait4: ::c_long = 260;
-pub const SYS_prlimit64: ::c_long = 261;
-pub const SYS_fanotify_init: ::c_long = 262;
-pub const SYS_fanotify_mark: ::c_long = 263;
-pub const SYS_name_to_handle_at: ::c_long = 264;
-pub const SYS_open_by_handle_at: ::c_long = 265;
-pub const SYS_clock_adjtime: ::c_long = 266;
-pub const SYS_syncfs: ::c_long = 267;
-pub const SYS_setns: ::c_long = 268;
-pub const SYS_sendmmsg: ::c_long = 269;
-pub const SYS_process_vm_readv: ::c_long = 270;
-pub const SYS_process_vm_writev: ::c_long = 271;
-pub const SYS_kcmp: ::c_long = 272;
-pub const SYS_finit_module: ::c_long = 273;
-pub const SYS_sched_setattr: ::c_long = 274;
-pub const SYS_sched_getattr: ::c_long = 275;
-pub const SYS_renameat2: ::c_long = 276;
-pub const SYS_seccomp: ::c_long = 277;
-pub const SYS_getrandom: ::c_long = 278;
-pub const SYS_memfd_create: ::c_long = 279;
-pub const SYS_bpf: ::c_long = 280;
-pub const SYS_execveat: ::c_long = 281;
-pub const SYS_userfaultfd: ::c_long = 282;
-pub const SYS_membarrier: ::c_long = 283;
-pub const SYS_mlock2: ::c_long = 284;
-pub const SYS_copy_file_range: ::c_long = 285;
-pub const SYS_preadv2: ::c_long = 286;
-pub const SYS_pwritev2: ::c_long = 287;
-pub const SYS_pkey_mprotect: ::c_long = 288;
-pub const SYS_pkey_alloc: ::c_long = 289;
-pub const SYS_pkey_free: ::c_long = 290;
-
-pub const RLIMIT_NLIMITS: ::c_int = 15;
-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
deleted file mode 100644
index 34b3766..0000000
--- a/libc/src/unix/notbsd/linux/musl/b64/mod.rs
+++ /dev/null
@@ -1,328 +0,0 @@
-pub type c_long = i64;
-pub type c_ulong = u64;
-
-s! {
- 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,
- pub f_fsid: ::c_ulong,
- pub f_flag: ::c_ulong,
- pub f_namemax: ::c_ulong,
- __f_spare: [::c_int; 6],
- }
-
- pub struct stack_t {
- pub ss_sp: *mut ::c_void,
- pub ss_flags: ::c_int,
- pub ss_size: ::size_t
- }
-
- pub struct pthread_attr_t {
- __size: [u64; 7]
- }
-
- pub struct sigset_t {
- __val: [::c_ulong; 16],
- }
-
- pub struct shmid_ds {
- pub shm_perm: ::ipc_perm,
- pub shm_segsz: ::size_t,
- pub shm_atime: ::time_t,
- pub shm_dtime: ::time_t,
- pub shm_ctime: ::time_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,
- pub msg_stime: ::time_t,
- pub msg_rtime: ::time_t,
- 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 msghdr {
- 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,
- #[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,
- }
-
- pub struct sem_t {
- __val: [::c_int; 8],
- }
-
- 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 const __SIZEOF_PTHREAD_RWLOCK_T: usize = 56;
-pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 40;
-
-pub const O_ASYNC: ::c_int = 0x2000;
-
-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 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 = 0x02000;
-pub const MAP_NORESERVE: ::c_int = 0x04000;
-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 ENAMETOOLONG: ::c_int = 36;
-pub const ENOLCK: ::c_int = 37;
-pub const ENOSYS: ::c_int = 38;
-pub const ENOTEMPTY: ::c_int = 39;
-pub const ELOOP: ::c_int = 40;
-pub const ENOMSG: ::c_int = 42;
-pub const EIDRM: ::c_int = 43;
-pub const ECHRNG: ::c_int = 44;
-pub const EL2NSYNC: ::c_int = 45;
-pub const EL3HLT: ::c_int = 46;
-pub const EL3RST: ::c_int = 47;
-pub const ELNRNG: ::c_int = 48;
-pub const EUNATCH: ::c_int = 49;
-pub const ENOCSI: ::c_int = 50;
-pub const EL2HLT: ::c_int = 51;
-pub const EBADE: ::c_int = 52;
-pub const EBADR: ::c_int = 53;
-pub const EXFULL: ::c_int = 54;
-pub const ENOANO: ::c_int = 55;
-pub const EBADRQC: ::c_int = 56;
-pub const EBADSLT: ::c_int = 57;
-pub const EMULTIHOP: ::c_int = 72;
-pub const 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_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 MAP_HUGETLB: ::c_int = 0x040000;
-
-pub const F_GETLK: ::c_int = 5;
-pub const F_GETOWN: ::c_int = 9;
-pub const F_SETLK: ::c_int = 6;
-pub const F_SETLKW: ::c_int = 7;
-pub const F_SETOWN: ::c_int = 8;
-
-pub const VEOF: usize = 4;
-
-pub const POLLWRNORM: ::c_short = 0x100;
-pub const POLLWRBAND: ::c_short = 0x200;
-
-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::*;
- } else {
- // Unknown target_arch
- }
-}
diff --git a/libc/src/unix/notbsd/linux/musl/b64/powerpc64.rs b/libc/src/unix/notbsd/linux/musl/b64/powerpc64.rs
deleted file mode 100644
index 4a8df27..0000000
--- a/libc/src/unix/notbsd/linux/musl/b64/powerpc64.rs
+++ /dev/null
@@ -1,587 +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 MADV_SOFT_OFFLINE: ::c_int = 101;
-pub const MAP_32BIT: ::c_int = 0x0040;
-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 = 10240;
-pub const MINSIGSTKSZ: ::size_t = 4096;
-
-#[doc(hidden)]
-#[deprecated(
- since = "0.2.55",
- note = "If you are using this report to: \
- https://github.com/rust-lang/libc/issues/665"
-)]
-pub const AF_MAX: ::c_int = 45;
-#[doc(hidden)]
-#[deprecated(
- since = "0.2.55",
- note = "If you are using this report to: \
- https://github.com/rust-lang/libc/issues/665"
-)]
-#[allow(deprecated)]
-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
deleted file mode 100644
index df0ce40..0000000
--- a/libc/src/unix/notbsd/linux/musl/b64/x86_64.rs
+++ /dev/null
@@ -1,649 +0,0 @@
-pub type c_char = i8;
-pub type wchar_t = i32;
-pub type nlink_t = u64;
-pub type blksize_t = ::c_long;
-pub type __u64 = ::c_ulonglong;
-
-s! {
- pub struct stat {
- pub st_dev: ::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 mcontext_t {
- __private: [u64; 32],
- }
-
- 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
- }
-}
-
-s_no_extra_traits!{
- pub struct ucontext_t {
- pub uc_flags: ::c_ulong,
- pub uc_link: *mut ucontext_t,
- pub uc_stack: ::stack_t,
- pub uc_mcontext: mcontext_t,
- pub uc_sigmask: ::sigset_t,
- __private: [u8; 512],
- }
-}
-
-cfg_if! {
- if #[cfg(feature = "extra_traits")] {
- impl PartialEq for ucontext_t {
- fn eq(&self, other: &ucontext_t) -> bool {
- self.uc_flags == other.uc_flags
- && self.uc_link == other.uc_link
- && self.uc_stack == other.uc_stack
- && self.uc_mcontext == other.uc_mcontext
- && self.uc_sigmask == other.uc_sigmask
- && self
- .__private
- .iter()
- .zip(other.__private.iter())
- .all(|(a,b)| a == b)
- }
- }
-
- impl Eq for ucontext_t {}
-
- impl ::fmt::Debug for ucontext_t {
- fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
- f.debug_struct("ucontext_t")
- .field("uc_flags", &self.uc_flags)
- .field("uc_link", &self.uc_link)
- .field("uc_stack", &self.uc_stack)
- .field("uc_mcontext", &self.uc_mcontext)
- .field("uc_sigmask", &self.uc_sigmask)
- // Ignore __private field
- .finish()
- }
- }
-
- impl ::hash::Hash for ucontext_t {
- fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
- self.uc_flags.hash(state);
- self.uc_link.hash(state);
- self.uc_stack.hash(state);
- self.uc_mcontext.hash(state);
- self.uc_sigmask.hash(state);
- self.__private.hash(state);
- }
- }
- }
-}
-
-// Syscall table
-
-pub const SYS_read: ::c_long = 0;
-pub const SYS_write: ::c_long = 1;
-pub const SYS_open: ::c_long = 2;
-pub const SYS_close: ::c_long = 3;
-pub const SYS_stat: ::c_long = 4;
-pub const SYS_fstat: ::c_long = 5;
-pub const SYS_lstat: ::c_long = 6;
-pub const SYS_poll: ::c_long = 7;
-pub const SYS_lseek: ::c_long = 8;
-pub const SYS_mmap: ::c_long = 9;
-pub const SYS_mprotect: ::c_long = 10;
-pub const SYS_munmap: ::c_long = 11;
-pub const SYS_brk: ::c_long = 12;
-pub const SYS_rt_sigaction: ::c_long = 13;
-pub const SYS_rt_sigprocmask: ::c_long = 14;
-pub const SYS_rt_sigreturn: ::c_long = 15;
-pub const SYS_ioctl: ::c_long = 16;
-pub const SYS_pread64: ::c_long = 17;
-pub const SYS_pwrite64: ::c_long = 18;
-pub const SYS_readv: ::c_long = 19;
-pub const SYS_writev: ::c_long = 20;
-pub const SYS_access: ::c_long = 21;
-pub const SYS_pipe: ::c_long = 22;
-pub const SYS_select: ::c_long = 23;
-pub const SYS_sched_yield: ::c_long = 24;
-pub const SYS_mremap: ::c_long = 25;
-pub const SYS_msync: ::c_long = 26;
-pub const SYS_mincore: ::c_long = 27;
-pub const SYS_madvise: ::c_long = 28;
-pub const SYS_shmget: ::c_long = 29;
-pub const SYS_shmat: ::c_long = 30;
-pub const SYS_shmctl: ::c_long = 31;
-pub const SYS_dup: ::c_long = 32;
-pub const SYS_dup2: ::c_long = 33;
-pub const SYS_pause: ::c_long = 34;
-pub const SYS_nanosleep: ::c_long = 35;
-pub const SYS_getitimer: ::c_long = 36;
-pub const SYS_alarm: ::c_long = 37;
-pub const SYS_setitimer: ::c_long = 38;
-pub const SYS_getpid: ::c_long = 39;
-pub const SYS_sendfile: ::c_long = 40;
-pub const SYS_socket: ::c_long = 41;
-pub const SYS_connect: ::c_long = 42;
-pub const SYS_accept: ::c_long = 43;
-pub const SYS_sendto: ::c_long = 44;
-pub const SYS_recvfrom: ::c_long = 45;
-pub const SYS_sendmsg: ::c_long = 46;
-pub const SYS_recvmsg: ::c_long = 47;
-pub const SYS_shutdown: ::c_long = 48;
-pub const SYS_bind: ::c_long = 49;
-pub const SYS_listen: ::c_long = 50;
-pub const SYS_getsockname: ::c_long = 51;
-pub const SYS_getpeername: ::c_long = 52;
-pub const SYS_socketpair: ::c_long = 53;
-pub const SYS_setsockopt: ::c_long = 54;
-pub const SYS_getsockopt: ::c_long = 55;
-pub const SYS_clone: ::c_long = 56;
-pub const SYS_fork: ::c_long = 57;
-pub const SYS_vfork: ::c_long = 58;
-pub const SYS_execve: ::c_long = 59;
-pub const SYS_exit: ::c_long = 60;
-pub const SYS_wait4: ::c_long = 61;
-pub const SYS_kill: ::c_long = 62;
-pub const SYS_uname: ::c_long = 63;
-pub const SYS_semget: ::c_long = 64;
-pub const SYS_semop: ::c_long = 65;
-pub const SYS_semctl: ::c_long = 66;
-pub const SYS_shmdt: ::c_long = 67;
-pub const SYS_msgget: ::c_long = 68;
-pub const SYS_msgsnd: ::c_long = 69;
-pub const SYS_msgrcv: ::c_long = 70;
-pub const SYS_msgctl: ::c_long = 71;
-pub const SYS_fcntl: ::c_long = 72;
-pub const SYS_flock: ::c_long = 73;
-pub const SYS_fsync: ::c_long = 74;
-pub const SYS_fdatasync: ::c_long = 75;
-pub const SYS_truncate: ::c_long = 76;
-pub const SYS_ftruncate: ::c_long = 77;
-pub const SYS_getdents: ::c_long = 78;
-pub const SYS_getcwd: ::c_long = 79;
-pub const SYS_chdir: ::c_long = 80;
-pub const SYS_fchdir: ::c_long = 81;
-pub const SYS_rename: ::c_long = 82;
-pub const SYS_mkdir: ::c_long = 83;
-pub const SYS_rmdir: ::c_long = 84;
-pub const SYS_creat: ::c_long = 85;
-pub const SYS_link: ::c_long = 86;
-pub const SYS_unlink: ::c_long = 87;
-pub const SYS_symlink: ::c_long = 88;
-pub const SYS_readlink: ::c_long = 89;
-pub const SYS_chmod: ::c_long = 90;
-pub const SYS_fchmod: ::c_long = 91;
-pub const SYS_chown: ::c_long = 92;
-pub const SYS_fchown: ::c_long = 93;
-pub const SYS_lchown: ::c_long = 94;
-pub const SYS_umask: ::c_long = 95;
-pub const SYS_gettimeofday: ::c_long = 96;
-pub const SYS_getrlimit: ::c_long = 97;
-pub const SYS_getrusage: ::c_long = 98;
-pub const SYS_sysinfo: ::c_long = 99;
-pub const SYS_times: ::c_long = 100;
-pub const SYS_ptrace: ::c_long = 101;
-pub const SYS_getuid: ::c_long = 102;
-pub const SYS_syslog: ::c_long = 103;
-pub const SYS_getgid: ::c_long = 104;
-pub const SYS_setuid: ::c_long = 105;
-pub const SYS_setgid: ::c_long = 106;
-pub const SYS_geteuid: ::c_long = 107;
-pub const SYS_getegid: ::c_long = 108;
-pub const SYS_setpgid: ::c_long = 109;
-pub const SYS_getppid: ::c_long = 110;
-pub const SYS_getpgrp: ::c_long = 111;
-pub const SYS_setsid: ::c_long = 112;
-pub const SYS_setreuid: ::c_long = 113;
-pub const SYS_setregid: ::c_long = 114;
-pub const SYS_getgroups: ::c_long = 115;
-pub const SYS_setgroups: ::c_long = 116;
-pub const SYS_setresuid: ::c_long = 117;
-pub const SYS_getresuid: ::c_long = 118;
-pub const SYS_setresgid: ::c_long = 119;
-pub const SYS_getresgid: ::c_long = 120;
-pub const SYS_getpgid: ::c_long = 121;
-pub const SYS_setfsuid: ::c_long = 122;
-pub const SYS_setfsgid: ::c_long = 123;
-pub const SYS_getsid: ::c_long = 124;
-pub const SYS_capget: ::c_long = 125;
-pub const SYS_capset: ::c_long = 126;
-pub const SYS_rt_sigpending: ::c_long = 127;
-pub const SYS_rt_sigtimedwait: ::c_long = 128;
-pub const SYS_rt_sigqueueinfo: ::c_long = 129;
-pub const SYS_rt_sigsuspend: ::c_long = 130;
-pub const SYS_sigaltstack: ::c_long = 131;
-pub const SYS_utime: ::c_long = 132;
-pub const SYS_mknod: ::c_long = 133;
-pub const SYS_uselib: ::c_long = 134;
-pub const SYS_personality: ::c_long = 135;
-pub const SYS_ustat: ::c_long = 136;
-pub const SYS_statfs: ::c_long = 137;
-pub const SYS_fstatfs: ::c_long = 138;
-pub const SYS_sysfs: ::c_long = 139;
-pub const SYS_getpriority: ::c_long = 140;
-pub const SYS_setpriority: ::c_long = 141;
-pub const SYS_sched_setparam: ::c_long = 142;
-pub const SYS_sched_getparam: ::c_long = 143;
-pub const SYS_sched_setscheduler: ::c_long = 144;
-pub const SYS_sched_getscheduler: ::c_long = 145;
-pub const SYS_sched_get_priority_max: ::c_long = 146;
-pub const SYS_sched_get_priority_min: ::c_long = 147;
-pub const SYS_sched_rr_get_interval: ::c_long = 148;
-pub const SYS_mlock: ::c_long = 149;
-pub const SYS_munlock: ::c_long = 150;
-pub const SYS_mlockall: ::c_long = 151;
-pub const SYS_munlockall: ::c_long = 152;
-pub const SYS_vhangup: ::c_long = 153;
-pub const SYS_modify_ldt: ::c_long = 154;
-pub const SYS_pivot_root: ::c_long = 155;
-pub const SYS__sysctl: ::c_long = 156;
-pub const SYS_prctl: ::c_long = 157;
-pub const SYS_arch_prctl: ::c_long = 158;
-pub const SYS_adjtimex: ::c_long = 159;
-pub const SYS_setrlimit: ::c_long = 160;
-pub const SYS_chroot: ::c_long = 161;
-pub const SYS_sync: ::c_long = 162;
-pub const SYS_acct: ::c_long = 163;
-pub const SYS_settimeofday: ::c_long = 164;
-pub const SYS_mount: ::c_long = 165;
-pub const SYS_umount2: ::c_long = 166;
-pub const SYS_swapon: ::c_long = 167;
-pub const SYS_swapoff: ::c_long = 168;
-pub const SYS_reboot: ::c_long = 169;
-pub const SYS_sethostname: ::c_long = 170;
-pub const SYS_setdomainname: ::c_long = 171;
-pub const SYS_iopl: ::c_long = 172;
-pub const SYS_ioperm: ::c_long = 173;
-pub const SYS_create_module: ::c_long = 174;
-pub const SYS_init_module: ::c_long = 175;
-pub const SYS_delete_module: ::c_long = 176;
-pub const SYS_get_kernel_syms: ::c_long = 177;
-pub const SYS_query_module: ::c_long = 178;
-pub const SYS_quotactl: ::c_long = 179;
-pub const SYS_nfsservctl: ::c_long = 180;
-pub const SYS_getpmsg: ::c_long = 181;
-pub const SYS_putpmsg: ::c_long = 182;
-pub const SYS_afs_syscall: ::c_long = 183;
-pub const SYS_tuxcall: ::c_long = 184;
-pub const SYS_security: ::c_long = 185;
-pub const SYS_gettid: ::c_long = 186;
-pub const SYS_readahead: ::c_long = 187;
-pub const SYS_setxattr: ::c_long = 188;
-pub const SYS_lsetxattr: ::c_long = 189;
-pub const SYS_fsetxattr: ::c_long = 190;
-pub const SYS_getxattr: ::c_long = 191;
-pub const SYS_lgetxattr: ::c_long = 192;
-pub const SYS_fgetxattr: ::c_long = 193;
-pub const SYS_listxattr: ::c_long = 194;
-pub const SYS_llistxattr: ::c_long = 195;
-pub const SYS_flistxattr: ::c_long = 196;
-pub const SYS_removexattr: ::c_long = 197;
-pub const SYS_lremovexattr: ::c_long = 198;
-pub const SYS_fremovexattr: ::c_long = 199;
-pub const SYS_tkill: ::c_long = 200;
-pub const SYS_time: ::c_long = 201;
-pub const SYS_futex: ::c_long = 202;
-pub const SYS_sched_setaffinity: ::c_long = 203;
-pub const SYS_sched_getaffinity: ::c_long = 204;
-pub const SYS_set_thread_area: ::c_long = 205;
-pub const SYS_io_setup: ::c_long = 206;
-pub const SYS_io_destroy: ::c_long = 207;
-pub const SYS_io_getevents: ::c_long = 208;
-pub const SYS_io_submit: ::c_long = 209;
-pub const SYS_io_cancel: ::c_long = 210;
-pub const SYS_get_thread_area: ::c_long = 211;
-pub const SYS_lookup_dcookie: ::c_long = 212;
-pub const SYS_epoll_create: ::c_long = 213;
-pub const SYS_epoll_ctl_old: ::c_long = 214;
-pub const SYS_epoll_wait_old: ::c_long = 215;
-pub const SYS_remap_file_pages: ::c_long = 216;
-pub const SYS_getdents64: ::c_long = 217;
-pub const SYS_set_tid_address: ::c_long = 218;
-pub const SYS_restart_syscall: ::c_long = 219;
-pub const SYS_semtimedop: ::c_long = 220;
-pub const SYS_fadvise64: ::c_long = 221;
-pub const SYS_timer_create: ::c_long = 222;
-pub const SYS_timer_settime: ::c_long = 223;
-pub const SYS_timer_gettime: ::c_long = 224;
-pub const SYS_timer_getoverrun: ::c_long = 225;
-pub const SYS_timer_delete: ::c_long = 226;
-pub const SYS_clock_settime: ::c_long = 227;
-pub const SYS_clock_gettime: ::c_long = 228;
-pub const SYS_clock_getres: ::c_long = 229;
-pub const SYS_clock_nanosleep: ::c_long = 230;
-pub const SYS_exit_group: ::c_long = 231;
-pub const SYS_epoll_wait: ::c_long = 232;
-pub const SYS_epoll_ctl: ::c_long = 233;
-pub const SYS_tgkill: ::c_long = 234;
-pub const SYS_utimes: ::c_long = 235;
-pub const SYS_vserver: ::c_long = 236;
-pub const SYS_mbind: ::c_long = 237;
-pub const SYS_set_mempolicy: ::c_long = 238;
-pub const SYS_get_mempolicy: ::c_long = 239;
-pub const SYS_mq_open: ::c_long = 240;
-pub const SYS_mq_unlink: ::c_long = 241;
-pub const SYS_mq_timedsend: ::c_long = 242;
-pub const SYS_mq_timedreceive: ::c_long = 243;
-pub const SYS_mq_notify: ::c_long = 244;
-pub const SYS_mq_getsetattr: ::c_long = 245;
-pub const SYS_kexec_load: ::c_long = 246;
-pub const SYS_waitid: ::c_long = 247;
-pub const SYS_add_key: ::c_long = 248;
-pub const SYS_request_key: ::c_long = 249;
-pub const SYS_keyctl: ::c_long = 250;
-pub const SYS_ioprio_set: ::c_long = 251;
-pub const SYS_ioprio_get: ::c_long = 252;
-pub const SYS_inotify_init: ::c_long = 253;
-pub const SYS_inotify_add_watch: ::c_long = 254;
-pub const SYS_inotify_rm_watch: ::c_long = 255;
-pub const SYS_migrate_pages: ::c_long = 256;
-pub const SYS_openat: ::c_long = 257;
-pub const SYS_mkdirat: ::c_long = 258;
-pub const SYS_mknodat: ::c_long = 259;
-pub const SYS_fchownat: ::c_long = 260;
-pub const SYS_futimesat: ::c_long = 261;
-pub const SYS_newfstatat: ::c_long = 262;
-pub const SYS_unlinkat: ::c_long = 263;
-pub const SYS_renameat: ::c_long = 264;
-pub const SYS_linkat: ::c_long = 265;
-pub const SYS_symlinkat: ::c_long = 266;
-pub const SYS_readlinkat: ::c_long = 267;
-pub const SYS_fchmodat: ::c_long = 268;
-pub const SYS_faccessat: ::c_long = 269;
-pub const SYS_pselect6: ::c_long = 270;
-pub const SYS_ppoll: ::c_long = 271;
-pub const SYS_unshare: ::c_long = 272;
-pub const SYS_set_robust_list: ::c_long = 273;
-pub const SYS_get_robust_list: ::c_long = 274;
-pub const SYS_splice: ::c_long = 275;
-pub const SYS_tee: ::c_long = 276;
-pub const SYS_sync_file_range: ::c_long = 277;
-pub const SYS_vmsplice: ::c_long = 278;
-pub const SYS_move_pages: ::c_long = 279;
-pub const SYS_utimensat: ::c_long = 280;
-pub const SYS_epoll_pwait: ::c_long = 281;
-pub const SYS_signalfd: ::c_long = 282;
-pub const SYS_timerfd_create: ::c_long = 283;
-pub const SYS_eventfd: ::c_long = 284;
-pub const SYS_fallocate: ::c_long = 285;
-pub const SYS_timerfd_settime: ::c_long = 286;
-pub const SYS_timerfd_gettime: ::c_long = 287;
-pub const SYS_accept4: ::c_long = 288;
-pub const SYS_signalfd4: ::c_long = 289;
-pub const SYS_eventfd2: ::c_long = 290;
-pub const SYS_epoll_create1: ::c_long = 291;
-pub const SYS_dup3: ::c_long = 292;
-pub const SYS_pipe2: ::c_long = 293;
-pub const SYS_inotify_init1: ::c_long = 294;
-pub const SYS_preadv: ::c_long = 295;
-pub const SYS_pwritev: ::c_long = 296;
-pub const SYS_rt_tgsigqueueinfo: ::c_long = 297;
-pub const SYS_perf_event_open: ::c_long = 298;
-pub const SYS_recvmmsg: ::c_long = 299;
-pub const SYS_fanotify_init: ::c_long = 300;
-pub const SYS_fanotify_mark: ::c_long = 301;
-pub const SYS_prlimit64: ::c_long = 302;
-pub const SYS_name_to_handle_at: ::c_long = 303;
-pub const SYS_open_by_handle_at: ::c_long = 304;
-pub const SYS_clock_adjtime: ::c_long = 305;
-pub const SYS_syncfs: ::c_long = 306;
-pub const SYS_sendmmsg: ::c_long = 307;
-pub const SYS_setns: ::c_long = 308;
-pub const SYS_getcpu: ::c_long = 309;
-pub const SYS_process_vm_readv: ::c_long = 310;
-pub const SYS_process_vm_writev: ::c_long = 311;
-pub const SYS_kcmp: ::c_long = 312;
-pub const SYS_finit_module: ::c_long = 313;
-pub const SYS_sched_setattr: ::c_long = 314;
-pub const SYS_sched_getattr: ::c_long = 315;
-pub const SYS_renameat2: ::c_long = 316;
-pub const SYS_seccomp: ::c_long = 317;
-pub const SYS_getrandom: ::c_long = 318;
-pub const SYS_memfd_create: ::c_long = 319;
-pub const SYS_kexec_file_load: ::c_long = 320;
-pub const SYS_bpf: ::c_long = 321;
-pub const SYS_execveat: ::c_long = 322;
-pub const SYS_userfaultfd: ::c_long = 323;
-pub const SYS_membarrier: ::c_long = 324;
-pub const SYS_mlock2: ::c_long = 325;
-pub const SYS_copy_file_range: ::c_long = 326;
-pub const SYS_preadv2: ::c_long = 327;
-pub const SYS_pwritev2: ::c_long = 328;
-// FIXME syscalls 329-331 have been added in musl 1.16
-// See discussion https://github.com/rust-lang/libc/pull/699
-
-// offsets in user_regs_structs, from sys/reg.h
-pub const R15: ::c_int = 0;
-pub const R14: ::c_int = 1;
-pub const R13: ::c_int = 2;
-pub const R12: ::c_int = 3;
-pub const RBP: ::c_int = 4;
-pub const RBX: ::c_int = 5;
-pub const R11: ::c_int = 6;
-pub const R10: ::c_int = 7;
-pub const R9: ::c_int = 8;
-pub const R8: ::c_int = 9;
-pub const RAX: ::c_int = 10;
-pub const RCX: ::c_int = 11;
-pub const RDX: ::c_int = 12;
-pub const RSI: ::c_int = 13;
-pub const RDI: ::c_int = 14;
-pub const ORIG_RAX: ::c_int = 15;
-pub const RIP: ::c_int = 16;
-pub const CS: ::c_int = 17;
-pub const EFLAGS: ::c_int = 18;
-pub const RSP: ::c_int = 19;
-pub const SS: ::c_int = 20;
-pub const FS_BASE: ::c_int = 21;
-pub const GS_BASE: ::c_int = 22;
-pub const DS: ::c_int = 23;
-pub const ES: ::c_int = 24;
-pub const FS: ::c_int = 25;
-pub const GS: ::c_int = 26;
-
-pub const MADV_SOFT_OFFLINE: ::c_int = 101;
-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 TIOCGRS485: ::c_int = 0x542E;
-pub const TIOCSRS485: ::c_int = 0x542F;
-
-pub const SIGSTKSZ: ::size_t = 8192;
-pub const MINSIGSTKSZ: ::size_t = 2048;
-
-#[doc(hidden)]
-#[deprecated(
- since = "0.2.55",
- note = "If you are using this report to: \
- https://github.com/rust-lang/libc/issues/665"
-)]
-pub const AF_MAX: ::c_int = 45;
-#[doc(hidden)]
-#[deprecated(
- since = "0.2.55",
- note = "If you are using this report to: \
- https://github.com/rust-lang/libc/issues/665"
-)]
-#[allow(deprecated)]
-pub const PF_MAX: ::c_int = AF_MAX;
-
-pub const RLIMIT_NLIMITS: ::c_int = 15;
-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
deleted file mode 100644
index 99d3ed8..0000000
--- a/libc/src/unix/notbsd/linux/musl/mod.rs
+++ /dev/null
@@ -1,394 +0,0 @@
-pub type pthread_t = *mut ::c_void;
-pub type clock_t = c_long;
-pub type time_t = c_long;
-pub type suseconds_t = c_long;
-pub type ino_t = u64;
-pub type off_t = i64;
-pub type blkcnt_t = i64;
-
-pub type shmatt_t = ::c_ulong;
-pub type msgqnum_t = ::c_ulong;
-pub type msglen_t = ::c_ulong;
-pub type fsblkcnt_t = ::c_ulonglong;
-pub type fsfilcnt_t = ::c_ulonglong;
-pub type rlim_t = ::c_ulonglong;
-
-s! {
- pub struct aiocb {
- pub aio_fildes: ::c_int,
- pub aio_lio_opcode: ::c_int,
- pub aio_reqprio: ::c_int,
- pub aio_buf: *mut ::c_void,
- pub aio_nbytes: ::size_t,
- pub aio_sigevent: ::sigevent,
- __td: *mut ::c_void,
- __lock: [::c_int; 2],
- __err: ::c_int,
- __ret: ::ssize_t,
- pub aio_offset: off_t,
- __next: *mut ::c_void,
- __prev: *mut ::c_void,
- #[cfg(target_pointer_width = "32")]
- __dummy4: [::c_char; 24],
- #[cfg(target_pointer_width = "64")]
- __dummy4: [::c_char; 16],
- }
-
- pub struct sigaction {
- pub sa_sigaction: ::sighandler_t,
- pub sa_mask: ::sigset_t,
- pub sa_flags: ::c_int,
- pub sa_restorer: ::Option<extern fn()>,
- }
-
- pub struct 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,
- pub c_cflag: ::tcflag_t,
- pub c_lflag: ::tcflag_t,
- pub c_line: ::cc_t,
- pub c_cc: [::cc_t; ::NCCS],
- pub __c_ispeed: ::speed_t,
- pub __c_ospeed: ::speed_t,
- }
-
- pub struct flock {
- pub l_type: ::c_short,
- pub l_whence: ::c_short,
- pub l_start: ::off_t,
- pub l_len: ::off_t,
- pub l_pid: ::pid_t,
- }
-}
-
-s_no_extra_traits!{
- pub struct sysinfo {
- pub uptime: ::c_ulong,
- pub loads: [::c_ulong; 3],
- pub totalram: ::c_ulong,
- pub freeram: ::c_ulong,
- pub sharedram: ::c_ulong,
- pub bufferram: ::c_ulong,
- pub totalswap: ::c_ulong,
- pub freeswap: ::c_ulong,
- pub procs: ::c_ushort,
- pub pad: ::c_ushort,
- pub totalhigh: ::c_ulong,
- pub freehigh: ::c_ulong,
- pub mem_unit: ::c_uint,
- pub __reserved: [::c_char; 256],
- }
-}
-
-cfg_if! {
- if #[cfg(feature = "extra_traits")] {
- impl PartialEq for sysinfo {
- fn eq(&self, other: &sysinfo) -> bool {
- self.uptime == other.uptime
- && self.loads == other.loads
- && self.totalram == other.totalram
- && self.freeram == other.freeram
- && self.sharedram == other.sharedram
- && self.bufferram == other.bufferram
- && self.totalswap == other.totalswap
- && self.freeswap == other.freeswap
- && self.procs == other.procs
- && self.pad == other.pad
- && self.totalhigh == other.totalhigh
- && self.freehigh == other.freehigh
- && self.mem_unit == other.mem_unit
- && self
- .__reserved
- .iter()
- .zip(other.__reserved.iter())
- .all(|(a,b)| a == b)
- }
- }
-
- impl Eq for sysinfo {}
-
- impl ::fmt::Debug for sysinfo {
- fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
- f.debug_struct("sysinfo")
- .field("uptime", &self.uptime)
- .field("loads", &self.loads)
- .field("totalram", &self.totalram)
- .field("freeram", &self.freeram)
- .field("sharedram", &self.sharedram)
- .field("bufferram", &self.bufferram)
- .field("totalswap", &self.totalswap)
- .field("freeswap", &self.freeswap)
- .field("procs", &self.procs)
- .field("pad", &self.pad)
- .field("totalhigh", &self.totalhigh)
- .field("freehigh", &self.freehigh)
- .field("mem_unit", &self.mem_unit)
- // FIXME: .field("__reserved", &self.__reserved)
- .finish()
- }
- }
-
- impl ::hash::Hash for sysinfo {
- fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
- self.uptime.hash(state);
- self.loads.hash(state);
- self.totalram.hash(state);
- self.freeram.hash(state);
- self.sharedram.hash(state);
- self.bufferram.hash(state);
- self.totalswap.hash(state);
- self.freeswap.hash(state);
- self.procs.hash(state);
- self.pad.hash(state);
- self.totalhigh.hash(state);
- self.freehigh.hash(state);
- self.mem_unit.hash(state);
- self.__reserved.hash(state);
- }
- }
- }
-}
-
-pub const MS_RMT_MASK: ::c_ulong = 0x02800051;
-
-pub const SFD_CLOEXEC: ::c_int = 0x080000;
-
-pub const NCCS: usize = 32;
-
-pub const O_TRUNC: ::c_int = 512;
-pub const O_NOATIME: ::c_int = 0o1000000;
-pub const O_CLOEXEC: ::c_int = 0x80000;
-pub const O_TMPFILE: ::c_int = 0o20000000 | O_DIRECTORY;
-
-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 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;
-pub const SA_NOCLDSTOP: ::c_int = 0x00000001;
-
-pub const EPOLL_CLOEXEC: ::c_int = 0x80000;
-
-pub const EFD_CLOEXEC: ::c_int = 0x80000;
-
-pub const BUFSIZ: ::c_uint = 1024;
-pub const TMP_MAX: ::c_uint = 10000;
-pub const FOPEN_MAX: ::c_uint = 1000;
-pub const O_PATH: ::c_int = 0o10000000;
-pub const O_EXEC: ::c_int = 0o10000000;
-pub const O_SEARCH: ::c_int = 0o10000000;
-pub const O_ACCMODE: ::c_int = 0o10000003;
-pub const O_NDELAY: ::c_int = O_NONBLOCK;
-pub const NI_MAXHOST: ::socklen_t = 255;
-pub const PTHREAD_STACK_MIN: ::size_t = 2048;
-pub const POSIX_FADV_DONTNEED: ::c_int = 4;
-pub const POSIX_FADV_NOREUSE: ::c_int = 5;
-
-pub const POSIX_MADV_DONTNEED: ::c_int = 4;
-
-pub const RLIM_INFINITY: ::rlim_t = !0;
-pub const RLIMIT_RTTIME: ::c_int = 15;
-
-pub const MAP_ANONYMOUS: ::c_int = MAP_ANON;
-
-pub const SOCK_DCCP: ::c_int = 6;
-pub const SOCK_PACKET: ::c_int = 10;
-
-pub const TCP_COOKIE_TRANSACTIONS: ::c_int = 15;
-pub const TCP_THIN_LINEAR_TIMEOUTS: ::c_int = 16;
-pub const TCP_THIN_DUPACK: ::c_int = 17;
-pub const TCP_USER_TIMEOUT: ::c_int = 18;
-pub const TCP_REPAIR: ::c_int = 19;
-pub const TCP_REPAIR_QUEUE: ::c_int = 20;
-pub const TCP_QUEUE_SEQ: ::c_int = 21;
-pub const TCP_REPAIR_OPTIONS: ::c_int = 22;
-pub const TCP_FASTOPEN: ::c_int = 23;
-pub const TCP_TIMESTAMP: ::c_int = 24;
-
-#[deprecated(
- since = "0.2.55",
- note = "Use SIGSYS instead"
-)]
-pub const SIGUNUSED: ::c_int = ::SIGSYS;
-
-pub const __SIZEOF_PTHREAD_CONDATTR_T: usize = 4;
-pub const __SIZEOF_PTHREAD_MUTEXATTR_T: usize = 4;
-pub const __SIZEOF_PTHREAD_RWLOCKATTR_T: usize = 8;
-
-pub const CPU_SETSIZE: ::c_int = 128;
-
-pub const PTRACE_TRACEME: ::c_int = 0;
-pub const PTRACE_PEEKTEXT: ::c_int = 1;
-pub const PTRACE_PEEKDATA: ::c_int = 2;
-pub const PTRACE_PEEKUSER: ::c_int = 3;
-pub const PTRACE_POKETEXT: ::c_int = 4;
-pub const PTRACE_POKEDATA: ::c_int = 5;
-pub const PTRACE_POKEUSER: ::c_int = 6;
-pub const PTRACE_CONT: ::c_int = 7;
-pub const PTRACE_KILL: ::c_int = 8;
-pub const PTRACE_SINGLESTEP: ::c_int = 9;
-pub const PTRACE_GETREGS: ::c_int = 12;
-pub const PTRACE_SETREGS: ::c_int = 13;
-pub const PTRACE_GETFPREGS: ::c_int = 14;
-pub const PTRACE_SETFPREGS: ::c_int = 15;
-pub const PTRACE_ATTACH: ::c_int = 16;
-pub const PTRACE_DETACH: ::c_int = 17;
-pub const PTRACE_GETFPXREGS: ::c_int = 18;
-pub const PTRACE_SETFPXREGS: ::c_int = 19;
-pub const PTRACE_SYSCALL: ::c_int = 24;
-pub const PTRACE_SETOPTIONS: ::c_int = 0x4200;
-pub const PTRACE_GETEVENTMSG: ::c_int = 0x4201;
-pub const PTRACE_GETSIGINFO: ::c_int = 0x4202;
-pub const PTRACE_SETSIGINFO: ::c_int = 0x4203;
-pub const PTRACE_GETREGSET: ::c_int = 0x4204;
-pub const PTRACE_SETREGSET: ::c_int = 0x4205;
-pub const PTRACE_SEIZE: ::c_int = 0x4206;
-pub const PTRACE_INTERRUPT: ::c_int = 0x4207;
-pub const PTRACE_LISTEN: ::c_int = 0x4208;
-pub const PTRACE_PEEKSIGINFO: ::c_int = 0x4209;
-
-pub const EPOLLWAKEUP: ::c_int = 0x20000000;
-
-pub const SEEK_DATA: ::c_int = 3;
-pub const SEEK_HOLE: ::c_int = 4;
-
-pub const EFD_NONBLOCK: ::c_int = ::O_NONBLOCK;
-
-pub const SFD_NONBLOCK: ::c_int = ::O_NONBLOCK;
-
-pub const TCSANOW: ::c_int = 0;
-pub const TCSADRAIN: ::c_int = 1;
-pub const TCSAFLUSH: ::c_int = 2;
-
-pub const RTLD_GLOBAL: ::c_int = 0x100;
-pub const RTLD_NOLOAD: ::c_int = 0x4;
-
-// TODO(#247) Temporarily musl-specific (available since musl 0.9.12 / Linux
-// kernel 3.10). See also notbsd/mod.rs
-pub const CLOCK_SGI_CYCLE: ::clockid_t = 10;
-pub const CLOCK_TAI: ::clockid_t = 11;
-
-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 SO_BINDTODEVICE: ::c_int = 25;
-pub const SO_TIMESTAMP: ::c_int = 29;
-pub const SO_MARK: ::c_int = 36;
-pub const SO_RXQ_OVFL: ::c_int = 40;
-pub const SO_PEEK_OFF: ::c_int = 42;
-pub const SO_BUSY_POLL: ::c_int = 46;
-
-pub const RLIMIT_CPU: ::c_int = 0;
-pub const RLIMIT_FSIZE: ::c_int = 1;
-pub const RLIMIT_DATA: ::c_int = 2;
-pub const RLIMIT_STACK: ::c_int = 3;
-pub const RLIMIT_CORE: ::c_int = 4;
-pub const RLIMIT_LOCKS: ::c_int = 10;
-pub const RLIMIT_SIGPENDING: ::c_int = 11;
-pub const RLIMIT_MSGQUEUE: ::c_int = 12;
-pub const RLIMIT_NICE: ::c_int = 13;
-pub const RLIMIT_RTPRIO: ::c_int = 14;
-
-extern {
- pub fn sendmmsg(sockfd: ::c_int, msgvec: *mut ::mmsghdr, vlen: ::c_uint,
- flags: ::c_uint) -> ::c_int;
- pub fn recvmmsg(sockfd: ::c_int, msgvec: *mut ::mmsghdr, vlen: ::c_uint,
- flags: ::c_uint, timeout: *mut ::timespec) -> ::c_int;
-
- pub fn getrlimit64(resource: ::c_int,
- rlim: *mut ::rlimit64) -> ::c_int;
- pub fn setrlimit64(resource: ::c_int,
- rlim: *const ::rlimit64) -> ::c_int;
- pub fn getrlimit(resource: ::c_int,
- rlim: *mut ::rlimit) -> ::c_int;
- pub fn setrlimit(resource: ::c_int,
- rlim: *const ::rlimit) -> ::c_int;
- pub fn prlimit(pid: ::pid_t,
- resource: ::c_int, new_limit: *const ::rlimit,
- old_limit: *mut ::rlimit) -> ::c_int;
- pub fn prlimit64(pid: ::pid_t,
- resource: ::c_int,
- new_limit: *const ::rlimit64,
- old_limit: *mut ::rlimit64) -> ::c_int;
-
- pub fn gettimeofday(tp: *mut ::timeval,
- tz: *mut ::c_void) -> ::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! {
- if #[cfg(any(target_arch = "x86_64",
- target_arch = "aarch64",
- target_arch = "powerpc64"))] {
- mod b64;
- pub use self::b64::*;
- } else if #[cfg(any(target_arch = "x86",
- target_arch = "mips",
- target_arch = "arm",
- target_arch = "powerpc"))] {
- mod b32;
- pub use self::b32::*;
- } else { }
-}
diff --git a/libc/src/unix/notbsd/linux/no_align.rs b/libc/src/unix/notbsd/linux/no_align.rs
deleted file mode 100644
index 1f5f2ee..0000000
--- a/libc/src/unix/notbsd/linux/no_align.rs
+++ /dev/null
@@ -1,80 +0,0 @@
-macro_rules! expand_align {
- () => {
- s! {
- pub struct pthread_mutexattr_t {
- #[cfg(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_int; 0],
- #[cfg(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],
- }
-
- pub struct pthread_rwlockattr_t {
- #[cfg(target_env = "musl")]
- __align: [::c_int; 0],
- #[cfg(not(target_env = "musl"))]
- __align: [::c_long; 0],
- size: [u8; ::__SIZEOF_PTHREAD_RWLOCKATTR_T],
- }
-
- pub struct pthread_condattr_t {
- __align: [::c_int; 0],
- size: [u8; ::__SIZEOF_PTHREAD_CONDATTR_T],
- }
- }
-
- s_no_extra_traits! {
- pub struct pthread_cond_t {
- #[cfg(target_env = "musl")]
- __align: [*const ::c_void; 0],
- #[cfg(not(target_env = "musl"))]
- __align: [::c_longlong; 0],
- size: [u8; ::__SIZEOF_PTHREAD_COND_T],
- }
-
- 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")))]
- __align: [::c_long; 0],
- #[cfg(not(any(target_arch = "mips",
- 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],
- }
-
- 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")))]
- __align: [::c_long; 0],
- #[cfg(not(any(target_arch = "mips",
- 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],
- }
- }
- }
-}
diff --git a/libc/src/unix/notbsd/linux/other/align.rs b/libc/src/unix/notbsd/linux/other/align.rs
deleted file mode 100644
index 4a0e074..0000000
--- a/libc/src/unix/notbsd/linux/other/align.rs
+++ /dev/null
@@ -1,13 +0,0 @@
-s! {
- // FIXME this is actually a union
- #[cfg_attr(target_pointer_width = "32",
- repr(align(4)))]
- #[cfg_attr(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],
- }
-}
diff --git a/libc/src/unix/notbsd/linux/other/b32/arm.rs b/libc/src/unix/notbsd/linux/other/b32/arm.rs
deleted file mode 100644
index a2d190d..0000000
--- a/libc/src/unix/notbsd/linux/other/b32/arm.rs
+++ /dev/null
@@ -1,612 +0,0 @@
-pub type c_char = u8;
-pub type wchar_t = u32;
-
-s! {
- pub struct ipc_perm {
- pub __key: ::key_t,
- pub uid: ::uid_t,
- pub gid: ::gid_t,
- pub cuid: ::uid_t,
- pub cgid: ::gid_t,
- pub mode: ::c_ushort,
- __pad1: ::c_ushort,
- pub __seq: ::c_ushort,
- __pad2: ::c_ushort,
- __unused1: ::c_ulong,
- __unused2: ::c_ulong
- }
-
- pub struct stat64 {
- pub st_dev: ::dev_t,
- __pad1: ::c_uint,
- __st_ino: ::ino_t,
- pub st_mode: ::mode_t,
- pub st_nlink: ::nlink_t,
- pub st_uid: ::uid_t,
- pub st_gid: ::gid_t,
- pub st_rdev: ::dev_t,
- __pad2: ::c_uint,
- pub st_size: ::off64_t,
- pub st_blksize: ::blksize_t,
- pub st_blocks: ::blkcnt64_t,
- pub st_atime: ::time_t,
- pub st_atime_nsec: ::c_long,
- pub st_mtime: ::time_t,
- pub st_mtime_nsec: ::c_long,
- pub st_ctime: ::time_t,
- pub st_ctime_nsec: ::c_long,
- pub st_ino: ::ino64_t,
- }
-
- pub struct statfs64 {
- pub f_type: ::__fsword_t,
- pub f_bsize: ::__fsword_t,
- pub f_blocks: u64,
- pub f_bfree: u64,
- pub f_bavail: u64,
- pub f_files: u64,
- pub f_ffree: u64,
- pub f_fsid: ::fsid_t,
- pub f_namelen: ::__fsword_t,
- pub f_frsize: ::__fsword_t,
- pub f_flags: ::__fsword_t,
- pub f_spare: [::__fsword_t; 4],
- }
-
- pub struct statvfs64 {
- pub f_bsize: ::c_ulong,
- pub f_frsize: ::c_ulong,
- pub f_blocks: u64,
- pub f_bfree: u64,
- pub f_bavail: u64,
- pub f_files: u64,
- pub f_ffree: u64,
- pub f_favail: u64,
- pub f_fsid: ::c_ulong,
- __f_unused: ::c_int,
- pub f_flag: ::c_ulong,
- pub f_namemax: ::c_ulong,
- __f_spare: [::c_int; 6],
- }
-
- pub struct shmid_ds {
- pub shm_perm: ::ipc_perm,
- pub shm_segsz: ::size_t,
- pub shm_atime: ::time_t,
- __unused1: ::c_ulong,
- pub shm_dtime: ::time_t,
- __unused2: ::c_ulong,
- pub shm_ctime: ::time_t,
- __unused3: ::c_ulong,
- pub shm_cpid: ::pid_t,
- pub shm_lpid: ::pid_t,
- pub shm_nattch: ::shmatt_t,
- __unused4: ::c_ulong,
- __unused5: ::c_ulong
- }
-
- pub struct msqid_ds {
- pub msg_perm: ::ipc_perm,
- pub msg_stime: ::time_t,
- __glibc_reserved1: ::c_ulong,
- pub msg_rtime: ::time_t,
- __glibc_reserved2: ::c_ulong,
- pub msg_ctime: ::time_t,
- __glibc_reserved3: ::c_ulong,
- __msg_cbytes: ::c_ulong,
- pub msg_qnum: ::msgqnum_t,
- pub msg_qbytes: ::msglen_t,
- pub msg_lspid: ::pid_t,
- pub msg_lrpid: ::pid_t,
- __glibc_reserved4: ::c_ulong,
- __glibc_reserved5: ::c_ulong,
- }
-
- pub struct termios2 {
- pub c_iflag: ::tcflag_t,
- pub c_oflag: ::tcflag_t,
- pub c_cflag: ::tcflag_t,
- pub c_lflag: ::tcflag_t,
- pub c_line: ::cc_t,
- pub c_cc: [::cc_t; 19],
- pub c_ispeed: ::speed_t,
- pub c_ospeed: ::speed_t,
- }
-}
-
-pub const O_DIRECT: ::c_int = 0x10000;
-pub const O_DIRECTORY: ::c_int = 0x4000;
-pub const O_NOFOLLOW: ::c_int = 0x8000;
-pub const O_LARGEFILE: ::c_int = 0o400000;
-
-pub const MAP_LOCKED: ::c_int = 0x02000;
-pub const MAP_NORESERVE: ::c_int = 0x04000;
-
-pub const EDEADLOCK: ::c_int = 35;
-
-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_SNDBUFFORCE: ::c_int = 32;
-pub const SO_RCVBUFFORCE: ::c_int = 33;
-
-pub const FIOCLEX: ::c_ulong = 0x5451;
-pub const FIONBIO: ::c_ulong = 0x5421;
-
-pub const MCL_CURRENT: ::c_int = 0x0001;
-pub const MCL_FUTURE: ::c_int = 0x0002;
-
-pub const SIGSTKSZ: ::size_t = 8192;
-pub const MINSIGSTKSZ: ::size_t = 2048;
-pub const CBAUD: ::tcflag_t = 0o0010017;
-pub const TAB1: ::tcflag_t = 0x00000800;
-pub const TAB2: ::tcflag_t = 0x00001000;
-pub const TAB3: ::tcflag_t = 0x00001800;
-pub const CR1: ::tcflag_t = 0x00000200;
-pub const CR2: ::tcflag_t = 0x00000400;
-pub const CR3: ::tcflag_t = 0x00000600;
-pub const FF1: ::tcflag_t = 0x00008000;
-pub const BS1: ::tcflag_t = 0x00002000;
-pub const VT1: ::tcflag_t = 0x00004000;
-pub const VWERASE: usize = 14;
-pub const VREPRINT: usize = 12;
-pub const VSUSP: usize = 10;
-pub const VSTART: usize = 8;
-pub const VSTOP: usize = 9;
-pub const VDISCARD: usize = 13;
-pub const VTIME: usize = 5;
-pub const IXON: ::tcflag_t = 0x00000400;
-pub const IXOFF: ::tcflag_t = 0x00001000;
-pub const ONLCR: ::tcflag_t = 0x4;
-pub const CSIZE: ::tcflag_t = 0x00000030;
-pub const CS6: ::tcflag_t = 0x00000010;
-pub const CS7: ::tcflag_t = 0x00000020;
-pub const CS8: ::tcflag_t = 0x00000030;
-pub const CSTOPB: ::tcflag_t = 0x00000040;
-pub const CREAD: ::tcflag_t = 0x00000080;
-pub const PARENB: ::tcflag_t = 0x00000100;
-pub const PARODD: ::tcflag_t = 0x00000200;
-pub const HUPCL: ::tcflag_t = 0x00000400;
-pub const CLOCAL: ::tcflag_t = 0x00000800;
-pub const ECHOKE: ::tcflag_t = 0x00000800;
-pub const ECHOE: ::tcflag_t = 0x00000010;
-pub const ECHOK: ::tcflag_t = 0x00000020;
-pub const ECHONL: ::tcflag_t = 0x00000040;
-pub const ECHOPRT: ::tcflag_t = 0x00000400;
-pub const ECHOCTL: ::tcflag_t = 0x00000200;
-pub const ISIG: ::tcflag_t = 0x00000001;
-pub const ICANON: ::tcflag_t = 0x00000002;
-pub const PENDIN: ::tcflag_t = 0x00004000;
-pub const NOFLSH: ::tcflag_t = 0x00000080;
-pub const CIBAUD: ::tcflag_t = 0o02003600000;
-pub const CBAUDEX: ::tcflag_t = 0o010000;
-pub const VSWTC: usize = 7;
-pub const OLCUC: ::tcflag_t = 0o000002;
-pub const NLDLY: ::tcflag_t = 0o000400;
-pub const CRDLY: ::tcflag_t = 0o003000;
-pub const TABDLY: ::tcflag_t = 0o014000;
-pub const BSDLY: ::tcflag_t = 0o020000;
-pub const FFDLY: ::tcflag_t = 0o100000;
-pub const VTDLY: ::tcflag_t = 0o040000;
-pub const XTABS: ::tcflag_t = 0o014000;
-
-pub const B0: ::speed_t = 0o000000;
-pub const B50: ::speed_t = 0o000001;
-pub const B75: ::speed_t = 0o000002;
-pub const B110: ::speed_t = 0o000003;
-pub const B134: ::speed_t = 0o000004;
-pub const B150: ::speed_t = 0o000005;
-pub const B200: ::speed_t = 0o000006;
-pub const B300: ::speed_t = 0o000007;
-pub const B600: ::speed_t = 0o000010;
-pub const B1200: ::speed_t = 0o000011;
-pub const B1800: ::speed_t = 0o000012;
-pub const B2400: ::speed_t = 0o000013;
-pub const B4800: ::speed_t = 0o000014;
-pub const B9600: ::speed_t = 0o000015;
-pub const B19200: ::speed_t = 0o000016;
-pub const B38400: ::speed_t = 0o000017;
-pub const EXTA: ::speed_t = B19200;
-pub const EXTB: ::speed_t = B38400;
-pub const BOTHER: ::speed_t = 0o010000;
-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 VEOL: usize = 11;
-pub const VEOL2: usize = 16;
-pub const VMIN: usize = 6;
-pub const IEXTEN: ::tcflag_t = 0x00008000;
-pub const TOSTOP: ::tcflag_t = 0x00000100;
-pub const FLUSHO: ::tcflag_t = 0x00001000;
-pub const EXTPROC: ::tcflag_t = 0x00010000;
-pub const TCGETS: ::c_ulong = 0x5401;
-pub const TCSETS: ::c_ulong = 0x5402;
-pub const TCSETSW: ::c_ulong = 0x5403;
-pub const TCSETSF: ::c_ulong = 0x5404;
-pub const TCGETA: ::c_ulong = 0x5405;
-pub const TCSETA: ::c_ulong = 0x5406;
-pub const TCSETAW: ::c_ulong = 0x5407;
-pub const TCSETAF: ::c_ulong = 0x5408;
-pub const TCSBRK: ::c_ulong = 0x5409;
-pub const TCXONC: ::c_ulong = 0x540A;
-pub const TCFLSH: ::c_ulong = 0x540B;
-pub const TIOCINQ: ::c_ulong = 0x541B;
-pub const TIOCGPGRP: ::c_ulong = 0x540F;
-pub const TIOCSPGRP: ::c_ulong = 0x5410;
-pub const TIOCOUTQ: ::c_ulong = 0x5411;
-pub const TIOCGWINSZ: ::c_ulong = 0x5413;
-pub const TIOCSWINSZ: ::c_ulong = 0x5414;
-pub const TIOCGRS485: ::c_int = 0x542E;
-pub const TIOCSRS485: ::c_int = 0x542F;
-pub const FIONREAD: ::c_ulong = 0x541B;
-
-// 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_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_mknod: ::c_long = 14;
-pub const SYS_chmod: ::c_long = 15;
-pub const SYS_lchown: ::c_long = 16;
-pub const SYS_lseek: ::c_long = 19;
-pub const SYS_getpid: ::c_long = 20;
-pub const SYS_mount: ::c_long = 21;
-pub const SYS_setuid: ::c_long = 23;
-pub const SYS_getuid: ::c_long = 24;
-pub const SYS_ptrace: ::c_long = 26;
-pub const SYS_pause: ::c_long = 29;
-pub const SYS_access: ::c_long = 33;
-pub const SYS_nice: ::c_long = 34;
-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_brk: ::c_long = 45;
-pub const SYS_setgid: ::c_long = 46;
-pub const SYS_getgid: ::c_long = 47;
-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_ioctl: ::c_long = 54;
-pub const SYS_fcntl: ::c_long = 55;
-pub const SYS_setpgid: ::c_long = 57;
-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_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_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_symlink: ::c_long = 83;
-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_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_statfs: ::c_long = 99;
-pub const SYS_fstatfs: ::c_long = 100;
-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_vhangup: ::c_long = 111;
-pub const SYS_wait4: ::c_long = 114;
-pub const SYS_swapoff: ::c_long = 115;
-pub const SYS_sysinfo: ::c_long = 116;
-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_adjtimex: ::c_long = 124;
-pub const SYS_mprotect: ::c_long = 125;
-pub const SYS_sigprocmask: ::c_long = 126;
-pub const SYS_init_module: ::c_long = 128;
-pub const SYS_delete_module: ::c_long = 129;
-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_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_poll: ::c_long = 168;
-pub const SYS_nfsservctl: ::c_long = 169;
-pub const SYS_setresgid: ::c_long = 170;
-pub const SYS_getresgid: ::c_long = 171;
-pub const SYS_prctl: ::c_long = 172;
-pub const SYS_rt_sigreturn: ::c_long = 173;
-pub const SYS_rt_sigaction: ::c_long = 174;
-pub const SYS_rt_sigprocmask: ::c_long = 175;
-pub const SYS_rt_sigpending: ::c_long = 176;
-pub const SYS_rt_sigtimedwait: ::c_long = 177;
-pub const SYS_rt_sigqueueinfo: ::c_long = 178;
-pub const SYS_rt_sigsuspend: ::c_long = 179;
-pub const SYS_pread64: ::c_long = 180;
-pub const SYS_pwrite64: ::c_long = 181;
-pub const SYS_chown: ::c_long = 182;
-pub const SYS_getcwd: ::c_long = 183;
-pub const SYS_capget: ::c_long = 184;
-pub const SYS_capset: ::c_long = 185;
-pub const SYS_sigaltstack: ::c_long = 186;
-pub const SYS_sendfile: ::c_long = 187;
-pub const SYS_vfork: ::c_long = 190;
-pub const SYS_ugetrlimit: ::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_lchown32: ::c_long = 198;
-pub const SYS_getuid32: ::c_long = 199;
-pub const SYS_getgid32: ::c_long = 200;
-pub const SYS_geteuid32: ::c_long = 201;
-pub const SYS_getegid32: ::c_long = 202;
-pub const SYS_setreuid32: ::c_long = 203;
-pub const SYS_setregid32: ::c_long = 204;
-pub const SYS_getgroups32: ::c_long = 205;
-pub const SYS_setgroups32: ::c_long = 206;
-pub const SYS_fchown32: ::c_long = 207;
-pub const SYS_setresuid32: ::c_long = 208;
-pub const SYS_getresuid32: ::c_long = 209;
-pub const SYS_setresgid32: ::c_long = 210;
-pub const SYS_getresgid32: ::c_long = 211;
-pub const SYS_chown32: ::c_long = 212;
-pub const SYS_setuid32: ::c_long = 213;
-pub const SYS_setgid32: ::c_long = 214;
-pub const SYS_setfsuid32: ::c_long = 215;
-pub const SYS_setfsgid32: ::c_long = 216;
-pub const SYS_getdents64: ::c_long = 217;
-pub const SYS_pivot_root: ::c_long = 218;
-pub const SYS_mincore: ::c_long = 219;
-pub const SYS_madvise: ::c_long = 220;
-pub const SYS_fcntl64: ::c_long = 221;
-pub const SYS_gettid: ::c_long = 224;
-pub const SYS_readahead: ::c_long = 225;
-pub const SYS_setxattr: ::c_long = 226;
-pub const SYS_lsetxattr: ::c_long = 227;
-pub const SYS_fsetxattr: ::c_long = 228;
-pub const SYS_getxattr: ::c_long = 229;
-pub const SYS_lgetxattr: ::c_long = 230;
-pub const SYS_fgetxattr: ::c_long = 231;
-pub const SYS_listxattr: ::c_long = 232;
-pub const SYS_llistxattr: ::c_long = 233;
-pub const SYS_flistxattr: ::c_long = 234;
-pub const SYS_removexattr: ::c_long = 235;
-pub const SYS_lremovexattr: ::c_long = 236;
-pub const SYS_fremovexattr: ::c_long = 237;
-pub const SYS_tkill: ::c_long = 238;
-pub const SYS_sendfile64: ::c_long = 239;
-pub const SYS_futex: ::c_long = 240;
-pub const SYS_sched_setaffinity: ::c_long = 241;
-pub const SYS_sched_getaffinity: ::c_long = 242;
-pub const SYS_io_setup: ::c_long = 243;
-pub const SYS_io_destroy: ::c_long = 244;
-pub const SYS_io_getevents: ::c_long = 245;
-pub const SYS_io_submit: ::c_long = 246;
-pub const SYS_io_cancel: ::c_long = 247;
-pub const SYS_exit_group: ::c_long = 248;
-pub const SYS_lookup_dcookie: ::c_long = 249;
-pub const SYS_epoll_create: ::c_long = 250;
-pub const SYS_epoll_ctl: ::c_long = 251;
-pub const SYS_epoll_wait: ::c_long = 252;
-pub const SYS_remap_file_pages: ::c_long = 253;
-pub const SYS_set_tid_address: ::c_long = 256;
-pub const SYS_timer_create: ::c_long = 257;
-pub const SYS_timer_settime: ::c_long = 258;
-pub const SYS_timer_gettime: ::c_long = 259;
-pub const SYS_timer_getoverrun: ::c_long = 260;
-pub const SYS_timer_delete: ::c_long = 261;
-pub const SYS_clock_settime: ::c_long = 262;
-pub const SYS_clock_gettime: ::c_long = 263;
-pub const SYS_clock_getres: ::c_long = 264;
-pub const SYS_clock_nanosleep: ::c_long = 265;
-pub const SYS_statfs64: ::c_long = 266;
-pub const SYS_fstatfs64: ::c_long = 267;
-pub const SYS_tgkill: ::c_long = 268;
-pub const SYS_utimes: ::c_long = 269;
-pub const SYS_arm_fadvise64_64: ::c_long = 270;
-pub const SYS_pciconfig_iobase: ::c_long = 271;
-pub const SYS_pciconfig_read: ::c_long = 272;
-pub const SYS_pciconfig_write: ::c_long = 273;
-pub const SYS_mq_open: ::c_long = 274;
-pub const SYS_mq_unlink: ::c_long = 275;
-pub const SYS_mq_timedsend: ::c_long = 276;
-pub const SYS_mq_timedreceive: ::c_long = 277;
-pub const SYS_mq_notify: ::c_long = 278;
-pub const SYS_mq_getsetattr: ::c_long = 279;
-pub const SYS_waitid: ::c_long = 280;
-pub const SYS_socket: ::c_long = 281;
-pub const SYS_bind: ::c_long = 282;
-pub const SYS_connect: ::c_long = 283;
-pub const SYS_listen: ::c_long = 284;
-pub const SYS_accept: ::c_long = 285;
-pub const SYS_getsockname: ::c_long = 286;
-pub const SYS_getpeername: ::c_long = 287;
-pub const SYS_socketpair: ::c_long = 288;
-pub const SYS_send: ::c_long = 289;
-pub const SYS_sendto: ::c_long = 290;
-pub const SYS_recv: ::c_long = 291;
-pub const SYS_recvfrom: ::c_long = 292;
-pub const SYS_shutdown: ::c_long = 293;
-pub const SYS_setsockopt: ::c_long = 294;
-pub const SYS_getsockopt: ::c_long = 295;
-pub const SYS_sendmsg: ::c_long = 296;
-pub const SYS_recvmsg: ::c_long = 297;
-pub const SYS_semop: ::c_long = 298;
-pub const SYS_semget: ::c_long = 299;
-pub const SYS_semctl: ::c_long = 300;
-pub const SYS_msgsnd: ::c_long = 301;
-pub const SYS_msgrcv: ::c_long = 302;
-pub const SYS_msgget: ::c_long = 303;
-pub const SYS_msgctl: ::c_long = 304;
-pub const SYS_shmat: ::c_long = 305;
-pub const SYS_shmdt: ::c_long = 306;
-pub const SYS_shmget: ::c_long = 307;
-pub const SYS_shmctl: ::c_long = 308;
-pub const SYS_add_key: ::c_long = 309;
-pub const SYS_request_key: ::c_long = 310;
-pub const SYS_keyctl: ::c_long = 311;
-pub const SYS_semtimedop: ::c_long = 312;
-pub const SYS_vserver: ::c_long = 313;
-pub const SYS_ioprio_set: ::c_long = 314;
-pub const SYS_ioprio_get: ::c_long = 315;
-pub const SYS_inotify_init: ::c_long = 316;
-pub const SYS_inotify_add_watch: ::c_long = 317;
-pub const SYS_inotify_rm_watch: ::c_long = 318;
-pub const SYS_mbind: ::c_long = 319;
-pub const SYS_get_mempolicy: ::c_long = 320;
-pub const SYS_set_mempolicy: ::c_long = 321;
-pub const SYS_openat: ::c_long = 322;
-pub const SYS_mkdirat: ::c_long = 323;
-pub const SYS_mknodat: ::c_long = 324;
-pub const SYS_fchownat: ::c_long = 325;
-pub const SYS_futimesat: ::c_long = 326;
-pub const SYS_fstatat64: ::c_long = 327;
-pub const SYS_unlinkat: ::c_long = 328;
-pub const SYS_renameat: ::c_long = 329;
-pub const SYS_linkat: ::c_long = 330;
-pub const SYS_symlinkat: ::c_long = 331;
-pub const SYS_readlinkat: ::c_long = 332;
-pub const SYS_fchmodat: ::c_long = 333;
-pub const SYS_faccessat: ::c_long = 334;
-pub const SYS_pselect6: ::c_long = 335;
-pub const SYS_ppoll: ::c_long = 336;
-pub const SYS_unshare: ::c_long = 337;
-pub const SYS_set_robust_list: ::c_long = 338;
-pub const SYS_get_robust_list: ::c_long = 339;
-pub const SYS_splice: ::c_long = 340;
-pub const SYS_arm_sync_file_range: ::c_long = 341;
-pub const SYS_tee: ::c_long = 342;
-pub const SYS_vmsplice: ::c_long = 343;
-pub const SYS_move_pages: ::c_long = 344;
-pub const SYS_getcpu: ::c_long = 345;
-pub const SYS_epoll_pwait: ::c_long = 346;
-pub const SYS_kexec_load: ::c_long = 347;
-pub const SYS_utimensat: ::c_long = 348;
-pub const SYS_signalfd: ::c_long = 349;
-pub const SYS_timerfd_create: ::c_long = 350;
-pub const SYS_eventfd: ::c_long = 351;
-pub const SYS_fallocate: ::c_long = 352;
-pub const SYS_timerfd_settime: ::c_long = 353;
-pub const SYS_timerfd_gettime: ::c_long = 354;
-pub const SYS_signalfd4: ::c_long = 355;
-pub const SYS_eventfd2: ::c_long = 356;
-pub const SYS_epoll_create1: ::c_long = 357;
-pub const SYS_dup3: ::c_long = 358;
-pub const SYS_pipe2: ::c_long = 359;
-pub const SYS_inotify_init1: ::c_long = 360;
-pub const SYS_preadv: ::c_long = 361;
-pub const SYS_pwritev: ::c_long = 362;
-pub const SYS_rt_tgsigqueueinfo: ::c_long = 363;
-pub const SYS_perf_event_open: ::c_long = 364;
-pub const SYS_recvmmsg: ::c_long = 365;
-pub const SYS_accept4: ::c_long = 366;
-pub const SYS_fanotify_init: ::c_long = 367;
-pub const SYS_fanotify_mark: ::c_long = 368;
-pub const SYS_prlimit64: ::c_long = 369;
-pub const SYS_name_to_handle_at: ::c_long = 370;
-pub const SYS_open_by_handle_at: ::c_long = 371;
-pub const SYS_clock_adjtime: ::c_long = 372;
-pub const SYS_syncfs: ::c_long = 373;
-pub const SYS_sendmmsg: ::c_long = 374;
-pub const SYS_setns: ::c_long = 375;
-pub const SYS_process_vm_readv: ::c_long = 376;
-pub const SYS_process_vm_writev: ::c_long = 377;
-pub const SYS_kcmp: ::c_long = 378;
-pub const SYS_finit_module: ::c_long = 379;
-pub const SYS_sched_setattr: ::c_long = 380;
-pub const SYS_sched_getattr: ::c_long = 381;
-pub const SYS_renameat2: ::c_long = 382;
-pub const SYS_seccomp: ::c_long = 383;
-pub const SYS_getrandom: ::c_long = 384;
-pub const SYS_memfd_create: ::c_long = 385;
-pub const SYS_bpf: ::c_long = 386;
-pub const SYS_execveat: ::c_long = 387;
-pub const SYS_userfaultfd: ::c_long = 388;
-pub const SYS_membarrier: ::c_long = 389;
-pub const SYS_mlock2: ::c_long = 390;
-pub const SYS_copy_file_range: ::c_long = 391;
-pub const SYS_preadv2: ::c_long = 392;
-pub const SYS_pwritev2: ::c_long = 393;
-pub const SYS_pkey_mprotect: ::c_long = 394;
-pub const SYS_pkey_alloc: ::c_long = 395;
-pub const SYS_pkey_free: ::c_long = 396;
-pub const SYS_statx: ::c_long = 397;
diff --git a/libc/src/unix/notbsd/linux/other/b32/mod.rs b/libc/src/unix/notbsd/linux/other/b32/mod.rs
deleted file mode 100644
index 32e510e..0000000
--- a/libc/src/unix/notbsd/linux/other/b32/mod.rs
+++ /dev/null
@@ -1,392 +0,0 @@
-//! 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;
-pub type time_t = i32;
-pub type suseconds_t = i32;
-pub type ino_t = u32;
-pub type off_t = i32;
-pub type blkcnt_t = i32;
-pub type __fsword_t = i32;
-
-pub type fsblkcnt_t = ::c_ulong;
-pub type fsfilcnt_t = ::c_ulong;
-pub type rlim_t = c_ulong;
-pub type shmatt_t = ::c_ulong;
-pub type msgqnum_t = ::c_ulong;
-pub type msglen_t = ::c_ulong;
-pub type blksize_t = i32;
-pub type nlink_t = u32;
-pub type __u64 = ::c_ulonglong;
-
-s! {
- pub struct stat {
- pub st_dev: ::dev_t,
- __pad1: ::c_short,
- 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,
- __pad2: ::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,
- __unused4: ::c_long,
- __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]
- }
-
- pub struct sigset_t {
- __val: [::c_ulong; 32],
- }
-
- pub struct sysinfo {
- pub uptime: ::c_long,
- pub loads: [::c_ulong; 3],
- pub totalram: ::c_ulong,
- pub freeram: ::c_ulong,
- pub sharedram: ::c_ulong,
- pub bufferram: ::c_ulong,
- pub totalswap: ::c_ulong,
- pub freeswap: ::c_ulong,
- pub procs: ::c_ushort,
- pub pad: ::c_ushort,
- pub totalhigh: ::c_ulong,
- pub freehigh: ::c_ulong,
- pub mem_unit: ::c_uint,
- pub _f: [::c_char; 8],
- }
-}
-
-pub const TIOCGSOFTCAR: ::c_ulong = 0x5419;
-pub const TIOCSSOFTCAR: ::c_ulong = 0x541A;
-
-pub const RLIMIT_NOFILE: ::c_int = 7;
-pub const RLIMIT_NPROC: ::c_int = 6;
-
-pub const O_APPEND: ::c_int = 1024;
-pub const O_CREAT: ::c_int = 64;
-pub const O_EXCL: ::c_int = 128;
-pub const O_NOCTTY: ::c_int = 256;
-pub const O_NONBLOCK: ::c_int = 2048;
-pub const O_SYNC: ::c_int = 1052672;
-pub const O_RSYNC: ::c_int = 1052672;
-pub const O_DSYNC: ::c_int = 4096;
-pub const O_FSYNC: ::c_int = 0x101000;
-pub const O_NOATIME: ::c_int = 0o1000000;
-pub const O_PATH: ::c_int = 0o10000000;
-pub const O_TMPFILE: ::c_int = 0o20000000 | O_DIRECTORY;
-
-pub const MAP_GROWSDOWN: ::c_int = 0x0100;
-
-pub const EDEADLK: ::c_int = 35;
-pub const ENAMETOOLONG: ::c_int = 36;
-pub const ENOLCK: ::c_int = 37;
-pub const ENOSYS: ::c_int = 38;
-pub const ENOTEMPTY: ::c_int = 39;
-pub const ELOOP: ::c_int = 40;
-pub const ENOMSG: ::c_int = 42;
-pub const EIDRM: ::c_int = 43;
-pub const ECHRNG: ::c_int = 44;
-pub const EL2NSYNC: ::c_int = 45;
-pub const EL3HLT: ::c_int = 46;
-pub const EL3RST: ::c_int = 47;
-pub const ELNRNG: ::c_int = 48;
-pub const EUNATCH: ::c_int = 49;
-pub const ENOCSI: ::c_int = 50;
-pub const EL2HLT: ::c_int = 51;
-pub const EBADE: ::c_int = 52;
-pub const EBADR: ::c_int = 53;
-pub const EXFULL: ::c_int = 54;
-pub const ENOANO: ::c_int = 55;
-pub const EBADRQC: ::c_int = 56;
-pub const EBADSLT: ::c_int = 57;
-pub const EMULTIHOP: ::c_int = 72;
-pub const EOVERFLOW: ::c_int = 75;
-pub const ENOTUNIQ: ::c_int = 76;
-pub const EBADFD: ::c_int = 77;
-pub const EBADMSG: ::c_int = 74;
-pub const EREMCHG: ::c_int = 78;
-pub const ELIBACC: ::c_int = 79;
-pub const ELIBBAD: ::c_int = 80;
-pub const ELIBSCN: ::c_int = 81;
-pub const ELIBMAX: ::c_int = 82;
-pub const ELIBEXEC: ::c_int = 83;
-pub const EILSEQ: ::c_int = 84;
-pub const ERESTART: ::c_int = 85;
-pub const ESTRPIPE: ::c_int = 86;
-pub const EUSERS: ::c_int = 87;
-pub const ENOTSOCK: ::c_int = 88;
-pub const EDESTADDRREQ: ::c_int = 89;
-pub const EMSGSIZE: ::c_int = 90;
-pub const EPROTOTYPE: ::c_int = 91;
-pub const ENOPROTOOPT: ::c_int = 92;
-pub const EPROTONOSUPPORT: ::c_int = 93;
-pub const ESOCKTNOSUPPORT: ::c_int = 94;
-pub const EOPNOTSUPP: ::c_int = 95;
-pub const EPFNOSUPPORT: ::c_int = 96;
-pub const EAFNOSUPPORT: ::c_int = 97;
-pub const EADDRINUSE: ::c_int = 98;
-pub const EADDRNOTAVAIL: ::c_int = 99;
-pub const ENETDOWN: ::c_int = 100;
-pub const ENETUNREACH: ::c_int = 101;
-pub const ENETRESET: ::c_int = 102;
-pub const ECONNABORTED: ::c_int = 103;
-pub const ECONNRESET: ::c_int = 104;
-pub const ENOBUFS: ::c_int = 105;
-pub const EISCONN: ::c_int = 106;
-pub const ENOTCONN: ::c_int = 107;
-pub const ESHUTDOWN: ::c_int = 108;
-pub const ETOOMANYREFS: ::c_int = 109;
-pub const ETIMEDOUT: ::c_int = 110;
-pub const ECONNREFUSED: ::c_int = 111;
-pub const EHOSTDOWN: ::c_int = 112;
-pub const EHOSTUNREACH: ::c_int = 113;
-pub const EALREADY: ::c_int = 114;
-pub const EINPROGRESS: ::c_int = 115;
-pub const ESTALE: ::c_int = 116;
-pub const EDQUOT: ::c_int = 122;
-pub const ENOMEDIUM: ::c_int = 123;
-pub const EMEDIUMTYPE: ::c_int = 124;
-pub const ECANCELED: ::c_int = 125;
-pub const ENOKEY: ::c_int = 126;
-pub const EKEYEXPIRED: ::c_int = 127;
-pub const EKEYREVOKED: ::c_int = 128;
-pub const EKEYREJECTED: ::c_int = 129;
-pub const EOWNERDEAD: ::c_int = 130;
-pub const ENOTRECOVERABLE: ::c_int = 131;
-pub const EHWPOISON: ::c_int = 133;
-pub const ERFKILL: ::c_int = 132;
-
-pub const SOL_SOCKET: ::c_int = 1;
-
-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_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_BINDTODEVICE: ::c_int = 25;
-pub const SO_TIMESTAMP: ::c_int = 29;
-pub const SO_ACCEPTCONN: ::c_int = 30;
-pub const SO_MARK: ::c_int = 36;
-pub const SO_PROTOCOL: ::c_int = 38;
-pub const SO_DOMAIN: ::c_int = 39;
-pub const SO_RXQ_OVFL: ::c_int = 40;
-pub const SO_PEEK_OFF: ::c_int = 42;
-pub const SO_BUSY_POLL: ::c_int = 46;
-
-pub const 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 SIGUSR1: ::c_int = 10;
-pub const SIGUSR2: ::c_int = 12;
-pub const SIGCONT: ::c_int = 18;
-pub const SIGSTOP: ::c_int = 19;
-pub const SIGTSTP: ::c_int = 20;
-pub const SIGURG: ::c_int = 23;
-pub const SIGIO: ::c_int = 29;
-pub const SIGSYS: ::c_int = 31;
-pub const SIGSTKFLT: ::c_int = 16;
-#[deprecated(
- since = "0.2.55",
- note = "Use SIGSYS instead"
-)]
-pub const SIGUNUSED: ::c_int = 31;
-pub const SIGPOLL: ::c_int = 29;
-pub const SIGPWR: ::c_int = 30;
-pub const SIG_SETMASK: ::c_int = 2;
-pub const SIG_BLOCK: ::c_int = 0x000000;
-pub const SIG_UNBLOCK: ::c_int = 0x01;
-
-pub const POLLWRNORM: ::c_short = 0x100;
-pub const POLLWRBAND: ::c_short = 0x200;
-
-pub const O_ASYNC: ::c_int = 0x2000;
-pub const O_NDELAY: ::c_int = 0x800;
-
-pub const PTRACE_DETACH: ::c_uint = 17;
-
-pub const EFD_NONBLOCK: ::c_int = 0x800;
-
-pub const F_GETLK: ::c_int = 5;
-pub const F_GETOWN: ::c_int = 9;
-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;
-pub const TIOCNXCL: ::c_ulong = 0x540D;
-pub const TIOCSCTTY: ::c_ulong = 0x540E;
-pub const TIOCSTI: ::c_ulong = 0x5412;
-pub const TIOCMGET: ::c_ulong = 0x5415;
-pub const TIOCMBIS: ::c_ulong = 0x5416;
-pub const TIOCMBIC: ::c_ulong = 0x5417;
-pub const TIOCMSET: ::c_ulong = 0x5418;
-pub const TIOCCONS: ::c_ulong = 0x541D;
-
-pub const SFD_CLOEXEC: ::c_int = 0x080000;
-
-pub const NCCS: usize = 32;
-
-pub const O_TRUNC: ::c_int = 512;
-
-pub const O_CLOEXEC: ::c_int = 0x80000;
-
-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 EDOTDOT: ::c_int = 73;
-
-pub const SA_NODEFER: ::c_int = 0x40000000;
-pub const SA_RESETHAND: ::c_int = 0x80000000;
-pub const SA_RESTART: ::c_int = 0x10000000;
-pub const SA_NOCLDSTOP: ::c_int = 0x00000001;
-
-pub const EPOLL_CLOEXEC: ::c_int = 0x80000;
-
-pub const EFD_CLOEXEC: ::c_int = 0x80000;
-
-pub const __SIZEOF_PTHREAD_CONDATTR_T: usize = 4;
-pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 24;
-pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 32;
-pub const __SIZEOF_PTHREAD_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;
-pub const PTRACE_SETREGS: ::c_uint = 13;
-
-#[link(name = "util")]
-extern {
- pub fn sysctl(name: *mut ::c_int,
- namelen: ::c_int,
- oldp: *mut ::c_void,
- oldlenp: *mut ::size_t,
- newp: *mut ::c_void,
- newlen: ::size_t)
- -> ::c_int;
-}
-
-cfg_if! {
- if #[cfg(target_arch = "x86")] {
- mod x86;
- pub use self::x86::*;
- } 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 {
- // Unknown target_arch
- }
-}
diff --git a/libc/src/unix/notbsd/linux/other/b32/powerpc.rs b/libc/src/unix/notbsd/linux/other/b32/powerpc.rs
deleted file mode 100644
index a64f075..0000000
--- a/libc/src/unix/notbsd/linux/other/b32/powerpc.rs
+++ /dev/null
@@ -1,617 +0,0 @@
-pub type c_char = u8;
-pub type wchar_t = i32;
-
-s! {
- pub struct 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,
- __seq: u32,
- __pad1: u32,
- __glibc_reserved1: u64,
- __glibc_reserved2: u64,
- }
-
- pub struct stat64 {
- pub st_dev: ::dev_t,
- pub st_ino: ::ino64_t,
- pub st_mode: ::mode_t,
- pub st_nlink: ::nlink_t,
- pub st_uid: ::uid_t,
- pub st_gid: ::gid_t,
- pub st_rdev: ::dev_t,
- __pad2: ::c_ushort,
- pub st_size: ::off64_t,
- pub st_blksize: ::blksize_t,
- pub st_blocks: ::blkcnt64_t,
- pub st_atime: ::time_t,
- pub st_atime_nsec: ::c_long,
- pub st_mtime: ::time_t,
- pub st_mtime_nsec: ::c_long,
- pub st_ctime: ::time_t,
- pub st_ctime_nsec: ::c_long,
- __glibc_reserved4: ::c_ulong,
- __glibc_reserved5: ::c_ulong,
- }
-
- pub struct statfs64 {
- pub f_type: ::__fsword_t,
- pub f_bsize: ::__fsword_t,
- pub f_blocks: u64,
- pub f_bfree: u64,
- pub f_bavail: u64,
- pub f_files: u64,
- pub f_ffree: u64,
- pub f_fsid: ::fsid_t,
- pub f_namelen: ::__fsword_t,
- pub f_frsize: ::__fsword_t,
- pub f_flags: ::__fsword_t,
- pub f_spare: [::__fsword_t; 4],
- }
-
- pub struct statvfs64 {
- pub f_bsize: ::c_ulong,
- pub f_frsize: ::c_ulong,
- pub f_blocks: u64,
- pub f_bfree: u64,
- pub f_bavail: u64,
- pub f_files: u64,
- pub f_ffree: u64,
- pub f_favail: u64,
- pub f_fsid: ::c_ulong,
- __f_unused: ::c_int,
- pub f_flag: ::c_ulong,
- pub f_namemax: ::c_ulong,
- __f_spare: [::c_int; 6],
- }
-
- pub struct shmid_ds {
- pub shm_perm: ::ipc_perm,
- __glibc_reserved1: ::c_uint,
- pub shm_atime: ::time_t,
- __glibc_reserved2: ::c_uint,
- pub shm_dtime: ::time_t,
- __glibc_reserved3: ::c_uint,
- pub shm_ctime: ::time_t,
- __glibc_reserved4: ::c_uint,
- pub shm_segsz: ::size_t,
- pub shm_cpid: ::pid_t,
- pub shm_lpid: ::pid_t,
- pub shm_nattch: ::shmatt_t,
- __glibc_reserved5: ::c_ulong,
- __glibc_reserved6: ::c_ulong,
- }
-
- pub struct msqid_ds {
- pub msg_perm: ::ipc_perm,
- __glibc_reserved1: ::c_uint,
- pub msg_stime: ::time_t,
- __glibc_reserved2: ::c_uint,
- pub msg_rtime: ::time_t,
- __glibc_reserved3: ::c_uint,
- 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,
- __glibc_reserved4: ::c_ulong,
- __glibc_reserved5: ::c_ulong,
- }
-}
-
-pub const O_DIRECT: ::c_int = 0x20000;
-pub const O_DIRECTORY: ::c_int = 0x4000;
-pub const O_NOFOLLOW: ::c_int = 0x8000;
-pub const O_LARGEFILE: ::c_int = 0o200000;
-
-pub const MAP_LOCKED: ::c_int = 0x00080;
-pub const MAP_NORESERVE: ::c_int = 0x00040;
-
-pub const EDEADLOCK: ::c_int = 58;
-
-pub const SO_SNDBUFFORCE: ::c_int = 32;
-pub const SO_RCVBUFFORCE: ::c_int = 33;
-pub const SO_NO_CHECK: ::c_int = 11;
-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 FIOCLEX: ::c_ulong = 0x20006601;
-pub const FIONBIO: ::c_ulong = 0x8004667e;
-
-pub const MCL_CURRENT: ::c_int = 0x2000;
-pub const MCL_FUTURE: ::c_int = 0x4000;
-
-pub const SIGSTKSZ: ::size_t = 0x4000;
-pub const MINSIGSTKSZ: ::size_t = 4096;
-pub const CBAUD: ::tcflag_t = 0xff;
-pub const TAB1: ::tcflag_t = 0x400;
-pub const TAB2: ::tcflag_t = 0x800;
-pub const TAB3: ::tcflag_t = 0xc00;
-pub const CR1: ::tcflag_t = 0x1000;
-pub const CR2: ::tcflag_t = 0x2000;
-pub const CR3: ::tcflag_t = 0x3000;
-pub const FF1: ::tcflag_t = 0x4000;
-pub const BS1: ::tcflag_t = 0x8000;
-pub const VT1: ::tcflag_t = 0x10000;
-pub const VWERASE: usize = 0xa;
-pub const VREPRINT: usize = 0xb;
-pub const VSUSP: usize = 0xc;
-pub const VSTART: usize = 0xd;
-pub const VSTOP: usize = 0xe;
-pub const VDISCARD: usize = 0x10;
-pub const VTIME: usize = 0x7;
-pub const IXON: ::tcflag_t = 0x200;
-pub const IXOFF: ::tcflag_t = 0x400;
-pub const ONLCR: ::tcflag_t = 0x2;
-pub const CSIZE: ::tcflag_t = 0x300;
-pub const CS6: ::tcflag_t = 0x100;
-pub const CS7: ::tcflag_t = 0x200;
-pub const CS8: ::tcflag_t = 0x300;
-pub const CSTOPB: ::tcflag_t = 0x400;
-pub const CREAD: ::tcflag_t = 0x800;
-pub const PARENB: ::tcflag_t = 0x1000;
-pub const PARODD: ::tcflag_t = 0x2000;
-pub const HUPCL: ::tcflag_t = 0x4000;
-pub const CLOCAL: ::tcflag_t = 0x8000;
-pub const ECHOKE: ::tcflag_t = 0x1;
-pub const ECHOE: ::tcflag_t = 0x2;
-pub const ECHOK: ::tcflag_t = 0x4;
-pub const ECHONL: ::tcflag_t = 0x10;
-pub const ECHOPRT: ::tcflag_t = 0x20;
-pub const ECHOCTL: ::tcflag_t = 0x40;
-pub const ISIG: ::tcflag_t = 0x80;
-pub const ICANON: ::tcflag_t = 0x100;
-pub const PENDIN: ::tcflag_t = 0x20000000;
-pub const NOFLSH: ::tcflag_t = 0x80000000;
-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 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 CBAUDEX: ::speed_t = 0o000020;
-pub const B57600: ::speed_t = 0o0020;
-pub const B115200: ::speed_t = 0o0021;
-pub const B230400: ::speed_t = 0o0022;
-pub const B460800: ::speed_t = 0o0023;
-pub const B500000: ::speed_t = 0o0024;
-pub const B576000: ::speed_t = 0o0025;
-pub const B921600: ::speed_t = 0o0026;
-pub const B1000000: ::speed_t = 0o0027;
-pub const B1152000: ::speed_t = 0o0030;
-pub const B1500000: ::speed_t = 0o0031;
-pub const B2000000: ::speed_t = 0o0032;
-pub const B2500000: ::speed_t = 0o0033;
-pub const B3000000: ::speed_t = 0o0034;
-pub const B3500000: ::speed_t = 0o0035;
-pub const B4000000: ::speed_t = 0o0036;
-pub const BOTHER: ::speed_t = 0o0037;
-
-pub const VEOL: usize = 6;
-pub const VEOL2: usize = 8;
-pub const VMIN: usize = 5;
-pub const IEXTEN: ::tcflag_t = 0x400;
-pub const TOSTOP: ::tcflag_t = 0x400000;
-pub const FLUSHO: ::tcflag_t = 0x800000;
-pub const EXTPROC: ::tcflag_t = 0x10000000;
-pub const TCGETS: ::c_ulong = 0x403c7413;
-pub const TCSETS: ::c_ulong = 0x803c7414;
-pub const TCSETSW: ::c_ulong = 0x803c7415;
-pub const TCSETSF: ::c_ulong = 0x803c7416;
-pub const TCGETA: ::c_ulong = 0x40147417;
-pub const TCSETA: ::c_ulong = 0x80147418;
-pub const TCSETAW: ::c_ulong = 0x80147419;
-pub const TCSETAF: ::c_ulong = 0x8014741c;
-pub const TCSBRK: ::c_ulong = 0x2000741d;
-pub const TCXONC: ::c_ulong = 0x2000741e;
-pub const TCFLSH: ::c_ulong = 0x2000741f;
-pub const TIOCINQ: ::c_ulong = 0x4004667f;
-pub const TIOCGPGRP: ::c_ulong = 0x40047477;
-pub const TIOCSPGRP: ::c_ulong = 0x80047476;
-pub const TIOCOUTQ: ::c_ulong = 0x40047473;
-pub const TIOCGWINSZ: ::c_ulong = 0x40087468;
-pub const TIOCSWINSZ: ::c_ulong = 0x80087467;
-pub const TIOCGRS485: ::c_int = 0x542e;
-pub const TIOCSRS485: ::c_int = 0x542f;
-pub const FIONREAD: ::c_ulong = 0x4004667f;
-
-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_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;
diff --git a/libc/src/unix/notbsd/linux/other/b32/x86.rs b/libc/src/unix/notbsd/linux/other/b32/x86.rs
deleted file mode 100644
index 00f1f1a..0000000
--- a/libc/src/unix/notbsd/linux/other/b32/x86.rs
+++ /dev/null
@@ -1,895 +0,0 @@
-pub type c_char = i8;
-pub type wchar_t = i32;
-pub type greg_t = i32;
-
-s! {
- pub struct _libc_fpreg {
- pub significand: [u16; 4],
- pub exponent: u16,
- }
-
- pub struct _libc_fpstate {
- pub cw: ::c_ulong,
- pub sw: ::c_ulong,
- pub tag: ::c_ulong,
- pub ipoff: ::c_ulong,
- pub cssel: ::c_ulong,
- pub dataoff: ::c_ulong,
- pub datasel: ::c_ulong,
- pub _st: [_libc_fpreg; 8],
- pub status: ::c_ulong,
- }
-
- pub struct user_fpregs_struct {
- pub cwd: ::c_long,
- pub swd: ::c_long,
- pub twd: ::c_long,
- pub fip: ::c_long,
- pub fcs: ::c_long,
- pub foo: ::c_long,
- pub fos: ::c_long,
- pub st_space: [::c_long; 20],
- }
-
- pub struct user_regs_struct {
- pub ebx: ::c_long,
- pub ecx: ::c_long,
- pub edx: ::c_long,
- pub esi: ::c_long,
- pub edi: ::c_long,
- pub ebp: ::c_long,
- pub eax: ::c_long,
- pub xds: ::c_long,
- pub xes: ::c_long,
- pub xfs: ::c_long,
- pub xgs: ::c_long,
- pub orig_eax: ::c_long,
- pub eip: ::c_long,
- pub xcs: ::c_long,
- pub eflags: ::c_long,
- pub esp: ::c_long,
- pub xss: ::c_long,
- }
-
- pub struct user {
- pub regs: user_regs_struct,
- pub u_fpvalid: ::c_int,
- pub i387: user_fpregs_struct,
- pub u_tsize: ::c_ulong,
- pub u_dsize: ::c_ulong,
- pub u_ssize: ::c_ulong,
- pub start_code: ::c_ulong,
- pub start_stack: ::c_ulong,
- pub signal: ::c_long,
- __reserved: ::c_int,
- pub u_ar0: *mut user_regs_struct,
- pub u_fpstate: *mut user_fpregs_struct,
- pub magic: ::c_ulong,
- pub u_comm: [c_char; 32],
- pub u_debugreg: [::c_int; 8],
- }
-
- pub struct mcontext_t {
- pub gregs: [greg_t; 19],
- pub fpregs: *mut _libc_fpstate,
- pub oldmask: ::c_ulong,
- pub cr2: ::c_ulong,
- }
-
- pub struct ipc_perm {
- pub __key: ::key_t,
- pub uid: ::uid_t,
- pub gid: ::gid_t,
- pub cuid: ::uid_t,
- pub cgid: ::gid_t,
- pub mode: ::c_ushort,
- __pad1: ::c_ushort,
- pub __seq: ::c_ushort,
- __pad2: ::c_ushort,
- __unused1: ::c_ulong,
- __unused2: ::c_ulong
- }
-
- pub struct stat64 {
- pub st_dev: ::dev_t,
- __pad1: ::c_uint,
- __st_ino: ::ino_t,
- pub st_mode: ::mode_t,
- pub st_nlink: ::nlink_t,
- pub st_uid: ::uid_t,
- pub st_gid: ::gid_t,
- pub st_rdev: ::dev_t,
- __pad2: ::c_uint,
- pub st_size: ::off64_t,
- pub st_blksize: ::blksize_t,
- pub st_blocks: ::blkcnt64_t,
- pub st_atime: ::time_t,
- pub st_atime_nsec: ::c_long,
- pub st_mtime: ::time_t,
- pub st_mtime_nsec: ::c_long,
- pub st_ctime: ::time_t,
- pub st_ctime_nsec: ::c_long,
- pub st_ino: ::ino64_t,
- }
-
- pub struct statfs64 {
- pub f_type: ::__fsword_t,
- pub f_bsize: ::__fsword_t,
- pub f_blocks: u64,
- pub f_bfree: u64,
- pub f_bavail: u64,
- pub f_files: u64,
- pub f_ffree: u64,
- pub f_fsid: ::fsid_t,
- pub f_namelen: ::__fsword_t,
- pub f_frsize: ::__fsword_t,
- pub f_flags: ::__fsword_t,
- pub f_spare: [::__fsword_t; 4],
- }
-
- pub struct statvfs64 {
- pub f_bsize: ::c_ulong,
- pub f_frsize: ::c_ulong,
- pub f_blocks: u64,
- pub f_bfree: u64,
- pub f_bavail: u64,
- pub f_files: u64,
- pub f_ffree: u64,
- pub f_favail: u64,
- pub f_fsid: ::c_ulong,
- __f_unused: ::c_int,
- pub f_flag: ::c_ulong,
- pub f_namemax: ::c_ulong,
- __f_spare: [::c_int; 6],
- }
-
- pub struct shmid_ds {
- pub shm_perm: ::ipc_perm,
- pub shm_segsz: ::size_t,
- pub shm_atime: ::time_t,
- __unused1: ::c_ulong,
- pub shm_dtime: ::time_t,
- __unused2: ::c_ulong,
- pub shm_ctime: ::time_t,
- __unused3: ::c_ulong,
- pub shm_cpid: ::pid_t,
- pub shm_lpid: ::pid_t,
- pub shm_nattch: ::shmatt_t,
- __unused4: ::c_ulong,
- __unused5: ::c_ulong
- }
-
- pub struct msqid_ds {
- pub msg_perm: ::ipc_perm,
- pub msg_stime: ::time_t,
- __glibc_reserved1: ::c_ulong,
- pub msg_rtime: ::time_t,
- __glibc_reserved2: ::c_ulong,
- pub msg_ctime: ::time_t,
- __glibc_reserved3: ::c_ulong,
- __msg_cbytes: ::c_ulong,
- pub msg_qnum: ::msgqnum_t,
- pub msg_qbytes: ::msglen_t,
- pub msg_lspid: ::pid_t,
- pub msg_lrpid: ::pid_t,
- __glibc_reserved4: ::c_ulong,
- __glibc_reserved5: ::c_ulong,
- }
-
- pub struct termios2 {
- pub c_iflag: ::tcflag_t,
- pub c_oflag: ::tcflag_t,
- pub c_cflag: ::tcflag_t,
- pub c_lflag: ::tcflag_t,
- pub c_line: ::cc_t,
- pub c_cc: [::cc_t; 19],
- pub c_ispeed: ::speed_t,
- pub c_ospeed: ::speed_t,
- }
-}
-
-s_no_extra_traits!{
- pub struct user_fpxregs_struct {
- pub cwd: ::c_ushort,
- pub swd: ::c_ushort,
- pub twd: ::c_ushort,
- pub fop: ::c_ushort,
- pub fip: ::c_long,
- pub fcs: ::c_long,
- pub foo: ::c_long,
- pub fos: ::c_long,
- pub mxcsr: ::c_long,
- __reserved: ::c_long,
- pub st_space: [::c_long; 32],
- pub xmm_space: [::c_long; 32],
- padding: [::c_long; 56],
- }
-
- pub struct ucontext_t {
- pub uc_flags: ::c_ulong,
- pub uc_link: *mut ucontext_t,
- pub uc_stack: ::stack_t,
- pub uc_mcontext: mcontext_t,
- pub uc_sigmask: ::sigset_t,
- __private: [u8; 112],
- __ssp: [::c_ulong; 4],
- }
-}
-
-cfg_if! {
- if #[cfg(feature = "extra_traits")] {
- impl PartialEq for user_fpxregs_struct {
- fn eq(&self, other: &user_fpxregs_struct) -> bool {
- self.cwd == other.cwd
- && self.swd == other.swd
- && self.twd == other.twd
- && self.fop == other.fop
- && self.fip == other.fip
- && self.fcs == other.fcs
- && self.foo == other.foo
- && self.fos == other.fos
- && self.mxcsr == other.mxcsr
- // Ignore __reserved field
- && self.st_space == other.st_space
- && self.xmm_space == other.xmm_space
- // Ignore padding field
- }
- }
-
- impl Eq for user_fpxregs_struct {}
-
- impl ::fmt::Debug for user_fpxregs_struct {
- fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
- f.debug_struct("user_fpxregs_struct")
- .field("cwd", &self.cwd)
- .field("swd", &self.swd)
- .field("twd", &self.twd)
- .field("fop", &self.fop)
- .field("fip", &self.fip)
- .field("fcs", &self.fcs)
- .field("foo", &self.foo)
- .field("fos", &self.fos)
- .field("mxcsr", &self.mxcsr)
- // Ignore __reserved field
- .field("st_space", &self.st_space)
- .field("xmm_space", &self.xmm_space)
- // Ignore padding field
- .finish()
- }
- }
-
- impl ::hash::Hash for user_fpxregs_struct {
- fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
- self.cwd.hash(state);
- self.swd.hash(state);
- self.twd.hash(state);
- self.fop.hash(state);
- self.fip.hash(state);
- self.fcs.hash(state);
- self.foo.hash(state);
- self.fos.hash(state);
- self.mxcsr.hash(state);
- // Ignore __reserved field
- self.st_space.hash(state);
- self.xmm_space.hash(state);
- // Ignore padding field
- }
- }
-
- impl PartialEq for ucontext_t {
- fn eq(&self, other: &ucontext_t) -> bool {
- self.uc_flags == other.uc_flags
- && self.uc_link == other.uc_link
- && self.uc_stack == other.uc_stack
- && self.uc_mcontext == other.uc_mcontext
- && self.uc_sigmask == other.uc_sigmask
- // Ignore __private field
- }
- }
-
- impl Eq for ucontext_t {}
-
- impl ::fmt::Debug for ucontext_t {
- fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
- f.debug_struct("ucontext_t")
- .field("uc_flags", &self.uc_flags)
- .field("uc_link", &self.uc_link)
- .field("uc_stack", &self.uc_stack)
- .field("uc_mcontext", &self.uc_mcontext)
- .field("uc_sigmask", &self.uc_sigmask)
- // Ignore __private field
- .finish()
- }
- }
-
- impl ::hash::Hash for ucontext_t {
- fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
- self.uc_flags.hash(state);
- self.uc_link.hash(state);
- self.uc_stack.hash(state);
- self.uc_mcontext.hash(state);
- self.uc_sigmask.hash(state);
- // Ignore __private field
- }
- }
- }
-}
-
-pub const O_DIRECT: ::c_int = 0x4000;
-pub const O_DIRECTORY: ::c_int = 0x10000;
-pub const O_NOFOLLOW: ::c_int = 0x20000;
-pub const O_LARGEFILE: ::c_int = 0o0100000;
-
-pub const MAP_LOCKED: ::c_int = 0x02000;
-pub const MAP_NORESERVE: ::c_int = 0x04000;
-pub const MAP_32BIT: ::c_int = 0x0040;
-
-pub const EDEADLOCK: ::c_int = 35;
-
-pub const SO_SNDBUFFORCE: ::c_int = 32;
-pub const SO_RCVBUFFORCE: ::c_int = 33;
-pub const SO_NO_CHECK: ::c_int = 11;
-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 FIOCLEX: ::c_ulong = 0x5451;
-pub const FIONBIO: ::c_ulong = 0x5421;
-
-pub const PTRACE_GETFPXREGS: ::c_uint = 18;
-pub const PTRACE_SETFPXREGS: ::c_uint = 19;
-
-pub const MCL_CURRENT: ::c_int = 0x0001;
-pub const MCL_FUTURE: ::c_int = 0x0002;
-
-pub const SIGSTKSZ: ::size_t = 8192;
-pub const MINSIGSTKSZ: ::size_t = 2048;
-pub const CBAUD: ::tcflag_t = 0o0010017;
-pub const TAB1: ::tcflag_t = 0x00000800;
-pub const TAB2: ::tcflag_t = 0x00001000;
-pub const TAB3: ::tcflag_t = 0x00001800;
-pub const CR1: ::tcflag_t = 0x00000200;
-pub const CR2: ::tcflag_t = 0x00000400;
-pub const CR3: ::tcflag_t = 0x00000600;
-pub const FF1: ::tcflag_t = 0x00008000;
-pub const BS1: ::tcflag_t = 0x00002000;
-pub const VT1: ::tcflag_t = 0x00004000;
-pub const VWERASE: usize = 14;
-pub const VREPRINT: usize = 12;
-pub const VSUSP: usize = 10;
-pub const VSTART: usize = 8;
-pub const VSTOP: usize = 9;
-pub const VDISCARD: usize = 13;
-pub const VTIME: usize = 5;
-pub const IXON: ::tcflag_t = 0x00000400;
-pub const IXOFF: ::tcflag_t = 0x00001000;
-pub const ONLCR: ::tcflag_t = 0x4;
-pub const CSIZE: ::tcflag_t = 0x00000030;
-pub const CS6: ::tcflag_t = 0x00000010;
-pub const CS7: ::tcflag_t = 0x00000020;
-pub const CS8: ::tcflag_t = 0x00000030;
-pub const CSTOPB: ::tcflag_t = 0x00000040;
-pub const CREAD: ::tcflag_t = 0x00000080;
-pub const PARENB: ::tcflag_t = 0x00000100;
-pub const PARODD: ::tcflag_t = 0x00000200;
-pub const HUPCL: ::tcflag_t = 0x00000400;
-pub const CLOCAL: ::tcflag_t = 0x00000800;
-pub const ECHOKE: ::tcflag_t = 0x00000800;
-pub const ECHOE: ::tcflag_t = 0x00000010;
-pub const ECHOK: ::tcflag_t = 0x00000020;
-pub const ECHONL: ::tcflag_t = 0x00000040;
-pub const ECHOPRT: ::tcflag_t = 0x00000400;
-pub const ECHOCTL: ::tcflag_t = 0x00000200;
-pub const ISIG: ::tcflag_t = 0x00000001;
-pub const ICANON: ::tcflag_t = 0x00000002;
-pub const PENDIN: ::tcflag_t = 0x00004000;
-pub const NOFLSH: ::tcflag_t = 0x00000080;
-pub const CIBAUD: ::tcflag_t = 0o02003600000;
-pub const CBAUDEX: ::tcflag_t = 0o010000;
-pub const VSWTC: usize = 7;
-pub const OLCUC: ::tcflag_t = 0o000002;
-pub const NLDLY: ::tcflag_t = 0o000400;
-pub const CRDLY: ::tcflag_t = 0o003000;
-pub const TABDLY: ::tcflag_t = 0o014000;
-pub const BSDLY: ::tcflag_t = 0o020000;
-pub const FFDLY: ::tcflag_t = 0o100000;
-pub const VTDLY: ::tcflag_t = 0o040000;
-pub const XTABS: ::tcflag_t = 0o014000;
-
-pub const B0: ::speed_t = 0o000000;
-pub const B50: ::speed_t = 0o000001;
-pub const B75: ::speed_t = 0o000002;
-pub const B110: ::speed_t = 0o000003;
-pub const B134: ::speed_t = 0o000004;
-pub const B150: ::speed_t = 0o000005;
-pub const B200: ::speed_t = 0o000006;
-pub const B300: ::speed_t = 0o000007;
-pub const B600: ::speed_t = 0o000010;
-pub const B1200: ::speed_t = 0o000011;
-pub const B1800: ::speed_t = 0o000012;
-pub const B2400: ::speed_t = 0o000013;
-pub const B4800: ::speed_t = 0o000014;
-pub const B9600: ::speed_t = 0o000015;
-pub const B19200: ::speed_t = 0o000016;
-pub const B38400: ::speed_t = 0o000017;
-pub const EXTA: ::speed_t = B19200;
-pub const EXTB: ::speed_t = B38400;
-pub const BOTHER: ::speed_t = 0o010000;
-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 VEOL: usize = 11;
-pub const VEOL2: usize = 16;
-pub const VMIN: usize = 6;
-pub const IEXTEN: ::tcflag_t = 0x00008000;
-pub const TOSTOP: ::tcflag_t = 0x00000100;
-pub const FLUSHO: ::tcflag_t = 0x00001000;
-pub const EXTPROC: ::tcflag_t = 0x00010000;
-pub const TCGETS: ::c_ulong = 0x5401;
-pub const TCSETS: ::c_ulong = 0x5402;
-pub const TCSETSW: ::c_ulong = 0x5403;
-pub const TCSETSF: ::c_ulong = 0x5404;
-pub const TCGETA: ::c_ulong = 0x5405;
-pub const TCSETA: ::c_ulong = 0x5406;
-pub const TCSETAW: ::c_ulong = 0x5407;
-pub const TCSETAF: ::c_ulong = 0x5408;
-pub const TCSBRK: ::c_ulong = 0x5409;
-pub const TCXONC: ::c_ulong = 0x540A;
-pub const TCFLSH: ::c_ulong = 0x540B;
-pub const TIOCINQ: ::c_ulong = 0x541B;
-pub const TIOCGPGRP: ::c_ulong = 0x540F;
-pub const TIOCSPGRP: ::c_ulong = 0x5410;
-pub const TIOCOUTQ: ::c_ulong = 0x5411;
-pub const TIOCGWINSZ: ::c_ulong = 0x5413;
-pub const TIOCSWINSZ: ::c_ulong = 0x5414;
-pub const TIOCGRS485: ::c_int = 0x542E;
-pub const TIOCSRS485: ::c_int = 0x542F;
-pub const FIONREAD: ::c_ulong = 0x541B;
-
-// 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_vm86old: ::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_vm86: ::c_long = 166;
-pub const SYS_query_module: ::c_long = 167;
-pub const SYS_poll: ::c_long = 168;
-pub const SYS_nfsservctl: ::c_long = 169;
-pub const SYS_setresgid: ::c_long = 170;
-pub const SYS_getresgid: ::c_long = 171;
-pub const SYS_prctl: ::c_long = 172;
-pub const SYS_rt_sigreturn: ::c_long = 173;
-pub const SYS_rt_sigaction: ::c_long = 174;
-pub const SYS_rt_sigprocmask: ::c_long = 175;
-pub const SYS_rt_sigpending: ::c_long = 176;
-pub const SYS_rt_sigtimedwait: ::c_long = 177;
-pub const SYS_rt_sigqueueinfo: ::c_long = 178;
-pub const SYS_rt_sigsuspend: ::c_long = 179;
-pub const SYS_pread64: ::c_long = 180;
-pub const SYS_pwrite64: ::c_long = 181;
-pub const SYS_chown: ::c_long = 182;
-pub const SYS_getcwd: ::c_long = 183;
-pub const SYS_capget: ::c_long = 184;
-pub const SYS_capset: ::c_long = 185;
-pub const SYS_sigaltstack: ::c_long = 186;
-pub const SYS_sendfile: ::c_long = 187;
-pub const SYS_getpmsg: ::c_long = 188;
-pub const SYS_putpmsg: ::c_long = 189;
-pub const SYS_vfork: ::c_long = 190;
-pub const SYS_ugetrlimit: ::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_lchown32: ::c_long = 198;
-pub const SYS_getuid32: ::c_long = 199;
-pub const SYS_getgid32: ::c_long = 200;
-pub const SYS_geteuid32: ::c_long = 201;
-pub const SYS_getegid32: ::c_long = 202;
-pub const SYS_setreuid32: ::c_long = 203;
-pub const SYS_setregid32: ::c_long = 204;
-pub const SYS_getgroups32: ::c_long = 205;
-pub const SYS_setgroups32: ::c_long = 206;
-pub const SYS_fchown32: ::c_long = 207;
-pub const SYS_setresuid32: ::c_long = 208;
-pub const SYS_getresuid32: ::c_long = 209;
-pub const SYS_setresgid32: ::c_long = 210;
-pub const SYS_getresgid32: ::c_long = 211;
-pub const SYS_chown32: ::c_long = 212;
-pub const SYS_setuid32: ::c_long = 213;
-pub const SYS_setgid32: ::c_long = 214;
-pub const SYS_setfsuid32: ::c_long = 215;
-pub const SYS_setfsgid32: ::c_long = 216;
-pub const SYS_pivot_root: ::c_long = 217;
-pub const SYS_mincore: ::c_long = 218;
-pub const SYS_madvise: ::c_long = 219;
-pub const SYS_getdents64: ::c_long = 220;
-pub const SYS_fcntl64: ::c_long = 221;
-pub const SYS_gettid: ::c_long = 224;
-pub const SYS_readahead: ::c_long = 225;
-pub const SYS_setxattr: ::c_long = 226;
-pub const SYS_lsetxattr: ::c_long = 227;
-pub const SYS_fsetxattr: ::c_long = 228;
-pub const SYS_getxattr: ::c_long = 229;
-pub const SYS_lgetxattr: ::c_long = 230;
-pub const SYS_fgetxattr: ::c_long = 231;
-pub const SYS_listxattr: ::c_long = 232;
-pub const SYS_llistxattr: ::c_long = 233;
-pub const SYS_flistxattr: ::c_long = 234;
-pub const SYS_removexattr: ::c_long = 235;
-pub const SYS_lremovexattr: ::c_long = 236;
-pub const SYS_fremovexattr: ::c_long = 237;
-pub const SYS_tkill: ::c_long = 238;
-pub const SYS_sendfile64: ::c_long = 239;
-pub const SYS_futex: ::c_long = 240;
-pub const SYS_sched_setaffinity: ::c_long = 241;
-pub const SYS_sched_getaffinity: ::c_long = 242;
-pub const SYS_set_thread_area: ::c_long = 243;
-pub const SYS_get_thread_area: ::c_long = 244;
-pub const SYS_io_setup: ::c_long = 245;
-pub const SYS_io_destroy: ::c_long = 246;
-pub const SYS_io_getevents: ::c_long = 247;
-pub const SYS_io_submit: ::c_long = 248;
-pub const SYS_io_cancel: ::c_long = 249;
-pub const SYS_fadvise64: ::c_long = 250;
-pub const SYS_exit_group: ::c_long = 252;
-pub const SYS_lookup_dcookie: ::c_long = 253;
-pub const SYS_epoll_create: ::c_long = 254;
-pub const SYS_epoll_ctl: ::c_long = 255;
-pub const SYS_epoll_wait: ::c_long = 256;
-pub const SYS_remap_file_pages: ::c_long = 257;
-pub const SYS_set_tid_address: ::c_long = 258;
-pub const SYS_timer_create: ::c_long = 259;
-pub const SYS_timer_settime: ::c_long = 260;
-pub const SYS_timer_gettime: ::c_long = 261;
-pub const SYS_timer_getoverrun: ::c_long = 262;
-pub const SYS_timer_delete: ::c_long = 263;
-pub const SYS_clock_settime: ::c_long = 264;
-pub const SYS_clock_gettime: ::c_long = 265;
-pub const SYS_clock_getres: ::c_long = 266;
-pub const SYS_clock_nanosleep: ::c_long = 267;
-pub const SYS_statfs64: ::c_long = 268;
-pub const SYS_fstatfs64: ::c_long = 269;
-pub const SYS_tgkill: ::c_long = 270;
-pub const SYS_utimes: ::c_long = 271;
-pub const SYS_fadvise64_64: ::c_long = 272;
-pub const SYS_vserver: ::c_long = 273;
-pub const SYS_mbind: ::c_long = 274;
-pub const SYS_get_mempolicy: ::c_long = 275;
-pub const SYS_set_mempolicy: ::c_long = 276;
-pub const SYS_mq_open: ::c_long = 277;
-pub const SYS_mq_unlink: ::c_long = 278;
-pub const SYS_mq_timedsend: ::c_long = 279;
-pub const SYS_mq_timedreceive: ::c_long = 280;
-pub const SYS_mq_notify: ::c_long = 281;
-pub const SYS_mq_getsetattr: ::c_long = 282;
-pub const SYS_kexec_load: ::c_long = 283;
-pub const SYS_waitid: ::c_long = 284;
-pub const SYS_add_key: ::c_long = 286;
-pub const SYS_request_key: ::c_long = 287;
-pub const SYS_keyctl: ::c_long = 288;
-pub const SYS_ioprio_set: ::c_long = 289;
-pub const SYS_ioprio_get: ::c_long = 290;
-pub const SYS_inotify_init: ::c_long = 291;
-pub const SYS_inotify_add_watch: ::c_long = 292;
-pub const SYS_inotify_rm_watch: ::c_long = 293;
-pub const SYS_migrate_pages: ::c_long = 294;
-pub const SYS_openat: ::c_long = 295;
-pub const SYS_mkdirat: ::c_long = 296;
-pub const SYS_mknodat: ::c_long = 297;
-pub const SYS_fchownat: ::c_long = 298;
-pub const SYS_futimesat: ::c_long = 299;
-pub const SYS_fstatat64: ::c_long = 300;
-pub const SYS_unlinkat: ::c_long = 301;
-pub const SYS_renameat: ::c_long = 302;
-pub const SYS_linkat: ::c_long = 303;
-pub const SYS_symlinkat: ::c_long = 304;
-pub const SYS_readlinkat: ::c_long = 305;
-pub const SYS_fchmodat: ::c_long = 306;
-pub const SYS_faccessat: ::c_long = 307;
-pub const SYS_pselect6: ::c_long = 308;
-pub const SYS_ppoll: ::c_long = 309;
-pub const SYS_unshare: ::c_long = 310;
-pub const SYS_set_robust_list: ::c_long = 311;
-pub const SYS_get_robust_list: ::c_long = 312;
-pub const SYS_splice: ::c_long = 313;
-pub const SYS_sync_file_range: ::c_long = 314;
-pub const SYS_tee: ::c_long = 315;
-pub const SYS_vmsplice: ::c_long = 316;
-pub const SYS_move_pages: ::c_long = 317;
-pub const SYS_getcpu: ::c_long = 318;
-pub const SYS_epoll_pwait: ::c_long = 319;
-pub const SYS_utimensat: ::c_long = 320;
-pub const SYS_signalfd: ::c_long = 321;
-pub const SYS_timerfd_create: ::c_long = 322;
-pub const SYS_eventfd: ::c_long = 323;
-pub const SYS_fallocate: ::c_long = 324;
-pub const SYS_timerfd_settime: ::c_long = 325;
-pub const SYS_timerfd_gettime: ::c_long = 326;
-pub const SYS_signalfd4: ::c_long = 327;
-pub const SYS_eventfd2: ::c_long = 328;
-pub const SYS_epoll_create1: ::c_long = 329;
-pub const SYS_dup3: ::c_long = 330;
-pub const SYS_pipe2: ::c_long = 331;
-pub const SYS_inotify_init1: ::c_long = 332;
-pub const SYS_preadv: ::c_long = 333;
-pub const SYS_pwritev: ::c_long = 334;
-pub const SYS_rt_tgsigqueueinfo: ::c_long = 335;
-pub const SYS_perf_event_open: ::c_long = 336;
-pub const SYS_recvmmsg: ::c_long = 337;
-pub const SYS_fanotify_init: ::c_long = 338;
-pub const SYS_fanotify_mark: ::c_long = 339;
-pub const SYS_prlimit64: ::c_long = 340;
-pub const SYS_name_to_handle_at: ::c_long = 341;
-pub const SYS_open_by_handle_at: ::c_long = 342;
-pub const SYS_clock_adjtime: ::c_long = 343;
-pub const SYS_syncfs: ::c_long = 344;
-pub const SYS_sendmmsg: ::c_long = 345;
-pub const SYS_setns: ::c_long = 346;
-pub const SYS_process_vm_readv: ::c_long = 347;
-pub const SYS_process_vm_writev: ::c_long = 348;
-pub const SYS_kcmp: ::c_long = 349;
-pub const SYS_finit_module: ::c_long = 350;
-pub const SYS_sched_setattr: ::c_long = 351;
-pub const SYS_sched_getattr: ::c_long = 352;
-pub const SYS_renameat2: ::c_long = 353;
-pub const SYS_seccomp: ::c_long = 354;
-pub const SYS_getrandom: ::c_long = 355;
-pub const SYS_memfd_create: ::c_long = 356;
-pub const SYS_bpf: ::c_long = 357;
-pub const SYS_execveat: ::c_long = 358;
-pub const SYS_socket: ::c_long = 359;
-pub const SYS_socketpair: ::c_long = 360;
-pub const SYS_bind: ::c_long = 361;
-pub const SYS_connect: ::c_long = 362;
-pub const SYS_listen: ::c_long = 363;
-pub const SYS_accept4: ::c_long = 364;
-pub const SYS_getsockopt: ::c_long = 365;
-pub const SYS_setsockopt: ::c_long = 366;
-pub const SYS_getsockname: ::c_long = 367;
-pub const SYS_getpeername: ::c_long = 368;
-pub const SYS_sendto: ::c_long = 369;
-pub const SYS_sendmsg: ::c_long = 370;
-pub const SYS_recvfrom: ::c_long = 371;
-pub const SYS_recvmsg: ::c_long = 372;
-pub const SYS_shutdown: ::c_long = 373;
-pub const SYS_userfaultfd: ::c_long = 374;
-pub const SYS_membarrier: ::c_long = 375;
-pub const SYS_mlock2: ::c_long = 376;
-pub const SYS_copy_file_range: ::c_long = 377;
-pub const SYS_preadv2: ::c_long = 378;
-pub const SYS_pwritev2: ::c_long = 379;
-pub const SYS_pkey_mprotect: ::c_long = 380;
-pub const SYS_pkey_alloc: ::c_long = 381;
-pub const SYS_pkey_free: ::c_long = 382;
-pub const SYS_statx: ::c_long = 383;
-
-// offsets in user_regs_structs, from sys/reg.h
-pub const EBX: ::c_int = 0;
-pub const ECX: ::c_int = 1;
-pub const EDX: ::c_int = 2;
-pub const ESI: ::c_int = 3;
-pub const EDI: ::c_int = 4;
-pub const EBP: ::c_int = 5;
-pub const EAX: ::c_int = 6;
-pub const DS: ::c_int = 7;
-pub const ES: ::c_int = 8;
-pub const FS: ::c_int = 9;
-pub const GS: ::c_int = 10;
-pub const ORIG_EAX: ::c_int = 11;
-pub const EIP: ::c_int = 12;
-pub const CS: ::c_int = 13;
-pub const EFL: ::c_int = 14;
-pub const UESP: ::c_int = 15;
-pub const SS: ::c_int = 16;
-
-// offsets in mcontext_t.gregs from sys/ucontext.h
-pub const REG_GS: ::c_int = 0;
-pub const REG_FS: ::c_int = 1;
-pub const REG_ES: ::c_int = 2;
-pub const REG_DS: ::c_int = 3;
-pub const REG_EDI: ::c_int = 4;
-pub const REG_ESI: ::c_int = 5;
-pub const REG_EBP: ::c_int = 6;
-pub const REG_ESP: ::c_int = 7;
-pub const REG_EBX: ::c_int = 8;
-pub const REG_EDX: ::c_int = 9;
-pub const REG_ECX: ::c_int = 10;
-pub const REG_EAX: ::c_int = 11;
-pub const REG_TRAPNO: ::c_int = 12;
-pub const REG_ERR: ::c_int = 13;
-pub const REG_EIP: ::c_int = 14;
-pub const REG_CS: ::c_int = 15;
-pub const REG_EFL: ::c_int = 16;
-pub const REG_UESP: ::c_int = 17;
-pub const REG_SS: ::c_int = 18;
-
-extern {
- pub fn getcontext(ucp: *mut ucontext_t) -> ::c_int;
- pub fn setcontext(ucp: *const ucontext_t) -> ::c_int;
- pub fn makecontext(ucp: *mut ucontext_t,
- func: extern fn (),
- argc: ::c_int, ...);
- pub fn swapcontext(uocp: *mut ucontext_t,
- ucp: *const ucontext_t) -> ::c_int;
-}
diff --git a/libc/src/unix/notbsd/linux/other/b64/aarch64.rs b/libc/src/unix/notbsd/linux/other/b64/aarch64.rs
deleted file mode 100644
index 090f893..0000000
--- a/libc/src/unix/notbsd/linux/other/b64/aarch64.rs
+++ /dev/null
@@ -1,836 +0,0 @@
-//! 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;
-pub type wchar_t = u32;
-pub type nlink_t = u32;
-pub type blksize_t = i32;
-pub type suseconds_t = i64;
-pub type __u64 = ::c_ulonglong;
-
-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,
- __pad1: ::dev_t,
- pub st_size: ::off_t,
- pub st_blksize: ::blksize_t,
- __pad2: ::c_int,
- 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_int; 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,
- __pad1: ::dev_t,
- pub st_size: ::off64_t,
- pub st_blksize: ::blksize_t,
- __pad2: ::c_int,
- 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,
- __unused: [::c_int; 2],
- }
-
- pub struct statfs64 {
- pub f_type: ::__fsword_t,
- pub f_bsize: ::__fsword_t,
- pub f_blocks: u64,
- pub f_bfree: u64,
- pub f_bavail: u64,
- pub f_files: u64,
- pub f_ffree: u64,
- pub f_fsid: ::fsid_t,
- pub f_namelen: ::__fsword_t,
- pub f_frsize: ::__fsword_t,
- pub f_flags: ::__fsword_t,
- pub f_spare: [::__fsword_t; 4],
- }
-
- pub struct 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,
- pub f_blocks: u64,
- pub f_bfree: u64,
- pub f_bavail: u64,
- pub f_files: u64,
- pub f_ffree: u64,
- pub f_favail: u64,
- pub f_fsid: ::c_ulong,
- pub f_flag: ::c_ulong,
- pub f_namemax: ::c_ulong,
- __f_spare: [::c_int; 6],
- }
-
- pub struct pthread_attr_t {
- __size: [u64; 8]
- }
-
- pub struct ipc_perm {
- pub __key: ::key_t,
- pub uid: ::uid_t,
- pub gid: ::gid_t,
- pub cuid: ::uid_t,
- pub cgid: ::gid_t,
- pub mode: ::c_uint,
- pub __seq: ::c_ushort,
- __pad1: ::c_ushort,
- __unused1: ::c_ulong,
- __unused2: ::c_ulong
- }
-
- pub struct shmid_ds {
- pub shm_perm: ::ipc_perm,
- pub shm_segsz: ::size_t,
- pub shm_atime: ::time_t,
- pub shm_dtime: ::time_t,
- pub shm_ctime: ::time_t,
- pub shm_cpid: ::pid_t,
- pub shm_lpid: ::pid_t,
- pub shm_nattch: ::shmatt_t,
- __unused4: ::c_ulong,
- __unused5: ::c_ulong
- }
-
- 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_line: ::cc_t,
- pub c_cc: [::cc_t; 19],
- pub c_ispeed: ::speed_t,
- pub c_ospeed: ::speed_t,
- }
-}
-
-pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 56;
-
-pub const TIOCGSOFTCAR: ::c_ulong = 0x5419;
-pub const TIOCSSOFTCAR: ::c_ulong = 0x541A;
-pub const TIOCGRS485: ::c_int = 0x542E;
-pub const TIOCSRS485: ::c_int = 0x542F;
-
-pub const RLIMIT_NOFILE: ::c_int = 7;
-pub const RLIMIT_NPROC: ::c_int = 6;
-
-pub const O_APPEND: ::c_int = 1024;
-pub const O_CREAT: ::c_int = 64;
-pub const O_EXCL: ::c_int = 128;
-pub const O_NOCTTY: ::c_int = 256;
-pub const O_NONBLOCK: ::c_int = 2048;
-pub const O_SYNC: ::c_int = 1052672;
-pub const O_RSYNC: ::c_int = 1052672;
-pub const O_DSYNC: ::c_int = 4096;
-pub const O_FSYNC: ::c_int = 0x101000;
-pub const O_NOATIME: ::c_int = 0o1000000;
-pub const O_PATH: ::c_int = 0o10000000;
-pub const O_TMPFILE: ::c_int = 0o20000000 | O_DIRECTORY;
-
-pub const MAP_GROWSDOWN: ::c_int = 0x0100;
-
-pub const EDEADLK: ::c_int = 35;
-pub const ENAMETOOLONG: ::c_int = 36;
-pub const ENOLCK: ::c_int = 37;
-pub const ENOSYS: ::c_int = 38;
-pub const ENOTEMPTY: ::c_int = 39;
-pub const ELOOP: ::c_int = 40;
-pub const ENOMSG: ::c_int = 42;
-pub const EIDRM: ::c_int = 43;
-pub const ECHRNG: ::c_int = 44;
-pub const EL2NSYNC: ::c_int = 45;
-pub const EL3HLT: ::c_int = 46;
-pub const EL3RST: ::c_int = 47;
-pub const ELNRNG: ::c_int = 48;
-pub const EUNATCH: ::c_int = 49;
-pub const ENOCSI: ::c_int = 50;
-pub const EL2HLT: ::c_int = 51;
-pub const EBADE: ::c_int = 52;
-pub const EBADR: ::c_int = 53;
-pub const EXFULL: ::c_int = 54;
-pub const ENOANO: ::c_int = 55;
-pub const EBADRQC: ::c_int = 56;
-pub const EBADSLT: ::c_int = 57;
-pub const EMULTIHOP: ::c_int = 72;
-pub const EOVERFLOW: ::c_int = 75;
-pub const ENOTUNIQ: ::c_int = 76;
-pub const EBADFD: ::c_int = 77;
-pub const EBADMSG: ::c_int = 74;
-pub const EREMCHG: ::c_int = 78;
-pub const ELIBACC: ::c_int = 79;
-pub const ELIBBAD: ::c_int = 80;
-pub const ELIBSCN: ::c_int = 81;
-pub const ELIBMAX: ::c_int = 82;
-pub const ELIBEXEC: ::c_int = 83;
-pub const EILSEQ: ::c_int = 84;
-pub const ERESTART: ::c_int = 85;
-pub const ESTRPIPE: ::c_int = 86;
-pub const EUSERS: ::c_int = 87;
-pub const ENOTSOCK: ::c_int = 88;
-pub const EDESTADDRREQ: ::c_int = 89;
-pub const EMSGSIZE: ::c_int = 90;
-pub const EPROTOTYPE: ::c_int = 91;
-pub const ENOPROTOOPT: ::c_int = 92;
-pub const EPROTONOSUPPORT: ::c_int = 93;
-pub const ESOCKTNOSUPPORT: ::c_int = 94;
-pub const EOPNOTSUPP: ::c_int = 95;
-pub const EPFNOSUPPORT: ::c_int = 96;
-pub const EAFNOSUPPORT: ::c_int = 97;
-pub const EADDRINUSE: ::c_int = 98;
-pub const EADDRNOTAVAIL: ::c_int = 99;
-pub const ENETDOWN: ::c_int = 100;
-pub const ENETUNREACH: ::c_int = 101;
-pub const ENETRESET: ::c_int = 102;
-pub const ECONNABORTED: ::c_int = 103;
-pub const ECONNRESET: ::c_int = 104;
-pub const ENOBUFS: ::c_int = 105;
-pub const EISCONN: ::c_int = 106;
-pub const ENOTCONN: ::c_int = 107;
-pub const ESHUTDOWN: ::c_int = 108;
-pub const ETOOMANYREFS: ::c_int = 109;
-pub const ETIMEDOUT: ::c_int = 110;
-pub const ECONNREFUSED: ::c_int = 111;
-pub const EHOSTDOWN: ::c_int = 112;
-pub const EHOSTUNREACH: ::c_int = 113;
-pub const EALREADY: ::c_int = 114;
-pub const EINPROGRESS: ::c_int = 115;
-pub const ESTALE: ::c_int = 116;
-pub const EDQUOT: ::c_int = 122;
-pub const ENOMEDIUM: ::c_int = 123;
-pub const EMEDIUMTYPE: ::c_int = 124;
-pub const ECANCELED: ::c_int = 125;
-pub const ENOKEY: ::c_int = 126;
-pub const EKEYEXPIRED: ::c_int = 127;
-pub const EKEYREVOKED: ::c_int = 128;
-pub const EKEYREJECTED: ::c_int = 129;
-pub const EOWNERDEAD: ::c_int = 130;
-pub const ENOTRECOVERABLE: ::c_int = 131;
-pub const EHWPOISON: ::c_int = 133;
-pub const ERFKILL: ::c_int = 132;
-
-pub const SOL_SOCKET: ::c_int = 1;
-
-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_SNDBUFFORCE: ::c_int = 32;
-pub const SO_RCVBUFFORCE: ::c_int = 33;
-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_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_SECURITY_AUTHENTICATION: ::c_int = 22;
-pub const SO_SECURITY_ENCRYPTION_TRANSPORT: ::c_int = 23;
-pub const SO_SECURITY_ENCRYPTION_NETWORK: ::c_int = 24;
-pub const SO_BINDTODEVICE: ::c_int = 25;
-pub const SO_ATTACH_FILTER: ::c_int = 26;
-pub const SO_DETACH_FILTER: ::c_int = 27;
-pub const SO_GET_FILTER: ::c_int = SO_ATTACH_FILTER;
-pub const SO_PEERNAME: ::c_int = 28;
-pub const SO_TIMESTAMP: ::c_int = 29;
-pub const SO_ACCEPTCONN: ::c_int = 30;
-pub const SO_PEERSEC: ::c_int = 31;
-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_PROTOCOL: ::c_int = 38;
-pub const SO_DOMAIN: ::c_int = 39;
-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;
-pub const SO_PEEK_OFF: ::c_int = 42;
-pub const SO_NOFCS: ::c_int = 43;
-pub const SO_LOCK_FILTER: ::c_int = 44;
-pub const SO_SELECT_ERR_QUEUE: ::c_int = 45;
-pub const SO_BUSY_POLL: ::c_int = 46;
-pub const SO_MAX_PACING_RATE: ::c_int = 47;
-pub const SO_BPF_EXTENSIONS: ::c_int = 48;
-pub const SO_INCOMING_CPU: ::c_int = 49;
-pub const SO_ATTACH_BPF: ::c_int = 50;
-pub const SO_DETACH_BPF: ::c_int = SO_DETACH_FILTER;
-
-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 SIGUSR1: ::c_int = 10;
-pub const SIGUSR2: ::c_int = 12;
-pub const SIGCONT: ::c_int = 18;
-pub const SIGSTOP: ::c_int = 19;
-pub const SIGTSTP: ::c_int = 20;
-pub const SIGURG: ::c_int = 23;
-pub const SIGIO: ::c_int = 29;
-pub const SIGSYS: ::c_int = 31;
-pub const SIGSTKFLT: ::c_int = 16;
-#[deprecated(
- since = "0.2.55",
- note = "Use SIGSYS instead"
-)]
-pub const SIGUNUSED: ::c_int = 31;
-pub const SIGPOLL: ::c_int = 29;
-pub const SIGPWR: ::c_int = 30;
-pub const SIG_SETMASK: ::c_int = 2;
-pub const SIG_BLOCK: ::c_int = 0x000000;
-pub const SIG_UNBLOCK: ::c_int = 0x01;
-
-pub const POLLWRNORM: ::c_short = 0x100;
-pub const POLLWRBAND: ::c_short = 0x200;
-
-pub const O_ASYNC: ::c_int = 0x2000;
-pub const O_NDELAY: ::c_int = 0x800;
-
-pub const PTRACE_DETACH: ::c_uint = 17;
-
-pub const EFD_NONBLOCK: ::c_int = 0x800;
-
-pub const F_GETLK: ::c_int = 5;
-pub const F_GETOWN: ::c_int = 9;
-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;
-pub const TIOCNXCL: ::c_ulong = 0x540D;
-pub const TIOCSCTTY: ::c_ulong = 0x540E;
-pub const TIOCSTI: ::c_ulong = 0x5412;
-pub const TIOCMGET: ::c_ulong = 0x5415;
-pub const TIOCMBIS: ::c_ulong = 0x5416;
-pub const TIOCMBIC: ::c_ulong = 0x5417;
-pub const TIOCMSET: ::c_ulong = 0x5418;
-pub const TIOCCONS: ::c_ulong = 0x541D;
-
-pub const SFD_CLOEXEC: ::c_int = 0x080000;
-
-pub const NCCS: usize = 32;
-
-pub const O_TRUNC: ::c_int = 512;
-
-pub const O_CLOEXEC: ::c_int = 0x80000;
-
-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 EDOTDOT: ::c_int = 73;
-
-pub const SA_NODEFER: ::c_int = 0x40000000;
-pub const SA_RESETHAND: ::c_int = 0x80000000;
-pub const SA_RESTART: ::c_int = 0x10000000;
-pub const SA_NOCLDSTOP: ::c_int = 0x00000001;
-
-pub const EPOLL_CLOEXEC: ::c_int = 0x80000;
-
-pub const EFD_CLOEXEC: ::c_int = 0x80000;
-
-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;
-
-pub const MAP_LOCKED: ::c_int = 0x02000;
-pub const MAP_NORESERVE: ::c_int = 0x04000;
-
-pub const EDEADLOCK: ::c_int = 35;
-
-pub const FIOCLEX: ::c_ulong = 0x5451;
-pub const FIONBIO: ::c_ulong = 0x5421;
-
-pub const MCL_CURRENT: ::c_int = 0x0001;
-pub const MCL_FUTURE: ::c_int = 0x0002;
-
-pub const SIGSTKSZ: ::size_t = 16384;
-pub const MINSIGSTKSZ: ::size_t = 5120;
-pub const CBAUD: ::tcflag_t = 0o0010017;
-pub const TAB1: ::tcflag_t = 0x00000800;
-pub const TAB2: ::tcflag_t = 0x00001000;
-pub const TAB3: ::tcflag_t = 0x00001800;
-pub const CR1: ::tcflag_t = 0x00000200;
-pub const CR2: ::tcflag_t = 0x00000400;
-pub const CR3: ::tcflag_t = 0x00000600;
-pub const FF1: ::tcflag_t = 0x00008000;
-pub const BS1: ::tcflag_t = 0x00002000;
-pub const VT1: ::tcflag_t = 0x00004000;
-pub const VWERASE: usize = 14;
-pub const VREPRINT: usize = 12;
-pub const VSUSP: usize = 10;
-pub const VSTART: usize = 8;
-pub const VSTOP: usize = 9;
-pub const VDISCARD: usize = 13;
-pub const VTIME: usize = 5;
-pub const IXON: ::tcflag_t = 0x00000400;
-pub const IXOFF: ::tcflag_t = 0x00001000;
-pub const ONLCR: ::tcflag_t = 0x4;
-pub const CSIZE: ::tcflag_t = 0x00000030;
-pub const CS6: ::tcflag_t = 0x00000010;
-pub const CS7: ::tcflag_t = 0x00000020;
-pub const CS8: ::tcflag_t = 0x00000030;
-pub const CSTOPB: ::tcflag_t = 0x00000040;
-pub const CREAD: ::tcflag_t = 0x00000080;
-pub const PARENB: ::tcflag_t = 0x00000100;
-pub const PARODD: ::tcflag_t = 0x00000200;
-pub const HUPCL: ::tcflag_t = 0x00000400;
-pub const CLOCAL: ::tcflag_t = 0x00000800;
-pub const ECHOKE: ::tcflag_t = 0x00000800;
-pub const ECHOE: ::tcflag_t = 0x00000010;
-pub const ECHOK: ::tcflag_t = 0x00000020;
-pub const ECHONL: ::tcflag_t = 0x00000040;
-pub const ECHOPRT: ::tcflag_t = 0x00000400;
-pub const ECHOCTL: ::tcflag_t = 0x00000200;
-pub const ISIG: ::tcflag_t = 0x00000001;
-pub const ICANON: ::tcflag_t = 0x00000002;
-pub const PENDIN: ::tcflag_t = 0x00004000;
-pub const NOFLSH: ::tcflag_t = 0x00000080;
-pub const CIBAUD: ::tcflag_t = 0o02003600000;
-pub const CBAUDEX: ::tcflag_t = 0o010000;
-pub const VSWTC: usize = 7;
-pub const OLCUC: ::tcflag_t = 0o000002;
-pub const NLDLY: ::tcflag_t = 0o000400;
-pub const CRDLY: ::tcflag_t = 0o003000;
-pub const TABDLY: ::tcflag_t = 0o014000;
-pub const BSDLY: ::tcflag_t = 0o020000;
-pub const FFDLY: ::tcflag_t = 0o100000;
-pub const VTDLY: ::tcflag_t = 0o040000;
-pub const XTABS: ::tcflag_t = 0o014000;
-
-pub const B0: ::speed_t = 0o000000;
-pub const B50: ::speed_t = 0o000001;
-pub const B75: ::speed_t = 0o000002;
-pub const B110: ::speed_t = 0o000003;
-pub const B134: ::speed_t = 0o000004;
-pub const B150: ::speed_t = 0o000005;
-pub const B200: ::speed_t = 0o000006;
-pub const B300: ::speed_t = 0o000007;
-pub const B600: ::speed_t = 0o000010;
-pub const B1200: ::speed_t = 0o000011;
-pub const B1800: ::speed_t = 0o000012;
-pub const B2400: ::speed_t = 0o000013;
-pub const B4800: ::speed_t = 0o000014;
-pub const B9600: ::speed_t = 0o000015;
-pub const B19200: ::speed_t = 0o000016;
-pub const B38400: ::speed_t = 0o000017;
-pub const EXTA: ::speed_t = B19200;
-pub const EXTB: ::speed_t = B38400;
-pub const BOTHER: ::speed_t = 0o010000;
-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 VEOL: usize = 11;
-pub const VEOL2: usize = 16;
-pub const VMIN: usize = 6;
-pub const IEXTEN: ::tcflag_t = 0x00008000;
-pub const TOSTOP: ::tcflag_t = 0x00000100;
-pub const FLUSHO: ::tcflag_t = 0x00001000;
-pub const EXTPROC: ::tcflag_t = 0x00010000;
-pub const TCGETS: ::c_ulong = 0x5401;
-pub const TCSETS: ::c_ulong = 0x5402;
-pub const TCSETSW: ::c_ulong = 0x5403;
-pub const TCSETSF: ::c_ulong = 0x5404;
-pub const TCGETA: ::c_ulong = 0x5405;
-pub const TCSETA: ::c_ulong = 0x5406;
-pub const TCSETAW: ::c_ulong = 0x5407;
-pub const TCSETAF: ::c_ulong = 0x5408;
-pub const TCSBRK: ::c_ulong = 0x5409;
-pub const TCXONC: ::c_ulong = 0x540A;
-pub const TCFLSH: ::c_ulong = 0x540B;
-pub const TIOCINQ: ::c_ulong = 0x541B;
-pub const TIOCGPGRP: ::c_ulong = 0x540F;
-pub const TIOCSPGRP: ::c_ulong = 0x5410;
-pub const TIOCOUTQ: ::c_ulong = 0x5411;
-pub const TIOCGWINSZ: ::c_ulong = 0x5413;
-pub const TIOCSWINSZ: ::c_ulong = 0x5414;
-pub const FIONREAD: ::c_ulong = 0x541B;
-
-// Syscall table
-pub const SYS_io_setup: ::c_long = 0;
-pub const SYS_io_destroy: ::c_long = 1;
-pub const SYS_io_submit: ::c_long = 2;
-pub const SYS_io_cancel: ::c_long = 3;
-pub const SYS_io_getevents: ::c_long = 4;
-pub const SYS_setxattr: ::c_long = 5;
-pub const SYS_lsetxattr: ::c_long = 6;
-pub const SYS_fsetxattr: ::c_long = 7;
-pub const SYS_getxattr: ::c_long = 8;
-pub const SYS_lgetxattr: ::c_long = 9;
-pub const SYS_fgetxattr: ::c_long = 10;
-pub const SYS_listxattr: ::c_long = 11;
-pub const SYS_llistxattr: ::c_long = 12;
-pub const SYS_flistxattr: ::c_long = 13;
-pub const SYS_removexattr: ::c_long = 14;
-pub const SYS_lremovexattr: ::c_long = 15;
-pub const SYS_fremovexattr: ::c_long = 16;
-pub const SYS_getcwd: ::c_long = 17;
-pub const SYS_lookup_dcookie: ::c_long = 18;
-pub const SYS_eventfd2: ::c_long = 19;
-pub const SYS_epoll_create1: ::c_long = 20;
-pub const SYS_epoll_ctl: ::c_long = 21;
-pub const SYS_epoll_pwait: ::c_long = 22;
-pub const SYS_dup: ::c_long = 23;
-pub const SYS_dup3: ::c_long = 24;
-pub const SYS_fcntl: ::c_long = 25;
-pub const SYS_inotify_init1: ::c_long = 26;
-pub const SYS_inotify_add_watch: ::c_long = 27;
-pub const SYS_inotify_rm_watch: ::c_long = 28;
-pub const SYS_ioctl: ::c_long = 29;
-pub const SYS_ioprio_set: ::c_long = 30;
-pub const SYS_ioprio_get: ::c_long = 31;
-pub const SYS_flock: ::c_long = 32;
-pub const SYS_mknodat: ::c_long = 33;
-pub const SYS_mkdirat: ::c_long = 34;
-pub const SYS_unlinkat: ::c_long = 35;
-pub const SYS_symlinkat: ::c_long = 36;
-pub const SYS_linkat: ::c_long = 37;
-pub const SYS_renameat: ::c_long = 38;
-pub const SYS_umount2: ::c_long = 39;
-pub const SYS_mount: ::c_long = 40;
-pub const SYS_pivot_root: ::c_long = 41;
-pub const SYS_nfsservctl: ::c_long = 42;
-pub const SYS_fallocate: ::c_long = 47;
-pub const SYS_faccessat: ::c_long = 48;
-pub const SYS_chdir: ::c_long = 49;
-pub const SYS_fchdir: ::c_long = 50;
-pub const SYS_chroot: ::c_long = 51;
-pub const SYS_fchmod: ::c_long = 52;
-pub const SYS_fchmodat: ::c_long = 53;
-pub const SYS_fchownat: ::c_long = 54;
-pub const SYS_fchown: ::c_long = 55;
-pub const SYS_openat: ::c_long = 56;
-pub const SYS_close: ::c_long = 57;
-pub const SYS_vhangup: ::c_long = 58;
-pub const SYS_pipe2: ::c_long = 59;
-pub const SYS_quotactl: ::c_long = 60;
-pub const SYS_getdents64: ::c_long = 61;
-pub const SYS_lseek: ::c_long = 62;
-pub const SYS_read: ::c_long = 63;
-pub const SYS_write: ::c_long = 64;
-pub const SYS_readv: ::c_long = 65;
-pub const SYS_writev: ::c_long = 66;
-pub const SYS_pread64: ::c_long = 67;
-pub const SYS_pwrite64: ::c_long = 68;
-pub const SYS_preadv: ::c_long = 69;
-pub const SYS_pwritev: ::c_long = 70;
-pub const SYS_pselect6: ::c_long = 72;
-pub const SYS_ppoll: ::c_long = 73;
-pub const SYS_signalfd4: ::c_long = 74;
-pub const SYS_vmsplice: ::c_long = 75;
-pub const SYS_splice: ::c_long = 76;
-pub const SYS_tee: ::c_long = 77;
-pub const SYS_readlinkat: ::c_long = 78;
-pub const SYS_newfstatat: ::c_long = 79;
-pub const SYS_fstat: ::c_long = 80;
-pub const SYS_sync: ::c_long = 81;
-pub const SYS_fsync: ::c_long = 82;
-pub const SYS_fdatasync: ::c_long = 83;
-pub const SYS_sync_file_range: ::c_long = 84;
-pub const SYS_timerfd_create: ::c_long = 85;
-pub const SYS_timerfd_settime: ::c_long = 86;
-pub const SYS_timerfd_gettime: ::c_long = 87;
-pub const SYS_utimensat: ::c_long = 88;
-pub const SYS_acct: ::c_long = 89;
-pub const SYS_capget: ::c_long = 90;
-pub const SYS_capset: ::c_long = 91;
-pub const SYS_personality: ::c_long = 92;
-pub const SYS_exit: ::c_long = 93;
-pub const SYS_exit_group: ::c_long = 94;
-pub const SYS_waitid: ::c_long = 95;
-pub const SYS_set_tid_address: ::c_long = 96;
-pub const SYS_unshare: ::c_long = 97;
-pub const SYS_futex: ::c_long = 98;
-pub const SYS_set_robust_list: ::c_long = 99;
-pub const SYS_get_robust_list: ::c_long = 100;
-pub const SYS_nanosleep: ::c_long = 101;
-pub const SYS_getitimer: ::c_long = 102;
-pub const SYS_setitimer: ::c_long = 103;
-pub const SYS_kexec_load: ::c_long = 104;
-pub const SYS_init_module: ::c_long = 105;
-pub const SYS_delete_module: ::c_long = 106;
-pub const SYS_timer_create: ::c_long = 107;
-pub const SYS_timer_gettime: ::c_long = 108;
-pub const SYS_timer_getoverrun: ::c_long = 109;
-pub const SYS_timer_settime: ::c_long = 110;
-pub const SYS_timer_delete: ::c_long = 111;
-pub const SYS_clock_settime: ::c_long = 112;
-pub const SYS_clock_gettime: ::c_long = 113;
-pub const SYS_clock_getres: ::c_long = 114;
-pub const SYS_clock_nanosleep: ::c_long = 115;
-pub const SYS_syslog: ::c_long = 116;
-pub const SYS_ptrace: ::c_long = 117;
-pub const SYS_sched_setparam: ::c_long = 118;
-pub const SYS_sched_setscheduler: ::c_long = 119;
-pub const SYS_sched_getscheduler: ::c_long = 120;
-pub const SYS_sched_getparam: ::c_long = 121;
-pub const SYS_sched_setaffinity: ::c_long = 122;
-pub const SYS_sched_getaffinity: ::c_long = 123;
-pub const SYS_sched_yield: ::c_long = 124;
-pub const SYS_sched_get_priority_max: ::c_long = 125;
-pub const SYS_sched_get_priority_min: ::c_long = 126;
-pub const SYS_sched_rr_get_interval: ::c_long = 127;
-pub const SYS_restart_syscall: ::c_long = 128;
-pub const SYS_kill: ::c_long = 129;
-pub const SYS_tkill: ::c_long = 130;
-pub const SYS_tgkill: ::c_long = 131;
-pub const SYS_sigaltstack: ::c_long = 132;
-pub const SYS_rt_sigsuspend: ::c_long = 133;
-pub const SYS_rt_sigaction: ::c_long = 134;
-pub const SYS_rt_sigprocmask: ::c_long = 135;
-pub const SYS_rt_sigpending: ::c_long = 136;
-pub const SYS_rt_sigtimedwait: ::c_long = 137;
-pub const SYS_rt_sigqueueinfo: ::c_long = 138;
-pub const SYS_rt_sigreturn: ::c_long = 139;
-pub const SYS_setpriority: ::c_long = 140;
-pub const SYS_getpriority: ::c_long = 141;
-pub const SYS_reboot: ::c_long = 142;
-pub const SYS_setregid: ::c_long = 143;
-pub const SYS_setgid: ::c_long = 144;
-pub const SYS_setreuid: ::c_long = 145;
-pub const SYS_setuid: ::c_long = 146;
-pub const SYS_setresuid: ::c_long = 147;
-pub const SYS_getresuid: ::c_long = 148;
-pub const SYS_setresgid: ::c_long = 149;
-pub const SYS_getresgid: ::c_long = 150;
-pub const SYS_setfsuid: ::c_long = 151;
-pub const SYS_setfsgid: ::c_long = 152;
-pub const SYS_times: ::c_long = 153;
-pub const SYS_setpgid: ::c_long = 154;
-pub const SYS_getpgid: ::c_long = 155;
-pub const SYS_getsid: ::c_long = 156;
-pub const SYS_setsid: ::c_long = 157;
-pub const SYS_getgroups: ::c_long = 158;
-pub const SYS_setgroups: ::c_long = 159;
-pub const SYS_uname: ::c_long = 160;
-pub const SYS_sethostname: ::c_long = 161;
-pub const SYS_setdomainname: ::c_long = 162;
-pub const SYS_getrlimit: ::c_long = 163;
-pub const SYS_setrlimit: ::c_long = 164;
-pub const SYS_getrusage: ::c_long = 165;
-pub const SYS_umask: ::c_long = 166;
-pub const SYS_prctl: ::c_long = 167;
-pub const SYS_getcpu: ::c_long = 168;
-pub const SYS_gettimeofday: ::c_long = 169;
-pub const SYS_settimeofday: ::c_long = 170;
-pub const SYS_adjtimex: ::c_long = 171;
-pub const SYS_getpid: ::c_long = 172;
-pub const SYS_getppid: ::c_long = 173;
-pub const SYS_getuid: ::c_long = 174;
-pub const SYS_geteuid: ::c_long = 175;
-pub const SYS_getgid: ::c_long = 176;
-pub const SYS_getegid: ::c_long = 177;
-pub const SYS_gettid: ::c_long = 178;
-pub const SYS_sysinfo: ::c_long = 179;
-pub const SYS_mq_open: ::c_long = 180;
-pub const SYS_mq_unlink: ::c_long = 181;
-pub const SYS_mq_timedsend: ::c_long = 182;
-pub const SYS_mq_timedreceive: ::c_long = 183;
-pub const SYS_mq_notify: ::c_long = 184;
-pub const SYS_mq_getsetattr: ::c_long = 185;
-pub const SYS_msgget: ::c_long = 186;
-pub const SYS_msgctl: ::c_long = 187;
-pub const SYS_msgrcv: ::c_long = 188;
-pub const SYS_msgsnd: ::c_long = 189;
-pub const SYS_semget: ::c_long = 190;
-pub const SYS_semctl: ::c_long = 191;
-pub const SYS_semtimedop: ::c_long = 192;
-pub const SYS_semop: ::c_long = 193;
-pub const SYS_shmget: ::c_long = 194;
-pub const SYS_shmctl: ::c_long = 195;
-pub const SYS_shmat: ::c_long = 196;
-pub const SYS_shmdt: ::c_long = 197;
-pub const SYS_socket: ::c_long = 198;
-pub const SYS_socketpair: ::c_long = 199;
-pub const SYS_bind: ::c_long = 200;
-pub const SYS_listen: ::c_long = 201;
-pub const SYS_accept: ::c_long = 202;
-pub const SYS_connect: ::c_long = 203;
-pub const SYS_getsockname: ::c_long = 204;
-pub const SYS_getpeername: ::c_long = 205;
-pub const SYS_sendto: ::c_long = 206;
-pub const SYS_recvfrom: ::c_long = 207;
-pub const SYS_setsockopt: ::c_long = 208;
-pub const SYS_getsockopt: ::c_long = 209;
-pub const SYS_shutdown: ::c_long = 210;
-pub const SYS_sendmsg: ::c_long = 211;
-pub const SYS_recvmsg: ::c_long = 212;
-pub const SYS_readahead: ::c_long = 213;
-pub const SYS_brk: ::c_long = 214;
-pub const SYS_munmap: ::c_long = 215;
-pub const SYS_mremap: ::c_long = 216;
-pub const SYS_add_key: ::c_long = 217;
-pub const SYS_request_key: ::c_long = 218;
-pub const SYS_keyctl: ::c_long = 219;
-pub const SYS_clone: ::c_long = 220;
-pub const SYS_execve: ::c_long = 221;
-pub const SYS_mmap: ::c_long = 222;
-pub const SYS_swapon: ::c_long = 224;
-pub const SYS_swapoff: ::c_long = 225;
-pub const SYS_mprotect: ::c_long = 226;
-pub const SYS_msync: ::c_long = 227;
-pub const SYS_mlock: ::c_long = 228;
-pub const SYS_munlock: ::c_long = 229;
-pub const SYS_mlockall: ::c_long = 230;
-pub const SYS_munlockall: ::c_long = 231;
-pub const SYS_mincore: ::c_long = 232;
-pub const SYS_madvise: ::c_long = 233;
-pub const SYS_remap_file_pages: ::c_long = 234;
-pub const SYS_mbind: ::c_long = 235;
-pub const SYS_get_mempolicy: ::c_long = 236;
-pub const SYS_set_mempolicy: ::c_long = 237;
-pub const SYS_migrate_pages: ::c_long = 238;
-pub const SYS_move_pages: ::c_long = 239;
-pub const SYS_rt_tgsigqueueinfo: ::c_long = 240;
-pub const SYS_perf_event_open: ::c_long = 241;
-pub const SYS_accept4: ::c_long = 242;
-pub const SYS_recvmmsg: ::c_long = 243;
-pub const SYS_wait4: ::c_long = 260;
-pub const SYS_prlimit64: ::c_long = 261;
-pub const SYS_fanotify_init: ::c_long = 262;
-pub const SYS_fanotify_mark: ::c_long = 263;
-pub const SYS_name_to_handle_at: ::c_long = 264;
-pub const SYS_open_by_handle_at: ::c_long = 265;
-pub const SYS_clock_adjtime: ::c_long = 266;
-pub const SYS_syncfs: ::c_long = 267;
-pub const SYS_setns: ::c_long = 268;
-pub const SYS_sendmmsg: ::c_long = 269;
-pub const SYS_process_vm_readv: ::c_long = 270;
-pub const SYS_process_vm_writev: ::c_long = 271;
-pub const SYS_kcmp: ::c_long = 272;
-pub const SYS_finit_module: ::c_long = 273;
-pub const SYS_sched_setattr: ::c_long = 274;
-pub const SYS_sched_getattr: ::c_long = 275;
-pub const SYS_renameat2: ::c_long = 276;
-pub const SYS_seccomp: ::c_long = 277;
-pub const SYS_getrandom: ::c_long = 278;
-pub const SYS_memfd_create: ::c_long = 279;
-pub const SYS_bpf: ::c_long = 280;
-pub const SYS_execveat: ::c_long = 281;
-pub const SYS_userfaultfd: ::c_long = 282;
-pub const SYS_membarrier: ::c_long = 283;
-pub const SYS_mlock2: ::c_long = 284;
-pub const SYS_copy_file_range: ::c_long = 285;
-pub const SYS_preadv2: ::c_long = 286;
-pub const SYS_pwritev2: ::c_long = 287;
-pub const SYS_pkey_mprotect: ::c_long = 288;
-pub const SYS_pkey_alloc: ::c_long = 289;
-pub const SYS_pkey_free: ::c_long = 290;
-
-#[link(name = "util")]
-extern {
- pub fn sysctl(name: *mut ::c_int,
- namelen: ::c_int,
- oldp: *mut ::c_void,
- oldlenp: *mut ::size_t,
- newp: *mut ::c_void,
- newlen: ::size_t)
- -> ::c_int;
-}
diff --git a/libc/src/unix/notbsd/linux/other/b64/mod.rs b/libc/src/unix/notbsd/linux/other/b64/mod.rs
deleted file mode 100644
index 7fcf8ba..0000000
--- a/libc/src/unix/notbsd/linux/other/b64/mod.rs
+++ /dev/null
@@ -1,85 +0,0 @@
-//! 64-bit specific definitions for linux-like values
-
-pub type clock_t = i64;
-pub type time_t = i64;
-pub type ino_t = u64;
-pub type off_t = i64;
-pub type blkcnt_t = i64;
-pub type __fsword_t = i64;
-pub type shmatt_t = u64;
-pub type msgqnum_t = u64;
-pub type msglen_t = u64;
-pub type fsblkcnt_t = u64;
-pub type fsfilcnt_t = u64;
-pub type rlim_t = u64;
-
-s! {
- pub struct sigset_t {
- #[cfg(target_pointer_width = "32")]
- __val: [u32; 32],
- #[cfg(target_pointer_width = "64")]
- __val: [u64; 16],
- }
-
- pub struct sysinfo {
- pub uptime: i64,
- pub loads: [u64; 3],
- pub totalram: u64,
- pub freeram: u64,
- pub sharedram: u64,
- pub bufferram: u64,
- pub totalswap: u64,
- pub freeswap: u64,
- pub procs: ::c_ushort,
- pub pad: ::c_ushort,
- pub totalhigh: u64,
- pub freehigh: u64,
- pub mem_unit: ::c_uint,
- pub _f: [::c_char; 0],
- }
-
- pub struct msqid_ds {
- pub msg_perm: ::ipc_perm,
- pub msg_stime: ::time_t,
- pub msg_rtime: ::time_t,
- pub msg_ctime: ::time_t,
- __msg_cbytes: u64,
- pub msg_qnum: ::msgqnum_t,
- pub msg_qbytes: ::msglen_t,
- pub msg_lspid: ::pid_t,
- pub msg_lrpid: ::pid_t,
- __glibc_reserved4: u64,
- __glibc_reserved5: u64,
- }
-}
-
-pub const __SIZEOF_PTHREAD_RWLOCKATTR_T: usize = 8;
-
-pub const O_LARGEFILE: ::c_int = 0;
-
-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 = "sparc64"))] {
- mod sparc64;
- pub use self::sparc64::*;
- } else if #[cfg(any(target_arch = "x86_64"))] {
- mod x86_64;
- pub use self::x86_64::*;
- cfg_if! {
- if #[cfg(target_pointer_width = "32")] {
- mod x32;
- pub use self::x32::*;
- } else {
- mod not_x32;
- pub use self::not_x32::*;
- }
- }
- } else {
- // Unknown target_arch
- }
-}
diff --git a/libc/src/unix/notbsd/linux/other/b64/not_x32.rs b/libc/src/unix/notbsd/linux/other/b64/not_x32.rs
deleted file mode 100644
index 97e21f2..0000000
--- a/libc/src/unix/notbsd/linux/other/b64/not_x32.rs
+++ /dev/null
@@ -1,422 +0,0 @@
-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;
-pub const SYS_write: ::c_long = 1;
-pub const SYS_open: ::c_long = 2;
-pub const SYS_close: ::c_long = 3;
-pub const SYS_stat: ::c_long = 4;
-pub const SYS_fstat: ::c_long = 5;
-pub const SYS_lstat: ::c_long = 6;
-pub const SYS_poll: ::c_long = 7;
-pub const SYS_lseek: ::c_long = 8;
-pub const SYS_mmap: ::c_long = 9;
-pub const SYS_mprotect: ::c_long = 10;
-pub const SYS_munmap: ::c_long = 11;
-pub const SYS_brk: ::c_long = 12;
-pub const SYS_rt_sigaction: ::c_long = 13;
-pub const SYS_rt_sigprocmask: ::c_long = 14;
-pub const SYS_rt_sigreturn: ::c_long = 15;
-pub const SYS_ioctl: ::c_long = 16;
-pub const SYS_pread64: ::c_long = 17;
-pub const SYS_pwrite64: ::c_long = 18;
-pub const SYS_readv: ::c_long = 19;
-pub const SYS_writev: ::c_long = 20;
-pub const SYS_access: ::c_long = 21;
-pub const SYS_pipe: ::c_long = 22;
-pub const SYS_select: ::c_long = 23;
-pub const SYS_sched_yield: ::c_long = 24;
-pub const SYS_mremap: ::c_long = 25;
-pub const SYS_msync: ::c_long = 26;
-pub const SYS_mincore: ::c_long = 27;
-pub const SYS_madvise: ::c_long = 28;
-pub const SYS_shmget: ::c_long = 29;
-pub const SYS_shmat: ::c_long = 30;
-pub const SYS_shmctl: ::c_long = 31;
-pub const SYS_dup: ::c_long = 32;
-pub const SYS_dup2: ::c_long = 33;
-pub const SYS_pause: ::c_long = 34;
-pub const SYS_nanosleep: ::c_long = 35;
-pub const SYS_getitimer: ::c_long = 36;
-pub const SYS_alarm: ::c_long = 37;
-pub const SYS_setitimer: ::c_long = 38;
-pub const SYS_getpid: ::c_long = 39;
-pub const SYS_sendfile: ::c_long = 40;
-pub const SYS_socket: ::c_long = 41;
-pub const SYS_connect: ::c_long = 42;
-pub const SYS_accept: ::c_long = 43;
-pub const SYS_sendto: ::c_long = 44;
-pub const SYS_recvfrom: ::c_long = 45;
-pub const SYS_sendmsg: ::c_long = 46;
-pub const SYS_recvmsg: ::c_long = 47;
-pub const SYS_shutdown: ::c_long = 48;
-pub const SYS_bind: ::c_long = 49;
-pub const SYS_listen: ::c_long = 50;
-pub const SYS_getsockname: ::c_long = 51;
-pub const SYS_getpeername: ::c_long = 52;
-pub const SYS_socketpair: ::c_long = 53;
-pub const SYS_setsockopt: ::c_long = 54;
-pub const SYS_getsockopt: ::c_long = 55;
-pub const SYS_clone: ::c_long = 56;
-pub const SYS_fork: ::c_long = 57;
-pub const SYS_vfork: ::c_long = 58;
-pub const SYS_execve: ::c_long = 59;
-pub const SYS_exit: ::c_long = 60;
-pub const SYS_wait4: ::c_long = 61;
-pub const SYS_kill: ::c_long = 62;
-pub const SYS_uname: ::c_long = 63;
-pub const SYS_semget: ::c_long = 64;
-pub const SYS_semop: ::c_long = 65;
-pub const SYS_semctl: ::c_long = 66;
-pub const SYS_shmdt: ::c_long = 67;
-pub const SYS_msgget: ::c_long = 68;
-pub const SYS_msgsnd: ::c_long = 69;
-pub const SYS_msgrcv: ::c_long = 70;
-pub const SYS_msgctl: ::c_long = 71;
-pub const SYS_fcntl: ::c_long = 72;
-pub const SYS_flock: ::c_long = 73;
-pub const SYS_fsync: ::c_long = 74;
-pub const SYS_fdatasync: ::c_long = 75;
-pub const SYS_truncate: ::c_long = 76;
-pub const SYS_ftruncate: ::c_long = 77;
-pub const SYS_getdents: ::c_long = 78;
-pub const SYS_getcwd: ::c_long = 79;
-pub const SYS_chdir: ::c_long = 80;
-pub const SYS_fchdir: ::c_long = 81;
-pub const SYS_rename: ::c_long = 82;
-pub const SYS_mkdir: ::c_long = 83;
-pub const SYS_rmdir: ::c_long = 84;
-pub const SYS_creat: ::c_long = 85;
-pub const SYS_link: ::c_long = 86;
-pub const SYS_unlink: ::c_long = 87;
-pub const SYS_symlink: ::c_long = 88;
-pub const SYS_readlink: ::c_long = 89;
-pub const SYS_chmod: ::c_long = 90;
-pub const SYS_fchmod: ::c_long = 91;
-pub const SYS_chown: ::c_long = 92;
-pub const SYS_fchown: ::c_long = 93;
-pub const SYS_lchown: ::c_long = 94;
-pub const SYS_umask: ::c_long = 95;
-pub const SYS_gettimeofday: ::c_long = 96;
-pub const SYS_getrlimit: ::c_long = 97;
-pub const SYS_getrusage: ::c_long = 98;
-pub const SYS_sysinfo: ::c_long = 99;
-pub const SYS_times: ::c_long = 100;
-pub const SYS_ptrace: ::c_long = 101;
-pub const SYS_getuid: ::c_long = 102;
-pub const SYS_syslog: ::c_long = 103;
-pub const SYS_getgid: ::c_long = 104;
-pub const SYS_setuid: ::c_long = 105;
-pub const SYS_setgid: ::c_long = 106;
-pub const SYS_geteuid: ::c_long = 107;
-pub const SYS_getegid: ::c_long = 108;
-pub const SYS_setpgid: ::c_long = 109;
-pub const SYS_getppid: ::c_long = 110;
-pub const SYS_getpgrp: ::c_long = 111;
-pub const SYS_setsid: ::c_long = 112;
-pub const SYS_setreuid: ::c_long = 113;
-pub const SYS_setregid: ::c_long = 114;
-pub const SYS_getgroups: ::c_long = 115;
-pub const SYS_setgroups: ::c_long = 116;
-pub const SYS_setresuid: ::c_long = 117;
-pub const SYS_getresuid: ::c_long = 118;
-pub const SYS_setresgid: ::c_long = 119;
-pub const SYS_getresgid: ::c_long = 120;
-pub const SYS_getpgid: ::c_long = 121;
-pub const SYS_setfsuid: ::c_long = 122;
-pub const SYS_setfsgid: ::c_long = 123;
-pub const SYS_getsid: ::c_long = 124;
-pub const SYS_capget: ::c_long = 125;
-pub const SYS_capset: ::c_long = 126;
-pub const SYS_rt_sigpending: ::c_long = 127;
-pub const SYS_rt_sigtimedwait: ::c_long = 128;
-pub const SYS_rt_sigqueueinfo: ::c_long = 129;
-pub const SYS_rt_sigsuspend: ::c_long = 130;
-pub const SYS_sigaltstack: ::c_long = 131;
-pub const SYS_utime: ::c_long = 132;
-pub const SYS_mknod: ::c_long = 133;
-pub const SYS_uselib: ::c_long = 134;
-pub const SYS_personality: ::c_long = 135;
-pub const SYS_ustat: ::c_long = 136;
-pub const SYS_statfs: ::c_long = 137;
-pub const SYS_fstatfs: ::c_long = 138;
-pub const SYS_sysfs: ::c_long = 139;
-pub const SYS_getpriority: ::c_long = 140;
-pub const SYS_setpriority: ::c_long = 141;
-pub const SYS_sched_setparam: ::c_long = 142;
-pub const SYS_sched_getparam: ::c_long = 143;
-pub const SYS_sched_setscheduler: ::c_long = 144;
-pub const SYS_sched_getscheduler: ::c_long = 145;
-pub const SYS_sched_get_priority_max: ::c_long = 146;
-pub const SYS_sched_get_priority_min: ::c_long = 147;
-pub const SYS_sched_rr_get_interval: ::c_long = 148;
-pub const SYS_mlock: ::c_long = 149;
-pub const SYS_munlock: ::c_long = 150;
-pub const SYS_mlockall: ::c_long = 151;
-pub const SYS_munlockall: ::c_long = 152;
-pub const SYS_vhangup: ::c_long = 153;
-pub const SYS_modify_ldt: ::c_long = 154;
-pub const SYS_pivot_root: ::c_long = 155;
-pub const SYS__sysctl: ::c_long = 156;
-pub const SYS_prctl: ::c_long = 157;
-pub const SYS_arch_prctl: ::c_long = 158;
-pub const SYS_adjtimex: ::c_long = 159;
-pub const SYS_setrlimit: ::c_long = 160;
-pub const SYS_chroot: ::c_long = 161;
-pub const SYS_sync: ::c_long = 162;
-pub const SYS_acct: ::c_long = 163;
-pub const SYS_settimeofday: ::c_long = 164;
-pub const SYS_mount: ::c_long = 165;
-pub const SYS_umount2: ::c_long = 166;
-pub const SYS_swapon: ::c_long = 167;
-pub const SYS_swapoff: ::c_long = 168;
-pub const SYS_reboot: ::c_long = 169;
-pub const SYS_sethostname: ::c_long = 170;
-pub const SYS_setdomainname: ::c_long = 171;
-pub const SYS_iopl: ::c_long = 172;
-pub const SYS_ioperm: ::c_long = 173;
-pub const SYS_create_module: ::c_long = 174;
-pub const SYS_init_module: ::c_long = 175;
-pub const SYS_delete_module: ::c_long = 176;
-pub const SYS_get_kernel_syms: ::c_long = 177;
-pub const SYS_query_module: ::c_long = 178;
-pub const SYS_quotactl: ::c_long = 179;
-pub const SYS_nfsservctl: ::c_long = 180;
-pub const SYS_getpmsg: ::c_long = 181;
-pub const SYS_putpmsg: ::c_long = 182;
-pub const SYS_afs_syscall: ::c_long = 183;
-pub const SYS_tuxcall: ::c_long = 184;
-pub const SYS_security: ::c_long = 185;
-pub const SYS_gettid: ::c_long = 186;
-pub const SYS_readahead: ::c_long = 187;
-pub const SYS_setxattr: ::c_long = 188;
-pub const SYS_lsetxattr: ::c_long = 189;
-pub const SYS_fsetxattr: ::c_long = 190;
-pub const SYS_getxattr: ::c_long = 191;
-pub const SYS_lgetxattr: ::c_long = 192;
-pub const SYS_fgetxattr: ::c_long = 193;
-pub const SYS_listxattr: ::c_long = 194;
-pub const SYS_llistxattr: ::c_long = 195;
-pub const SYS_flistxattr: ::c_long = 196;
-pub const SYS_removexattr: ::c_long = 197;
-pub const SYS_lremovexattr: ::c_long = 198;
-pub const SYS_fremovexattr: ::c_long = 199;
-pub const SYS_tkill: ::c_long = 200;
-pub const SYS_time: ::c_long = 201;
-pub const SYS_futex: ::c_long = 202;
-pub const SYS_sched_setaffinity: ::c_long = 203;
-pub const SYS_sched_getaffinity: ::c_long = 204;
-pub const SYS_set_thread_area: ::c_long = 205;
-pub const SYS_io_setup: ::c_long = 206;
-pub const SYS_io_destroy: ::c_long = 207;
-pub const SYS_io_getevents: ::c_long = 208;
-pub const SYS_io_submit: ::c_long = 209;
-pub const SYS_io_cancel: ::c_long = 210;
-pub const SYS_get_thread_area: ::c_long = 211;
-pub const SYS_lookup_dcookie: ::c_long = 212;
-pub const SYS_epoll_create: ::c_long = 213;
-pub const SYS_epoll_ctl_old: ::c_long = 214;
-pub const SYS_epoll_wait_old: ::c_long = 215;
-pub const SYS_remap_file_pages: ::c_long = 216;
-pub const SYS_getdents64: ::c_long = 217;
-pub const SYS_set_tid_address: ::c_long = 218;
-pub const SYS_restart_syscall: ::c_long = 219;
-pub const SYS_semtimedop: ::c_long = 220;
-pub const SYS_fadvise64: ::c_long = 221;
-pub const SYS_timer_create: ::c_long = 222;
-pub const SYS_timer_settime: ::c_long = 223;
-pub const SYS_timer_gettime: ::c_long = 224;
-pub const SYS_timer_getoverrun: ::c_long = 225;
-pub const SYS_timer_delete: ::c_long = 226;
-pub const SYS_clock_settime: ::c_long = 227;
-pub const SYS_clock_gettime: ::c_long = 228;
-pub const SYS_clock_getres: ::c_long = 229;
-pub const SYS_clock_nanosleep: ::c_long = 230;
-pub const SYS_exit_group: ::c_long = 231;
-pub const SYS_epoll_wait: ::c_long = 232;
-pub const SYS_epoll_ctl: ::c_long = 233;
-pub const SYS_tgkill: ::c_long = 234;
-pub const SYS_utimes: ::c_long = 235;
-pub const SYS_vserver: ::c_long = 236;
-pub const SYS_mbind: ::c_long = 237;
-pub const SYS_set_mempolicy: ::c_long = 238;
-pub const SYS_get_mempolicy: ::c_long = 239;
-pub const SYS_mq_open: ::c_long = 240;
-pub const SYS_mq_unlink: ::c_long = 241;
-pub const SYS_mq_timedsend: ::c_long = 242;
-pub const SYS_mq_timedreceive: ::c_long = 243;
-pub const SYS_mq_notify: ::c_long = 244;
-pub const SYS_mq_getsetattr: ::c_long = 245;
-pub const SYS_kexec_load: ::c_long = 246;
-pub const SYS_waitid: ::c_long = 247;
-pub const SYS_add_key: ::c_long = 248;
-pub const SYS_request_key: ::c_long = 249;
-pub const SYS_keyctl: ::c_long = 250;
-pub const SYS_ioprio_set: ::c_long = 251;
-pub const SYS_ioprio_get: ::c_long = 252;
-pub const SYS_inotify_init: ::c_long = 253;
-pub const SYS_inotify_add_watch: ::c_long = 254;
-pub const SYS_inotify_rm_watch: ::c_long = 255;
-pub const SYS_migrate_pages: ::c_long = 256;
-pub const SYS_openat: ::c_long = 257;
-pub const SYS_mkdirat: ::c_long = 258;
-pub const SYS_mknodat: ::c_long = 259;
-pub const SYS_fchownat: ::c_long = 260;
-pub const SYS_futimesat: ::c_long = 261;
-pub const SYS_newfstatat: ::c_long = 262;
-pub const SYS_unlinkat: ::c_long = 263;
-pub const SYS_renameat: ::c_long = 264;
-pub const SYS_linkat: ::c_long = 265;
-pub const SYS_symlinkat: ::c_long = 266;
-pub const SYS_readlinkat: ::c_long = 267;
-pub const SYS_fchmodat: ::c_long = 268;
-pub const SYS_faccessat: ::c_long = 269;
-pub const SYS_pselect6: ::c_long = 270;
-pub const SYS_ppoll: ::c_long = 271;
-pub const SYS_unshare: ::c_long = 272;
-pub const SYS_set_robust_list: ::c_long = 273;
-pub const SYS_get_robust_list: ::c_long = 274;
-pub const SYS_splice: ::c_long = 275;
-pub const SYS_tee: ::c_long = 276;
-pub const SYS_sync_file_range: ::c_long = 277;
-pub const SYS_vmsplice: ::c_long = 278;
-pub const SYS_move_pages: ::c_long = 279;
-pub const SYS_utimensat: ::c_long = 280;
-pub const SYS_epoll_pwait: ::c_long = 281;
-pub const SYS_signalfd: ::c_long = 282;
-pub const SYS_timerfd_create: ::c_long = 283;
-pub const SYS_eventfd: ::c_long = 284;
-pub const SYS_fallocate: ::c_long = 285;
-pub const SYS_timerfd_settime: ::c_long = 286;
-pub const SYS_timerfd_gettime: ::c_long = 287;
-pub const SYS_accept4: ::c_long = 288;
-pub const SYS_signalfd4: ::c_long = 289;
-pub const SYS_eventfd2: ::c_long = 290;
-pub const SYS_epoll_create1: ::c_long = 291;
-pub const SYS_dup3: ::c_long = 292;
-pub const SYS_pipe2: ::c_long = 293;
-pub const SYS_inotify_init1: ::c_long = 294;
-pub const SYS_preadv: ::c_long = 295;
-pub const SYS_pwritev: ::c_long = 296;
-pub const SYS_rt_tgsigqueueinfo: ::c_long = 297;
-pub const SYS_perf_event_open: ::c_long = 298;
-pub const SYS_recvmmsg: ::c_long = 299;
-pub const SYS_fanotify_init: ::c_long = 300;
-pub const SYS_fanotify_mark: ::c_long = 301;
-pub const SYS_prlimit64: ::c_long = 302;
-pub const SYS_name_to_handle_at: ::c_long = 303;
-pub const SYS_open_by_handle_at: ::c_long = 304;
-pub const SYS_clock_adjtime: ::c_long = 305;
-pub const SYS_syncfs: ::c_long = 306;
-pub const SYS_sendmmsg: ::c_long = 307;
-pub const SYS_setns: ::c_long = 308;
-pub const SYS_getcpu: ::c_long = 309;
-pub const SYS_process_vm_readv: ::c_long = 310;
-pub const SYS_process_vm_writev: ::c_long = 311;
-pub const SYS_kcmp: ::c_long = 312;
-pub const SYS_finit_module: ::c_long = 313;
-pub const SYS_sched_setattr: ::c_long = 314;
-pub const SYS_sched_getattr: ::c_long = 315;
-pub const SYS_renameat2: ::c_long = 316;
-pub const SYS_seccomp: ::c_long = 317;
-pub const SYS_getrandom: ::c_long = 318;
-pub const SYS_memfd_create: ::c_long = 319;
-pub const SYS_kexec_file_load: ::c_long = 320;
-pub const SYS_bpf: ::c_long = 321;
-pub const SYS_execveat: ::c_long = 322;
-pub const SYS_userfaultfd: ::c_long = 323;
-pub const SYS_membarrier: ::c_long = 324;
-pub const SYS_mlock2: ::c_long = 325;
-pub const SYS_copy_file_range: ::c_long = 326;
-pub const SYS_preadv2: ::c_long = 327;
-pub const SYS_pwritev2: ::c_long = 328;
-pub const SYS_pkey_mprotect: ::c_long = 329;
-pub const SYS_pkey_alloc: ::c_long = 330;
-pub const SYS_pkey_free: ::c_long = 331;
-pub const SYS_statx: ::c_long = 332;
-
-#[link(name = "util")]
-extern {
- pub fn sysctl(name: *mut ::c_int,
- namelen: ::c_int,
- oldp: *mut ::c_void,
- oldlenp: *mut ::size_t,
- newp: *mut ::c_void,
- newlen: ::size_t)
- -> ::c_int;
-}
diff --git a/libc/src/unix/notbsd/linux/other/b64/powerpc64.rs b/libc/src/unix/notbsd/linux/other/b64/powerpc64.rs
deleted file mode 100644
index b31248b..0000000
--- a/libc/src/unix/notbsd/linux/other/b64/powerpc64.rs
+++ /dev/null
@@ -1,937 +0,0 @@
-//! 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;
-pub type wchar_t = i32;
-pub type nlink_t = u64;
-pub type blksize_t = i64;
-pub type suseconds_t = i64;
-pub type __u64 = ::c_ulong;
-
-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: ::off64_t,
- pub st_blksize: ::blksize_t,
- pub st_blocks: ::blkcnt64_t,
- pub st_atime: ::time_t,
- pub st_atime_nsec: ::c_long,
- pub st_mtime: ::time_t,
- pub st_mtime_nsec: ::c_long,
- pub st_ctime: ::time_t,
- pub st_ctime_nsec: ::c_long,
- __reserved: [::c_long; 3],
- }
-
- pub struct statfs64 {
- pub f_type: ::__fsword_t,
- pub f_bsize: ::__fsword_t,
- pub f_blocks: u64,
- pub f_bfree: u64,
- pub f_bavail: u64,
- pub f_files: u64,
- pub f_ffree: u64,
- pub f_fsid: ::fsid_t,
- pub f_namelen: ::__fsword_t,
- pub f_frsize: ::__fsword_t,
- pub f_flags: ::__fsword_t,
- pub f_spare: [::__fsword_t; 4],
- }
-
- pub struct 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,
- pub f_blocks: u64,
- pub f_bfree: u64,
- pub f_bavail: u64,
- pub f_files: u64,
- pub f_ffree: u64,
- pub f_favail: u64,
- pub f_fsid: ::c_ulong,
- pub f_flag: ::c_ulong,
- pub f_namemax: ::c_ulong,
- __f_spare: [::c_int; 6],
- }
-
- pub struct pthread_attr_t {
- __size: [u64; 7]
- }
-
- pub struct ipc_perm {
- pub __key: ::key_t,
- pub uid: ::uid_t,
- pub gid: ::gid_t,
- pub cuid: ::uid_t,
- pub cgid: ::gid_t,
- pub mode: ::mode_t,
- pub __seq: u32,
- __pad1: u32,
- __unused1: u64,
- __unused2: ::c_ulong,
- }
-
- pub struct shmid_ds {
- pub shm_perm: ::ipc_perm,
- pub shm_atime: ::time_t,
- pub shm_dtime: ::time_t,
- pub shm_ctime: ::time_t,
- pub shm_segsz: ::size_t,
- pub shm_cpid: ::pid_t,
- pub shm_lpid: ::pid_t,
- pub shm_nattch: ::shmatt_t,
- __unused4: ::c_ulong,
- __unused5: ::c_ulong
- }
-}
-
-pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 56;
-
-pub const TIOCGSOFTCAR: ::c_ulong = 0x5419;
-pub const TIOCSSOFTCAR: ::c_ulong = 0x541A;
-
-pub const RLIMIT_NOFILE: ::c_int = 7;
-pub const RLIMIT_NPROC: ::c_int = 6;
-
-pub const O_APPEND: ::c_int = 1024;
-pub const O_CREAT: ::c_int = 64;
-pub const O_EXCL: ::c_int = 128;
-pub const O_NOCTTY: ::c_int = 256;
-pub const O_NONBLOCK: ::c_int = 2048;
-pub const O_SYNC: ::c_int = 1052672;
-pub const O_RSYNC: ::c_int = 1052672;
-pub const O_DSYNC: ::c_int = 4096;
-pub const O_FSYNC: ::c_int = 0x101000;
-pub const O_NOATIME: ::c_int = 0o1000000;
-pub const O_PATH: ::c_int = 0o10000000;
-pub const O_TMPFILE: ::c_int = 0o20000000 | O_DIRECTORY;
-
-pub const MAP_GROWSDOWN: ::c_int = 0x0100;
-
-pub const EDEADLK: ::c_int = 35;
-pub const ENAMETOOLONG: ::c_int = 36;
-pub const ENOLCK: ::c_int = 37;
-pub const ENOSYS: ::c_int = 38;
-pub const ENOTEMPTY: ::c_int = 39;
-pub const ELOOP: ::c_int = 40;
-pub const ENOMSG: ::c_int = 42;
-pub const EIDRM: ::c_int = 43;
-pub const ECHRNG: ::c_int = 44;
-pub const EL2NSYNC: ::c_int = 45;
-pub const EL3HLT: ::c_int = 46;
-pub const EL3RST: ::c_int = 47;
-pub const ELNRNG: ::c_int = 48;
-pub const EUNATCH: ::c_int = 49;
-pub const ENOCSI: ::c_int = 50;
-pub const EL2HLT: ::c_int = 51;
-pub const EBADE: ::c_int = 52;
-pub const EBADR: ::c_int = 53;
-pub const EXFULL: ::c_int = 54;
-pub const ENOANO: ::c_int = 55;
-pub const EBADRQC: ::c_int = 56;
-pub const EBADSLT: ::c_int = 57;
-pub const EMULTIHOP: ::c_int = 72;
-pub const EOVERFLOW: ::c_int = 75;
-pub const ENOTUNIQ: ::c_int = 76;
-pub const EBADFD: ::c_int = 77;
-pub const EBADMSG: ::c_int = 74;
-pub const EREMCHG: ::c_int = 78;
-pub const ELIBACC: ::c_int = 79;
-pub const ELIBBAD: ::c_int = 80;
-pub const ELIBSCN: ::c_int = 81;
-pub const ELIBMAX: ::c_int = 82;
-pub const ELIBEXEC: ::c_int = 83;
-pub const EILSEQ: ::c_int = 84;
-pub const ERESTART: ::c_int = 85;
-pub const ESTRPIPE: ::c_int = 86;
-pub const EUSERS: ::c_int = 87;
-pub const ENOTSOCK: ::c_int = 88;
-pub const EDESTADDRREQ: ::c_int = 89;
-pub const EMSGSIZE: ::c_int = 90;
-pub const EPROTOTYPE: ::c_int = 91;
-pub const ENOPROTOOPT: ::c_int = 92;
-pub const EPROTONOSUPPORT: ::c_int = 93;
-pub const ESOCKTNOSUPPORT: ::c_int = 94;
-pub const EOPNOTSUPP: ::c_int = 95;
-pub const EPFNOSUPPORT: ::c_int = 96;
-pub const EAFNOSUPPORT: ::c_int = 97;
-pub const EADDRINUSE: ::c_int = 98;
-pub const EADDRNOTAVAIL: ::c_int = 99;
-pub const ENETDOWN: ::c_int = 100;
-pub const ENETUNREACH: ::c_int = 101;
-pub const ENETRESET: ::c_int = 102;
-pub const ECONNABORTED: ::c_int = 103;
-pub const ECONNRESET: ::c_int = 104;
-pub const ENOBUFS: ::c_int = 105;
-pub const EISCONN: ::c_int = 106;
-pub const ENOTCONN: ::c_int = 107;
-pub const ESHUTDOWN: ::c_int = 108;
-pub const ETOOMANYREFS: ::c_int = 109;
-pub const ETIMEDOUT: ::c_int = 110;
-pub const ECONNREFUSED: ::c_int = 111;
-pub const EHOSTDOWN: ::c_int = 112;
-pub const EHOSTUNREACH: ::c_int = 113;
-pub const EALREADY: ::c_int = 114;
-pub const EINPROGRESS: ::c_int = 115;
-pub const ESTALE: ::c_int = 116;
-pub const EDQUOT: ::c_int = 122;
-pub const ENOMEDIUM: ::c_int = 123;
-pub const EMEDIUMTYPE: ::c_int = 124;
-pub const ECANCELED: ::c_int = 125;
-pub const ENOKEY: ::c_int = 126;
-pub const EKEYEXPIRED: ::c_int = 127;
-pub const EKEYREVOKED: ::c_int = 128;
-pub const EKEYREJECTED: ::c_int = 129;
-pub const EOWNERDEAD: ::c_int = 130;
-pub const ENOTRECOVERABLE: ::c_int = 131;
-pub const EHWPOISON: ::c_int = 133;
-pub const ERFKILL: ::c_int = 132;
-
-pub const SOL_SOCKET: ::c_int = 1;
-
-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_SNDBUFFORCE: ::c_int = 32;
-pub const SO_RCVBUFFORCE: ::c_int = 33;
-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_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 SO_SECURITY_AUTHENTICATION: ::c_int = 22;
-pub const SO_SECURITY_ENCRYPTION_TRANSPORT: ::c_int = 23;
-pub const SO_SECURITY_ENCRYPTION_NETWORK: ::c_int = 24;
-pub const SO_BINDTODEVICE: ::c_int = 25;
-pub const SO_ATTACH_FILTER: ::c_int = 26;
-pub const SO_DETACH_FILTER: ::c_int = 27;
-pub const SO_GET_FILTER: ::c_int = SO_ATTACH_FILTER;
-pub const SO_PEERNAME: ::c_int = 28;
-pub const SO_TIMESTAMP: ::c_int = 29;
-pub const SO_ACCEPTCONN: ::c_int = 30;
-pub const SO_PEERSEC: ::c_int = 31;
-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_PROTOCOL: ::c_int = 38;
-pub const SO_DOMAIN: ::c_int = 39;
-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;
-pub const SO_PEEK_OFF: ::c_int = 42;
-pub const SO_NOFCS: ::c_int = 43;
-pub const SO_LOCK_FILTER: ::c_int = 44;
-pub const SO_SELECT_ERR_QUEUE: ::c_int = 45;
-pub const SO_BUSY_POLL: ::c_int = 46;
-pub const SO_MAX_PACING_RATE: ::c_int = 47;
-pub const SO_BPF_EXTENSIONS: ::c_int = 48;
-pub const SO_INCOMING_CPU: ::c_int = 49;
-pub const SO_ATTACH_BPF: ::c_int = 50;
-pub const SO_DETACH_BPF: ::c_int = SO_DETACH_FILTER;
-
-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 SIGUSR1: ::c_int = 10;
-pub const SIGUSR2: ::c_int = 12;
-pub const SIGCONT: ::c_int = 18;
-pub const SIGSTOP: ::c_int = 19;
-pub const SIGTSTP: ::c_int = 20;
-pub const SIGURG: ::c_int = 23;
-pub const SIGIO: ::c_int = 29;
-pub const SIGSYS: ::c_int = 31;
-pub const SIGSTKFLT: ::c_int = 16;
-#[deprecated(
- since = "0.2.55",
- note = "Use SIGSYS instead"
-)]
-pub const SIGUNUSED: ::c_int = 31;
-pub const SIGPOLL: ::c_int = 29;
-pub const SIGPWR: ::c_int = 30;
-pub const SIG_SETMASK: ::c_int = 2;
-pub const SIG_BLOCK: ::c_int = 0x000000;
-pub const SIG_UNBLOCK: ::c_int = 0x01;
-
-pub const POLLWRNORM: ::c_short = 0x100;
-pub const POLLWRBAND: ::c_short = 0x200;
-
-pub const O_ASYNC: ::c_int = 0x2000;
-pub const O_NDELAY: ::c_int = 0x800;
-
-pub const PTRACE_DETACH: ::c_uint = 17;
-
-pub const EFD_NONBLOCK: ::c_int = 0x800;
-
-pub const F_GETLK: ::c_int = 5;
-pub const F_GETOWN: ::c_int = 9;
-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;
-pub const TIOCNXCL: ::c_ulong = 0x540D;
-pub const TIOCSCTTY: ::c_ulong = 0x540E;
-pub const TIOCSTI: ::c_ulong = 0x5412;
-pub const TIOCMGET: ::c_ulong = 0x5415;
-pub const TIOCMBIS: ::c_ulong = 0x5416;
-pub const TIOCMBIC: ::c_ulong = 0x5417;
-pub const TIOCMSET: ::c_ulong = 0x5418;
-pub const TIOCCONS: ::c_ulong = 0x541D;
-pub const TIOCGRS485: ::c_int = 0x542E;
-pub const TIOCSRS485: ::c_int = 0x542F;
-
-pub const SFD_CLOEXEC: ::c_int = 0x080000;
-
-pub const NCCS: usize = 32;
-
-pub const O_TRUNC: ::c_int = 512;
-
-pub const O_CLOEXEC: ::c_int = 0x80000;
-
-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 EDOTDOT: ::c_int = 73;
-
-pub const SA_NODEFER: ::c_int = 0x40000000;
-pub const SA_RESETHAND: ::c_int = 0x80000000;
-pub const SA_RESTART: ::c_int = 0x10000000;
-pub const SA_NOCLDSTOP: ::c_int = 0x00000001;
-
-pub const EPOLL_CLOEXEC: ::c_int = 0x80000;
-
-pub const EFD_CLOEXEC: ::c_int = 0x80000;
-
-pub const __SIZEOF_PTHREAD_CONDATTR_T: usize = 4;
-pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 40;
-pub const __SIZEOF_PTHREAD_MUTEXATTR_T: usize = 4;
-
-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;
-
-pub const MAP_LOCKED: ::c_int = 0x00080;
-pub const MAP_NORESERVE: ::c_int = 0x00040;
-
-pub const EDEADLOCK: ::c_int = 58;
-
-pub const FIOCLEX: ::c_ulong = 0x20006601;
-pub const FIONBIO: ::c_ulong = 0x8004667e;
-
-pub const MCL_CURRENT: ::c_int = 0x2000;
-pub const MCL_FUTURE: ::c_int = 0x4000;
-
-pub const SIGSTKSZ: ::size_t = 0x4000;
-pub const MINSIGSTKSZ: ::size_t = 4096;
-pub const CBAUD: ::tcflag_t = 0xff;
-pub const TAB1: ::tcflag_t = 0x400;
-pub const TAB2: ::tcflag_t = 0x800;
-pub const TAB3: ::tcflag_t = 0xc00;
-pub const CR1: ::tcflag_t = 0x1000;
-pub const CR2: ::tcflag_t = 0x2000;
-pub const CR3: ::tcflag_t = 0x3000;
-pub const FF1: ::tcflag_t = 0x4000;
-pub const BS1: ::tcflag_t = 0x8000;
-pub const VT1: ::tcflag_t = 0x10000;
-pub const VWERASE: usize = 0xa;
-pub const VREPRINT: usize = 0xb;
-pub const VSUSP: usize = 0xc;
-pub const VSTART: usize = 0xd;
-pub const VSTOP: usize = 0xe;
-pub const VDISCARD: usize = 0x10;
-pub const VTIME: usize = 0x7;
-pub const IXON: ::tcflag_t = 0x200;
-pub const IXOFF: ::tcflag_t = 0x400;
-pub const ONLCR: ::tcflag_t = 0x2;
-pub const CSIZE: ::tcflag_t = 0x300;
-pub const CS6: ::tcflag_t = 0x100;
-pub const CS7: ::tcflag_t = 0x200;
-pub const CS8: ::tcflag_t = 0x300;
-pub const CSTOPB: ::tcflag_t = 0x400;
-pub const CREAD: ::tcflag_t = 0x800;
-pub const PARENB: ::tcflag_t = 0x1000;
-pub const PARODD: ::tcflag_t = 0x2000;
-pub const HUPCL: ::tcflag_t = 0x4000;
-pub const CLOCAL: ::tcflag_t = 0x8000;
-pub const ECHOKE: ::tcflag_t = 0x1;
-pub const ECHOE: ::tcflag_t = 0x2;
-pub const ECHOK: ::tcflag_t = 0x4;
-pub const ECHONL: ::tcflag_t = 0x10;
-pub const ECHOPRT: ::tcflag_t = 0x20;
-pub const ECHOCTL: ::tcflag_t = 0x40;
-pub const ISIG: ::tcflag_t = 0x80;
-pub const ICANON: ::tcflag_t = 0x100;
-pub const PENDIN: ::tcflag_t = 0x20000000;
-pub const NOFLSH: ::tcflag_t = 0x80000000;
-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 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 CBAUDEX: ::speed_t = 0o000020;
-pub const B57600: ::speed_t = 0o0020;
-pub const B115200: ::speed_t = 0o0021;
-pub const B230400: ::speed_t = 0o0022;
-pub const B460800: ::speed_t = 0o0023;
-pub const B500000: ::speed_t = 0o0024;
-pub const B576000: ::speed_t = 0o0025;
-pub const B921600: ::speed_t = 0o0026;
-pub const B1000000: ::speed_t = 0o0027;
-pub const B1152000: ::speed_t = 0o0030;
-pub const B1500000: ::speed_t = 0o0031;
-pub const B2000000: ::speed_t = 0o0032;
-pub const B2500000: ::speed_t = 0o0033;
-pub const B3000000: ::speed_t = 0o0034;
-pub const B3500000: ::speed_t = 0o0035;
-pub const B4000000: ::speed_t = 0o0036;
-pub const BOTHER: ::speed_t = 0o0037;
-
-pub const VEOL: usize = 6;
-pub const VEOL2: usize = 8;
-pub const VMIN: usize = 5;
-pub const IEXTEN: ::tcflag_t = 0x400;
-pub const TOSTOP: ::tcflag_t = 0x400000;
-pub const FLUSHO: ::tcflag_t = 0x800000;
-pub const EXTPROC: ::tcflag_t = 0x10000000;
-pub const TCGETS: ::c_ulong = 0x403c7413;
-pub const TCSETS: ::c_ulong = 0x803c7414;
-pub const TCSETSW: ::c_ulong = 0x803c7415;
-pub const TCSETSF: ::c_ulong = 0x803c7416;
-pub const TCGETA: ::c_ulong = 0x40147417;
-pub const TCSETA: ::c_ulong = 0x80147418;
-pub const TCSETAW: ::c_ulong = 0x80147419;
-pub const TCSETAF: ::c_ulong = 0x8014741c;
-pub const TCSBRK: ::c_ulong = 0x2000741d;
-pub const TCXONC: ::c_ulong = 0x2000741e;
-pub const TCFLSH: ::c_ulong = 0x2000741f;
-pub const TIOCINQ: ::c_ulong = 0x4004667f;
-pub const TIOCGPGRP: ::c_ulong = 0x40047477;
-pub const TIOCSPGRP: ::c_ulong = 0x80047476;
-pub const TIOCOUTQ: ::c_ulong = 0x40047473;
-pub const TIOCGWINSZ: ::c_ulong = 0x40087468;
-pub const TIOCSWINSZ: ::c_ulong = 0x80087467;
-pub const FIONREAD: ::c_ulong = 0x4004667f;
-
-// 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 SYS_statx: ::c_long = 383;
-
-#[link(name = "util")]
-extern {
- pub fn sysctl(name: *mut ::c_int,
- namelen: ::c_int,
- oldp: *mut ::c_void,
- oldlenp: *mut ::size_t,
- newp: *mut ::c_void,
- newlen: ::size_t)
- -> ::c_int;
-}
diff --git a/libc/src/unix/notbsd/linux/other/b64/sparc64.rs b/libc/src/unix/notbsd/linux/other/b64/sparc64.rs
deleted file mode 100644
index f54504a..0000000
--- a/libc/src/unix/notbsd/linux/other/b64/sparc64.rs
+++ /dev/null
@@ -1,869 +0,0 @@
-//! 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;
-pub type wchar_t = i32;
-pub type nlink_t = u32;
-pub type blksize_t = i64;
-pub type suseconds_t = i32;
-pub type __u64 = ::c_ulonglong;
-
-s! {
- pub struct stat {
- pub st_dev: ::dev_t,
- __pad0: u64,
- 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,
- __pad1: u64,
- 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,
- __pad0: u64,
- pub st_ino: ::ino64_t,
- pub st_mode: ::mode_t,
- pub st_nlink: ::nlink_t,
- pub st_uid: ::uid_t,
- pub st_gid: ::gid_t,
- pub st_rdev: ::dev_t,
- __pad2: ::c_int,
- pub st_size: ::off64_t,
- pub st_blksize: ::blksize_t,
- pub st_blocks: ::blkcnt64_t,
- pub st_atime: ::time_t,
- pub st_atime_nsec: ::c_long,
- pub st_mtime: ::time_t,
- pub st_mtime_nsec: ::c_long,
- pub st_ctime: ::time_t,
- pub st_ctime_nsec: ::c_long,
- __reserved: [::c_long; 2],
- }
-
- pub struct statfs64 {
- pub f_type: ::__fsword_t,
- pub f_bsize: ::__fsword_t,
- pub f_blocks: u64,
- pub f_bfree: u64,
- pub f_bavail: u64,
- pub f_files: u64,
- pub f_ffree: u64,
- pub f_fsid: ::fsid_t,
- pub f_namelen: ::__fsword_t,
- pub f_frsize: ::__fsword_t,
- pub f_flags: ::__fsword_t,
- pub f_spare: [::__fsword_t; 4],
- }
-
- pub struct 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,
- pub f_blocks: u64,
- pub f_bfree: u64,
- pub f_bavail: u64,
- pub f_files: u64,
- pub f_ffree: u64,
- pub f_favail: u64,
- pub f_fsid: ::c_ulong,
- pub f_flag: ::c_ulong,
- pub f_namemax: ::c_ulong,
- __f_spare: [::c_int; 6],
- }
-
- pub struct pthread_attr_t {
- __size: [u64; 7]
- }
-
- pub struct ipc_perm {
- pub __key: ::key_t,
- pub uid: ::uid_t,
- pub gid: ::gid_t,
- pub cuid: ::uid_t,
- pub cgid: ::gid_t,
- pub mode: ::mode_t,
- __pad0: u16,
- pub __seq: ::c_ushort,
- __unused1: ::c_ulonglong,
- __unused2: ::c_ulonglong,
- }
-
- pub struct shmid_ds {
- pub shm_perm: ::ipc_perm,
- pub shm_atime: ::time_t,
- pub shm_dtime: ::time_t,
- pub shm_ctime: ::time_t,
- pub shm_segsz: ::size_t,
- pub shm_cpid: ::pid_t,
- pub shm_lpid: ::pid_t,
- pub shm_nattch: ::shmatt_t,
- __reserved1: ::c_ulong,
- __reserved2: ::c_ulong
- }
-
- 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_line: ::cc_t,
- pub c_cc: [::cc_t; 19],
- pub c_ispeed: ::speed_t,
- pub c_ospeed: ::speed_t,
- }
-}
-
-pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 56;
-
-pub const TIOCGSOFTCAR: ::c_ulong = 0x40047464;
-pub const TIOCSSOFTCAR: ::c_ulong = 0x80047465;
-
-pub const RLIMIT_NOFILE: ::c_int = 6;
-pub const RLIMIT_NPROC: ::c_int = 7;
-
-pub const O_APPEND: ::c_int = 0x8;
-pub const O_CREAT: ::c_int = 0x200;
-pub const O_EXCL: ::c_int = 0x800;
-pub const O_NOCTTY: ::c_int = 0x8000;
-pub const O_NONBLOCK: ::c_int = 0x4000;
-pub const O_SYNC: ::c_int = 0x802000;
-pub const O_RSYNC: ::c_int = 0x802000;
-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 = 0x2000000 | O_DIRECTORY;
-
-pub const MAP_GROWSDOWN: ::c_int = 0x0200;
-
-pub const EDEADLK: ::c_int = 78;
-pub const ENAMETOOLONG: ::c_int = 63;
-pub const ENOLCK: ::c_int = 79;
-pub const ENOSYS: ::c_int = 90;
-pub const ENOTEMPTY: ::c_int = 66;
-pub const ELOOP: ::c_int = 62;
-pub const ENOMSG: ::c_int = 75;
-pub const EIDRM: ::c_int = 77;
-pub const ECHRNG: ::c_int = 94;
-pub const EL2NSYNC: ::c_int = 95;
-pub const EL3HLT: ::c_int = 96;
-pub const EL3RST: ::c_int = 97;
-pub const ELNRNG: ::c_int = 98;
-pub const EUNATCH: ::c_int = 99;
-pub const ENOCSI: ::c_int = 100;
-pub const EL2HLT: ::c_int = 101;
-pub const EBADE: ::c_int = 102;
-pub const EBADR: ::c_int = 103;
-pub const EXFULL: ::c_int = 104;
-pub const ENOANO: ::c_int = 105;
-pub const EBADRQC: ::c_int = 106;
-pub const EBADSLT: ::c_int = 107;
-pub const EMULTIHOP: ::c_int = 87;
-pub const EOVERFLOW: ::c_int = 92;
-pub const ENOTUNIQ: ::c_int = 115;
-pub const EBADFD: ::c_int = 93;
-pub const EBADMSG: ::c_int = 76;
-pub const EREMCHG: ::c_int = 89;
-pub const ELIBACC: ::c_int = 114;
-pub const ELIBBAD: ::c_int = 112;
-pub const ELIBSCN: ::c_int = 124;
-pub const ELIBMAX: ::c_int = 123;
-pub const ELIBEXEC: ::c_int = 110;
-pub const EILSEQ: ::c_int = 122;
-pub const ERESTART: ::c_int = 116;
-pub const ESTRPIPE: ::c_int = 91;
-pub const EUSERS: ::c_int = 68;
-pub const ENOTSOCK: ::c_int = 38;
-pub const EDESTADDRREQ: ::c_int = 39;
-pub const EMSGSIZE: ::c_int = 40;
-pub const EPROTOTYPE: ::c_int = 41;
-pub const ENOPROTOOPT: ::c_int = 42;
-pub const EPROTONOSUPPORT: ::c_int = 43;
-pub const ESOCKTNOSUPPORT: ::c_int = 44;
-pub const EOPNOTSUPP: ::c_int = 45;
-pub const EPFNOSUPPORT: ::c_int = 46;
-pub const EAFNOSUPPORT: ::c_int = 47;
-pub const EADDRINUSE: ::c_int = 48;
-pub const EADDRNOTAVAIL: ::c_int = 49;
-pub const ENETDOWN: ::c_int = 50;
-pub const ENETUNREACH: ::c_int = 51;
-pub const ENETRESET: ::c_int = 52;
-pub const ECONNABORTED: ::c_int = 53;
-pub const ECONNRESET: ::c_int = 54;
-pub const ENOBUFS: ::c_int = 55;
-pub const EISCONN: ::c_int = 56;
-pub const ENOTCONN: ::c_int = 57;
-pub const ESHUTDOWN: ::c_int = 58;
-pub const ETOOMANYREFS: ::c_int = 59;
-pub const ETIMEDOUT: ::c_int = 60;
-pub const ECONNREFUSED: ::c_int = 61;
-pub const EHOSTDOWN: ::c_int = 64;
-pub const EHOSTUNREACH: ::c_int = 65;
-pub const EALREADY: ::c_int = 37;
-pub const EINPROGRESS: ::c_int = 36;
-pub const ESTALE: ::c_int = 70;
-pub const EDQUOT: ::c_int = 69;
-pub const ENOMEDIUM: ::c_int = 125;
-pub const EMEDIUMTYPE: ::c_int = 126;
-pub const ECANCELED: ::c_int = 127;
-pub const ENOKEY: ::c_int = 128;
-pub const EKEYEXPIRED: ::c_int = 129;
-pub const EKEYREVOKED: ::c_int = 130;
-pub const EKEYREJECTED: ::c_int = 131;
-pub const EOWNERDEAD: ::c_int = 132;
-pub const ENOTRECOVERABLE: ::c_int = 133;
-pub const EHWPOISON: ::c_int = 135;
-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;
-pub const SO_MARK: ::c_int = 0x0022;
-pub const SO_RXQ_OVFL: ::c_int = 0x0024;
-pub const SO_PEEK_OFF: ::c_int = 0x0026;
-pub const SO_BUSY_POLL: ::c_int = 0x0030;
-pub const SO_TYPE: ::c_int = 0x1008;
-pub const SO_ERROR: ::c_int = 0x1007;
-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;
-pub const SO_LINGER: ::c_int = 128;
-pub const SO_REUSEPORT: ::c_int = 0x200;
-pub const SO_ACCEPTCONN: ::c_int = 0x8000;
-
-pub const SA_ONSTACK: ::c_int = 1;
-pub const SA_SIGINFO: ::c_int = 0x200;
-pub const SA_NOCLDWAIT: ::c_int = 0x100;
-
-pub const SIGCHLD: ::c_int = 20;
-pub const SIGBUS: ::c_int = 10;
-pub const SIGUSR1: ::c_int = 30;
-pub const SIGUSR2: ::c_int = 31;
-pub const SIGCONT: ::c_int = 19;
-pub const SIGSTOP: ::c_int = 17;
-pub const SIGTSTP: ::c_int = 18;
-pub const SIGURG: ::c_int = 16;
-pub const SIGIO: ::c_int = 23;
-pub const SIGSYS: ::c_int = 12;
-pub const SIGPOLL: ::c_int = 23;
-pub const SIGPWR: ::c_int = 29;
-pub const SIG_SETMASK: ::c_int = 4;
-pub const SIG_BLOCK: ::c_int = 1;
-pub const SIG_UNBLOCK: ::c_int = 2;
-
-pub const POLLWRNORM: ::c_short = 4;
-pub const POLLWRBAND: ::c_short = 0x100;
-
-pub const O_ASYNC: ::c_int = 0x40;
-pub const O_NDELAY: ::c_int = 0x4004;
-
-pub const PTRACE_DETACH: ::c_uint = 11;
-
-pub const EFD_NONBLOCK: ::c_int = 0x4000;
-
-pub const F_GETLK: ::c_int = 7;
-pub const F_GETOWN: ::c_int = 5;
-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;
-pub const TIOCNXCL: ::c_ulong = 0x2000740e;
-pub const TIOCSCTTY: ::c_ulong = 0x20007484;
-pub const TIOCSTI: ::c_ulong = 0x80017472;
-pub const TIOCMGET: ::c_ulong = 0x4004746a;
-pub const TIOCMBIS: ::c_ulong = 0x8004746c;
-pub const TIOCMBIC: ::c_ulong = 0x8004746b;
-pub const TIOCMSET: ::c_ulong = 0x8004746d;
-pub const TIOCCONS: ::c_ulong = 0x20007424;
-
-pub const SFD_CLOEXEC: ::c_int = 0x400000;
-
-pub const NCCS: usize = 17;
-pub const O_TRUNC: ::c_int = 0x400;
-
-pub const O_CLOEXEC: ::c_int = 0x400000;
-
-pub const EBFONT: ::c_int = 109;
-pub const ENOSTR: ::c_int = 72;
-pub const ENODATA: ::c_int = 111;
-pub const ETIME: ::c_int = 73;
-pub const ENOSR: ::c_int = 74;
-pub const ENONET: ::c_int = 80;
-pub const ENOPKG: ::c_int = 113;
-pub const EREMOTE: ::c_int = 71;
-pub const ENOLINK: ::c_int = 82;
-pub const EADV: ::c_int = 83;
-pub const ESRMNT: ::c_int = 84;
-pub const ECOMM: ::c_int = 85;
-pub const EPROTO: ::c_int = 86;
-pub const EDOTDOT: ::c_int = 88;
-
-pub const SA_NODEFER: ::c_int = 0x20;
-pub const SA_RESETHAND: ::c_int = 0x4;
-pub const SA_RESTART: ::c_int = 0x2;
-pub const SA_NOCLDSTOP: ::c_int = 0x00000008;
-
-pub const EPOLL_CLOEXEC: ::c_int = 0x400000;
-
-pub const EFD_CLOEXEC: ::c_int = 0x400000;
-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;
-
-pub const MAP_LOCKED: ::c_int = 0x0100;
-pub const MAP_NORESERVE: ::c_int = 0x00040;
-
-pub const EDEADLOCK: ::c_int = 108;
-
-pub const SO_PEERCRED: ::c_int = 0x40;
-pub const SO_RCVLOWAT: ::c_int = 0x800;
-pub const SO_SNDLOWAT: ::c_int = 0x1000;
-pub const SO_RCVTIMEO: ::c_int = 0x2000;
-pub const SO_SNDTIMEO: ::c_int = 0x4000;
-
-pub const FIOCLEX: ::c_ulong = 0x20006601;
-pub const FIONBIO: ::c_ulong = 0x8004667e;
-
-pub const MCL_CURRENT: ::c_int = 0x2000;
-pub const MCL_FUTURE: ::c_int = 0x4000;
-
-pub const SIGSTKSZ: ::size_t = 16384;
-pub const MINSIGSTKSZ: ::size_t = 4096;
-pub const CBAUD: ::tcflag_t = 0x0000100f;
-pub const TAB1: ::tcflag_t = 0x800;
-pub const TAB2: ::tcflag_t = 0x1000;
-pub const TAB3: ::tcflag_t = 0x1800;
-pub const CR1: ::tcflag_t = 0x200;
-pub const CR2: ::tcflag_t = 0x400;
-pub const CR3: ::tcflag_t = 0x600;
-pub const FF1: ::tcflag_t = 0x8000;
-pub const BS1: ::tcflag_t = 0x2000;
-pub const VT1: ::tcflag_t = 0x4000;
-pub const VWERASE: usize = 0xe;
-pub const VREPRINT: usize = 0xc;
-pub const VSUSP: usize = 0xa;
-pub const VSTART: usize = 0x8;
-pub const VSTOP: usize = 0x9;
-pub const VDISCARD: usize = 0xd;
-pub const VTIME: usize = 0x5;
-pub const IXON: ::tcflag_t = 0x400;
-pub const IXOFF: ::tcflag_t = 0x1000;
-pub const ONLCR: ::tcflag_t = 0x4;
-pub const CSIZE: ::tcflag_t = 0x30;
-pub const CS6: ::tcflag_t = 0x10;
-pub const CS7: ::tcflag_t = 0x20;
-pub const CS8: ::tcflag_t = 0x30;
-pub const CSTOPB: ::tcflag_t = 0x40;
-pub const CREAD: ::tcflag_t = 0x80;
-pub const PARENB: ::tcflag_t = 0x100;
-pub const PARODD: ::tcflag_t = 0x200;
-pub const HUPCL: ::tcflag_t = 0x400;
-pub const CLOCAL: ::tcflag_t = 0x800;
-pub const ECHOKE: ::tcflag_t = 0x800;
-pub const ECHOE: ::tcflag_t = 0x10;
-pub const ECHOK: ::tcflag_t = 0x20;
-pub const ECHONL: ::tcflag_t = 0x40;
-pub const ECHOPRT: ::tcflag_t = 0x400;
-pub const ECHOCTL: ::tcflag_t = 0x200;
-pub const ISIG: ::tcflag_t = 0x1;
-pub const ICANON: ::tcflag_t = 0x2;
-pub const PENDIN: ::tcflag_t = 0x4000;
-pub const NOFLSH: ::tcflag_t = 0x80;
-pub const CIBAUD: ::tcflag_t = 0o02003600000;
-pub const CBAUDEX: ::tcflag_t = 0x00001000;
-pub const VSWTC: usize = 7;
-pub const OLCUC: ::tcflag_t = 0o000002;
-pub const NLDLY: ::tcflag_t = 0o000400;
-pub const CRDLY: ::tcflag_t = 0o003000;
-pub const TABDLY: ::tcflag_t = 0o014000;
-pub const BSDLY: ::tcflag_t = 0o020000;
-pub const FFDLY: ::tcflag_t = 0o100000;
-pub const VTDLY: ::tcflag_t = 0o040000;
-pub const XTABS: ::tcflag_t = 0o014000;
-
-pub const B0: ::speed_t = 0o000000;
-pub const B50: ::speed_t = 0o000001;
-pub const B75: ::speed_t = 0o000002;
-pub const B110: ::speed_t = 0o000003;
-pub const B134: ::speed_t = 0o000004;
-pub const B150: ::speed_t = 0o000005;
-pub const B200: ::speed_t = 0o000006;
-pub const B300: ::speed_t = 0o000007;
-pub const B600: ::speed_t = 0o000010;
-pub const B1200: ::speed_t = 0o000011;
-pub const B1800: ::speed_t = 0o000012;
-pub const B2400: ::speed_t = 0o000013;
-pub const B4800: ::speed_t = 0o000014;
-pub const B9600: ::speed_t = 0o000015;
-pub const B19200: ::speed_t = 0o000016;
-pub const B38400: ::speed_t = 0o000017;
-pub const EXTA: ::speed_t = B19200;
-pub const EXTB: ::speed_t = B38400;
-pub const 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;
-pub const IEXTEN: ::tcflag_t = 0x8000;
-pub const TOSTOP: ::tcflag_t = 0x100;
-pub const FLUSHO: ::tcflag_t = 0x1000;
-pub const EXTPROC: ::tcflag_t = 0x10000;
-pub const TCGETS: ::c_ulong = 0x40245408;
-pub const TCSETS: ::c_ulong = 0x80245409;
-pub const TCSETSW: ::c_ulong = 0x8024540a;
-pub const TCSETSF: ::c_ulong = 0x8024540b;
-pub const TCGETA: ::c_ulong = 0x40125401;
-pub const TCSETA: ::c_ulong = 0x80125402;
-pub const TCSETAW: ::c_ulong = 0x80125403;
-pub const TCSETAF: ::c_ulong = 0x80125404;
-pub const TCSBRK: ::c_ulong = 0x20005405;
-pub const TCXONC: ::c_ulong = 0x20005406;
-pub const TCFLSH: ::c_ulong = 0x20005407;
-pub const TIOCINQ: ::c_ulong = 0x4004667f;
-pub const TIOCGPGRP: ::c_ulong = 0x40047483;
-pub const TIOCSPGRP: ::c_ulong = 0x80047482;
-pub const TIOCOUTQ: ::c_ulong = 0x40047473;
-pub const TIOCGWINSZ: ::c_ulong = 0x40087468;
-pub const TIOCSWINSZ: ::c_ulong = 0x80087467;
-pub const FIONREAD: ::c_ulong = 0x4004667f;
-
-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_wait4: ::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_execv: ::c_long = 11;
-pub const SYS_chdir: ::c_long = 12;
-pub const SYS_chown: ::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_brk: ::c_long = 17;
-pub const SYS_perfctr: ::c_long = 18;
-pub const SYS_lseek: ::c_long = 19;
-pub const SYS_getpid: ::c_long = 20;
-pub const SYS_capget: ::c_long = 21;
-pub const SYS_capset: ::c_long = 22;
-pub const SYS_setuid: ::c_long = 23;
-pub const SYS_getuid: ::c_long = 24;
-pub const SYS_vmsplice: ::c_long = 25;
-pub const SYS_ptrace: ::c_long = 26;
-pub const SYS_alarm: ::c_long = 27;
-pub const SYS_sigaltstack: ::c_long = 28;
-pub const SYS_pause: ::c_long = 29;
-pub const SYS_utime: ::c_long = 30;
-pub const SYS_access: ::c_long = 33;
-pub const SYS_nice: ::c_long = 34;
-pub const SYS_sync: ::c_long = 36;
-pub const SYS_kill: ::c_long = 37;
-pub const SYS_stat: ::c_long = 38;
-pub const SYS_sendfile: ::c_long = 39;
-pub const SYS_lstat: ::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_umount2: ::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_memory_ordering: ::c_long = 52;
-pub const SYS_ioctl: ::c_long = 54;
-pub const SYS_reboot: ::c_long = 55;
-pub const SYS_symlink: ::c_long = 57;
-pub const SYS_readlink: ::c_long = 58;
-pub const SYS_execve: ::c_long = 59;
-pub const SYS_umask: ::c_long = 60;
-pub const SYS_chroot: ::c_long = 61;
-pub const SYS_fstat: ::c_long = 62;
-pub const SYS_fstat64: ::c_long = 63;
-pub const SYS_getpagesize: ::c_long = 64;
-pub const SYS_msync: ::c_long = 65;
-pub const SYS_vfork: ::c_long = 66;
-pub const SYS_pread64: ::c_long = 67;
-pub const SYS_pwrite64: ::c_long = 68;
-pub const SYS_mmap: ::c_long = 71;
-pub const SYS_munmap: ::c_long = 73;
-pub const SYS_mprotect: ::c_long = 74;
-pub const SYS_madvise: ::c_long = 75;
-pub const SYS_vhangup: ::c_long = 76;
-pub const SYS_mincore: ::c_long = 78;
-pub const SYS_getgroups: ::c_long = 79;
-pub const SYS_setgroups: ::c_long = 80;
-pub const SYS_getpgrp: ::c_long = 81;
-pub const SYS_setitimer: ::c_long = 83;
-pub const SYS_swapon: ::c_long = 85;
-pub const SYS_getitimer: ::c_long = 86;
-pub const SYS_sethostname: ::c_long = 88;
-pub const SYS_dup2: ::c_long = 90;
-pub const SYS_fcntl: ::c_long = 92;
-pub const SYS_select: ::c_long = 93;
-pub const SYS_fsync: ::c_long = 95;
-pub const SYS_setpriority: ::c_long = 96;
-pub const SYS_socket: ::c_long = 97;
-pub const SYS_connect: ::c_long = 98;
-pub const SYS_accept: ::c_long = 99;
-pub const SYS_getpriority: ::c_long = 100;
-pub const SYS_rt_sigreturn: ::c_long = 101;
-pub const SYS_rt_sigaction: ::c_long = 102;
-pub const SYS_rt_sigprocmask: ::c_long = 103;
-pub const SYS_rt_sigpending: ::c_long = 104;
-pub const SYS_rt_sigtimedwait: ::c_long = 105;
-pub const SYS_rt_sigqueueinfo: ::c_long = 106;
-pub const SYS_rt_sigsuspend: ::c_long = 107;
-pub const SYS_setresuid: ::c_long = 108;
-pub const SYS_getresuid: ::c_long = 109;
-pub const SYS_setresgid: ::c_long = 110;
-pub const SYS_getresgid: ::c_long = 111;
-pub const SYS_recvmsg: ::c_long = 113;
-pub const SYS_sendmsg: ::c_long = 114;
-pub const SYS_gettimeofday: ::c_long = 116;
-pub const SYS_getrusage: ::c_long = 117;
-pub const SYS_getsockopt: ::c_long = 118;
-pub const SYS_getcwd: ::c_long = 119;
-pub const SYS_readv: ::c_long = 120;
-pub const SYS_writev: ::c_long = 121;
-pub const SYS_settimeofday: ::c_long = 122;
-pub const SYS_fchown: ::c_long = 123;
-pub const SYS_fchmod: ::c_long = 124;
-pub const SYS_recvfrom: ::c_long = 125;
-pub const SYS_setreuid: ::c_long = 126;
-pub const SYS_setregid: ::c_long = 127;
-pub const SYS_rename: ::c_long = 128;
-pub const SYS_truncate: ::c_long = 129;
-pub const SYS_ftruncate: ::c_long = 130;
-pub const SYS_flock: ::c_long = 131;
-pub const SYS_lstat64: ::c_long = 132;
-pub const SYS_sendto: ::c_long = 133;
-pub const SYS_shutdown: ::c_long = 134;
-pub const SYS_socketpair: ::c_long = 135;
-pub const SYS_mkdir: ::c_long = 136;
-pub const SYS_rmdir: ::c_long = 137;
-pub const SYS_utimes: ::c_long = 138;
-pub const SYS_stat64: ::c_long = 139;
-pub const SYS_sendfile64: ::c_long = 140;
-pub const SYS_getpeername: ::c_long = 141;
-pub const SYS_futex: ::c_long = 142;
-pub const SYS_gettid: ::c_long = 143;
-pub const SYS_getrlimit: ::c_long = 144;
-pub const SYS_setrlimit: ::c_long = 145;
-pub const SYS_pivot_root: ::c_long = 146;
-pub const SYS_prctl: ::c_long = 147;
-pub const SYS_pciconfig_read: ::c_long = 148;
-pub const SYS_pciconfig_write: ::c_long = 149;
-pub const SYS_getsockname: ::c_long = 150;
-pub const SYS_inotify_init: ::c_long = 151;
-pub const SYS_inotify_add_watch: ::c_long = 152;
-pub const SYS_poll: ::c_long = 153;
-pub const SYS_getdents64: ::c_long = 154;
-pub const SYS_inotify_rm_watch: ::c_long = 156;
-pub const SYS_statfs: ::c_long = 157;
-pub const SYS_fstatfs: ::c_long = 158;
-pub const SYS_umount: ::c_long = 159;
-pub const SYS_sched_set_affinity: ::c_long = 160;
-pub const SYS_sched_get_affinity: ::c_long = 161;
-pub const SYS_getdomainname: ::c_long = 162;
-pub const SYS_setdomainname: ::c_long = 163;
-pub const SYS_utrap_install: ::c_long = 164;
-pub const SYS_quotactl: ::c_long = 165;
-pub const SYS_set_tid_address: ::c_long = 166;
-pub const SYS_mount: ::c_long = 167;
-pub const SYS_ustat: ::c_long = 168;
-pub const SYS_setxattr: ::c_long = 169;
-pub const SYS_lsetxattr: ::c_long = 170;
-pub const SYS_fsetxattr: ::c_long = 171;
-pub const SYS_getxattr: ::c_long = 172;
-pub const SYS_lgetxattr: ::c_long = 173;
-pub const SYS_getdents: ::c_long = 174;
-pub const SYS_setsid: ::c_long = 175;
-pub const SYS_fchdir: ::c_long = 176;
-pub const SYS_fgetxattr: ::c_long = 177;
-pub const SYS_listxattr: ::c_long = 178;
-pub const SYS_llistxattr: ::c_long = 179;
-pub const SYS_flistxattr: ::c_long = 180;
-pub const SYS_removexattr: ::c_long = 181;
-pub const SYS_lremovexattr: ::c_long = 182;
-pub const SYS_sigpending: ::c_long = 183;
-pub const SYS_query_module: ::c_long = 184;
-pub const SYS_setpgid: ::c_long = 185;
-pub const SYS_fremovexattr: ::c_long = 186;
-pub const SYS_tkill: ::c_long = 187;
-pub const SYS_exit_group: ::c_long = 188;
-pub const SYS_uname: ::c_long = 189;
-pub const SYS_init_module: ::c_long = 190;
-pub const SYS_personality: ::c_long = 191;
-pub const SYS_remap_file_pages: ::c_long = 192;
-pub const SYS_epoll_create: ::c_long = 193;
-pub const SYS_epoll_ctl: ::c_long = 194;
-pub const SYS_epoll_wait: ::c_long = 195;
-pub const SYS_ioprio_set: ::c_long = 196;
-pub const SYS_getppid: ::c_long = 197;
-pub const SYS_sigaction: ::c_long = 198;
-pub const SYS_sgetmask: ::c_long = 199;
-pub const SYS_ssetmask: ::c_long = 200;
-pub const SYS_sigsuspend: ::c_long = 201;
-pub const SYS_oldlstat: ::c_long = 202;
-pub const SYS_uselib: ::c_long = 203;
-pub const SYS_readdir: ::c_long = 204;
-pub const SYS_readahead: ::c_long = 205;
-pub const SYS_socketcall: ::c_long = 206;
-pub const SYS_syslog: ::c_long = 207;
-pub const SYS_lookup_dcookie: ::c_long = 208;
-pub const SYS_fadvise64: ::c_long = 209;
-pub const SYS_fadvise64_64: ::c_long = 210;
-pub const SYS_tgkill: ::c_long = 211;
-pub const SYS_waitpid: ::c_long = 212;
-pub const SYS_swapoff: ::c_long = 213;
-pub const SYS_sysinfo: ::c_long = 214;
-pub const SYS_ipc: ::c_long = 215;
-pub const SYS_sigreturn: ::c_long = 216;
-pub const SYS_clone: ::c_long = 217;
-pub const SYS_ioprio_get: ::c_long = 218;
-pub const SYS_adjtimex: ::c_long = 219;
-pub const SYS_sigprocmask: ::c_long = 220;
-pub const SYS_create_module: ::c_long = 221;
-pub const SYS_delete_module: ::c_long = 222;
-pub const SYS_get_kernel_syms: ::c_long = 223;
-pub const SYS_getpgid: ::c_long = 224;
-pub const SYS_bdflush: ::c_long = 225;
-pub const SYS_sysfs: ::c_long = 226;
-pub const SYS_afs_syscall: ::c_long = 227;
-pub const SYS_setfsuid: ::c_long = 228;
-pub const SYS_setfsgid: ::c_long = 229;
-pub const SYS__newselect: ::c_long = 230;
-pub const SYS_splice: ::c_long = 232;
-pub const SYS_stime: ::c_long = 233;
-pub const SYS_statfs64: ::c_long = 234;
-pub const SYS_fstatfs64: ::c_long = 235;
-pub const SYS__llseek: ::c_long = 236;
-pub const SYS_mlock: ::c_long = 237;
-pub const SYS_munlock: ::c_long = 238;
-pub const SYS_mlockall: ::c_long = 239;
-pub const SYS_munlockall: ::c_long = 240;
-pub const SYS_sched_setparam: ::c_long = 241;
-pub const SYS_sched_getparam: ::c_long = 242;
-pub const SYS_sched_setscheduler: ::c_long =243;
-pub const SYS_sched_getscheduler: ::c_long =244;
-pub const SYS_sched_yield: ::c_long = 245;
-pub const SYS_sched_get_priority_max: ::c_long =246;
-pub const SYS_sched_get_priority_min: ::c_long =247;
-pub const SYS_sched_rr_get_interval: ::c_long = 248;
-pub const SYS_nanosleep: ::c_long = 249;
-pub const SYS_mremap: ::c_long = 250;
-pub const SYS__sysctl: ::c_long = 251;
-pub const SYS_getsid: ::c_long = 252;
-pub const SYS_fdatasync: ::c_long = 253;
-pub const SYS_nfsservctl: ::c_long = 254;
-pub const SYS_sync_file_range: ::c_long = 255;
-pub const SYS_clock_settime: ::c_long = 256;
-pub const SYS_clock_gettime: ::c_long = 257;
-pub const SYS_clock_getres: ::c_long = 258;
-pub const SYS_clock_nanosleep: ::c_long = 259;
-pub const SYS_sched_getaffinity: ::c_long = 260;
-pub const SYS_sched_setaffinity: ::c_long = 261;
-pub const SYS_timer_settime: ::c_long = 262;
-pub const SYS_timer_gettime: ::c_long = 263;
-pub const SYS_timer_getoverrun: ::c_long = 264;
-pub const SYS_timer_delete: ::c_long = 265;
-pub const SYS_timer_create: ::c_long = 266;
-pub const SYS_io_setup: ::c_long = 268;
-pub const SYS_io_destroy: ::c_long = 269;
-pub const SYS_io_submit: ::c_long = 270;
-pub const SYS_io_cancel: ::c_long = 271;
-pub const SYS_io_getevents: ::c_long = 272;
-pub const SYS_mq_open: ::c_long = 273;
-pub const SYS_mq_unlink: ::c_long = 274;
-pub const SYS_mq_timedsend: ::c_long = 275;
-pub const SYS_mq_timedreceive: ::c_long = 276;
-pub const SYS_mq_notify: ::c_long = 277;
-pub const SYS_mq_getsetattr: ::c_long = 278;
-pub const SYS_waitid: ::c_long = 279;
-pub const SYS_tee: ::c_long = 280;
-pub const SYS_add_key: ::c_long = 281;
-pub const SYS_request_key: ::c_long = 282;
-pub const SYS_keyctl: ::c_long = 283;
-pub const SYS_openat: ::c_long = 284;
-pub const SYS_mkdirat: ::c_long = 285;
-pub const SYS_mknodat: ::c_long = 286;
-pub const SYS_fchownat: ::c_long = 287;
-pub const SYS_futimesat: ::c_long = 288;
-pub const SYS_fstatat64: ::c_long = 289;
-pub const SYS_unlinkat: ::c_long = 290;
-pub const SYS_renameat: ::c_long = 291;
-pub const SYS_linkat: ::c_long = 292;
-pub const SYS_symlinkat: ::c_long = 293;
-pub const SYS_readlinkat: ::c_long = 294;
-pub const SYS_fchmodat: ::c_long = 295;
-pub const SYS_faccessat: ::c_long = 296;
-pub const SYS_pselect6: ::c_long = 297;
-pub const SYS_ppoll: ::c_long = 298;
-pub const SYS_unshare: ::c_long = 299;
-pub const SYS_set_robust_list: ::c_long = 300;
-pub const SYS_get_robust_list: ::c_long = 301;
-pub const SYS_migrate_pages: ::c_long =302;
-pub const SYS_mbind: ::c_long = 303;
-pub const SYS_get_mempolicy: ::c_long = 304;
-pub const SYS_set_mempolicy: ::c_long = 305;
-pub const SYS_kexec_load: ::c_long = 306;
-pub const SYS_move_pages: ::c_long = 307;
-pub const SYS_getcpu: ::c_long = 308;
-pub const SYS_epoll_pwait: ::c_long = 309;
-pub const SYS_utimensat: ::c_long = 310;
-pub const SYS_signalfd: ::c_long = 311;
-pub const SYS_timerfd_create: ::c_long = 312;
-pub const SYS_eventfd: ::c_long = 313;
-pub const SYS_fallocate: ::c_long = 314;
-pub const SYS_timerfd_settime: ::c_long = 315;
-pub const SYS_timerfd_gettime: ::c_long = 316;
-pub const SYS_signalfd4: ::c_long = 317;
-pub const SYS_eventfd2: ::c_long = 318;
-pub const SYS_epoll_create1: ::c_long = 319;
-pub const SYS_dup3: ::c_long = 320;
-pub const SYS_pipe2: ::c_long = 321;
-pub const SYS_inotify_init1: ::c_long = 322;
-pub const SYS_accept4: ::c_long = 323;
-pub const SYS_preadv: ::c_long = 324;
-pub const SYS_pwritev: ::c_long = 325;
-pub const SYS_rt_tgsigqueueinfo: ::c_long = 326;
-pub const SYS_perf_event_open: ::c_long = 327;
-pub const SYS_recvmmsg: ::c_long = 328;
-pub const SYS_fanotify_init: ::c_long = 329;
-pub const SYS_fanotify_mark: ::c_long = 330;
-pub const SYS_prlimit64: ::c_long = 331;
-pub const SYS_name_to_handle_at: ::c_long = 332;
-pub const SYS_open_by_handle_at: ::c_long = 333;
-pub const SYS_clock_adjtime: ::c_long = 334;
-pub const SYS_syncfs: ::c_long = 335;
-pub const SYS_sendmmsg: ::c_long = 336;
-pub const SYS_setns: ::c_long = 337;
-pub const SYS_process_vm_readv: ::c_long = 338;
-pub const SYS_process_vm_writev: ::c_long = 339;
-pub const SYS_kern_features: ::c_long = 340;
-pub const SYS_kcmp: ::c_long = 341;
-pub const SYS_finit_module: ::c_long = 342;
-pub const SYS_sched_setattr: ::c_long = 343;
-pub const SYS_sched_getattr: ::c_long = 344;
-pub const SYS_renameat2: ::c_long = 345;
-pub const SYS_seccomp: ::c_long = 346;
-pub const SYS_getrandom: ::c_long = 347;
-pub const SYS_memfd_create: ::c_long = 348;
-pub const SYS_bpf: ::c_long = 349;
-pub const SYS_execveat: ::c_long = 350;
-pub const SYS_membarrier: ::c_long = 351;
-pub const SYS_userfaultfd: ::c_long = 352;
-pub const SYS_bind: ::c_long = 353;
-pub const SYS_listen: ::c_long = 354;
-pub const SYS_setsockopt: ::c_long = 355;
-pub const SYS_mlock2: ::c_long = 356;
-pub const SYS_copy_file_range: ::c_long = 357;
-pub const SYS_preadv2: ::c_long = 358;
-pub const SYS_pwritev2: ::c_long = 359;
-pub const SYS_statx: ::c_long = 360;
-
-#[link(name = "util")]
-extern {
- pub fn sysctl(name: *mut ::c_int,
- namelen: ::c_int,
- oldp: *mut ::c_void,
- oldlenp: *mut ::size_t,
- newp: *mut ::c_void,
- newlen: ::size_t)
- -> ::c_int;
-}
diff --git a/libc/src/unix/notbsd/linux/other/b64/x32.rs b/libc/src/unix/notbsd/linux/other/b64/x32.rs
deleted file mode 100644
index 3746881..0000000
--- a/libc/src/unix/notbsd/linux/other/b64/x32.rs
+++ /dev/null
@@ -1,375 +0,0 @@
-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;
-
-pub const SYS_read: ::c_long = __X32_SYSCALL_BIT + 0;
-pub const SYS_write: ::c_long = __X32_SYSCALL_BIT + 1;
-pub const SYS_open: ::c_long = __X32_SYSCALL_BIT + 2;
-pub const SYS_close: ::c_long = __X32_SYSCALL_BIT + 3;
-pub const SYS_stat: ::c_long = __X32_SYSCALL_BIT + 4;
-pub const SYS_fstat: ::c_long = __X32_SYSCALL_BIT + 5;
-pub const SYS_lstat: ::c_long = __X32_SYSCALL_BIT + 6;
-pub const SYS_poll: ::c_long = __X32_SYSCALL_BIT + 7;
-pub const SYS_lseek: ::c_long = __X32_SYSCALL_BIT + 8;
-pub const SYS_mmap: ::c_long = __X32_SYSCALL_BIT + 9;
-pub const SYS_mprotect: ::c_long = __X32_SYSCALL_BIT + 10;
-pub const SYS_munmap: ::c_long = __X32_SYSCALL_BIT + 11;
-pub const SYS_brk: ::c_long = __X32_SYSCALL_BIT + 12;
-pub const SYS_rt_sigprocmask: ::c_long = __X32_SYSCALL_BIT + 14;
-pub const SYS_pread64: ::c_long = __X32_SYSCALL_BIT + 17;
-pub const SYS_pwrite64: ::c_long = __X32_SYSCALL_BIT + 18;
-pub const SYS_access: ::c_long = __X32_SYSCALL_BIT + 21;
-pub const SYS_pipe: ::c_long = __X32_SYSCALL_BIT + 22;
-pub const SYS_select: ::c_long = __X32_SYSCALL_BIT + 23;
-pub const SYS_sched_yield: ::c_long = __X32_SYSCALL_BIT + 24;
-pub const SYS_mremap: ::c_long = __X32_SYSCALL_BIT + 25;
-pub const SYS_msync: ::c_long = __X32_SYSCALL_BIT + 26;
-pub const SYS_mincore: ::c_long = __X32_SYSCALL_BIT + 27;
-pub const SYS_madvise: ::c_long = __X32_SYSCALL_BIT + 28;
-pub const SYS_shmget: ::c_long = __X32_SYSCALL_BIT + 29;
-pub const SYS_shmat: ::c_long = __X32_SYSCALL_BIT + 30;
-pub const SYS_shmctl: ::c_long = __X32_SYSCALL_BIT + 31;
-pub const SYS_dup: ::c_long = __X32_SYSCALL_BIT + 32;
-pub const SYS_dup2: ::c_long = __X32_SYSCALL_BIT + 33;
-pub const SYS_pause: ::c_long = __X32_SYSCALL_BIT + 34;
-pub const SYS_nanosleep: ::c_long = __X32_SYSCALL_BIT + 35;
-pub const SYS_getitimer: ::c_long = __X32_SYSCALL_BIT + 36;
-pub const SYS_alarm: ::c_long = __X32_SYSCALL_BIT + 37;
-pub const SYS_setitimer: ::c_long = __X32_SYSCALL_BIT + 38;
-pub const SYS_getpid: ::c_long = __X32_SYSCALL_BIT + 39;
-pub const SYS_sendfile: ::c_long = __X32_SYSCALL_BIT + 40;
-pub const SYS_socket: ::c_long = __X32_SYSCALL_BIT + 41;
-pub const SYS_connect: ::c_long = __X32_SYSCALL_BIT + 42;
-pub const SYS_accept: ::c_long = __X32_SYSCALL_BIT + 43;
-pub const SYS_sendto: ::c_long = __X32_SYSCALL_BIT + 44;
-pub const SYS_shutdown: ::c_long = __X32_SYSCALL_BIT + 48;
-pub const SYS_bind: ::c_long = __X32_SYSCALL_BIT + 49;
-pub const SYS_listen: ::c_long = __X32_SYSCALL_BIT + 50;
-pub const SYS_getsockname: ::c_long = __X32_SYSCALL_BIT + 51;
-pub const SYS_getpeername: ::c_long = __X32_SYSCALL_BIT + 52;
-pub const SYS_socketpair: ::c_long = __X32_SYSCALL_BIT + 53;
-pub const SYS_clone: ::c_long = __X32_SYSCALL_BIT + 56;
-pub const SYS_fork: ::c_long = __X32_SYSCALL_BIT + 57;
-pub const SYS_vfork: ::c_long = __X32_SYSCALL_BIT + 58;
-pub const SYS_exit: ::c_long = __X32_SYSCALL_BIT + 60;
-pub const SYS_wait4: ::c_long = __X32_SYSCALL_BIT + 61;
-pub const SYS_kill: ::c_long = __X32_SYSCALL_BIT + 62;
-pub const SYS_uname: ::c_long = __X32_SYSCALL_BIT + 63;
-pub const SYS_semget: ::c_long = __X32_SYSCALL_BIT + 64;
-pub const SYS_semop: ::c_long = __X32_SYSCALL_BIT + 65;
-pub const SYS_semctl: ::c_long = __X32_SYSCALL_BIT + 66;
-pub const SYS_shmdt: ::c_long = __X32_SYSCALL_BIT + 67;
-pub const SYS_msgget: ::c_long = __X32_SYSCALL_BIT + 68;
-pub const SYS_msgsnd: ::c_long = __X32_SYSCALL_BIT + 69;
-pub const SYS_msgrcv: ::c_long = __X32_SYSCALL_BIT + 70;
-pub const SYS_msgctl: ::c_long = __X32_SYSCALL_BIT + 71;
-pub const SYS_fcntl: ::c_long = __X32_SYSCALL_BIT + 72;
-pub const SYS_flock: ::c_long = __X32_SYSCALL_BIT + 73;
-pub const SYS_fsync: ::c_long = __X32_SYSCALL_BIT + 74;
-pub const SYS_fdatasync: ::c_long = __X32_SYSCALL_BIT + 75;
-pub const SYS_truncate: ::c_long = __X32_SYSCALL_BIT + 76;
-pub const SYS_ftruncate: ::c_long = __X32_SYSCALL_BIT + 77;
-pub const SYS_getdents: ::c_long = __X32_SYSCALL_BIT + 78;
-pub const SYS_getcwd: ::c_long = __X32_SYSCALL_BIT + 79;
-pub const SYS_chdir: ::c_long = __X32_SYSCALL_BIT + 80;
-pub const SYS_fchdir: ::c_long = __X32_SYSCALL_BIT + 81;
-pub const SYS_rename: ::c_long = __X32_SYSCALL_BIT + 82;
-pub const SYS_mkdir: ::c_long = __X32_SYSCALL_BIT + 83;
-pub const SYS_rmdir: ::c_long = __X32_SYSCALL_BIT + 84;
-pub const SYS_creat: ::c_long = __X32_SYSCALL_BIT + 85;
-pub const SYS_link: ::c_long = __X32_SYSCALL_BIT + 86;
-pub const SYS_unlink: ::c_long = __X32_SYSCALL_BIT + 87;
-pub const SYS_symlink: ::c_long = __X32_SYSCALL_BIT + 88;
-pub const SYS_readlink: ::c_long = __X32_SYSCALL_BIT + 89;
-pub const SYS_chmod: ::c_long = __X32_SYSCALL_BIT + 90;
-pub const SYS_fchmod: ::c_long = __X32_SYSCALL_BIT + 91;
-pub const SYS_chown: ::c_long = __X32_SYSCALL_BIT + 92;
-pub const SYS_fchown: ::c_long = __X32_SYSCALL_BIT + 93;
-pub const SYS_lchown: ::c_long = __X32_SYSCALL_BIT + 94;
-pub const SYS_umask: ::c_long = __X32_SYSCALL_BIT + 95;
-pub const SYS_gettimeofday: ::c_long = __X32_SYSCALL_BIT + 96;
-pub const SYS_getrlimit: ::c_long = __X32_SYSCALL_BIT + 97;
-pub const SYS_getrusage: ::c_long = __X32_SYSCALL_BIT + 98;
-pub const SYS_sysinfo: ::c_long = __X32_SYSCALL_BIT + 99;
-pub const SYS_times: ::c_long = __X32_SYSCALL_BIT + 100;
-pub const SYS_getuid: ::c_long = __X32_SYSCALL_BIT + 102;
-pub const SYS_syslog: ::c_long = __X32_SYSCALL_BIT + 103;
-pub const SYS_getgid: ::c_long = __X32_SYSCALL_BIT + 104;
-pub const SYS_setuid: ::c_long = __X32_SYSCALL_BIT + 105;
-pub const SYS_setgid: ::c_long = __X32_SYSCALL_BIT + 106;
-pub const SYS_geteuid: ::c_long = __X32_SYSCALL_BIT + 107;
-pub const SYS_getegid: ::c_long = __X32_SYSCALL_BIT + 108;
-pub const SYS_setpgid: ::c_long = __X32_SYSCALL_BIT + 109;
-pub const SYS_getppid: ::c_long = __X32_SYSCALL_BIT + 110;
-pub const SYS_getpgrp: ::c_long = __X32_SYSCALL_BIT + 111;
-pub const SYS_setsid: ::c_long = __X32_SYSCALL_BIT + 112;
-pub const SYS_setreuid: ::c_long = __X32_SYSCALL_BIT + 113;
-pub const SYS_setregid: ::c_long = __X32_SYSCALL_BIT + 114;
-pub const SYS_getgroups: ::c_long = __X32_SYSCALL_BIT + 115;
-pub const SYS_setgroups: ::c_long = __X32_SYSCALL_BIT + 116;
-pub const SYS_setresuid: ::c_long = __X32_SYSCALL_BIT + 117;
-pub const SYS_getresuid: ::c_long = __X32_SYSCALL_BIT + 118;
-pub const SYS_setresgid: ::c_long = __X32_SYSCALL_BIT + 119;
-pub const SYS_getresgid: ::c_long = __X32_SYSCALL_BIT + 120;
-pub const SYS_getpgid: ::c_long = __X32_SYSCALL_BIT + 121;
-pub const SYS_setfsuid: ::c_long = __X32_SYSCALL_BIT + 122;
-pub const SYS_setfsgid: ::c_long = __X32_SYSCALL_BIT + 123;
-pub const SYS_getsid: ::c_long = __X32_SYSCALL_BIT + 124;
-pub const SYS_capget: ::c_long = __X32_SYSCALL_BIT + 125;
-pub const SYS_capset: ::c_long = __X32_SYSCALL_BIT + 126;
-pub const SYS_rt_sigsuspend: ::c_long = __X32_SYSCALL_BIT + 130;
-pub const SYS_utime: ::c_long = __X32_SYSCALL_BIT + 132;
-pub const SYS_mknod: ::c_long = __X32_SYSCALL_BIT + 133;
-pub const SYS_personality: ::c_long = __X32_SYSCALL_BIT + 135;
-pub const SYS_ustat: ::c_long = __X32_SYSCALL_BIT + 136;
-pub const SYS_statfs: ::c_long = __X32_SYSCALL_BIT + 137;
-pub const SYS_fstatfs: ::c_long = __X32_SYSCALL_BIT + 138;
-pub const SYS_sysfs: ::c_long = __X32_SYSCALL_BIT + 139;
-pub const SYS_getpriority: ::c_long = __X32_SYSCALL_BIT + 140;
-pub const SYS_setpriority: ::c_long = __X32_SYSCALL_BIT + 141;
-pub const SYS_sched_setparam: ::c_long = __X32_SYSCALL_BIT + 142;
-pub const SYS_sched_getparam: ::c_long = __X32_SYSCALL_BIT + 143;
-pub const SYS_sched_setscheduler: ::c_long = __X32_SYSCALL_BIT + 144;
-pub const SYS_sched_getscheduler: ::c_long = __X32_SYSCALL_BIT + 145;
-pub const SYS_sched_get_priority_max: ::c_long = __X32_SYSCALL_BIT + 146;
-pub const SYS_sched_get_priority_min: ::c_long = __X32_SYSCALL_BIT + 147;
-pub const SYS_sched_rr_get_interval: ::c_long = __X32_SYSCALL_BIT + 148;
-pub const SYS_mlock: ::c_long = __X32_SYSCALL_BIT + 149;
-pub const SYS_munlock: ::c_long = __X32_SYSCALL_BIT + 150;
-pub const SYS_mlockall: ::c_long = __X32_SYSCALL_BIT + 151;
-pub const SYS_munlockall: ::c_long = __X32_SYSCALL_BIT + 152;
-pub const SYS_vhangup: ::c_long = __X32_SYSCALL_BIT + 153;
-pub const SYS_modify_ldt: ::c_long = __X32_SYSCALL_BIT + 154;
-pub const SYS_pivot_root: ::c_long = __X32_SYSCALL_BIT + 155;
-pub const SYS_prctl: ::c_long = __X32_SYSCALL_BIT + 157;
-pub const SYS_arch_prctl: ::c_long = __X32_SYSCALL_BIT + 158;
-pub const SYS_adjtimex: ::c_long = __X32_SYSCALL_BIT + 159;
-pub const SYS_setrlimit: ::c_long = __X32_SYSCALL_BIT + 160;
-pub const SYS_chroot: ::c_long = __X32_SYSCALL_BIT + 161;
-pub const SYS_sync: ::c_long = __X32_SYSCALL_BIT + 162;
-pub const SYS_acct: ::c_long = __X32_SYSCALL_BIT + 163;
-pub const SYS_settimeofday: ::c_long = __X32_SYSCALL_BIT + 164;
-pub const SYS_mount: ::c_long = __X32_SYSCALL_BIT + 165;
-pub const SYS_umount2: ::c_long = __X32_SYSCALL_BIT + 166;
-pub const SYS_swapon: ::c_long = __X32_SYSCALL_BIT + 167;
-pub const SYS_swapoff: ::c_long = __X32_SYSCALL_BIT + 168;
-pub const SYS_reboot: ::c_long = __X32_SYSCALL_BIT + 169;
-pub const SYS_sethostname: ::c_long = __X32_SYSCALL_BIT + 170;
-pub const SYS_setdomainname: ::c_long = __X32_SYSCALL_BIT + 171;
-pub const SYS_iopl: ::c_long = __X32_SYSCALL_BIT + 172;
-pub const SYS_ioperm: ::c_long = __X32_SYSCALL_BIT + 173;
-pub const SYS_init_module: ::c_long = __X32_SYSCALL_BIT + 175;
-pub const SYS_delete_module: ::c_long = __X32_SYSCALL_BIT + 176;
-pub const SYS_quotactl: ::c_long = __X32_SYSCALL_BIT + 179;
-pub const SYS_getpmsg: ::c_long = __X32_SYSCALL_BIT + 181;
-pub const SYS_putpmsg: ::c_long = __X32_SYSCALL_BIT + 182;
-pub const SYS_afs_syscall: ::c_long = __X32_SYSCALL_BIT + 183;
-pub const SYS_tuxcall: ::c_long = __X32_SYSCALL_BIT + 184;
-pub const SYS_security: ::c_long = __X32_SYSCALL_BIT + 185;
-pub const SYS_gettid: ::c_long = __X32_SYSCALL_BIT + 186;
-pub const SYS_readahead: ::c_long = __X32_SYSCALL_BIT + 187;
-pub const SYS_setxattr: ::c_long = __X32_SYSCALL_BIT + 188;
-pub const SYS_lsetxattr: ::c_long = __X32_SYSCALL_BIT + 189;
-pub const SYS_fsetxattr: ::c_long = __X32_SYSCALL_BIT + 190;
-pub const SYS_getxattr: ::c_long = __X32_SYSCALL_BIT + 191;
-pub const SYS_lgetxattr: ::c_long = __X32_SYSCALL_BIT + 192;
-pub const SYS_fgetxattr: ::c_long = __X32_SYSCALL_BIT + 193;
-pub const SYS_listxattr: ::c_long = __X32_SYSCALL_BIT + 194;
-pub const SYS_llistxattr: ::c_long = __X32_SYSCALL_BIT + 195;
-pub const SYS_flistxattr: ::c_long = __X32_SYSCALL_BIT + 196;
-pub const SYS_removexattr: ::c_long = __X32_SYSCALL_BIT + 197;
-pub const SYS_lremovexattr: ::c_long = __X32_SYSCALL_BIT + 198;
-pub const SYS_fremovexattr: ::c_long = __X32_SYSCALL_BIT + 199;
-pub const SYS_tkill: ::c_long = __X32_SYSCALL_BIT + 200;
-pub const SYS_time: ::c_long = __X32_SYSCALL_BIT + 201;
-pub const SYS_futex: ::c_long = __X32_SYSCALL_BIT + 202;
-pub const SYS_sched_setaffinity: ::c_long = __X32_SYSCALL_BIT + 203;
-pub const SYS_sched_getaffinity: ::c_long = __X32_SYSCALL_BIT + 204;
-pub const SYS_io_destroy: ::c_long = __X32_SYSCALL_BIT + 207;
-pub const SYS_io_getevents: ::c_long = __X32_SYSCALL_BIT + 208;
-pub const SYS_io_cancel: ::c_long = __X32_SYSCALL_BIT + 210;
-pub const SYS_lookup_dcookie: ::c_long = __X32_SYSCALL_BIT + 212;
-pub const SYS_epoll_create: ::c_long = __X32_SYSCALL_BIT + 213;
-pub const SYS_remap_file_pages: ::c_long = __X32_SYSCALL_BIT + 216;
-pub const SYS_getdents64: ::c_long = __X32_SYSCALL_BIT + 217;
-pub const SYS_set_tid_address: ::c_long = __X32_SYSCALL_BIT + 218;
-pub const SYS_restart_syscall: ::c_long = __X32_SYSCALL_BIT + 219;
-pub const SYS_semtimedop: ::c_long = __X32_SYSCALL_BIT + 220;
-pub const SYS_fadvise64: ::c_long = __X32_SYSCALL_BIT + 221;
-pub const SYS_timer_settime: ::c_long = __X32_SYSCALL_BIT + 223;
-pub const SYS_timer_gettime: ::c_long = __X32_SYSCALL_BIT + 224;
-pub const SYS_timer_getoverrun: ::c_long = __X32_SYSCALL_BIT + 225;
-pub const SYS_timer_delete: ::c_long = __X32_SYSCALL_BIT + 226;
-pub const SYS_clock_settime: ::c_long = __X32_SYSCALL_BIT + 227;
-pub const SYS_clock_gettime: ::c_long = __X32_SYSCALL_BIT + 228;
-pub const SYS_clock_getres: ::c_long = __X32_SYSCALL_BIT + 229;
-pub const SYS_clock_nanosleep: ::c_long = __X32_SYSCALL_BIT + 230;
-pub const SYS_exit_group: ::c_long = __X32_SYSCALL_BIT + 231;
-pub const SYS_epoll_wait: ::c_long = __X32_SYSCALL_BIT + 232;
-pub const SYS_epoll_ctl: ::c_long = __X32_SYSCALL_BIT + 233;
-pub const SYS_tgkill: ::c_long = __X32_SYSCALL_BIT + 234;
-pub const SYS_utimes: ::c_long = __X32_SYSCALL_BIT + 235;
-pub const SYS_mbind: ::c_long = __X32_SYSCALL_BIT + 237;
-pub const SYS_set_mempolicy: ::c_long = __X32_SYSCALL_BIT + 238;
-pub const SYS_get_mempolicy: ::c_long = __X32_SYSCALL_BIT + 239;
-pub const SYS_mq_open: ::c_long = __X32_SYSCALL_BIT + 240;
-pub const SYS_mq_unlink: ::c_long = __X32_SYSCALL_BIT + 241;
-pub const SYS_mq_timedsend: ::c_long = __X32_SYSCALL_BIT + 242;
-pub const SYS_mq_timedreceive: ::c_long = __X32_SYSCALL_BIT + 243;
-pub const SYS_mq_getsetattr: ::c_long = __X32_SYSCALL_BIT + 245;
-pub const SYS_add_key: ::c_long = __X32_SYSCALL_BIT + 248;
-pub const SYS_request_key: ::c_long = __X32_SYSCALL_BIT + 249;
-pub const SYS_keyctl: ::c_long = __X32_SYSCALL_BIT + 250;
-pub const SYS_ioprio_set: ::c_long = __X32_SYSCALL_BIT + 251;
-pub const SYS_ioprio_get: ::c_long = __X32_SYSCALL_BIT + 252;
-pub const SYS_inotify_init: ::c_long = __X32_SYSCALL_BIT + 253;
-pub const SYS_inotify_add_watch: ::c_long = __X32_SYSCALL_BIT + 254;
-pub const SYS_inotify_rm_watch: ::c_long = __X32_SYSCALL_BIT + 255;
-pub const SYS_migrate_pages: ::c_long = __X32_SYSCALL_BIT + 256;
-pub const SYS_openat: ::c_long = __X32_SYSCALL_BIT + 257;
-pub const SYS_mkdirat: ::c_long = __X32_SYSCALL_BIT + 258;
-pub const SYS_mknodat: ::c_long = __X32_SYSCALL_BIT + 259;
-pub const SYS_fchownat: ::c_long = __X32_SYSCALL_BIT + 260;
-pub const SYS_futimesat: ::c_long = __X32_SYSCALL_BIT + 261;
-pub const SYS_newfstatat: ::c_long = __X32_SYSCALL_BIT + 262;
-pub const SYS_unlinkat: ::c_long = __X32_SYSCALL_BIT + 263;
-pub const SYS_renameat: ::c_long = __X32_SYSCALL_BIT + 264;
-pub const SYS_linkat: ::c_long = __X32_SYSCALL_BIT + 265;
-pub const SYS_symlinkat: ::c_long = __X32_SYSCALL_BIT + 266;
-pub const SYS_readlinkat: ::c_long = __X32_SYSCALL_BIT + 267;
-pub const SYS_fchmodat: ::c_long = __X32_SYSCALL_BIT + 268;
-pub const SYS_faccessat: ::c_long = __X32_SYSCALL_BIT + 269;
-pub const SYS_pselect6: ::c_long = __X32_SYSCALL_BIT + 270;
-pub const SYS_ppoll: ::c_long = __X32_SYSCALL_BIT + 271;
-pub const SYS_unshare: ::c_long = __X32_SYSCALL_BIT + 272;
-pub const SYS_splice: ::c_long = __X32_SYSCALL_BIT + 275;
-pub const SYS_tee: ::c_long = __X32_SYSCALL_BIT + 276;
-pub const SYS_sync_file_range: ::c_long = __X32_SYSCALL_BIT + 277;
-pub const SYS_utimensat: ::c_long = __X32_SYSCALL_BIT + 280;
-pub const SYS_epoll_pwait: ::c_long = __X32_SYSCALL_BIT + 281;
-pub const SYS_signalfd: ::c_long = __X32_SYSCALL_BIT + 282;
-pub const SYS_timerfd_create: ::c_long = __X32_SYSCALL_BIT + 283;
-pub const SYS_eventfd: ::c_long = __X32_SYSCALL_BIT + 284;
-pub const SYS_fallocate: ::c_long = __X32_SYSCALL_BIT + 285;
-pub const SYS_timerfd_settime: ::c_long = __X32_SYSCALL_BIT + 286;
-pub const SYS_timerfd_gettime: ::c_long = __X32_SYSCALL_BIT + 287;
-pub const SYS_accept4: ::c_long = __X32_SYSCALL_BIT + 288;
-pub const SYS_signalfd4: ::c_long = __X32_SYSCALL_BIT + 289;
-pub const SYS_eventfd2: ::c_long = __X32_SYSCALL_BIT + 290;
-pub const SYS_epoll_create1: ::c_long = __X32_SYSCALL_BIT + 291;
-pub const SYS_dup3: ::c_long = __X32_SYSCALL_BIT + 292;
-pub const SYS_pipe2: ::c_long = __X32_SYSCALL_BIT + 293;
-pub const SYS_inotify_init1: ::c_long = __X32_SYSCALL_BIT + 294;
-pub const SYS_perf_event_open: ::c_long = __X32_SYSCALL_BIT + 298;
-pub const SYS_fanotify_init: ::c_long = __X32_SYSCALL_BIT + 300;
-pub const SYS_fanotify_mark: ::c_long = __X32_SYSCALL_BIT + 301;
-pub const SYS_prlimit64: ::c_long = __X32_SYSCALL_BIT + 302;
-pub const SYS_name_to_handle_at: ::c_long = __X32_SYSCALL_BIT + 303;
-pub const SYS_open_by_handle_at: ::c_long = __X32_SYSCALL_BIT + 304;
-pub const SYS_clock_adjtime: ::c_long = __X32_SYSCALL_BIT + 305;
-pub const SYS_syncfs: ::c_long = __X32_SYSCALL_BIT + 306;
-pub const SYS_setns: ::c_long = __X32_SYSCALL_BIT + 308;
-pub const SYS_getcpu: ::c_long = __X32_SYSCALL_BIT + 309;
-pub const SYS_kcmp: ::c_long = __X32_SYSCALL_BIT + 312;
-pub const SYS_finit_module: ::c_long = __X32_SYSCALL_BIT + 313;
-pub const SYS_sched_setattr: ::c_long = __X32_SYSCALL_BIT + 314;
-pub const SYS_sched_getattr: ::c_long = __X32_SYSCALL_BIT + 315;
-pub const SYS_renameat2: ::c_long = __X32_SYSCALL_BIT + 316;
-pub const SYS_seccomp: ::c_long = __X32_SYSCALL_BIT + 317;
-pub const SYS_getrandom: ::c_long = __X32_SYSCALL_BIT + 318;
-pub const SYS_memfd_create: ::c_long = __X32_SYSCALL_BIT + 319;
-pub const SYS_kexec_file_load: ::c_long = __X32_SYSCALL_BIT + 320;
-pub const SYS_bpf: ::c_long = __X32_SYSCALL_BIT + 321;
-pub const SYS_userfaultfd: ::c_long = __X32_SYSCALL_BIT + 323;
-pub const SYS_membarrier: ::c_long = __X32_SYSCALL_BIT + 324;
-pub const SYS_mlock2: ::c_long = __X32_SYSCALL_BIT + 325;
-pub const SYS_copy_file_range: ::c_long = __X32_SYSCALL_BIT + 326;
-pub const SYS_pkey_mprotect: ::c_long = __X32_SYSCALL_BIT + 329;
-pub const SYS_pkey_alloc: ::c_long = __X32_SYSCALL_BIT + 330;
-pub const SYS_pkey_free: ::c_long = __X32_SYSCALL_BIT + 331;
-pub const SYS_statx: ::c_long = __X32_SYSCALL_BIT + 332;
-pub const SYS_rt_sigaction: ::c_long = __X32_SYSCALL_BIT + 512;
-pub const SYS_rt_sigreturn: ::c_long = __X32_SYSCALL_BIT + 513;
-pub const SYS_ioctl: ::c_long = __X32_SYSCALL_BIT + 514;
-pub const SYS_readv: ::c_long = __X32_SYSCALL_BIT + 515;
-pub const SYS_writev: ::c_long = __X32_SYSCALL_BIT + 516;
-pub const SYS_recvfrom: ::c_long = __X32_SYSCALL_BIT + 517;
-pub const SYS_sendmsg: ::c_long = __X32_SYSCALL_BIT + 518;
-pub const SYS_recvmsg: ::c_long = __X32_SYSCALL_BIT + 519;
-pub const SYS_execve: ::c_long = __X32_SYSCALL_BIT + 520;
-pub const SYS_ptrace: ::c_long = __X32_SYSCALL_BIT + 521;
-pub const SYS_rt_sigpending: ::c_long = __X32_SYSCALL_BIT + 522;
-pub const SYS_rt_sigtimedwait: ::c_long = __X32_SYSCALL_BIT + 523;
-pub const SYS_rt_sigqueueinfo: ::c_long = __X32_SYSCALL_BIT + 524;
-pub const SYS_sigaltstack: ::c_long = __X32_SYSCALL_BIT + 525;
-pub const SYS_timer_create: ::c_long = __X32_SYSCALL_BIT + 526;
-pub const SYS_mq_notify: ::c_long = __X32_SYSCALL_BIT + 527;
-pub const SYS_kexec_load: ::c_long = __X32_SYSCALL_BIT + 528;
-pub const SYS_waitid: ::c_long = __X32_SYSCALL_BIT + 529;
-pub const SYS_set_robust_list: ::c_long = __X32_SYSCALL_BIT + 530;
-pub const SYS_get_robust_list: ::c_long = __X32_SYSCALL_BIT + 531;
-pub const SYS_vmsplice: ::c_long = __X32_SYSCALL_BIT + 532;
-pub const SYS_move_pages: ::c_long = __X32_SYSCALL_BIT + 533;
-pub const SYS_preadv: ::c_long = __X32_SYSCALL_BIT + 534;
-pub const SYS_pwritev: ::c_long = __X32_SYSCALL_BIT + 535;
-pub const SYS_rt_tgsigqueueinfo: ::c_long = __X32_SYSCALL_BIT + 536;
-pub const SYS_recvmmsg: ::c_long = __X32_SYSCALL_BIT + 537;
-pub const SYS_sendmmsg: ::c_long = __X32_SYSCALL_BIT + 538;
-pub const SYS_process_vm_readv: ::c_long = __X32_SYSCALL_BIT + 539;
-pub const SYS_process_vm_writev: ::c_long = __X32_SYSCALL_BIT + 540;
-pub const SYS_setsockopt: ::c_long = __X32_SYSCALL_BIT + 541;
-pub const SYS_getsockopt: ::c_long = __X32_SYSCALL_BIT + 542;
-pub const SYS_io_setup: ::c_long = __X32_SYSCALL_BIT + 543;
-pub const SYS_io_submit: ::c_long = __X32_SYSCALL_BIT + 544;
-pub const SYS_execveat: ::c_long = __X32_SYSCALL_BIT + 545;
-pub const SYS_preadv2: ::c_long = __X32_SYSCALL_BIT + 546;
-pub const SYS_pwritev2: ::c_long = __X32_SYSCALL_BIT + 547;
diff --git a/libc/src/unix/notbsd/linux/other/b64/x86_64.rs b/libc/src/unix/notbsd/linux/other/b64/x86_64.rs
deleted file mode 100644
index fb39bf3..0000000
--- a/libc/src/unix/notbsd/linux/other/b64/x86_64.rs
+++ /dev/null
@@ -1,787 +0,0 @@
-//! x86_64-specific definitions for 64-bit linux-like values
-
-pub type c_char = i8;
-pub type wchar_t = i32;
-pub type nlink_t = u64;
-pub type blksize_t = i64;
-pub type greg_t = i64;
-pub type suseconds_t = i64;
-pub type __u64 = ::c_ulonglong;
-
-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: i64,
- pub st_mtime: ::time_t,
- pub st_mtime_nsec: i64,
- pub st_ctime: ::time_t,
- pub st_ctime_nsec: i64,
- __unused: [i64; 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: i64,
- pub st_mtime: ::time_t,
- pub st_mtime_nsec: i64,
- pub st_ctime: ::time_t,
- pub st_ctime_nsec: i64,
- __reserved: [i64; 3],
- }
-
- pub struct statfs64 {
- pub f_type: ::__fsword_t,
- pub f_bsize: ::__fsword_t,
- pub f_blocks: u64,
- pub f_bfree: u64,
- pub f_bavail: u64,
- pub f_files: u64,
- pub f_ffree: u64,
- pub f_fsid: ::fsid_t,
- pub f_namelen: ::__fsword_t,
- pub f_frsize: ::__fsword_t,
- pub f_flags: ::__fsword_t,
- pub f_spare: [::__fsword_t; 4],
- }
-
- pub struct statvfs64 {
- pub f_bsize: ::c_ulong,
- pub f_frsize: ::c_ulong,
- pub f_blocks: u64,
- pub f_bfree: u64,
- pub f_bavail: u64,
- pub f_files: u64,
- pub f_ffree: u64,
- pub f_favail: u64,
- pub f_fsid: ::c_ulong,
- pub f_flag: ::c_ulong,
- pub f_namemax: ::c_ulong,
- __f_spare: [::c_int; 6],
- }
-
- pub struct pthread_attr_t {
- #[cfg(target_pointer_width = "32")]
- __size: [u32; 8],
- #[cfg(target_pointer_width = "64")]
- __size: [u64; 7]
- }
-
- pub struct _libc_fpxreg {
- pub significand: [u16; 4],
- pub exponent: u16,
- __private: [u16; 3],
- }
-
- pub struct _libc_xmmreg {
- pub element: [u32; 4],
- }
-
- pub struct _libc_fpstate {
- pub cwd: u16,
- pub swd: u16,
- pub ftw: u16,
- pub fop: u16,
- pub rip: u64,
- pub rdp: u64,
- pub mxcsr: u32,
- pub mxcr_mask: u32,
- pub _st: [_libc_fpxreg; 8],
- pub _xmm: [_libc_xmmreg; 16],
- __private: [u64; 12],
- }
-
- pub struct user_regs_struct {
- pub r15: ::c_ulonglong,
- pub r14: ::c_ulonglong,
- pub r13: ::c_ulonglong,
- pub r12: ::c_ulonglong,
- pub rbp: ::c_ulonglong,
- pub rbx: ::c_ulonglong,
- pub r11: ::c_ulonglong,
- pub r10: ::c_ulonglong,
- pub r9: ::c_ulonglong,
- pub r8: ::c_ulonglong,
- pub rax: ::c_ulonglong,
- pub rcx: ::c_ulonglong,
- pub rdx: ::c_ulonglong,
- pub rsi: ::c_ulonglong,
- pub rdi: ::c_ulonglong,
- pub orig_rax: ::c_ulonglong,
- pub rip: ::c_ulonglong,
- pub cs: ::c_ulonglong,
- pub eflags: ::c_ulonglong,
- pub rsp: ::c_ulonglong,
- pub ss: ::c_ulonglong,
- pub fs_base: ::c_ulonglong,
- pub gs_base: ::c_ulonglong,
- pub ds: ::c_ulonglong,
- pub es: ::c_ulonglong,
- pub fs: ::c_ulonglong,
- pub gs: ::c_ulonglong,
- }
-
- pub struct user {
- pub regs: user_regs_struct,
- pub u_fpvalid: ::c_int,
- pub i387: user_fpregs_struct,
- pub u_tsize: ::c_ulonglong,
- pub u_dsize: ::c_ulonglong,
- pub u_ssize: ::c_ulonglong,
- pub start_code: ::c_ulonglong,
- pub start_stack: ::c_ulonglong,
- pub signal: ::c_longlong,
- __reserved: ::c_int,
- #[cfg(target_pointer_width = "32")]
- __pad1: u32,
- pub u_ar0: *mut user_regs_struct,
- #[cfg(target_pointer_width = "32")]
- __pad2: u32,
- pub u_fpstate: *mut user_fpregs_struct,
- pub magic: ::c_ulonglong,
- pub u_comm: [::c_char; 32],
- pub u_debugreg: [::c_ulonglong; 8],
- }
-
- pub struct mcontext_t {
- pub gregs: [greg_t; 23],
- pub fpregs: *mut _libc_fpstate,
- __private: [u64; 8],
- }
-
- pub struct ipc_perm {
- pub __key: ::key_t,
- pub uid: ::uid_t,
- pub gid: ::gid_t,
- pub cuid: ::uid_t,
- pub cgid: ::gid_t,
- pub mode: ::c_ushort,
- __pad1: ::c_ushort,
- pub __seq: ::c_ushort,
- __pad2: ::c_ushort,
- __unused1: u64,
- __unused2: u64
- }
-
- pub struct shmid_ds {
- pub shm_perm: ::ipc_perm,
- pub shm_segsz: ::size_t,
- pub shm_atime: ::time_t,
- pub shm_dtime: ::time_t,
- pub shm_ctime: ::time_t,
- pub shm_cpid: ::pid_t,
- pub shm_lpid: ::pid_t,
- pub shm_nattch: ::shmatt_t,
- __unused4: u64,
- __unused5: u64
- }
-
- 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_line: ::cc_t,
- pub c_cc: [::cc_t; 19],
- pub c_ispeed: ::speed_t,
- pub c_ospeed: ::speed_t,
- }
-}
-
-s_no_extra_traits! {
- pub struct user_fpregs_struct {
- pub cwd: ::c_ushort,
- pub swd: ::c_ushort,
- pub ftw: ::c_ushort,
- pub fop: ::c_ushort,
- pub rip: ::c_ulonglong,
- pub rdp: ::c_ulonglong,
- pub mxcsr: ::c_uint,
- pub mxcr_mask: ::c_uint,
- pub st_space: [::c_uint; 32],
- pub xmm_space: [::c_uint; 64],
- padding: [::c_uint; 24],
- }
-
- pub struct ucontext_t {
- pub uc_flags: ::c_ulong,
- pub uc_link: *mut ucontext_t,
- pub uc_stack: ::stack_t,
- pub uc_mcontext: mcontext_t,
- pub uc_sigmask: ::sigset_t,
- __private: [u8; 512],
- __ssp: [::c_ulonglong; 4],
- }
-}
-
-cfg_if! {
- if #[cfg(feature = "extra_traits")] {
- impl PartialEq for user_fpregs_struct {
- fn eq(&self, other: &user_fpregs_struct) -> bool {
- self.cwd == other.cwd
- && self.swd == other.swd
- && self.ftw == other.ftw
- && self.fop == other.fop
- && self.rip == other.rip
- && self.rdp == other.rdp
- && self.mxcsr == other.mxcsr
- && self.mxcr_mask == other.mxcr_mask
- && self.st_space == other.st_space
- && self
- .xmm_space
- .iter()
- .zip(other.xmm_space.iter())
- .all(|(a,b)| a == b)
- // Ignore padding field
- }
- }
-
- impl Eq for user_fpregs_struct {}
-
- impl ::fmt::Debug for user_fpregs_struct {
- fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
- f.debug_struct("user_fpregs_struct")
- .field("cwd", &self.cwd)
- .field("ftw", &self.ftw)
- .field("fop", &self.fop)
- .field("rip", &self.rip)
- .field("rdp", &self.rdp)
- .field("mxcsr", &self.mxcsr)
- .field("mxcr_mask", &self.mxcr_mask)
- .field("st_space", &self.st_space)
- // FIXME: .field("xmm_space", &self.xmm_space)
- // Ignore padding field
- .finish()
- }
- }
-
- impl ::hash::Hash for user_fpregs_struct {
- fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
- self.cwd.hash(state);
- self.ftw.hash(state);
- self.fop.hash(state);
- self.rip.hash(state);
- self.rdp.hash(state);
- self.mxcsr.hash(state);
- self.mxcr_mask.hash(state);
- self.st_space.hash(state);
- self.xmm_space.hash(state);
- // Ignore padding field
- }
- }
-
- impl PartialEq for ucontext_t {
- fn eq(&self, other: &ucontext_t) -> bool {
- self.uc_flags == other.uc_flags
- && self.uc_link == other.uc_link
- && self.uc_stack == other.uc_stack
- && self.uc_mcontext == other.uc_mcontext
- && self.uc_sigmask == other.uc_sigmask
- // Ignore __private field
- }
- }
-
- impl Eq for ucontext_t {}
-
- impl ::fmt::Debug for ucontext_t {
- fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
- f.debug_struct("ucontext_t")
- .field("uc_flags", &self.uc_flags)
- .field("uc_link", &self.uc_link)
- .field("uc_stack", &self.uc_stack)
- .field("uc_mcontext", &self.uc_mcontext)
- .field("uc_sigmask", &self.uc_sigmask)
- // Ignore __private field
- .finish()
- }
- }
-
- impl ::hash::Hash for ucontext_t {
- fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
- self.uc_flags.hash(state);
- self.uc_link.hash(state);
- self.uc_stack.hash(state);
- self.uc_mcontext.hash(state);
- self.uc_sigmask.hash(state);
- // Ignore __private field
- }
- }
- }
-}
-
-pub const TIOCGSOFTCAR: ::c_ulong = 0x5419;
-pub const TIOCSSOFTCAR: ::c_ulong = 0x541A;
-pub const TIOCGRS485: ::c_int = 0x542E;
-pub const TIOCSRS485: ::c_int = 0x542F;
-
-pub const RLIMIT_NOFILE: ::c_int = 7;
-pub const RLIMIT_NPROC: ::c_int = 6;
-
-pub const O_APPEND: ::c_int = 1024;
-pub const O_CREAT: ::c_int = 64;
-pub const O_EXCL: ::c_int = 128;
-pub const O_NOCTTY: ::c_int = 256;
-pub const O_NONBLOCK: ::c_int = 2048;
-pub const O_SYNC: ::c_int = 1052672;
-pub const O_RSYNC: ::c_int = 1052672;
-pub const O_DSYNC: ::c_int = 4096;
-pub const O_FSYNC: ::c_int = 0x101000;
-pub const O_NOATIME: ::c_int = 0o1000000;
-pub const O_PATH: ::c_int = 0o10000000;
-pub const O_TMPFILE: ::c_int = 0o20000000 | O_DIRECTORY;
-
-pub const MAP_GROWSDOWN: ::c_int = 0x0100;
-
-pub const EDEADLK: ::c_int = 35;
-pub const ENAMETOOLONG: ::c_int = 36;
-pub const ENOLCK: ::c_int = 37;
-pub const ENOSYS: ::c_int = 38;
-pub const ENOTEMPTY: ::c_int = 39;
-pub const ELOOP: ::c_int = 40;
-pub const ENOMSG: ::c_int = 42;
-pub const EIDRM: ::c_int = 43;
-pub const ECHRNG: ::c_int = 44;
-pub const EL2NSYNC: ::c_int = 45;
-pub const EL3HLT: ::c_int = 46;
-pub const EL3RST: ::c_int = 47;
-pub const ELNRNG: ::c_int = 48;
-pub const EUNATCH: ::c_int = 49;
-pub const ENOCSI: ::c_int = 50;
-pub const EL2HLT: ::c_int = 51;
-pub const EBADE: ::c_int = 52;
-pub const EBADR: ::c_int = 53;
-pub const EXFULL: ::c_int = 54;
-pub const ENOANO: ::c_int = 55;
-pub const EBADRQC: ::c_int = 56;
-pub const EBADSLT: ::c_int = 57;
-pub const EMULTIHOP: ::c_int = 72;
-pub const EOVERFLOW: ::c_int = 75;
-pub const ENOTUNIQ: ::c_int = 76;
-pub const EBADFD: ::c_int = 77;
-pub const EBADMSG: ::c_int = 74;
-pub const EREMCHG: ::c_int = 78;
-pub const ELIBACC: ::c_int = 79;
-pub const ELIBBAD: ::c_int = 80;
-pub const ELIBSCN: ::c_int = 81;
-pub const ELIBMAX: ::c_int = 82;
-pub const ELIBEXEC: ::c_int = 83;
-pub const EILSEQ: ::c_int = 84;
-pub const ERESTART: ::c_int = 85;
-pub const ESTRPIPE: ::c_int = 86;
-pub const EUSERS: ::c_int = 87;
-pub const ENOTSOCK: ::c_int = 88;
-pub const EDESTADDRREQ: ::c_int = 89;
-pub const EMSGSIZE: ::c_int = 90;
-pub const EPROTOTYPE: ::c_int = 91;
-pub const ENOPROTOOPT: ::c_int = 92;
-pub const EPROTONOSUPPORT: ::c_int = 93;
-pub const ESOCKTNOSUPPORT: ::c_int = 94;
-pub const EOPNOTSUPP: ::c_int = 95;
-pub const EPFNOSUPPORT: ::c_int = 96;
-pub const EAFNOSUPPORT: ::c_int = 97;
-pub const EADDRINUSE: ::c_int = 98;
-pub const EADDRNOTAVAIL: ::c_int = 99;
-pub const ENETDOWN: ::c_int = 100;
-pub const ENETUNREACH: ::c_int = 101;
-pub const ENETRESET: ::c_int = 102;
-pub const ECONNABORTED: ::c_int = 103;
-pub const ECONNRESET: ::c_int = 104;
-pub const ENOBUFS: ::c_int = 105;
-pub const EISCONN: ::c_int = 106;
-pub const ENOTCONN: ::c_int = 107;
-pub const ESHUTDOWN: ::c_int = 108;
-pub const ETOOMANYREFS: ::c_int = 109;
-pub const ETIMEDOUT: ::c_int = 110;
-pub const ECONNREFUSED: ::c_int = 111;
-pub const EHOSTDOWN: ::c_int = 112;
-pub const EHOSTUNREACH: ::c_int = 113;
-pub const EALREADY: ::c_int = 114;
-pub const EINPROGRESS: ::c_int = 115;
-pub const ESTALE: ::c_int = 116;
-pub const EDQUOT: ::c_int = 122;
-pub const ENOMEDIUM: ::c_int = 123;
-pub const EMEDIUMTYPE: ::c_int = 124;
-pub const ECANCELED: ::c_int = 125;
-pub const ENOKEY: ::c_int = 126;
-pub const EKEYEXPIRED: ::c_int = 127;
-pub const EKEYREVOKED: ::c_int = 128;
-pub const EKEYREJECTED: ::c_int = 129;
-pub const EOWNERDEAD: ::c_int = 130;
-pub const ENOTRECOVERABLE: ::c_int = 131;
-pub const EHWPOISON: ::c_int = 133;
-pub const ERFKILL: ::c_int = 132;
-
-pub const SOL_SOCKET: ::c_int = 1;
-
-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_SNDBUFFORCE: ::c_int = 32;
-pub const SO_RCVBUFFORCE: ::c_int = 33;
-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_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_SECURITY_AUTHENTICATION: ::c_int = 22;
-pub const SO_SECURITY_ENCRYPTION_TRANSPORT: ::c_int = 23;
-pub const SO_SECURITY_ENCRYPTION_NETWORK: ::c_int = 24;
-pub const SO_BINDTODEVICE: ::c_int = 25;
-pub const SO_ATTACH_FILTER: ::c_int = 26;
-pub const SO_DETACH_FILTER: ::c_int = 27;
-pub const SO_GET_FILTER: ::c_int = SO_ATTACH_FILTER;
-pub const SO_PEERNAME: ::c_int = 28;
-pub const SO_TIMESTAMP: ::c_int = 29;
-pub const SO_ACCEPTCONN: ::c_int = 30;
-pub const SO_PEERSEC: ::c_int = 31;
-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_PROTOCOL: ::c_int = 38;
-pub const SO_DOMAIN: ::c_int = 39;
-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;
-pub const SO_PEEK_OFF: ::c_int = 42;
-pub const SO_NOFCS: ::c_int = 43;
-pub const SO_LOCK_FILTER: ::c_int = 44;
-pub const SO_SELECT_ERR_QUEUE: ::c_int = 45;
-pub const SO_BUSY_POLL: ::c_int = 46;
-pub const SO_MAX_PACING_RATE: ::c_int = 47;
-pub const SO_BPF_EXTENSIONS: ::c_int = 48;
-pub const SO_INCOMING_CPU: ::c_int = 49;
-pub const SO_ATTACH_BPF: ::c_int = 50;
-pub const SO_DETACH_BPF: ::c_int = SO_DETACH_FILTER;
-
-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 SIGUSR1: ::c_int = 10;
-pub const SIGUSR2: ::c_int = 12;
-pub const SIGCONT: ::c_int = 18;
-pub const SIGSTOP: ::c_int = 19;
-pub const SIGTSTP: ::c_int = 20;
-pub const SIGURG: ::c_int = 23;
-pub const SIGIO: ::c_int = 29;
-pub const SIGSYS: ::c_int = 31;
-pub const SIGSTKFLT: ::c_int = 16;
-#[deprecated(
- since = "0.2.55",
- note = "Use SIGSYS instead"
-)]
-pub const SIGUNUSED: ::c_int = 31;
-pub const SIGPOLL: ::c_int = 29;
-pub const SIGPWR: ::c_int = 30;
-pub const SIG_SETMASK: ::c_int = 2;
-pub const SIG_BLOCK: ::c_int = 0x000000;
-pub const SIG_UNBLOCK: ::c_int = 0x01;
-
-pub const POLLWRNORM: ::c_short = 0x100;
-pub const POLLWRBAND: ::c_short = 0x200;
-
-pub const O_ASYNC: ::c_int = 0x2000;
-pub const O_NDELAY: ::c_int = 0x800;
-
-pub const PTRACE_DETACH: ::c_uint = 17;
-
-pub const EFD_NONBLOCK: ::c_int = 0x800;
-
-pub const F_GETLK: ::c_int = 5;
-pub const F_GETOWN: ::c_int = 9;
-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;
-pub const TIOCNXCL: ::c_ulong = 0x540D;
-pub const TIOCSCTTY: ::c_ulong = 0x540E;
-pub const TIOCSTI: ::c_ulong = 0x5412;
-pub const TIOCMGET: ::c_ulong = 0x5415;
-pub const TIOCMBIS: ::c_ulong = 0x5416;
-pub const TIOCMBIC: ::c_ulong = 0x5417;
-pub const TIOCMSET: ::c_ulong = 0x5418;
-pub const TIOCCONS: ::c_ulong = 0x541D;
-
-pub const SFD_CLOEXEC: ::c_int = 0x080000;
-
-pub const NCCS: usize = 32;
-
-pub const O_TRUNC: ::c_int = 512;
-
-pub const O_CLOEXEC: ::c_int = 0x80000;
-
-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 EDOTDOT: ::c_int = 73;
-
-pub const SA_NODEFER: ::c_int = 0x40000000;
-pub const SA_RESETHAND: ::c_int = 0x80000000;
-pub const SA_RESTART: ::c_int = 0x10000000;
-pub const SA_NOCLDSTOP: ::c_int = 0x00000001;
-
-pub const EPOLL_CLOEXEC: ::c_int = 0x80000;
-
-pub const EFD_CLOEXEC: ::c_int = 0x80000;
-
-pub const __SIZEOF_PTHREAD_CONDATTR_T: usize = 4;
-pub const __SIZEOF_PTHREAD_MUTEXATTR_T: usize = 4;
-
-pub const O_DIRECT: ::c_int = 0x4000;
-pub const O_DIRECTORY: ::c_int = 0x10000;
-pub const O_NOFOLLOW: ::c_int = 0x20000;
-
-pub const MAP_LOCKED: ::c_int = 0x02000;
-pub const MAP_NORESERVE: ::c_int = 0x04000;
-pub const MAP_32BIT: ::c_int = 0x0040;
-
-pub const EDEADLOCK: ::c_int = 35;
-
-pub const FIOCLEX: ::c_ulong = 0x5451;
-pub const FIONBIO: ::c_ulong = 0x5421;
-
-pub const PTRACE_GETFPREGS: ::c_uint = 14;
-pub const PTRACE_SETFPREGS: ::c_uint = 15;
-pub const PTRACE_GETFPXREGS: ::c_uint = 18;
-pub const PTRACE_SETFPXREGS: ::c_uint = 19;
-pub const PTRACE_GETREGS: ::c_uint = 12;
-pub const PTRACE_SETREGS: ::c_uint = 13;
-pub const PTRACE_PEEKSIGINFO_SHARED: ::c_uint = 1;
-
-pub const MCL_CURRENT: ::c_int = 0x0001;
-pub const MCL_FUTURE: ::c_int = 0x0002;
-
-pub const SIGSTKSZ: ::size_t = 8192;
-pub const MINSIGSTKSZ: ::size_t = 2048;
-pub const CBAUD: ::tcflag_t = 0o0010017;
-pub const TAB1: ::tcflag_t = 0x00000800;
-pub const TAB2: ::tcflag_t = 0x00001000;
-pub const TAB3: ::tcflag_t = 0x00001800;
-pub const CR1: ::tcflag_t = 0x00000200;
-pub const CR2: ::tcflag_t = 0x00000400;
-pub const CR3: ::tcflag_t = 0x00000600;
-pub const FF1: ::tcflag_t = 0x00008000;
-pub const BS1: ::tcflag_t = 0x00002000;
-pub const VT1: ::tcflag_t = 0x00004000;
-pub const VWERASE: usize = 14;
-pub const VREPRINT: usize = 12;
-pub const VSUSP: usize = 10;
-pub const VSTART: usize = 8;
-pub const VSTOP: usize = 9;
-pub const VDISCARD: usize = 13;
-pub const VTIME: usize = 5;
-pub const IXON: ::tcflag_t = 0x00000400;
-pub const IXOFF: ::tcflag_t = 0x00001000;
-pub const ONLCR: ::tcflag_t = 0x4;
-pub const CSIZE: ::tcflag_t = 0x00000030;
-pub const CS6: ::tcflag_t = 0x00000010;
-pub const CS7: ::tcflag_t = 0x00000020;
-pub const CS8: ::tcflag_t = 0x00000030;
-pub const CSTOPB: ::tcflag_t = 0x00000040;
-pub const CREAD: ::tcflag_t = 0x00000080;
-pub const PARENB: ::tcflag_t = 0x00000100;
-pub const PARODD: ::tcflag_t = 0x00000200;
-pub const HUPCL: ::tcflag_t = 0x00000400;
-pub const CLOCAL: ::tcflag_t = 0x00000800;
-pub const ECHOKE: ::tcflag_t = 0x00000800;
-pub const ECHOE: ::tcflag_t = 0x00000010;
-pub const ECHOK: ::tcflag_t = 0x00000020;
-pub const ECHONL: ::tcflag_t = 0x00000040;
-pub const ECHOPRT: ::tcflag_t = 0x00000400;
-pub const ECHOCTL: ::tcflag_t = 0x00000200;
-pub const ISIG: ::tcflag_t = 0x00000001;
-pub const ICANON: ::tcflag_t = 0x00000002;
-pub const PENDIN: ::tcflag_t = 0x00004000;
-pub const NOFLSH: ::tcflag_t = 0x00000080;
-pub const CIBAUD: ::tcflag_t = 0o02003600000;
-pub const CBAUDEX: ::tcflag_t = 0o010000;
-pub const VSWTC: usize = 7;
-pub const OLCUC: ::tcflag_t = 0o000002;
-pub const NLDLY: ::tcflag_t = 0o000400;
-pub const CRDLY: ::tcflag_t = 0o003000;
-pub const TABDLY: ::tcflag_t = 0o014000;
-pub const BSDLY: ::tcflag_t = 0o020000;
-pub const FFDLY: ::tcflag_t = 0o100000;
-pub const VTDLY: ::tcflag_t = 0o040000;
-pub const XTABS: ::tcflag_t = 0o014000;
-
-pub const B0: ::speed_t = 0o000000;
-pub const B50: ::speed_t = 0o000001;
-pub const B75: ::speed_t = 0o000002;
-pub const B110: ::speed_t = 0o000003;
-pub const B134: ::speed_t = 0o000004;
-pub const B150: ::speed_t = 0o000005;
-pub const B200: ::speed_t = 0o000006;
-pub const B300: ::speed_t = 0o000007;
-pub const B600: ::speed_t = 0o000010;
-pub const B1200: ::speed_t = 0o000011;
-pub const B1800: ::speed_t = 0o000012;
-pub const B2400: ::speed_t = 0o000013;
-pub const B4800: ::speed_t = 0o000014;
-pub const B9600: ::speed_t = 0o000015;
-pub const B19200: ::speed_t = 0o000016;
-pub const B38400: ::speed_t = 0o000017;
-pub const EXTA: ::speed_t = B19200;
-pub const EXTB: ::speed_t = B38400;
-pub const BOTHER: ::speed_t = 0o010000;
-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 VEOL: usize = 11;
-pub const VEOL2: usize = 16;
-pub const VMIN: usize = 6;
-pub const IEXTEN: ::tcflag_t = 0x00008000;
-pub const TOSTOP: ::tcflag_t = 0x00000100;
-pub const FLUSHO: ::tcflag_t = 0x00001000;
-pub const EXTPROC: ::tcflag_t = 0x00010000;
-pub const TCGETS: ::c_ulong = 0x5401;
-pub const TCSETS: ::c_ulong = 0x5402;
-pub const TCSETSW: ::c_ulong = 0x5403;
-pub const TCSETSF: ::c_ulong = 0x5404;
-pub const TCGETA: ::c_ulong = 0x5405;
-pub const TCSETA: ::c_ulong = 0x5406;
-pub const TCSETAW: ::c_ulong = 0x5407;
-pub const TCSETAF: ::c_ulong = 0x5408;
-pub const TCSBRK: ::c_ulong = 0x5409;
-pub const TCXONC: ::c_ulong = 0x540A;
-pub const TCFLSH: ::c_ulong = 0x540B;
-pub const TIOCINQ: ::c_ulong = 0x541B;
-pub const TIOCGPGRP: ::c_ulong = 0x540F;
-pub const TIOCSPGRP: ::c_ulong = 0x5410;
-pub const TIOCOUTQ: ::c_ulong = 0x5411;
-pub const TIOCGWINSZ: ::c_ulong = 0x5413;
-pub const TIOCSWINSZ: ::c_ulong = 0x5414;
-pub const FIONREAD: ::c_ulong = 0x541B;
-
-// offsets in user_regs_structs, from sys/reg.h
-pub const R15: ::c_int = 0;
-pub const R14: ::c_int = 1;
-pub const R13: ::c_int = 2;
-pub const R12: ::c_int = 3;
-pub const RBP: ::c_int = 4;
-pub const RBX: ::c_int = 5;
-pub const R11: ::c_int = 6;
-pub const R10: ::c_int = 7;
-pub const R9: ::c_int = 8;
-pub const R8: ::c_int = 9;
-pub const RAX: ::c_int = 10;
-pub const RCX: ::c_int = 11;
-pub const RDX: ::c_int = 12;
-pub const RSI: ::c_int = 13;
-pub const RDI: ::c_int = 14;
-pub const ORIG_RAX: ::c_int = 15;
-pub const RIP: ::c_int = 16;
-pub const CS: ::c_int = 17;
-pub const EFLAGS: ::c_int = 18;
-pub const RSP: ::c_int = 19;
-pub const SS: ::c_int = 20;
-pub const FS_BASE: ::c_int = 21;
-pub const GS_BASE: ::c_int = 22;
-pub const DS: ::c_int = 23;
-pub const ES: ::c_int = 24;
-pub const FS: ::c_int = 25;
-pub const GS: ::c_int = 26;
-
-// offsets in mcontext_t.gregs from sys/ucontext.h
-pub const REG_R8: ::c_int = 0;
-pub const REG_R9: ::c_int = 1;
-pub const REG_R10: ::c_int = 2;
-pub const REG_R11: ::c_int = 3;
-pub const REG_R12: ::c_int = 4;
-pub const REG_R13: ::c_int = 5;
-pub const REG_R14: ::c_int = 6;
-pub const REG_R15: ::c_int = 7;
-pub const REG_RDI: ::c_int = 8;
-pub const REG_RSI: ::c_int = 9;
-pub const REG_RBP: ::c_int = 10;
-pub const REG_RBX: ::c_int = 11;
-pub const REG_RDX: ::c_int = 12;
-pub const REG_RAX: ::c_int = 13;
-pub const REG_RCX: ::c_int = 14;
-pub const REG_RSP: ::c_int = 15;
-pub const REG_RIP: ::c_int = 16;
-pub const REG_EFL: ::c_int = 17;
-pub const REG_CSGSFS: ::c_int = 18;
-pub const REG_ERR: ::c_int = 19;
-pub const REG_TRAPNO: ::c_int = 20;
-pub const REG_OLDMASK: ::c_int = 21;
-pub const REG_CR2: ::c_int = 22;
-
-extern {
- pub fn getcontext(ucp: *mut ucontext_t) -> ::c_int;
- pub fn setcontext(ucp: *const ucontext_t) -> ::c_int;
- pub fn makecontext(ucp: *mut ucontext_t,
- func: extern fn (),
- argc: ::c_int, ...);
- pub fn swapcontext(uocp: *mut ucontext_t,
- ucp: *const ucontext_t) -> ::c_int;
- pub fn iopl(level: ::c_int) -> ::c_int;
- pub fn ioperm(from: ::c_ulong, num: ::c_ulong,
- turn_on: ::c_int) -> ::c_int;
-}
diff --git a/libc/src/unix/notbsd/linux/other/mod.rs b/libc/src/unix/notbsd/linux/other/mod.rs
deleted file mode 100644
index 7ce58ad..0000000
--- a/libc/src/unix/notbsd/linux/other/mod.rs
+++ /dev/null
@@ -1,1142 +0,0 @@
-pub type pthread_t = c_ulong;
-pub type __priority_which_t = ::c_uint;
-pub type __rlimit_resource_t = ::c_uint;
-
-s! {
- pub struct statx {
- pub stx_mask: u32,
- pub stx_blksize: u32,
- pub stx_attributes: u64,
- pub stx_nlink: u32,
- pub stx_uid: u32,
- pub stx_gid: u32,
- pub stx_mode: u16,
- pub __statx_pad1: [u16; 1],
- pub stx_ino: u64,
- pub stx_size: u64,
- pub stx_blocks: u64,
- pub stx_attributes_mask: u64,
- pub stx_atime: ::statx_timestamp,
- pub stx_btime: ::statx_timestamp,
- pub stx_ctime: ::statx_timestamp,
- pub stx_mtime: ::statx_timestamp,
- pub stx_rdev_major: u32,
- pub stx_rdev_minor: u32,
- pub stx_dev_major: u32,
- pub stx_dev_minor: u32,
- pub __statx_pad2: [u64; 14],
- }
-
- pub struct statx_timestamp {
- pub tv_sec: i64,
- pub tv_nsec: u32,
- pub __statx_timestamp_pad1: [i32; 1],
- }
-
- pub struct aiocb {
- pub aio_fildes: ::c_int,
- pub aio_lio_opcode: ::c_int,
- pub aio_reqprio: ::c_int,
- pub aio_buf: *mut ::c_void,
- pub aio_nbytes: ::size_t,
- pub aio_sigevent: ::sigevent,
- __next_prio: *mut aiocb,
- __abs_prio: ::c_int,
- __policy: ::c_int,
- __error_code: ::c_int,
- __return_value: ::ssize_t,
- pub aio_offset: off_t,
- #[cfg(all(not(target_arch = "x86_64"), target_pointer_width = "32"))]
- __unused1: [::c_char; 4],
- __glibc_reserved: [::c_char; 32]
- }
-
- pub struct __exit_status {
- pub e_termination: ::c_short,
- pub e_exit: ::c_short,
- }
-
- pub struct __timeval {
- pub tv_sec: i32,
- pub tv_usec: i32,
- }
-
- pub struct sigaction {
- pub sa_sigaction: ::sighandler_t,
- pub sa_mask: ::sigset_t,
- #[cfg(target_arch = "sparc64")]
- __reserved0: ::c_int,
- pub sa_flags: ::c_int,
- pub sa_restorer: ::Option<extern fn()>,
- }
-
- pub struct stack_t {
- pub ss_sp: *mut ::c_void,
- pub ss_flags: ::c_int,
- pub ss_size: ::size_t
- }
-
- pub struct siginfo_t {
- pub si_signo: ::c_int,
- pub si_errno: ::c_int,
- pub si_code: ::c_int,
- #[doc(hidden)]
- #[deprecated(
- since="0.2.54",
- note="Please leave a comment on \
- https://github.com/rust-lang/libc/pull/1316 if you're using \
- this field"
- )]
- pub _pad: [::c_int; 29],
- #[cfg(target_arch = "x86_64")]
- _align: [u64; 0],
- #[cfg(not(target_arch = "x86_64"))]
- _align: [usize; 0],
- }
-
- pub struct glob64_t {
- pub gl_pathc: ::size_t,
- pub gl_pathv: *mut *mut ::c_char,
- pub gl_offs: ::size_t,
- pub gl_flags: ::c_int,
-
- __unused1: *mut ::c_void,
- __unused2: *mut ::c_void,
- __unused3: *mut ::c_void,
- __unused4: *mut ::c_void,
- __unused5: *mut ::c_void,
- }
-
- pub struct statfs {
- pub f_type: __fsword_t,
- pub f_bsize: __fsword_t,
- pub f_blocks: ::fsblkcnt_t,
- pub f_bfree: ::fsblkcnt_t,
- pub f_bavail: ::fsblkcnt_t,
-
- pub f_files: ::fsfilcnt_t,
- pub f_ffree: ::fsfilcnt_t,
- pub f_fsid: ::fsid_t,
-
- pub f_namelen: __fsword_t,
- pub f_frsize: __fsword_t,
- f_spare: [__fsword_t; 5],
- }
-
- pub struct msghdr {
- pub msg_name: *mut ::c_void,
- pub msg_namelen: ::socklen_t,
- pub msg_iov: *mut ::iovec,
- pub msg_iovlen: ::size_t,
- pub msg_control: *mut ::c_void,
- pub msg_controllen: ::size_t,
- pub msg_flags: ::c_int,
- }
-
- pub struct cmsghdr {
- pub cmsg_len: ::size_t,
- pub cmsg_level: ::c_int,
- pub cmsg_type: ::c_int,
- }
-
- pub struct termios {
- pub c_iflag: ::tcflag_t,
- pub c_oflag: ::tcflag_t,
- pub c_cflag: ::tcflag_t,
- pub c_lflag: ::tcflag_t,
- pub c_line: ::cc_t,
- pub c_cc: [::cc_t; ::NCCS],
- #[cfg(not(target_arch = "sparc64"))]
- pub c_ispeed: ::speed_t,
- #[cfg(not(target_arch = "sparc64"))]
- pub c_ospeed: ::speed_t,
- }
-
- pub struct flock {
- pub l_type: ::c_short,
- pub l_whence: ::c_short,
- pub l_start: ::off_t,
- pub l_len: ::off_t,
- pub l_pid: ::pid_t,
- }
-
- pub struct 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,
- }
-}
-
-impl siginfo_t {
- pub unsafe fn si_addr(&self) -> *mut ::c_void {
- #[repr(C)]
- struct siginfo_sigfault {
- _si_signo: ::c_int,
- _si_errno: ::c_int,
- _si_code: ::c_int,
- si_addr: *mut ::c_void
- }
- (*(self as *const siginfo_t as *const siginfo_sigfault)).si_addr
- }
-}
-
-s_no_extra_traits! {
- pub struct utmpx {
- pub ut_type: ::c_short,
- pub ut_pid: ::pid_t,
- pub ut_line: [::c_char; __UT_LINESIZE],
- pub ut_id: [::c_char; 4],
-
- pub ut_user: [::c_char; __UT_NAMESIZE],
- pub ut_host: [::c_char; __UT_HOSTSIZE],
- pub ut_exit: __exit_status,
-
- #[cfg(any(target_arch = "aarch64",
- all(target_pointer_width = "32",
- not(target_arch = "x86_64"))))]
- pub ut_session: ::c_long,
- #[cfg(any(target_arch = "aarch64",
- all(target_pointer_width = "32",
- not(target_arch = "x86_64"))))]
- pub ut_tv: ::timeval,
-
- #[cfg(not(any(target_arch = "aarch64",
- all(target_pointer_width = "32",
- not(target_arch = "x86_64")))))]
- pub ut_session: i32,
- #[cfg(not(any(target_arch = "aarch64",
- all(target_pointer_width = "32",
- not(target_arch = "x86_64")))))]
- pub ut_tv: __timeval,
-
- pub ut_addr_v6: [i32; 4],
- __glibc_reserved: [::c_char; 20],
- }
-}
-
-cfg_if! {
- if #[cfg(feature = "extra_traits")] {
- impl PartialEq for utmpx {
- fn eq(&self, other: &utmpx) -> bool {
- self.ut_type == other.ut_type
- && self.ut_pid == other.ut_pid
- && self.ut_line == other.ut_line
- && self.ut_id == other.ut_id
- && self.ut_user == other.ut_user
- && self
- .ut_host
- .iter()
- .zip(other.ut_host.iter())
- .all(|(a,b)| a == b)
- && self.ut_exit == other.ut_exit
- && self.ut_session == other.ut_session
- && self.ut_tv == other.ut_tv
- && self.ut_addr_v6 == other.ut_addr_v6
- && self.__glibc_reserved == other.__glibc_reserved
- }
- }
-
- impl Eq for utmpx {}
-
- impl ::fmt::Debug for utmpx {
- fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
- f.debug_struct("utmpx")
- .field("ut_type", &self.ut_type)
- .field("ut_pid", &self.ut_pid)
- .field("ut_line", &self.ut_line)
- .field("ut_id", &self.ut_id)
- .field("ut_user", &self.ut_user)
- // FIXME: .field("ut_host", &self.ut_host)
- .field("ut_exit", &self.ut_exit)
- .field("ut_session", &self.ut_session)
- .field("ut_tv", &self.ut_tv)
- .field("ut_addr_v6", &self.ut_addr_v6)
- .field("__glibc_reserved", &self.__glibc_reserved)
- .finish()
- }
- }
-
- impl ::hash::Hash for utmpx {
- fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
- self.ut_type.hash(state);
- self.ut_pid.hash(state);
- self.ut_line.hash(state);
- self.ut_id.hash(state);
- self.ut_user.hash(state);
- self.ut_host.hash(state);
- self.ut_exit.hash(state);
- self.ut_session.hash(state);
- self.ut_tv.hash(state);
- self.ut_addr_v6.hash(state);
- self.__glibc_reserved.hash(state);
- }
- }
- }
-}
-
-pub const RLIMIT_CPU: ::__rlimit_resource_t = 0;
-pub const RLIMIT_FSIZE: ::__rlimit_resource_t = 1;
-pub const RLIMIT_DATA: ::__rlimit_resource_t = 2;
-pub const RLIMIT_STACK: ::__rlimit_resource_t = 3;
-pub const RLIMIT_CORE: ::__rlimit_resource_t = 4;
-pub const RLIMIT_LOCKS: ::__rlimit_resource_t = 10;
-pub const RLIMIT_SIGPENDING: ::__rlimit_resource_t = 11;
-pub const RLIMIT_MSGQUEUE: ::__rlimit_resource_t = 12;
-pub const RLIMIT_NICE: ::__rlimit_resource_t = 13;
-pub const RLIMIT_RTPRIO: ::__rlimit_resource_t = 14;
-
-pub const MADV_SOFT_OFFLINE: ::c_int = 101;
-pub const MS_RMT_MASK: ::c_ulong = 0x02800051;
-
-pub const __UT_LINESIZE: usize = 32;
-pub const __UT_NAMESIZE: usize = 32;
-pub const __UT_HOSTSIZE: usize = 256;
-pub const EMPTY: ::c_short = 0;
-pub const RUN_LVL: ::c_short = 1;
-pub const BOOT_TIME: ::c_short = 2;
-pub const NEW_TIME: ::c_short = 3;
-pub const OLD_TIME: ::c_short = 4;
-pub const INIT_PROCESS: ::c_short = 5;
-pub const LOGIN_PROCESS: ::c_short = 6;
-pub const USER_PROCESS: ::c_short = 7;
-pub const DEAD_PROCESS: ::c_short = 8;
-pub const ACCOUNTING: ::c_short = 9;
-
-pub const RLIMIT_RSS: ::c_int = 5;
-pub const RLIMIT_AS: ::c_int = 9;
-pub const RLIMIT_MEMLOCK: ::c_int = 8;
-pub const RLIM_INFINITY: ::rlim_t = !0;
-pub const RLIMIT_RTTIME: ::c_int = 15;
-pub const RLIMIT_NLIMITS: ::c_int = 16;
-
-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_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_NFC: ::c_int = 280;
-pub const SOL_XDP: ::c_int = 283;
-
-pub const MSG_TRYHARD: ::c_int = 4;
-
-pub const LC_PAPER: ::c_int = 7;
-pub const LC_NAME: ::c_int = 8;
-pub const LC_ADDRESS: ::c_int = 9;
-pub const LC_TELEPHONE: ::c_int = 10;
-pub const LC_MEASUREMENT: ::c_int = 11;
-pub const LC_IDENTIFICATION: ::c_int = 12;
-pub const LC_PAPER_MASK: ::c_int = (1 << LC_PAPER);
-pub const LC_NAME_MASK: ::c_int = (1 << LC_NAME);
-pub const LC_ADDRESS_MASK: ::c_int = (1 << LC_ADDRESS);
-pub const LC_TELEPHONE_MASK: ::c_int = (1 << LC_TELEPHONE);
-pub const LC_MEASUREMENT_MASK: ::c_int = (1 << LC_MEASUREMENT);
-pub const LC_IDENTIFICATION_MASK: ::c_int = (1 << LC_IDENTIFICATION);
-pub const LC_ALL_MASK: ::c_int = ::LC_CTYPE_MASK
- | ::LC_NUMERIC_MASK
- | ::LC_TIME_MASK
- | ::LC_COLLATE_MASK
- | ::LC_MONETARY_MASK
- | ::LC_MESSAGES_MASK
- | LC_PAPER_MASK
- | LC_NAME_MASK
- | LC_ADDRESS_MASK
- | LC_TELEPHONE_MASK
- | LC_MEASUREMENT_MASK
- | LC_IDENTIFICATION_MASK;
-
-pub const MAP_ANON: ::c_int = 0x0020;
-pub const MAP_ANONYMOUS: ::c_int = 0x0020;
-pub const MAP_DENYWRITE: ::c_int = 0x0800;
-pub const MAP_EXECUTABLE: ::c_int = 0x01000;
-pub const MAP_POPULATE: ::c_int = 0x08000;
-pub const MAP_NONBLOCK: ::c_int = 0x010000;
-pub const MAP_STACK: ::c_int = 0x020000;
-pub const MAP_SHARED_VALIDATE: ::c_int = 0x3;
-pub const MAP_FIXED_NOREPLACE: ::c_int = 0x100000;
-
-pub const ENOTSUP: ::c_int = EOPNOTSUPP;
-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 SOCK_STREAM: ::c_int = 1;
-pub const SOCK_DGRAM: ::c_int = 2;
-pub const SOCK_SEQPACKET: ::c_int = 5;
-pub const SOCK_DCCP: ::c_int = 6;
-pub const SOCK_PACKET: ::c_int = 10;
-
-pub const TCP_COOKIE_TRANSACTIONS: ::c_int = 15;
-pub const TCP_THIN_LINEAR_TIMEOUTS: ::c_int = 16;
-pub const TCP_THIN_DUPACK: ::c_int = 17;
-pub const TCP_USER_TIMEOUT: ::c_int = 18;
-pub const TCP_REPAIR: ::c_int = 19;
-pub const TCP_REPAIR_QUEUE: ::c_int = 20;
-pub const TCP_QUEUE_SEQ: ::c_int = 21;
-pub const TCP_REPAIR_OPTIONS: ::c_int = 22;
-pub const TCP_FASTOPEN: ::c_int = 23;
-pub const TCP_TIMESTAMP: ::c_int = 24;
-
-/* DCCP socket options */
-pub const DCCP_SOCKOPT_PACKET_SIZE: ::c_int = 1;
-pub const DCCP_SOCKOPT_SERVICE: ::c_int = 2;
-pub const DCCP_SOCKOPT_CHANGE_L: ::c_int = 3;
-pub const DCCP_SOCKOPT_CHANGE_R: ::c_int = 4;
-pub const DCCP_SOCKOPT_GET_CUR_MPS: ::c_int = 5;
-pub const DCCP_SOCKOPT_SERVER_TIMEWAIT: ::c_int = 6;
-pub const DCCP_SOCKOPT_SEND_CSCOV: ::c_int = 10;
-pub const DCCP_SOCKOPT_RECV_CSCOV: ::c_int = 11;
-pub const DCCP_SOCKOPT_AVAILABLE_CCIDS: ::c_int = 12;
-pub const DCCP_SOCKOPT_CCID: ::c_int = 13;
-pub const DCCP_SOCKOPT_TX_CCID: ::c_int = 14;
-pub const DCCP_SOCKOPT_RX_CCID: ::c_int = 15;
-pub const DCCP_SOCKOPT_QPOLICY_ID: ::c_int = 16;
-pub const DCCP_SOCKOPT_QPOLICY_TXQLEN: ::c_int = 17;
-pub const DCCP_SOCKOPT_CCID_RX_INFO: ::c_int = 128;
-pub const DCCP_SOCKOPT_CCID_TX_INFO: ::c_int = 192;
-
-/// maximum number of services provided on the same listening port
-pub const DCCP_SERVICE_LIST_MAX_LEN: ::c_int = 32;
-
-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 SIGEV_THREAD_ID: ::c_int = 4;
-
-pub const BUFSIZ: ::c_uint = 8192;
-pub const TMP_MAX: ::c_uint = 238328;
-pub const FOPEN_MAX: ::c_uint = 16;
-pub const POSIX_FADV_DONTNEED: ::c_int = 4;
-pub const POSIX_FADV_NOREUSE: ::c_int = 5;
-pub const POSIX_MADV_DONTNEED: ::c_int = 4;
-pub const _SC_EQUIV_CLASS_MAX: ::c_int = 41;
-pub const _SC_CHARCLASS_NAME_MAX: ::c_int = 45;
-pub const _SC_PII: ::c_int = 53;
-pub const _SC_PII_XTI: ::c_int = 54;
-pub const _SC_PII_SOCKET: ::c_int = 55;
-pub const _SC_PII_INTERNET: ::c_int = 56;
-pub const _SC_PII_OSI: ::c_int = 57;
-pub const _SC_POLL: ::c_int = 58;
-pub const _SC_SELECT: ::c_int = 59;
-pub const _SC_PII_INTERNET_STREAM: ::c_int = 61;
-pub const _SC_PII_INTERNET_DGRAM: ::c_int = 62;
-pub const _SC_PII_OSI_COTS: ::c_int = 63;
-pub const _SC_PII_OSI_CLTS: ::c_int = 64;
-pub const _SC_PII_OSI_M: ::c_int = 65;
-pub const _SC_T_IOV_MAX: ::c_int = 66;
-pub const _SC_2_C_VERSION: ::c_int = 96;
-pub const _SC_CHAR_BIT: ::c_int = 101;
-pub const _SC_CHAR_MAX: ::c_int = 102;
-pub const _SC_CHAR_MIN: ::c_int = 103;
-pub const _SC_INT_MAX: ::c_int = 104;
-pub const _SC_INT_MIN: ::c_int = 105;
-pub const _SC_LONG_BIT: ::c_int = 106;
-pub const _SC_WORD_BIT: ::c_int = 107;
-pub const _SC_MB_LEN_MAX: ::c_int = 108;
-pub const _SC_SSIZE_MAX: ::c_int = 110;
-pub const _SC_SCHAR_MAX: ::c_int = 111;
-pub const _SC_SCHAR_MIN: ::c_int = 112;
-pub const _SC_SHRT_MAX: ::c_int = 113;
-pub const _SC_SHRT_MIN: ::c_int = 114;
-pub const _SC_UCHAR_MAX: ::c_int = 115;
-pub const _SC_UINT_MAX: ::c_int = 116;
-pub const _SC_ULONG_MAX: ::c_int = 117;
-pub const _SC_USHRT_MAX: ::c_int = 118;
-pub const _SC_NL_ARGMAX: ::c_int = 119;
-pub const _SC_NL_LANGMAX: ::c_int = 120;
-pub const _SC_NL_MSGMAX: ::c_int = 121;
-pub const _SC_NL_NMAX: ::c_int = 122;
-pub const _SC_NL_SETMAX: ::c_int = 123;
-pub const _SC_NL_TEXTMAX: ::c_int = 124;
-pub const _SC_BASE: ::c_int = 134;
-pub const _SC_C_LANG_SUPPORT: ::c_int = 135;
-pub const _SC_C_LANG_SUPPORT_R: ::c_int = 136;
-pub const _SC_DEVICE_IO: ::c_int = 140;
-pub const _SC_DEVICE_SPECIFIC: ::c_int = 141;
-pub const _SC_DEVICE_SPECIFIC_R: ::c_int = 142;
-pub const _SC_FD_MGMT: ::c_int = 143;
-pub const _SC_FIFO: ::c_int = 144;
-pub const _SC_PIPE: ::c_int = 145;
-pub const _SC_FILE_ATTRIBUTES: ::c_int = 146;
-pub const _SC_FILE_LOCKING: ::c_int = 147;
-pub const _SC_FILE_SYSTEM: ::c_int = 148;
-pub const _SC_MULTI_PROCESS: ::c_int = 150;
-pub const _SC_SINGLE_PROCESS: ::c_int = 151;
-pub const _SC_NETWORKING: ::c_int = 152;
-pub const _SC_REGEX_VERSION: ::c_int = 156;
-pub const _SC_SIGNALS: ::c_int = 158;
-pub const _SC_SYSTEM_DATABASE: ::c_int = 162;
-pub const _SC_SYSTEM_DATABASE_R: ::c_int = 163;
-pub const _SC_USER_GROUPS: ::c_int = 166;
-pub const _SC_USER_GROUPS_R: ::c_int = 167;
-pub const _SC_LEVEL1_ICACHE_SIZE: ::c_int = 185;
-pub const _SC_LEVEL1_ICACHE_ASSOC: ::c_int = 186;
-pub const _SC_LEVEL1_ICACHE_LINESIZE: ::c_int = 187;
-pub const _SC_LEVEL1_DCACHE_SIZE: ::c_int = 188;
-pub const _SC_LEVEL1_DCACHE_ASSOC: ::c_int = 189;
-pub const _SC_LEVEL1_DCACHE_LINESIZE: ::c_int = 190;
-pub const _SC_LEVEL2_CACHE_SIZE: ::c_int = 191;
-pub const _SC_LEVEL2_CACHE_ASSOC: ::c_int = 192;
-pub const _SC_LEVEL2_CACHE_LINESIZE: ::c_int = 193;
-pub const _SC_LEVEL3_CACHE_SIZE: ::c_int = 194;
-pub const _SC_LEVEL3_CACHE_ASSOC: ::c_int = 195;
-pub const _SC_LEVEL3_CACHE_LINESIZE: ::c_int = 196;
-pub const _SC_LEVEL4_CACHE_SIZE: ::c_int = 197;
-pub const _SC_LEVEL4_CACHE_ASSOC: ::c_int = 198;
-pub const _SC_LEVEL4_CACHE_LINESIZE: ::c_int = 199;
-pub const O_ACCMODE: ::c_int = 3;
-pub const ST_RELATIME: ::c_ulong = 4096;
-pub const NI_MAXHOST: ::socklen_t = 1025;
-
-pub const ADFS_SUPER_MAGIC: ::c_long = 0x0000adf5;
-pub const AFFS_SUPER_MAGIC: ::c_long = 0x0000adff;
-pub const CODA_SUPER_MAGIC: ::c_long = 0x73757245;
-pub const CRAMFS_MAGIC: ::c_long = 0x28cd3d45;
-pub const EFS_SUPER_MAGIC: ::c_long = 0x00414a53;
-pub const EXT2_SUPER_MAGIC: ::c_long = 0x0000ef53;
-pub const EXT3_SUPER_MAGIC: ::c_long = 0x0000ef53;
-pub const EXT4_SUPER_MAGIC: ::c_long = 0x0000ef53;
-pub const HPFS_SUPER_MAGIC: ::c_long = 0xf995e849;
-pub const HUGETLBFS_MAGIC: ::c_long = 0x958458f6;
-pub const ISOFS_SUPER_MAGIC: ::c_long = 0x00009660;
-pub const JFFS2_SUPER_MAGIC: ::c_long = 0x000072b6;
-pub const MINIX_SUPER_MAGIC: ::c_long = 0x0000137f;
-pub const MINIX_SUPER_MAGIC2: ::c_long = 0x0000138f;
-pub const MINIX2_SUPER_MAGIC: ::c_long = 0x00002468;
-pub const MINIX2_SUPER_MAGIC2: ::c_long = 0x00002478;
-pub const MSDOS_SUPER_MAGIC: ::c_long = 0x00004d44;
-pub const NCP_SUPER_MAGIC: ::c_long = 0x0000564c;
-pub const NFS_SUPER_MAGIC: ::c_long = 0x00006969;
-pub const OPENPROM_SUPER_MAGIC: ::c_long = 0x00009fa1;
-pub const PROC_SUPER_MAGIC: ::c_long = 0x00009fa0;
-pub const QNX4_SUPER_MAGIC: ::c_long = 0x0000002f;
-pub const REISERFS_SUPER_MAGIC: ::c_long = 0x52654973;
-pub const SMB_SUPER_MAGIC: ::c_long = 0x0000517b;
-pub const TMPFS_MAGIC: ::c_long = 0x01021994;
-pub const USBDEVICE_SUPER_MAGIC: ::c_long = 0x00009fa2;
-
-pub const VEOF: usize = 4;
-
-pub const CPU_SETSIZE: ::c_int = 0x400;
-
-pub const PTRACE_TRACEME: ::c_uint = 0;
-pub const PTRACE_PEEKTEXT: ::c_uint = 1;
-pub const PTRACE_PEEKDATA: ::c_uint = 2;
-pub const PTRACE_PEEKUSER: ::c_uint = 3;
-pub const PTRACE_POKETEXT: ::c_uint = 4;
-pub const PTRACE_POKEDATA: ::c_uint = 5;
-pub const PTRACE_POKEUSER: ::c_uint = 6;
-pub const PTRACE_CONT: ::c_uint = 7;
-pub const PTRACE_KILL: ::c_uint = 8;
-pub const PTRACE_SINGLESTEP: ::c_uint = 9;
-pub const PTRACE_ATTACH: ::c_uint = 16;
-pub const PTRACE_SYSCALL: ::c_uint = 24;
-pub const PTRACE_SETOPTIONS: ::c_uint = 0x4200;
-pub const PTRACE_GETEVENTMSG: ::c_uint = 0x4201;
-pub const PTRACE_GETSIGINFO: ::c_uint = 0x4202;
-pub const PTRACE_SETSIGINFO: ::c_uint = 0x4203;
-pub const PTRACE_GETREGSET: ::c_uint = 0x4204;
-pub const PTRACE_SETREGSET: ::c_uint = 0x4205;
-pub const PTRACE_SEIZE: ::c_uint = 0x4206;
-pub const PTRACE_INTERRUPT: ::c_uint = 0x4207;
-pub const PTRACE_LISTEN: ::c_uint = 0x4208;
-pub const PTRACE_PEEKSIGINFO: ::c_uint = 0x4209;
-
-pub const EPOLLWAKEUP: ::c_int = 0x20000000;
-
-pub const MAP_HUGETLB: ::c_int = 0x040000;
-
-pub const SEEK_DATA: ::c_int = 3;
-pub const SEEK_HOLE: ::c_int = 4;
-
-pub const TCSANOW: ::c_int = 0;
-pub const TCSADRAIN: ::c_int = 1;
-pub const TCSAFLUSH: ::c_int = 2;
-
-pub const TIOCLINUX: ::c_ulong = 0x541C;
-pub const TIOCGSERIAL: ::c_ulong = 0x541E;
-
-pub const RTLD_DEEPBIND: ::c_int = 0x8;
-pub const RTLD_GLOBAL: ::c_int = 0x100;
-pub const RTLD_NOLOAD: ::c_int = 0x4;
-
-pub const LINUX_REBOOT_MAGIC1: ::c_int = 0xfee1dead;
-pub const LINUX_REBOOT_MAGIC2: ::c_int = 672274793;
-pub const LINUX_REBOOT_MAGIC2A: ::c_int = 85072278;
-pub const LINUX_REBOOT_MAGIC2B: ::c_int = 369367448;
-pub const LINUX_REBOOT_MAGIC2C: ::c_int = 537993216;
-
-pub const LINUX_REBOOT_CMD_RESTART: ::c_int = 0x01234567;
-pub const LINUX_REBOOT_CMD_HALT: ::c_int = 0xCDEF0123;
-pub const LINUX_REBOOT_CMD_CAD_ON: ::c_int = 0x89ABCDEF;
-pub const LINUX_REBOOT_CMD_CAD_OFF: ::c_int = 0x00000000;
-pub const LINUX_REBOOT_CMD_POWER_OFF: ::c_int = 0x4321FEDC;
-pub const LINUX_REBOOT_CMD_RESTART2: ::c_int = 0xA1B2C3D4;
-pub const LINUX_REBOOT_CMD_SW_SUSPEND: ::c_int = 0xD000FCE2;
-pub const LINUX_REBOOT_CMD_KEXEC: ::c_int = 0x45584543;
-
-// linux/rtnetlink.h
-pub const TCA_PAD: ::c_ushort = 9;
-pub const TCA_DUMP_INVISIBLE: ::c_ushort = 10;
-pub const TCA_CHAIN: ::c_ushort = 11;
-pub const TCA_HW_OFFLOAD: ::c_ushort = 12;
-
-pub const RTM_F_LOOKUP_TABLE: ::c_uint = 0x1000;
-pub const RTM_F_FIB_MATCH: ::c_uint = 0x2000;
-
-pub const RTA_VIA: ::c_ushort = 18;
-pub const RTA_NEWDST: ::c_ushort = 19;
-pub const RTA_PREF: ::c_ushort = 20;
-pub const RTA_ENCAP_TYPE: ::c_ushort = 21;
-pub const RTA_ENCAP: ::c_ushort = 22;
-pub const RTA_EXPIRES: ::c_ushort = 23;
-pub const RTA_PAD: ::c_ushort = 24;
-pub const RTA_UID: ::c_ushort = 25;
-pub const RTA_TTL_PROPAGATE: ::c_ushort = 26;
-
-// linux/neighbor.h
-pub const NTF_EXT_LEARNED: u8 = 0x10;
-pub const NTF_OFFLOADED: u8 = 0x20;
-
-pub const NDA_MASTER: ::c_ushort = 9;
-pub const NDA_LINK_NETNSID: ::c_ushort = 10;
-pub const NDA_SRC_VNI: ::c_ushort = 11;
-
-// linux/if_addr.h
-pub const IFA_FLAGS: ::c_ushort = 8;
-
-pub const IFA_F_MANAGETEMPADDR: u32 = 0x100;
-pub const IFA_F_NOPREFIXROUTE: u32 = 0x200;
-pub const IFA_F_MCAUTOJOIN: u32 = 0x400;
-pub const IFA_F_STABLE_PRIVACY: u32 = 0x800;
-
-pub const NETLINK_ROUTE: ::c_int = 0;
-pub const NETLINK_UNUSED: ::c_int = 1;
-pub const NETLINK_USERSOCK: ::c_int = 2;
-pub const NETLINK_FIREWALL: ::c_int = 3;
-pub const NETLINK_SOCK_DIAG: ::c_int = 4;
-pub const NETLINK_NFLOG: ::c_int = 5;
-pub const NETLINK_XFRM: ::c_int = 6;
-pub const NETLINK_SELINUX: ::c_int = 7;
-pub const NETLINK_ISCSI: ::c_int = 8;
-pub const NETLINK_AUDIT: ::c_int = 9;
-pub const NETLINK_FIB_LOOKUP: ::c_int = 10;
-pub const NETLINK_CONNECTOR: ::c_int = 11;
-pub const NETLINK_NETFILTER: ::c_int = 12;
-pub const NETLINK_IP6_FW: ::c_int = 13;
-pub const NETLINK_DNRTMSG: ::c_int = 14;
-pub const NETLINK_KOBJECT_UEVENT: ::c_int = 15;
-pub const NETLINK_GENERIC: ::c_int = 16;
-pub const NETLINK_SCSITRANSPORT: ::c_int = 18;
-pub const NETLINK_ECRYPTFS: ::c_int = 19;
-pub const NETLINK_RDMA: ::c_int = 20;
-pub const NETLINK_CRYPTO: ::c_int = 21;
-pub const NETLINK_INET_DIAG: ::c_int = NETLINK_SOCK_DIAG;
-
-pub const MAX_LINKS: ::c_int = 32;
-
-pub const NLM_F_REQUEST: ::c_int = 1;
-pub const NLM_F_MULTI: ::c_int = 2;
-pub const NLM_F_ACK: ::c_int = 4;
-pub const NLM_F_ECHO: ::c_int = 8;
-pub const NLM_F_DUMP_INTR: ::c_int = 16;
-pub const NLM_F_DUMP_FILTERED: ::c_int = 32;
-
-pub const NLM_F_ROOT: ::c_int = 0x100;
-pub const NLM_F_MATCH: ::c_int = 0x200;
-pub const NLM_F_ATOMIC: ::c_int = 0x400;
-pub const NLM_F_DUMP: ::c_int = NLM_F_ROOT | NLM_F_MATCH;
-
-pub const NLM_F_REPLACE: ::c_int = 0x100;
-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 NETLINK_ADD_MEMBERSHIP: ::c_int = 1;
-pub const NETLINK_DROP_MEMBERSHIP: ::c_int = 2;
-pub const NETLINK_PKTINFO: ::c_int = 3;
-pub const NETLINK_BROADCAST_ERROR: ::c_int = 4;
-pub const NETLINK_NO_ENOBUFS: ::c_int = 5;
-pub const NETLINK_RX_RING: ::c_int = 6;
-pub const NETLINK_TX_RING: ::c_int = 7;
-pub const NETLINK_LISTEN_ALL_NSID: ::c_int = 8;
-pub const NETLINK_LIST_MEMBERSHIPS: ::c_int = 9;
-pub const NETLINK_CAP_ACK: ::c_int = 10;
-
-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;
-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 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
-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 = 25;
-
-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)]
-#[deprecated(
- since = "0.2.55",
- note = "If you are using this report to: \
- https://github.com/rust-lang/libc/issues/665"
-)]
-pub const AF_MAX: ::c_int = 45;
-#[doc(hidden)]
-#[deprecated(
- since = "0.2.55",
- note = "If you are using this report to: \
- https://github.com/rust-lang/libc/issues/665"
-)]
-#[allow(deprecated)]
-pub const PF_MAX: ::c_int = AF_MAX;
-
-pub const AT_STATX_SYNC_TYPE: ::c_int = 0x6000;
-pub const AT_STATX_SYNC_AS_STAT: ::c_int = 0x0000;
-pub const AT_STATX_FORCE_SYNC: ::c_int = 0x2000;
-pub const AT_STATX_DONT_SYNC: ::c_int = 0x4000;
-pub const STATX_TYPE: ::c_uint = 0x0001;
-pub const STATX_MODE: ::c_uint = 0x0002;
-pub const STATX_NLINK: ::c_uint = 0x0004;
-pub const STATX_UID: ::c_uint = 0x0008;
-pub const STATX_GID: ::c_uint = 0x0010;
-pub const STATX_ATIME: ::c_uint = 0x0020;
-pub const STATX_MTIME: ::c_uint = 0x0040;
-pub const STATX_CTIME: ::c_uint = 0x0080;
-pub const STATX_INO: ::c_uint = 0x0100;
-pub const STATX_SIZE: ::c_uint = 0x0200;
-pub const STATX_BLOCKS: ::c_uint = 0x0400;
-pub const STATX_BASIC_STATS: ::c_uint = 0x07ff;
-pub const STATX_BTIME: ::c_uint = 0x0800;
-pub const STATX_ALL: ::c_uint = 0x0fff;
-pub const STATX__RESERVED: ::c_int = 0x80000000;
-pub const STATX_ATTR_COMPRESSED: ::c_int = 0x0004;
-pub const STATX_ATTR_IMMUTABLE: ::c_int = 0x0010;
-pub const STATX_ATTR_APPEND: ::c_int = 0x0020;
-pub const STATX_ATTR_NODUMP: ::c_int = 0x0040;
-pub const STATX_ATTR_ENCRYPTED: ::c_int = 0x0800;
-pub const STATX_ATTR_AUTOMOUNT: ::c_int = 0x1000;
-
-cfg_if! {
- if #[cfg(any(target_arch = "arm", target_arch = "x86",
- target_arch = "x86_64"))] {
- pub const PTHREAD_STACK_MIN: ::size_t = 16384;
- } else if #[cfg(target_arch = "sparc64")] {
- pub const PTHREAD_STACK_MIN: ::size_t = 0x6000;
- } else {
- 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 sendmmsg(sockfd: ::c_int, msgvec: *mut ::mmsghdr, vlen: ::c_uint,
- flags: ::c_int) -> ::c_int;
- pub fn recvmmsg(sockfd: ::c_int, msgvec: *mut ::mmsghdr, vlen: ::c_uint,
- flags: ::c_int, timeout: *mut ::timespec) -> ::c_int;
-
- pub fn getrlimit64(resource: ::__rlimit_resource_t,
- rlim: *mut ::rlimit64) -> ::c_int;
- pub fn setrlimit64(resource: ::__rlimit_resource_t,
- rlim: *const ::rlimit64) -> ::c_int;
- pub fn getrlimit(resource: ::__rlimit_resource_t,
- rlim: *mut ::rlimit) -> ::c_int;
- pub fn setrlimit(resource: ::__rlimit_resource_t,
- rlim: *const ::rlimit) -> ::c_int;
- pub fn prlimit(pid: ::pid_t,
- resource: ::__rlimit_resource_t, new_limit: *const ::rlimit,
- old_limit: *mut ::rlimit) -> ::c_int;
- pub fn prlimit64(pid: ::pid_t,
- resource: ::__rlimit_resource_t,
- new_limit: *const ::rlimit64,
- old_limit: *mut ::rlimit64) -> ::c_int;
- pub fn utmpxname(file: *const ::c_char) -> ::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 pututxline(ut: *const utmpx) -> *mut utmpx;
- pub fn setutxent();
- pub fn endutxent();
- pub fn getpt() -> ::c_int;
- pub fn mallopt(param: ::c_int, value: ::c_int) -> ::c_int;
- pub fn gettimeofday(tp: *mut ::timeval,
- tz: *mut ::timezone) -> ::c_int;
- pub fn statx(dirfd: ::c_int, pathname: *const c_char, flags: ::c_int,
- mask: ::c_uint, statxbuf: *mut statx) -> ::c_int;
-}
-
-#[link(name = "util")]
-extern {
- pub fn ioctl(fd: ::c_int, request: ::c_ulong, ...) -> ::c_int;
- pub fn backtrace(buf: *mut *mut ::c_void,
- sz: ::c_int) -> ::c_int;
- pub fn glob64(pattern: *const ::c_char,
- flags: ::c_int,
- errfunc: ::Option<extern fn(epath: *const ::c_char,
- errno: ::c_int)
- -> ::c_int>,
- pglob: *mut glob64_t) -> ::c_int;
- pub fn globfree64(pglob: *mut glob64_t);
- pub fn ptrace(request: ::c_uint, ...) -> ::c_long;
- pub fn pthread_attr_getaffinity_np(attr: *const ::pthread_attr_t,
- cpusetsize: ::size_t,
- cpuset: *mut ::cpu_set_t) -> ::c_int;
- pub fn pthread_attr_setaffinity_np(attr: *mut ::pthread_attr_t,
- cpusetsize: ::size_t,
- cpuset: *const ::cpu_set_t) -> ::c_int;
- pub fn getpriority(which: ::__priority_which_t, who: ::id_t) -> ::c_int;
- pub fn setpriority(which: ::__priority_which_t, 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 pthread_rwlockattr_getkind_np(attr: *const ::pthread_rwlockattr_t,
- val: *mut ::c_int) -> ::c_int;
- 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! {
- if #[cfg(any(target_arch = "x86",
- target_arch = "arm",
- target_arch = "powerpc"))] {
- mod b32;
- pub use self::b32::*;
- } else if #[cfg(any(target_arch = "x86_64",
- target_arch = "aarch64",
- target_arch = "powerpc64",
- target_arch = "sparc64"))] {
- mod b64;
- pub use self::b64::*;
- } else {
- // Unknown target_arch
- }
-}
-
-cfg_if! {
- if #[cfg(libc_align)] {
- mod align;
- pub use self::align::*;
- } else {
- mod no_align;
- pub use self::no_align::*;
- }
-}
diff --git a/libc/src/unix/notbsd/linux/other/no_align.rs b/libc/src/unix/notbsd/linux/other/no_align.rs
deleted file mode 100644
index e32bf67..0000000
--- a/libc/src/unix/notbsd/linux/other/no_align.rs
+++ /dev/null
@@ -1,10 +0,0 @@
-s! {
- // FIXME this is actually a union
- pub struct sem_t {
- #[cfg(target_pointer_width = "32")]
- __size: [::c_char; 16],
- #[cfg(target_pointer_width = "64")]
- __size: [::c_char; 32],
- __align: [::c_long; 0],
- }
-}
diff --git a/libc/src/unix/notbsd/linux/s390x/align.rs b/libc/src/unix/notbsd/linux/s390x/align.rs
deleted file mode 100644
index 21e2190..0000000
--- a/libc/src/unix/notbsd/linux/s390x/align.rs
+++ /dev/null
@@ -1,10 +0,0 @@
-s! {
- // FIXME this is actually a union
- #[cfg_attr(target_pointer_width = "32",
- repr(align(4)))]
- #[cfg_attr(target_pointer_width = "64",
- repr(align(8)))]
- pub struct sem_t {
- __size: [::c_char; 32],
- }
-}
diff --git a/libc/src/unix/notbsd/linux/s390x/mod.rs b/libc/src/unix/notbsd/linux/s390x/mod.rs
deleted file mode 100644
index 5572094..0000000
--- a/libc/src/unix/notbsd/linux/s390x/mod.rs
+++ /dev/null
@@ -1,1403 +0,0 @@
-use ::pthread_mutex_t;
-
-pub type __rlimit_resource_t = ::c_uint;
-pub type pthread_t = c_ulong;
-pub type blkcnt_t = i64;
-pub type blksize_t = i64;
-pub type c_char = u8;
-pub type c_long = i64;
-pub type c_ulong = u64;
-pub type fsblkcnt_t = u64;
-pub type fsfilcnt_t = u64;
-pub type ino_t = u64;
-pub type nlink_t = u64;
-pub type off_t = i64;
-pub type rlim_t = u64;
-pub type suseconds_t = i64;
-pub type time_t = i64;
-pub type wchar_t = i32;
-pub type greg_t = u64;
-pub type clock_t = i64;
-pub type shmatt_t = ::c_ulong;
-pub type msgqnum_t = ::c_ulong;
-pub type msglen_t = ::c_ulong;
-pub type __fsword_t = ::c_long;
-pub type __priority_which_t = ::c_uint;
-pub type __u64 = u64;
-
-s! {
- pub struct aiocb {
- pub aio_fildes: ::c_int,
- pub aio_lio_opcode: ::c_int,
- pub aio_reqprio: ::c_int,
- pub aio_buf: *mut ::c_void,
- pub aio_nbytes: ::size_t,
- pub aio_sigevent: ::sigevent,
- __next_prio: *mut aiocb,
- __abs_prio: ::c_int,
- __policy: ::c_int,
- __error_code: ::c_int,
- __return_value: ::ssize_t,
- pub aio_offset: off_t,
- #[cfg(target_pointer_width = "32")]
- __unused1: [::c_char; 4],
- __glibc_reserved: [::c_char; 32]
- }
-
- 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,
- st_pad0: ::c_int,
- 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,
- __glibc_reserved: [::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,
- st_pad0: ::c_int,
- 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: ::blkcnt64_t,
- __glibc_reserved: [::c_long; 3],
- }
-
- pub struct pthread_attr_t {
- __size: [::c_ulong; 7]
- }
-
- pub struct sigaction {
- pub sa_sigaction: ::sighandler_t,
- __glibc_reserved0: ::c_int,
- pub sa_flags: ::c_int,
- pub sa_restorer: ::Option<extern fn()>,
- pub sa_mask: sigset_t,
- }
-
- pub struct stack_t {
- pub ss_sp: *mut ::c_void,
- pub ss_flags: ::c_int,
- pub ss_size: ::size_t,
- }
-
- pub struct sigset_t {
- __size: [::c_ulong; 16],
- }
-
- pub struct siginfo_t {
- pub si_signo: ::c_int,
- pub si_errno: ::c_int,
- pub si_code: ::c_int,
- _pad: ::c_int,
- _pad2: [::c_long; 14],
- }
-
- pub struct ipc_perm {
- pub __key: ::key_t,
- pub uid: ::uid_t,
- pub gid: ::gid_t,
- pub cuid: ::uid_t,
- pub cgid: ::gid_t,
- pub mode: ::mode_t,
- pub __seq: ::c_ushort,
- __pad1: ::c_ushort,
- __unused1: ::c_ulong,
- __unused2: ::c_ulong
- }
-
- pub struct shmid_ds {
- pub shm_perm: ::ipc_perm,
- pub shm_segsz: ::size_t,
- pub shm_atime: ::time_t,
- pub shm_dtime: ::time_t,
- pub shm_ctime: ::time_t,
- pub shm_cpid: ::pid_t,
- pub shm_lpid: ::pid_t,
- pub shm_nattch: ::shmatt_t,
- __unused4: ::c_ulong,
- __unused5: ::c_ulong
- }
-
- pub struct statfs {
- pub f_type: ::c_uint,
- pub f_bsize: ::c_uint,
- 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_uint,
- pub f_frsize: ::c_uint,
- pub f_flags: ::c_uint,
- 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,
- pub msg_iov: *mut ::iovec,
- pub msg_iovlen: ::size_t,
- pub msg_control: *mut ::c_void,
- pub msg_controllen: ::size_t,
- pub msg_flags: ::c_int,
- }
-
- pub struct cmsghdr {
- pub cmsg_len: ::size_t,
- pub cmsg_level: ::c_int,
- pub cmsg_type: ::c_int,
- }
-
- pub struct termios {
- pub c_iflag: ::tcflag_t,
- pub c_oflag: ::tcflag_t,
- pub c_cflag: ::tcflag_t,
- pub c_lflag: ::tcflag_t,
- pub c_line: ::cc_t,
- pub c_cc: [::cc_t; ::NCCS],
- pub c_ispeed: ::speed_t,
- pub c_ospeed: ::speed_t,
- }
-
- 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_line: ::cc_t,
- pub c_cc: [::cc_t; 19],
- pub c_ispeed: ::speed_t,
- pub c_ospeed: ::speed_t,
- }
-
- pub struct sysinfo {
- pub uptime: ::c_long,
- pub loads: [::c_ulong; 3],
- pub totalram: ::c_ulong,
- pub freeram: ::c_ulong,
- pub sharedram: ::c_ulong,
- pub bufferram: ::c_ulong,
- pub totalswap: ::c_ulong,
- pub freeswap: ::c_ulong,
- pub procs: ::c_ushort,
- pub pad: ::c_ushort,
- pub totalhigh: ::c_ulong,
- pub freehigh: ::c_ulong,
- pub mem_unit: ::c_uint,
- pub _f: [::c_char; 0],
- }
-
- pub struct glob64_t {
- pub gl_pathc: ::size_t,
- pub gl_pathv: *mut *mut ::c_char,
- pub gl_offs: ::size_t,
- pub gl_flags: ::c_int,
-
- __unused1: *mut ::c_void,
- __unused2: *mut ::c_void,
- __unused3: *mut ::c_void,
- __unused4: *mut ::c_void,
- __unused5: *mut ::c_void,
- }
-
- pub struct flock {
- pub l_type: ::c_short,
- pub l_whence: ::c_short,
- pub l_start: ::off_t,
- pub l_len: ::off_t,
- pub l_pid: ::pid_t,
- }
-
- pub struct __psw_t {
- pub mask: u64,
- pub addr: u64,
- }
-
- pub struct fpregset_t {
- pub fpc: u32,
- __pad: u32,
- pub fprs: [fpreg_t; 16],
- }
-
- pub struct mcontext_t {
- pub psw: __psw_t,
- pub gregs: [u64; 16],
- pub aregs: [u32; 16],
- pub fpregs: fpregset_t,
- }
-
- pub struct ucontext_t {
- pub uc_flags: ::c_ulong,
- pub uc_link: *mut ucontext_t,
- pub uc_stack: ::stack_t,
- pub uc_mcontext: mcontext_t,
- pub uc_sigmask: ::sigset_t,
- }
-
- pub struct msqid_ds {
- pub msg_perm: ::ipc_perm,
- pub msg_stime: ::time_t,
- pub msg_rtime: ::time_t,
- 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,
- __glibc_reserved4: ::c_ulong,
- __glibc_reserved5: ::c_ulong,
- }
-
- pub struct statfs64 {
- pub f_type: ::c_uint,
- pub f_bsize: ::c_uint,
- pub f_blocks: u64,
- pub f_bfree: u64,
- pub f_bavail: u64,
- pub f_files: u64,
- pub f_ffree: u64,
- pub f_fsid: ::fsid_t,
- pub f_namelen: ::c_uint,
- pub f_frsize: ::c_uint,
- pub f_flags: ::c_uint,
- pub f_spare: [::c_uint; 4],
- }
-
- pub struct statvfs64 {
- pub f_bsize: ::c_ulong,
- pub f_frsize: ::c_ulong,
- pub f_blocks: u64,
- pub f_bfree: u64,
- pub f_bavail: u64,
- pub f_files: u64,
- pub f_ffree: u64,
- pub f_favail: u64,
- pub f_fsid: ::c_ulong,
- pub f_flag: ::c_ulong,
- pub f_namemax: ::c_ulong,
- __f_spare: [::c_int; 6],
- }
-}
-
-s_no_extra_traits!{
- // FIXME: This is actually a union.
- pub struct fpreg_t {
- pub d: ::c_double,
- // f: ::c_float,
- }
-}
-
-cfg_if! {
- if #[cfg(feature = "extra_traits")] {
- impl PartialEq for fpreg_t {
- fn eq(&self, other: &fpreg_t) -> bool {
- self.d == other.d
- }
- }
-
- impl Eq for fpreg_t {}
-
- impl ::fmt::Debug for fpreg_t {
- fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
- f.debug_struct("fpreg_t")
- .field("d", &self.d)
- .finish()
- }
- }
-
- impl ::hash::Hash for fpreg_t {
- fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
- let d: u64 = unsafe { ::mem::transmute(self.d) };
- d.hash(state);
- }
- }
- }
-}
-
-pub const MADV_SOFT_OFFLINE: ::c_int = 101;
-pub const MS_RMT_MASK: ::c_ulong = 0x02800051;
-
-pub const SFD_CLOEXEC: ::c_int = 0x080000;
-
-pub const NCCS: usize = 32;
-
-pub const O_TRUNC: ::c_int = 512;
-pub const O_LARGEFILE: ::c_int = 0;
-pub const O_NOATIME: ::c_int = 0o1000000;
-pub const O_CLOEXEC: ::c_int = 0x80000;
-pub const O_PATH: ::c_int = 0o10000000;
-pub const O_TMPFILE: ::c_int = 0o20000000 | O_DIRECTORY;
-
-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 EDOTDOT: ::c_int = 73;
-
-pub const SA_NODEFER: ::c_int = 0x40000000;
-pub const SA_RESETHAND: ::c_int = 0x80000000;
-pub const SA_RESTART: ::c_int = 0x10000000;
-pub const SA_NOCLDSTOP: ::c_int = 0x00000001;
-
-pub const EPOLL_CLOEXEC: ::c_int = 0x80000;
-
-pub const EFD_CLOEXEC: ::c_int = 0x80000;
-
-pub const POSIX_FADV_DONTNEED: ::c_int = 6;
-pub const POSIX_FADV_NOREUSE: ::c_int = 7;
-
-pub const __SIZEOF_PTHREAD_CONDATTR_T: usize = 4;
-pub const __SIZEOF_PTHREAD_MUTEXATTR_T: usize = 4;
-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;
-pub const ECONNREFUSED: ::c_int = 111;
-pub const ECONNRESET: ::c_int = 104;
-pub const EDEADLK: ::c_int = 35;
-pub const ENOSYS: ::c_int = 38;
-pub const ENOTCONN: ::c_int = 107;
-pub const ETIMEDOUT: ::c_int = 110;
-pub const FIOCLEX: ::c_ulong = 0x5451;
-pub const FIONBIO: ::c_ulong = 0x5421;
-pub const MAP_ANON: ::c_int = 0x20;
-pub const O_ACCMODE: ::c_int = 3;
-pub const O_APPEND: ::c_int = 1024;
-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;
-pub const SA_SIGINFO: ::c_int = 4;
-pub const SIGBUS: ::c_int = 7;
-pub const SIGSTKSZ: ::size_t = 0x2000;
-pub const MINSIGSTKSZ: ::size_t = 2048;
-pub const SIG_SETMASK: ::c_int = 2;
-pub const SOCK_DGRAM: ::c_int = 2;
-pub const SOCK_STREAM: ::c_int = 1;
-pub const SOL_SOCKET: ::c_int = 1;
-pub const SO_BROADCAST: ::c_int = 6;
-pub const SO_ERROR: ::c_int = 4;
-pub const SO_RCVTIMEO: ::c_int = 20;
-pub const SO_REUSEADDR: ::c_int = 2;
-pub const SO_SNDTIMEO: ::c_int = 21;
-pub const SO_BINDTODEVICE: ::c_int = 25;
-pub const SO_TIMESTAMP: ::c_int = 29;
-pub const SO_MARK: ::c_int = 36;
-pub const SO_PROTOCOL: ::c_int = 38;
-pub const SO_DOMAIN: ::c_int = 39;
-pub const SO_RXQ_OVFL: ::c_int = 40;
-pub const SO_PEEK_OFF: ::c_int = 42;
-pub const SO_BUSY_POLL: ::c_int = 46;
-
-pub const 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_RTTIME: ::c_int = 15;
-pub const RLIMIT_NLIMITS: ::c_int = 16;
-
-pub const O_NOCTTY: ::c_int = 256;
-pub const O_SYNC: ::c_int = 1052672;
-pub const O_RSYNC: ::c_int = 1052672;
-pub const O_DSYNC: ::c_int = 4096;
-pub const O_FSYNC: ::c_int = 0x101000;
-pub const O_DIRECT: ::c_int = 0x4000;
-pub const O_DIRECTORY: ::c_int = 0x10000;
-pub const O_NOFOLLOW: ::c_int = 0x20000;
-
-pub const SOCK_NONBLOCK: ::c_int = O_NONBLOCK;
-
-pub const LC_PAPER: ::c_int = 7;
-pub const LC_NAME: ::c_int = 8;
-pub const LC_ADDRESS: ::c_int = 9;
-pub const LC_TELEPHONE: ::c_int = 10;
-pub const LC_MEASUREMENT: ::c_int = 11;
-pub const LC_IDENTIFICATION: ::c_int = 12;
-pub const LC_PAPER_MASK: ::c_int = (1 << LC_PAPER);
-pub const LC_NAME_MASK: ::c_int = (1 << LC_NAME);
-pub const LC_ADDRESS_MASK: ::c_int = (1 << LC_ADDRESS);
-pub const LC_TELEPHONE_MASK: ::c_int = (1 << LC_TELEPHONE);
-pub const LC_MEASUREMENT_MASK: ::c_int = (1 << LC_MEASUREMENT);
-pub const LC_IDENTIFICATION_MASK: ::c_int = (1 << LC_IDENTIFICATION);
-pub const LC_ALL_MASK: ::c_int = ::LC_CTYPE_MASK
- | ::LC_NUMERIC_MASK
- | ::LC_TIME_MASK
- | ::LC_COLLATE_MASK
- | ::LC_MONETARY_MASK
- | ::LC_MESSAGES_MASK
- | LC_PAPER_MASK
- | LC_NAME_MASK
- | LC_ADDRESS_MASK
- | LC_TELEPHONE_MASK
- | LC_MEASUREMENT_MASK
- | LC_IDENTIFICATION_MASK;
-
-pub const MAP_ANONYMOUS: ::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 = 0x02000;
-pub const MAP_NORESERVE: ::c_int = 0x04000;
-pub const MAP_POPULATE: ::c_int = 0x08000;
-pub const MAP_NONBLOCK: ::c_int = 0x010000;
-pub const MAP_STACK: ::c_int = 0x020000;
-pub const MAP_SHARED_VALIDATE: ::c_int = 0x3;
-pub const MAP_FIXED_NOREPLACE: ::c_int = 0x100000;
-
-pub const EDEADLOCK: ::c_int = 35;
-pub const ENAMETOOLONG: ::c_int = 36;
-pub const ENOLCK: ::c_int = 37;
-pub const ENOTEMPTY: ::c_int = 39;
-pub const ELOOP: ::c_int = 40;
-pub const ENOMSG: ::c_int = 42;
-pub const EIDRM: ::c_int = 43;
-pub const ECHRNG: ::c_int = 44;
-pub const EL2NSYNC: ::c_int = 45;
-pub const EL3HLT: ::c_int = 46;
-pub const EL3RST: ::c_int = 47;
-pub const ELNRNG: ::c_int = 48;
-pub const EUNATCH: ::c_int = 49;
-pub const ENOCSI: ::c_int = 50;
-pub const EL2HLT: ::c_int = 51;
-pub const EBADE: ::c_int = 52;
-pub const EBADR: ::c_int = 53;
-pub const EXFULL: ::c_int = 54;
-pub const ENOANO: ::c_int = 55;
-pub const EBADRQC: ::c_int = 56;
-pub const EBADSLT: ::c_int = 57;
-pub const EMULTIHOP: ::c_int = 72;
-pub const EOVERFLOW: ::c_int = 75;
-pub const ENOTUNIQ: ::c_int = 76;
-pub const EBADFD: ::c_int = 77;
-pub const EBADMSG: ::c_int = 74;
-pub const EREMCHG: ::c_int = 78;
-pub const ELIBACC: ::c_int = 79;
-pub const ELIBBAD: ::c_int = 80;
-pub const ELIBSCN: ::c_int = 81;
-pub const ELIBMAX: ::c_int = 82;
-pub const ELIBEXEC: ::c_int = 83;
-pub const EILSEQ: ::c_int = 84;
-pub const ERESTART: ::c_int = 85;
-pub const ESTRPIPE: ::c_int = 86;
-pub const EUSERS: ::c_int = 87;
-pub const ENOTSOCK: ::c_int = 88;
-pub const EDESTADDRREQ: ::c_int = 89;
-pub const EMSGSIZE: ::c_int = 90;
-pub const EPROTOTYPE: ::c_int = 91;
-pub const ENOPROTOOPT: ::c_int = 92;
-pub const EPROTONOSUPPORT: ::c_int = 93;
-pub const ESOCKTNOSUPPORT: ::c_int = 94;
-pub const EOPNOTSUPP: ::c_int = 95;
-pub const ENOTSUP: ::c_int = EOPNOTSUPP;
-pub const EPFNOSUPPORT: ::c_int = 96;
-pub const EAFNOSUPPORT: ::c_int = 97;
-pub const ENETDOWN: ::c_int = 100;
-pub const ENETUNREACH: ::c_int = 101;
-pub const ENETRESET: ::c_int = 102;
-pub const ENOBUFS: ::c_int = 105;
-pub const EISCONN: ::c_int = 106;
-pub const ESHUTDOWN: ::c_int = 108;
-pub const ETOOMANYREFS: ::c_int = 109;
-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 EHWPOISON: ::c_int = 133;
-pub const ERFKILL: ::c_int = 132;
-
-pub const SOCK_SEQPACKET: ::c_int = 5;
-
-pub const SO_TYPE: ::c_int = 3;
-pub const SO_DONTROUTE: ::c_int = 5;
-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_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_ACCEPTCONN: ::c_int = 30;
-pub const SO_SNDBUFFORCE: ::c_int = 32;
-pub const SO_RCVBUFFORCE: ::c_int = 33;
-
-pub const TCP_COOKIE_TRANSACTIONS: ::c_int = 15;
-pub const TCP_THIN_LINEAR_TIMEOUTS: ::c_int = 16;
-pub const TCP_THIN_DUPACK: ::c_int = 17;
-pub const TCP_USER_TIMEOUT: ::c_int = 18;
-pub const TCP_REPAIR: ::c_int = 19;
-pub const TCP_REPAIR_QUEUE: ::c_int = 20;
-pub const TCP_QUEUE_SEQ: ::c_int = 21;
-pub const TCP_REPAIR_OPTIONS: ::c_int = 22;
-pub const TCP_FASTOPEN: ::c_int = 23;
-pub const TCP_TIMESTAMP: ::c_int = 24;
-
-pub const SIGCHLD: ::c_int = 17;
-pub const SIGUSR1: ::c_int = 10;
-pub const SIGUSR2: ::c_int = 12;
-pub const SIGCONT: ::c_int = 18;
-pub const SIGSTOP: ::c_int = 19;
-pub const SIGTSTP: ::c_int = 20;
-pub const SIGURG: ::c_int = 23;
-pub const SIGIO: ::c_int = 29;
-pub const SIGSYS: ::c_int = 31;
-pub const SIGSTKFLT: ::c_int = 16;
-#[deprecated(
- since = "0.2.55",
- note = "Use SIGSYS instead"
-)]
-pub const SIGUNUSED: ::c_int = 31;
-pub const 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 SIGPOLL: ::c_int = 29;
-pub const SIGPWR: ::c_int = 30;
-pub const SIG_BLOCK: ::c_int = 0x000000;
-pub const SIG_UNBLOCK: ::c_int = 0x01;
-
-pub const BUFSIZ: ::c_uint = 8192;
-pub const TMP_MAX: ::c_uint = 238328;
-pub const FOPEN_MAX: ::c_uint = 16;
-pub const POSIX_MADV_DONTNEED: ::c_int = 4;
-pub const _SC_EQUIV_CLASS_MAX: ::c_int = 41;
-pub const _SC_CHARCLASS_NAME_MAX: ::c_int = 45;
-pub const _SC_PII: ::c_int = 53;
-pub const _SC_PII_XTI: ::c_int = 54;
-pub const _SC_PII_SOCKET: ::c_int = 55;
-pub const _SC_PII_INTERNET: ::c_int = 56;
-pub const _SC_PII_OSI: ::c_int = 57;
-pub const _SC_POLL: ::c_int = 58;
-pub const _SC_SELECT: ::c_int = 59;
-pub const _SC_PII_INTERNET_STREAM: ::c_int = 61;
-pub const _SC_PII_INTERNET_DGRAM: ::c_int = 62;
-pub const _SC_PII_OSI_COTS: ::c_int = 63;
-pub const _SC_PII_OSI_CLTS: ::c_int = 64;
-pub const _SC_PII_OSI_M: ::c_int = 65;
-pub const _SC_T_IOV_MAX: ::c_int = 66;
-pub const _SC_2_C_VERSION: ::c_int = 96;
-pub const _SC_CHAR_BIT: ::c_int = 101;
-pub const _SC_CHAR_MAX: ::c_int = 102;
-pub const _SC_CHAR_MIN: ::c_int = 103;
-pub const _SC_INT_MAX: ::c_int = 104;
-pub const _SC_INT_MIN: ::c_int = 105;
-pub const _SC_LONG_BIT: ::c_int = 106;
-pub const _SC_WORD_BIT: ::c_int = 107;
-pub const _SC_MB_LEN_MAX: ::c_int = 108;
-pub const _SC_SSIZE_MAX: ::c_int = 110;
-pub const _SC_SCHAR_MAX: ::c_int = 111;
-pub const _SC_SCHAR_MIN: ::c_int = 112;
-pub const _SC_SHRT_MAX: ::c_int = 113;
-pub const _SC_SHRT_MIN: ::c_int = 114;
-pub const _SC_UCHAR_MAX: ::c_int = 115;
-pub const _SC_UINT_MAX: ::c_int = 116;
-pub const _SC_ULONG_MAX: ::c_int = 117;
-pub const _SC_USHRT_MAX: ::c_int = 118;
-pub const _SC_NL_ARGMAX: ::c_int = 119;
-pub const _SC_NL_LANGMAX: ::c_int = 120;
-pub const _SC_NL_MSGMAX: ::c_int = 121;
-pub const _SC_NL_NMAX: ::c_int = 122;
-pub const _SC_NL_SETMAX: ::c_int = 123;
-pub const _SC_NL_TEXTMAX: ::c_int = 124;
-pub const _SC_BASE: ::c_int = 134;
-pub const _SC_C_LANG_SUPPORT: ::c_int = 135;
-pub const _SC_C_LANG_SUPPORT_R: ::c_int = 136;
-pub const _SC_DEVICE_IO: ::c_int = 140;
-pub const _SC_DEVICE_SPECIFIC: ::c_int = 141;
-pub const _SC_DEVICE_SPECIFIC_R: ::c_int = 142;
-pub const _SC_FD_MGMT: ::c_int = 143;
-pub const _SC_FIFO: ::c_int = 144;
-pub const _SC_PIPE: ::c_int = 145;
-pub const _SC_FILE_ATTRIBUTES: ::c_int = 146;
-pub const _SC_FILE_LOCKING: ::c_int = 147;
-pub const _SC_FILE_SYSTEM: ::c_int = 148;
-pub const _SC_MULTI_PROCESS: ::c_int = 150;
-pub const _SC_SINGLE_PROCESS: ::c_int = 151;
-pub const _SC_NETWORKING: ::c_int = 152;
-pub const _SC_REGEX_VERSION: ::c_int = 156;
-pub const _SC_SIGNALS: ::c_int = 158;
-pub const _SC_SYSTEM_DATABASE: ::c_int = 162;
-pub const _SC_SYSTEM_DATABASE_R: ::c_int = 163;
-pub const _SC_USER_GROUPS: ::c_int = 166;
-pub const _SC_USER_GROUPS_R: ::c_int = 167;
-pub const _SC_LEVEL1_ICACHE_SIZE: ::c_int = 185;
-pub const _SC_LEVEL1_ICACHE_ASSOC: ::c_int = 186;
-pub const _SC_LEVEL1_ICACHE_LINESIZE: ::c_int = 187;
-pub const _SC_LEVEL1_DCACHE_SIZE: ::c_int = 188;
-pub const _SC_LEVEL1_DCACHE_ASSOC: ::c_int = 189;
-pub const _SC_LEVEL1_DCACHE_LINESIZE: ::c_int = 190;
-pub const _SC_LEVEL2_CACHE_SIZE: ::c_int = 191;
-pub const _SC_LEVEL2_CACHE_ASSOC: ::c_int = 192;
-pub const _SC_LEVEL2_CACHE_LINESIZE: ::c_int = 193;
-pub const _SC_LEVEL3_CACHE_SIZE: ::c_int = 194;
-pub const _SC_LEVEL3_CACHE_ASSOC: ::c_int = 195;
-pub const _SC_LEVEL3_CACHE_LINESIZE: ::c_int = 196;
-pub const _SC_LEVEL4_CACHE_SIZE: ::c_int = 197;
-pub const _SC_LEVEL4_CACHE_ASSOC: ::c_int = 198;
-pub const _SC_LEVEL4_CACHE_LINESIZE: ::c_int = 199;
-pub const O_ASYNC: ::c_int = 0x2000;
-pub const O_NDELAY: ::c_int = 0x800;
-pub const ST_RELATIME: ::c_ulong = 4096;
-pub const NI_MAXHOST: ::socklen_t = 1025;
-
-pub const ADFS_SUPER_MAGIC: ::c_int = 0x0000adf5;
-pub const AFFS_SUPER_MAGIC: ::c_int = 0x0000adff;
-pub const CODA_SUPER_MAGIC: ::c_int = 0x73757245;
-pub const CRAMFS_MAGIC: ::c_int = 0x28cd3d45;
-pub const EFS_SUPER_MAGIC: ::c_int = 0x00414a53;
-pub const EXT2_SUPER_MAGIC: ::c_int = 0x0000ef53;
-pub const EXT3_SUPER_MAGIC: ::c_int = 0x0000ef53;
-pub const EXT4_SUPER_MAGIC: ::c_int = 0x0000ef53;
-pub const HPFS_SUPER_MAGIC: ::c_int = 0xf995e849;
-pub const HUGETLBFS_MAGIC: ::c_int = 0x958458f6;
-pub const ISOFS_SUPER_MAGIC: ::c_int = 0x00009660;
-pub const JFFS2_SUPER_MAGIC: ::c_int = 0x000072b6;
-pub const MINIX_SUPER_MAGIC: ::c_int = 0x0000137f;
-pub const MINIX_SUPER_MAGIC2: ::c_int = 0x0000138f;
-pub const MINIX2_SUPER_MAGIC: ::c_int = 0x00002468;
-pub const MINIX2_SUPER_MAGIC2: ::c_int = 0x00002478;
-pub const MSDOS_SUPER_MAGIC: ::c_int = 0x00004d44;
-pub const NCP_SUPER_MAGIC: ::c_int = 0x0000564c;
-pub const NFS_SUPER_MAGIC: ::c_int = 0x00006969;
-pub const OPENPROM_SUPER_MAGIC: ::c_int = 0x00009fa1;
-pub const PROC_SUPER_MAGIC: ::c_int = 0x00009fa0;
-pub const QNX4_SUPER_MAGIC: ::c_int = 0x0000002f;
-pub const REISERFS_SUPER_MAGIC: ::c_int = 0x52654973;
-pub const SMB_SUPER_MAGIC: ::c_int = 0x0000517b;
-pub const TMPFS_MAGIC: ::c_int = 0x01021994;
-pub const USBDEVICE_SUPER_MAGIC: ::c_int = 0x00009fa2;
-
-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 CPU_SETSIZE: ::c_int = 0x400;
-
-pub const EXTPROC: ::tcflag_t = 0x00010000;
-
-pub const PTRACE_TRACEME: ::c_uint = 0;
-pub const PTRACE_PEEKTEXT: ::c_uint = 1;
-pub const PTRACE_PEEKDATA: ::c_uint = 2;
-pub const PTRACE_PEEKUSER: ::c_uint = 3;
-pub const PTRACE_POKETEXT: ::c_uint = 4;
-pub const PTRACE_POKEDATA: ::c_uint = 5;
-pub const PTRACE_POKEUSER: ::c_uint = 6;
-pub const PTRACE_CONT: ::c_uint = 7;
-pub const PTRACE_KILL: ::c_uint = 8;
-pub const PTRACE_SINGLESTEP: ::c_uint = 9;
-pub const PTRACE_ATTACH: ::c_uint = 16;
-pub const PTRACE_DETACH: ::c_uint = 17;
-pub const PTRACE_SYSCALL: ::c_uint = 24;
-pub const PTRACE_SETOPTIONS: ::c_uint = 0x4200;
-pub const PTRACE_GETEVENTMSG: ::c_uint = 0x4201;
-pub const PTRACE_GETSIGINFO: ::c_uint = 0x4202;
-pub const PTRACE_SETSIGINFO: ::c_uint = 0x4203;
-pub const PTRACE_GETREGSET: ::c_uint = 0x4204;
-pub const PTRACE_SETREGSET: ::c_uint = 0x4205;
-pub const PTRACE_SEIZE: ::c_uint = 0x4206;
-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;
-
-pub const EFD_NONBLOCK: ::c_int = 0x800;
-
-pub const F_RDLCK: ::c_int = 0;
-pub const F_WRLCK: ::c_int = 1;
-pub const F_UNLCK: ::c_int = 2;
-pub const F_GETLK: ::c_int = 5;
-pub const F_GETOWN: ::c_int = 9;
-pub const F_SETOWN: ::c_int = 8;
-pub const F_SETLK: ::c_int = 6;
-pub const F_SETLKW: ::c_int = 7;
-
-pub const SEEK_DATA: ::c_int = 3;
-pub const SEEK_HOLE: ::c_int = 4;
-
-pub const SFD_NONBLOCK: ::c_int = 0x0800;
-
-pub const TCSANOW: ::c_int = 0;
-pub const TCSADRAIN: ::c_int = 1;
-pub const TCSAFLUSH: ::c_int = 2;
-
-pub const TCGETS: ::c_ulong = 0x5401;
-pub const TCSETS: ::c_ulong = 0x5402;
-pub const TCSETSW: ::c_ulong = 0x5403;
-pub const TCSETSF: ::c_ulong = 0x5404;
-pub const TCGETA: ::c_ulong = 0x5405;
-pub const TCSETA: ::c_ulong = 0x5406;
-pub const TCSETAW: ::c_ulong = 0x5407;
-pub const TCSETAF: ::c_ulong = 0x5408;
-pub const TCSBRK: ::c_ulong = 0x5409;
-pub const TCXONC: ::c_ulong = 0x540A;
-pub const TCFLSH: ::c_ulong = 0x540B;
-pub const TIOCGSOFTCAR: ::c_ulong = 0x5419;
-pub const TIOCSSOFTCAR: ::c_ulong = 0x541A;
-pub const TIOCINQ: ::c_ulong = 0x541B;
-pub const TIOCLINUX: ::c_ulong = 0x541C;
-pub const TIOCGSERIAL: ::c_ulong = 0x541E;
-pub const TIOCEXCL: ::c_ulong = 0x540C;
-pub const TIOCNXCL: ::c_ulong = 0x540D;
-pub const TIOCSCTTY: ::c_ulong = 0x540E;
-pub const TIOCGPGRP: ::c_ulong = 0x540F;
-pub const TIOCSPGRP: ::c_ulong = 0x5410;
-pub const TIOCOUTQ: ::c_ulong = 0x5411;
-pub const TIOCSTI: ::c_ulong = 0x5412;
-pub const TIOCGWINSZ: ::c_ulong = 0x5413;
-pub const TIOCSWINSZ: ::c_ulong = 0x5414;
-pub const TIOCMGET: ::c_ulong = 0x5415;
-pub const TIOCMBIS: ::c_ulong = 0x5416;
-pub const TIOCMBIC: ::c_ulong = 0x5417;
-pub const TIOCMSET: ::c_ulong = 0x5418;
-pub const FIONREAD: ::c_ulong = 0x541B;
-pub const TIOCCONS: ::c_ulong = 0x541D;
-
-pub const RTLD_DEEPBIND: ::c_int = 0x8;
-pub const RTLD_GLOBAL: ::c_int = 0x100;
-pub const RTLD_NOLOAD: ::c_int = 0x4;
-
-pub const LINUX_REBOOT_MAGIC1: ::c_int = 0xfee1dead;
-pub const LINUX_REBOOT_MAGIC2: ::c_int = 672274793;
-pub const LINUX_REBOOT_MAGIC2A: ::c_int = 85072278;
-pub const LINUX_REBOOT_MAGIC2B: ::c_int = 369367448;
-pub const LINUX_REBOOT_MAGIC2C: ::c_int = 537993216;
-
-pub const LINUX_REBOOT_CMD_RESTART: ::c_int = 0x01234567;
-pub const LINUX_REBOOT_CMD_HALT: ::c_int = 0xCDEF0123;
-pub const LINUX_REBOOT_CMD_CAD_ON: ::c_int = 0x89ABCDEF;
-pub const LINUX_REBOOT_CMD_CAD_OFF: ::c_int = 0x00000000;
-pub const LINUX_REBOOT_CMD_POWER_OFF: ::c_int = 0x4321FEDC;
-pub const LINUX_REBOOT_CMD_RESTART2: ::c_int = 0xA1B2C3D4;
-pub const LINUX_REBOOT_CMD_SW_SUSPEND: ::c_int = 0xD000FCE2;
-pub const LINUX_REBOOT_CMD_KEXEC: ::c_int = 0x45584543;
-
-pub const VTIME: usize = 5;
-pub const VSWTC: usize = 7;
-pub const VSTART: usize = 8;
-pub const VSTOP: usize = 9;
-pub const VSUSP: usize = 10;
-pub const VREPRINT: usize = 12;
-pub const VDISCARD: usize = 13;
-pub const VWERASE: usize = 14;
-pub const OLCUC: ::tcflag_t = 0o000002;
-pub const ONLCR: ::tcflag_t = 0o000004;
-pub const NLDLY: ::tcflag_t = 0o000400;
-pub const CRDLY: ::tcflag_t = 0o003000;
-pub const CR1: ::tcflag_t = 0x00000200;
-pub const CR2: ::tcflag_t = 0x00000400;
-pub const CR3: ::tcflag_t = 0x00000600;
-pub const TABDLY: ::tcflag_t = 0o014000;
-pub const TAB1: ::tcflag_t = 0x00000800;
-pub const TAB2: ::tcflag_t = 0x00001000;
-pub const TAB3: ::tcflag_t = 0x00001800;
-pub const BSDLY: ::tcflag_t = 0o020000;
-pub const BS1: ::tcflag_t = 0x00002000;
-pub const FFDLY: ::tcflag_t = 0o100000;
-pub const FF1: ::tcflag_t = 0x00008000;
-pub const VTDLY: ::tcflag_t = 0o040000;
-pub const VT1: ::tcflag_t = 0x00004000;
-pub const XTABS: ::tcflag_t = 0o014000;
-
-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 SIGEV_THREAD_ID: ::c_int = 4;
-
-pub const CBAUD: ::speed_t = 0o010017;
-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 CSIZE: ::tcflag_t = 0o000060;
-pub const CS6: ::tcflag_t = 0o000020;
-pub const CS7: ::tcflag_t = 0o000040;
-pub const CS8: ::tcflag_t = 0o000060;
-pub const CSTOPB: ::tcflag_t = 0o000100;
-pub const CREAD: ::tcflag_t = 0o000200;
-pub const PARENB: ::tcflag_t = 0o000400;
-pub const PARODD: ::tcflag_t = 0o001000;
-pub const HUPCL: ::tcflag_t = 0o002000;
-pub const CLOCAL: ::tcflag_t = 0o004000;
-pub const CBAUDEX: ::tcflag_t = 0o010000;
-pub const BOTHER: ::speed_t = 0o010000;
-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 CIBAUD: ::tcflag_t = 0o02003600000;
-
-pub const ISIG: ::tcflag_t = 0o000001;
-pub const ICANON: ::tcflag_t = 0o000002;
-pub const XCASE: ::tcflag_t = 0o000004;
-pub const ECHOE: ::tcflag_t = 0o000020;
-pub const ECHOK: ::tcflag_t = 0o000040;
-pub const ECHONL: ::tcflag_t = 0o000100;
-pub const NOFLSH: ::tcflag_t = 0o000200;
-pub const ECHOCTL: ::tcflag_t = 0o001000;
-pub const ECHOPRT: ::tcflag_t = 0o002000;
-pub const ECHOKE: ::tcflag_t = 0o004000;
-pub const PENDIN: ::tcflag_t = 0o040000;
-
-pub const POLLWRNORM: ::c_short = 0x100;
-pub const POLLWRBAND: ::c_short = 0x200;
-
-pub const IXON: ::tcflag_t = 0o002000;
-pub const IXOFF: ::tcflag_t = 0o010000;
-
-pub const RLIMIT_CPU: ::__rlimit_resource_t = 0;
-pub const RLIMIT_FSIZE: ::__rlimit_resource_t = 1;
-pub const RLIMIT_DATA: ::__rlimit_resource_t = 2;
-pub const RLIMIT_STACK: ::__rlimit_resource_t = 3;
-pub const RLIMIT_CORE: ::__rlimit_resource_t = 4;
-pub const RLIMIT_LOCKS: ::__rlimit_resource_t = 10;
-pub const RLIMIT_SIGPENDING: ::__rlimit_resource_t = 11;
-pub const RLIMIT_MSGQUEUE: ::__rlimit_resource_t = 12;
-pub const RLIMIT_NICE: ::__rlimit_resource_t = 13;
-pub const RLIMIT_RTPRIO: ::__rlimit_resource_t = 14;
-
-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_restart_syscall: ::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_mknod: ::c_long = 14;
-pub const SYS_chmod: ::c_long = 15;
-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_ptrace: ::c_long = 26;
-pub const SYS_alarm: ::c_long = 27;
-pub const SYS_pause: ::c_long = 29;
-pub const SYS_utime: ::c_long = 30;
-pub const SYS_access: ::c_long = 33;
-pub const SYS_nice: ::c_long = 34;
-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_brk: ::c_long = 45;
-pub const SYS_signal: ::c_long = 48;
-pub const SYS_acct: ::c_long = 51;
-pub const SYS_umount2: ::c_long = 52;
-pub const SYS_ioctl: ::c_long = 54;
-pub const SYS_fcntl: ::c_long = 55;
-pub const SYS_setpgid: ::c_long = 57;
-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_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_getrusage: ::c_long = 77;
-pub const SYS_gettimeofday: ::c_long = 78;
-pub const SYS_settimeofday: ::c_long = 79;
-pub const SYS_symlink: ::c_long = 83;
-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_getpriority: ::c_long = 96;
-pub const SYS_setpriority: ::c_long = 97;
-pub const SYS_statfs: ::c_long = 99;
-pub const SYS_fstatfs: ::c_long = 100;
-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_lookup_dcookie: ::c_long = 110;
-pub const SYS_vhangup: ::c_long = 111;
-pub const SYS_idle: ::c_long = 112;
-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_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_getdents: ::c_long = 141;
-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_query_module: ::c_long = 167;
-pub const SYS_poll: ::c_long = 168;
-pub const SYS_nfsservctl: ::c_long = 169;
-pub const SYS_prctl: ::c_long = 172;
-pub const SYS_rt_sigreturn: ::c_long = 173;
-pub const SYS_rt_sigaction: ::c_long = 174;
-pub const SYS_rt_sigprocmask: ::c_long = 175;
-pub const SYS_rt_sigpending: ::c_long = 176;
-pub const SYS_rt_sigtimedwait: ::c_long = 177;
-pub const SYS_rt_sigqueueinfo: ::c_long = 178;
-pub const SYS_rt_sigsuspend: ::c_long = 179;
-pub const SYS_pread64: ::c_long = 180;
-pub const SYS_pwrite64: ::c_long = 181;
-pub const SYS_getcwd: ::c_long = 183;
-pub const SYS_capget: ::c_long = 184;
-pub const SYS_capset: ::c_long = 185;
-pub const SYS_sigaltstack: ::c_long = 186;
-pub const SYS_sendfile: ::c_long = 187;
-pub const SYS_getpmsg: ::c_long = 188;
-pub const SYS_putpmsg: ::c_long = 189;
-pub const SYS_vfork: ::c_long = 190;
-pub const SYS_pivot_root: ::c_long = 217;
-pub const SYS_mincore: ::c_long = 218;
-pub const SYS_madvise: ::c_long = 219;
-pub const SYS_getdents64: ::c_long = 220;
-pub const SYS_readahead: ::c_long = 222;
-pub const SYS_setxattr: ::c_long = 224;
-pub const SYS_lsetxattr: ::c_long = 225;
-pub const SYS_fsetxattr: ::c_long = 226;
-pub const SYS_getxattr: ::c_long = 227;
-pub const SYS_lgetxattr: ::c_long = 228;
-pub const SYS_fgetxattr: ::c_long = 229;
-pub const SYS_listxattr: ::c_long = 230;
-pub const SYS_llistxattr: ::c_long = 231;
-pub const SYS_flistxattr: ::c_long = 232;
-pub const SYS_removexattr: ::c_long = 233;
-pub const SYS_lremovexattr: ::c_long = 234;
-pub const SYS_fremovexattr: ::c_long = 235;
-pub const SYS_gettid: ::c_long = 236;
-pub const SYS_tkill: ::c_long = 237;
-pub const SYS_futex: ::c_long = 238;
-pub const SYS_sched_setaffinity: ::c_long = 239;
-pub const SYS_sched_getaffinity: ::c_long = 240;
-pub const SYS_tgkill: ::c_long = 241;
-pub const SYS_io_setup: ::c_long = 243;
-pub const SYS_io_destroy: ::c_long = 244;
-pub const SYS_io_getevents: ::c_long = 245;
-pub const SYS_io_submit: ::c_long = 246;
-pub const SYS_io_cancel: ::c_long = 247;
-pub const SYS_exit_group: ::c_long = 248;
-pub const SYS_epoll_create: ::c_long = 249;
-pub const SYS_epoll_ctl: ::c_long = 250;
-pub const SYS_epoll_wait: ::c_long = 251;
-pub const SYS_set_tid_address: ::c_long = 252;
-pub const SYS_fadvise64: ::c_long = 253;
-pub const SYS_timer_create: ::c_long = 254;
-pub const SYS_timer_settime: ::c_long = 255;
-pub const SYS_timer_gettime: ::c_long = 256;
-pub const SYS_timer_getoverrun: ::c_long = 257;
-pub const SYS_timer_delete: ::c_long = 258;
-pub const SYS_clock_settime: ::c_long = 259;
-pub const SYS_clock_gettime: ::c_long = 260;
-pub const SYS_clock_getres: ::c_long = 261;
-pub const SYS_clock_nanosleep: ::c_long = 262;
-pub const SYS_statfs64: ::c_long = 265;
-pub const SYS_fstatfs64: ::c_long = 266;
-pub const SYS_remap_file_pages: ::c_long = 267;
-pub const SYS_mbind: ::c_long = 268;
-pub const SYS_get_mempolicy: ::c_long = 269;
-pub const SYS_set_mempolicy: ::c_long = 270;
-pub const SYS_mq_open: ::c_long = 271;
-pub const SYS_mq_unlink: ::c_long = 272;
-pub const SYS_mq_timedsend: ::c_long = 273;
-pub const SYS_mq_timedreceive: ::c_long = 274;
-pub const SYS_mq_notify: ::c_long = 275;
-pub const SYS_mq_getsetattr: ::c_long = 276;
-pub const SYS_kexec_load: ::c_long = 277;
-pub const SYS_add_key: ::c_long = 278;
-pub const SYS_request_key: ::c_long = 279;
-pub const SYS_keyctl: ::c_long = 280;
-pub const SYS_waitid: ::c_long = 281;
-pub const SYS_ioprio_set: ::c_long = 282;
-pub const SYS_ioprio_get: ::c_long = 283;
-pub const SYS_inotify_init: ::c_long = 284;
-pub const SYS_inotify_add_watch: ::c_long = 285;
-pub const SYS_inotify_rm_watch: ::c_long = 286;
-pub const SYS_migrate_pages: ::c_long = 287;
-pub const SYS_openat: ::c_long = 288;
-pub const SYS_mkdirat: ::c_long = 289;
-pub const SYS_mknodat: ::c_long = 290;
-pub const SYS_fchownat: ::c_long = 291;
-pub const SYS_futimesat: ::c_long = 292;
-pub const SYS_unlinkat: ::c_long = 294;
-pub const SYS_renameat: ::c_long = 295;
-pub const SYS_linkat: ::c_long = 296;
-pub const SYS_symlinkat: ::c_long = 297;
-pub const SYS_readlinkat: ::c_long = 298;
-pub const SYS_fchmodat: ::c_long = 299;
-pub const SYS_faccessat: ::c_long = 300;
-pub const SYS_pselect6: ::c_long = 301;
-pub const SYS_ppoll: ::c_long = 302;
-pub const SYS_unshare: ::c_long = 303;
-pub const SYS_set_robust_list: ::c_long = 304;
-pub const SYS_get_robust_list: ::c_long = 305;
-pub const SYS_splice: ::c_long = 306;
-pub const SYS_sync_file_range: ::c_long = 307;
-pub const SYS_tee: ::c_long = 308;
-pub const SYS_vmsplice: ::c_long = 309;
-pub const SYS_move_pages: ::c_long = 310;
-pub const SYS_getcpu: ::c_long = 311;
-pub const SYS_epoll_pwait: ::c_long = 312;
-pub const SYS_utimes: ::c_long = 313;
-pub const SYS_fallocate: ::c_long = 314;
-pub const SYS_utimensat: ::c_long = 315;
-pub const SYS_signalfd: ::c_long = 316;
-pub const SYS_timerfd: ::c_long = 317;
-pub const SYS_eventfd: ::c_long = 318;
-pub const SYS_timerfd_create: ::c_long = 319;
-pub const SYS_timerfd_settime: ::c_long = 320;
-pub const SYS_timerfd_gettime: ::c_long = 321;
-pub const SYS_signalfd4: ::c_long = 322;
-pub const SYS_eventfd2: ::c_long = 323;
-pub const SYS_inotify_init1: ::c_long = 324;
-pub const SYS_pipe2: ::c_long = 325;
-pub const SYS_dup3: ::c_long = 326;
-pub const SYS_epoll_create1: ::c_long = 327;
-pub const SYS_preadv: ::c_long = 328;
-pub const SYS_pwritev: ::c_long = 329;
-pub const SYS_rt_tgsigqueueinfo: ::c_long = 330;
-pub const SYS_perf_event_open: ::c_long = 331;
-pub const SYS_fanotify_init: ::c_long = 332;
-pub const SYS_fanotify_mark: ::c_long = 333;
-pub const SYS_prlimit64: ::c_long = 334;
-pub const SYS_name_to_handle_at: ::c_long = 335;
-pub const SYS_open_by_handle_at: ::c_long = 336;
-pub const SYS_clock_adjtime: ::c_long = 337;
-pub const SYS_syncfs: ::c_long = 338;
-pub const SYS_setns: ::c_long = 339;
-pub const SYS_process_vm_readv: ::c_long = 340;
-pub const SYS_process_vm_writev: ::c_long = 341;
-pub const SYS_s390_runtime_instr: ::c_long = 342;
-pub const SYS_kcmp: ::c_long = 343;
-pub const SYS_finit_module: ::c_long = 344;
-pub const SYS_sched_setattr: ::c_long = 345;
-pub const SYS_sched_getattr: ::c_long = 346;
-pub const SYS_renameat2: ::c_long = 347;
-pub const SYS_seccomp: ::c_long = 348;
-pub const SYS_getrandom: ::c_long = 349;
-pub const SYS_memfd_create: ::c_long = 350;
-pub const SYS_bpf: ::c_long = 351;
-pub const SYS_s390_pci_mmio_write: ::c_long = 352;
-pub const SYS_s390_pci_mmio_read: ::c_long = 353;
-pub const SYS_execveat: ::c_long = 354;
-pub const SYS_userfaultfd: ::c_long = 355;
-pub const SYS_membarrier: ::c_long = 356;
-pub const SYS_recvmmsg: ::c_long = 357;
-pub const SYS_sendmmsg: ::c_long = 358;
-pub const SYS_socket: ::c_long = 359;
-pub const SYS_socketpair: ::c_long = 360;
-pub const SYS_bind: ::c_long = 361;
-pub const SYS_connect: ::c_long = 362;
-pub const SYS_listen: ::c_long = 363;
-pub const SYS_accept4: ::c_long = 364;
-pub const SYS_getsockopt: ::c_long = 365;
-pub const SYS_setsockopt: ::c_long = 366;
-pub const SYS_getsockname: ::c_long = 367;
-pub const SYS_getpeername: ::c_long = 368;
-pub const SYS_sendto: ::c_long = 369;
-pub const SYS_sendmsg: ::c_long = 370;
-pub const SYS_recvfrom: ::c_long = 371;
-pub const SYS_recvmsg: ::c_long = 372;
-pub const SYS_shutdown: ::c_long = 373;
-pub const SYS_mlock2: ::c_long = 374;
-pub const SYS_copy_file_range: ::c_long = 375;
-pub const SYS_preadv2: ::c_long = 376;
-pub const SYS_pwritev2: ::c_long = 377;
-pub const SYS_lchown: ::c_long = 198;
-pub const SYS_setuid: ::c_long = 213;
-pub const SYS_getuid: ::c_long = 199;
-pub const SYS_setgid: ::c_long = 214;
-pub const SYS_getgid: ::c_long = 200;
-pub const SYS_geteuid: ::c_long = 201;
-pub const SYS_setreuid: ::c_long = 203;
-pub const SYS_setregid: ::c_long = 204;
-pub const SYS_getrlimit: ::c_long = 191;
-pub const SYS_getgroups: ::c_long = 205;
-pub const SYS_fchown: ::c_long = 207;
-pub const SYS_setresuid: ::c_long = 208;
-pub const SYS_setresgid: ::c_long = 210;
-pub const SYS_getresgid: ::c_long = 211;
-pub const SYS_select: ::c_long = 142;
-pub const SYS_getegid: ::c_long = 202;
-pub const SYS_setgroups: ::c_long = 206;
-pub const SYS_getresuid: ::c_long = 209;
-pub const SYS_chown: ::c_long = 212;
-pub const SYS_setfsuid: ::c_long = 215;
-pub const SYS_setfsgid: ::c_long = 216;
-pub const SYS_newfstatat: ::c_long = 293;
-
-#[link(name = "util")]
-extern {
- pub fn sendmmsg(sockfd: ::c_int, msgvec: *mut ::mmsghdr, vlen: ::c_uint,
- flags: ::c_int) -> ::c_int;
- pub fn recvmmsg(sockfd: ::c_int, msgvec: *mut ::mmsghdr, vlen: ::c_uint,
- flags: ::c_int, timeout: *mut ::timespec) -> ::c_int;
-
- pub fn getrlimit64(resource: ::__rlimit_resource_t,
- rlim: *mut ::rlimit64) -> ::c_int;
- pub fn setrlimit64(resource: ::__rlimit_resource_t,
- rlim: *const ::rlimit64) -> ::c_int;
- pub fn getrlimit(resource: ::__rlimit_resource_t,
- rlim: *mut ::rlimit) -> ::c_int;
- pub fn setrlimit(resource: ::__rlimit_resource_t,
- rlim: *const ::rlimit) -> ::c_int;
- pub fn prlimit(pid: ::pid_t,
- resource: ::__rlimit_resource_t, new_limit: *const ::rlimit,
- old_limit: *mut ::rlimit) -> ::c_int;
- pub fn prlimit64(pid: ::pid_t,
- resource: ::__rlimit_resource_t,
- new_limit: *const ::rlimit64,
- old_limit: *mut ::rlimit64) -> ::c_int;
-
- pub fn sysctl(name: *mut ::c_int,
- namelen: ::c_int,
- oldp: *mut ::c_void,
- oldlenp: *mut ::size_t,
- newp: *mut ::c_void,
- newlen: ::size_t)
- -> ::c_int;
- pub fn ioctl(fd: ::c_int, request: ::c_ulong, ...) -> ::c_int;
- pub fn backtrace(buf: *mut *mut ::c_void,
- sz: ::c_int) -> ::c_int;
- pub fn glob64(pattern: *const ::c_char,
- flags: ::c_int,
- errfunc: ::Option<extern fn(epath: *const ::c_char,
- errno: ::c_int)
- -> ::c_int>,
- pglob: *mut glob64_t) -> ::c_int;
- pub fn globfree64(pglob: *mut glob64_t);
- pub fn ptrace(request: ::c_uint, ...) -> ::c_long;
- pub fn pthread_attr_getaffinity_np(attr: *const ::pthread_attr_t,
- cpusetsize: ::size_t,
- cpuset: *mut ::cpu_set_t) -> ::c_int;
- pub fn pthread_attr_setaffinity_np(attr: *mut ::pthread_attr_t,
- cpusetsize: ::size_t,
- cpuset: *const ::cpu_set_t) -> ::c_int;
- pub fn getpriority(which: ::__priority_which_t, who: ::id_t) -> ::c_int;
- pub fn setpriority(which: ::__priority_which_t, 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;
- pub fn getcontext(ucp: *mut ucontext_t) -> ::c_int;
- pub fn setcontext(ucp: *const ucontext_t) -> ::c_int;
- pub fn makecontext(ucp: *mut ucontext_t,
- func: extern fn (),
- argc: ::c_int, ...);
- pub fn swapcontext(uocp: *mut ucontext_t,
- ucp: *const ucontext_t) -> ::c_int;
-}
-
-cfg_if! {
- if #[cfg(libc_align)] {
- mod align;
- pub use self::align::*;
- } else {
- mod no_align;
- pub use self::no_align::*;
- }
-}
diff --git a/libc/src/unix/notbsd/linux/s390x/no_align.rs b/libc/src/unix/notbsd/linux/s390x/no_align.rs
deleted file mode 100644
index 8909114..0000000
--- a/libc/src/unix/notbsd/linux/s390x/no_align.rs
+++ /dev/null
@@ -1,7 +0,0 @@
-s! {
- // FIXME this is actually a union
- pub struct sem_t {
- __size: [::c_char; 32],
- __align: [::c_long; 0],
- }
-}
diff --git a/libc/src/unix/notbsd/mod.rs b/libc/src/unix/notbsd/mod.rs
deleted file mode 100644
index 2706466..0000000
--- a/libc/src/unix/notbsd/mod.rs
+++ /dev/null
@@ -1,1404 +0,0 @@
-pub type sa_family_t = u16;
-pub type speed_t = ::c_uint;
-pub type tcflag_t = ::c_uint;
-pub type clockid_t = ::c_int;
-pub type key_t = ::c_int;
-pub type id_t = ::c_uint;
-
-#[cfg_attr(feature = "extra_traits", derive(Debug))]
-pub enum timezone {}
-impl ::Copy for timezone {}
-impl ::Clone for timezone {
- fn clone(&self) -> timezone { *self }
-}
-
-s! {
- pub struct in_addr {
- pub s_addr: ::in_addr_t,
- }
-
- pub struct ip_mreq {
- pub imr_multiaddr: in_addr,
- pub imr_interface: in_addr,
- }
-
- pub struct sockaddr {
- pub sa_family: sa_family_t,
- pub sa_data: [::c_char; 14],
- }
-
- pub struct sockaddr_in {
- pub sin_family: sa_family_t,
- pub sin_port: ::in_port_t,
- pub sin_addr: ::in_addr,
- pub sin_zero: [u8; 8],
- }
-
- pub struct sockaddr_in6 {
- 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 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,
-
- #[cfg(any(target_os = "linux",
- target_os = "emscripten"))]
- pub ai_addr: *mut ::sockaddr,
-
- pub ai_canonname: *mut c_char,
-
- #[cfg(target_os = "android")]
- pub ai_addr: *mut ::sockaddr,
-
- pub ai_next: *mut addrinfo,
- }
-
- pub struct sockaddr_ll {
- pub sll_family: ::c_ushort,
- pub sll_protocol: ::c_ushort,
- pub sll_ifindex: ::c_int,
- pub sll_hatype: ::c_ushort,
- pub sll_pkttype: ::c_uchar,
- pub sll_halen: ::c_uchar,
- pub sll_addr: [::c_uchar; 8]
- }
-
- pub struct fd_set {
- fds_bits: [::c_ulong; FD_SETSIZE / ULONG_SIZE],
- }
-
- 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 tm_gmtoff: ::c_long,
- pub tm_zone: *const ::c_char,
- }
-
- pub struct sched_param {
- pub sched_priority: ::c_int,
- #[cfg(any(target_env = "musl", target_os = "emscripten"))]
- pub sched_ss_low_priority: ::c_int,
- #[cfg(any(target_env = "musl", target_os = "emscripten"))]
- pub sched_ss_repl_period: ::timespec,
- #[cfg(any(target_env = "musl", target_os = "emscripten"))]
- pub sched_ss_init_budget: ::timespec,
- #[cfg(any(target_env = "musl", target_os = "emscripten"))]
- pub sched_ss_max_repl: ::c_int,
- }
-
- pub struct Dl_info {
- pub dli_fname: *const ::c_char,
- pub dli_fbase: *mut ::c_void,
- pub dli_sname: *const ::c_char,
- pub dli_saddr: *mut ::c_void,
- }
-
- 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 sigevent {
- 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 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,
- }
-
- pub struct mmsghdr {
- pub msg_hdr: ::msghdr,
- pub msg_len: ::c_uint,
- }
-}
-
-s_no_extra_traits!{
- #[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: u32,
- pub u64: u64,
- }
-
- pub struct sockaddr_un {
- pub sun_family: sa_family_t,
- pub sun_path: [::c_char; 108]
- }
-
- pub struct sockaddr_storage {
- pub ss_family: sa_family_t,
- __ss_align: ::size_t,
- #[cfg(target_pointer_width = "32")]
- __ss_pad2: [u8; 128 - 2 * 4],
- #[cfg(target_pointer_width = "64")]
- __ss_pad2: [u8; 128 - 2 * 8],
- }
-
- pub struct utsname {
- pub sysname: [::c_char; 65],
- pub nodename: [::c_char; 65],
- pub release: [::c_char; 65],
- pub version: [::c_char; 65],
- pub machine: [::c_char; 65],
- pub domainname: [::c_char; 65]
- }
-}
-
-cfg_if! {
- if #[cfg(feature = "extra_traits")] {
- impl PartialEq for epoll_event {
- fn eq(&self, other: &epoll_event) -> bool {
- self.events == other.events
- && self.u64 == other.u64
- }
- }
- impl Eq for epoll_event {}
- impl ::fmt::Debug for epoll_event {
- fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
- let events = self.events;
- let u64 = self.u64;
- f.debug_struct("epoll_event")
- .field("events", &events)
- .field("u64", &u64)
- .finish()
- }
- }
- impl ::hash::Hash for epoll_event {
- fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
- let events = self.events;
- let u64 = self.u64;
- events.hash(state);
- u64.hash(state);
- }
- }
-
- impl PartialEq for sockaddr_un {
- fn eq(&self, other: &sockaddr_un) -> bool {
- self.sun_family == other.sun_family
- && self
- .sun_path
- .iter()
- .zip(other.sun_path.iter())
- .all(|(a, b)| a == b)
- }
- }
- impl Eq for sockaddr_un {}
- impl ::fmt::Debug for sockaddr_un {
- fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
- f.debug_struct("sockaddr_un")
- .field("sun_family", &self.sun_family)
- // FIXME: .field("sun_path", &self.sun_path)
- .finish()
- }
- }
- impl ::hash::Hash for sockaddr_un {
- fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
- self.sun_family.hash(state);
- self.sun_path.hash(state);
- }
- }
-
- impl PartialEq for sockaddr_storage {
- fn eq(&self, other: &sockaddr_storage) -> bool {
- self.ss_family == other.ss_family
- && self
- .__ss_pad2
- .iter()
- .zip(other.__ss_pad2.iter())
- .all(|(a, b)| a == b)
- }
- }
-
- impl Eq for sockaddr_storage {}
-
- impl ::fmt::Debug for sockaddr_storage {
- fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
- f.debug_struct("sockaddr_storage")
- .field("ss_family", &self.ss_family)
- .field("__ss_align", &self.__ss_align)
- // FIXME: .field("__ss_pad2", &self.__ss_pad2)
- .finish()
- }
- }
-
- impl ::hash::Hash for sockaddr_storage {
- fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
- self.ss_family.hash(state);
- self.__ss_pad2.hash(state);
- }
- }
-
- impl PartialEq for utsname {
- fn eq(&self, other: &utsname) -> bool {
- self.sysname
- .iter()
- .zip(other.sysname.iter())
- .all(|(a, b)| a == b)
- && self
- .nodename
- .iter()
- .zip(other.nodename.iter())
- .all(|(a, b)| a == b)
- && self
- .release
- .iter()
- .zip(other.release.iter())
- .all(|(a, b)| a == b)
- && self
- .version
- .iter()
- .zip(other.version.iter())
- .all(|(a, b)| a == b)
- && self
- .machine
- .iter()
- .zip(other.machine.iter())
- .all(|(a, b)| a == b)
- && self
- .domainname
- .iter()
- .zip(other.domainname.iter())
- .all(|(a, b)| a == b)
- }
- }
-
- impl Eq for utsname {}
-
- impl ::fmt::Debug for utsname {
- fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
- f.debug_struct("utsname")
- // FIXME: .field("sysname", &self.sysname)
- // FIXME: .field("nodename", &self.nodename)
- // FIXME: .field("release", &self.release)
- // FIXME: .field("version", &self.version)
- // FIXME: .field("machine", &self.machine)
- // FIXME: .field("domainname", &self.domainname)
- .finish()
- }
- }
-
- impl ::hash::Hash for utsname {
- fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
- self.sysname.hash(state);
- self.nodename.hash(state);
- self.release.hash(state);
- self.version.hash(state);
- self.machine.hash(state);
- self.domainname.hash(state);
- }
- }
- }
-}
-
-// intentionally not public, only used for fd_set
-cfg_if! {
- if #[cfg(target_pointer_width = "32")] {
- const ULONG_SIZE: usize = 32;
- } else if #[cfg(target_pointer_width = "64")] {
- const ULONG_SIZE: usize = 64;
- } else {
- // Unknown target_pointer_width
- }
-}
-
-pub const EXIT_FAILURE: ::c_int = 1;
-pub const EXIT_SUCCESS: ::c_int = 0;
-pub const RAND_MAX: ::c_int = 2147483647;
-pub const EOF: ::c_int = -1;
-pub const SEEK_SET: ::c_int = 0;
-pub const SEEK_CUR: ::c_int = 1;
-pub const SEEK_END: ::c_int = 2;
-pub const _IOFBF: ::c_int = 0;
-pub const _IONBF: ::c_int = 2;
-pub const _IOLBF: ::c_int = 1;
-
-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;
-
-// Linux-specific fcntls
-pub const F_SETLEASE: ::c_int = 1024;
-pub const F_GETLEASE: ::c_int = 1025;
-pub const F_NOTIFY: ::c_int = 1026;
-pub const F_CANCELLK: ::c_int = 1029;
-pub const F_DUPFD_CLOEXEC: ::c_int = 1030;
-pub const F_SETPIPE_SZ: ::c_int = 1031;
-pub const F_GETPIPE_SZ: ::c_int = 1032;
-pub const F_ADD_SEALS: ::c_int = 1033;
-pub const F_GET_SEALS: ::c_int = 1034;
-
-pub const F_SEAL_SEAL: ::c_int = 0x0001;
-pub const F_SEAL_SHRINK: ::c_int = 0x0002;
-pub const F_SEAL_GROW: ::c_int = 0x0004;
-pub const F_SEAL_WRITE: ::c_int = 0x0008;
-
-// TODO(#235): Include file sealing fcntls once we have a way to verify them.
-
-pub const SIGTRAP: ::c_int = 5;
-
-pub const PTHREAD_CREATE_JOINABLE: ::c_int = 0;
-pub const PTHREAD_CREATE_DETACHED: ::c_int = 1;
-
-pub const CLOCK_REALTIME: ::clockid_t = 0;
-pub const CLOCK_MONOTONIC: ::clockid_t = 1;
-pub const CLOCK_PROCESS_CPUTIME_ID: ::clockid_t = 2;
-pub const CLOCK_THREAD_CPUTIME_ID: ::clockid_t = 3;
-pub const CLOCK_MONOTONIC_RAW: ::clockid_t = 4;
-pub const CLOCK_REALTIME_COARSE: ::clockid_t = 5;
-pub const CLOCK_MONOTONIC_COARSE: ::clockid_t = 6;
-pub const CLOCK_BOOTTIME: ::clockid_t = 7;
-pub const CLOCK_REALTIME_ALARM: ::clockid_t = 8;
-pub const CLOCK_BOOTTIME_ALARM: ::clockid_t = 9;
-// TODO(#247) Someday our Travis shall have glibc 2.21 (released in Sep
-// 2014.) See also musl/mod.rs
-// pub const CLOCK_SGI_CYCLE: ::clockid_t = 10;
-// pub const CLOCK_TAI: ::clockid_t = 11;
-pub const TIMER_ABSTIME: ::c_int = 1;
-
-pub const RUSAGE_SELF: ::c_int = 0;
-
-pub const O_RDONLY: ::c_int = 0;
-pub const O_WRONLY: ::c_int = 1;
-pub const O_RDWR: ::c_int = 2;
-
-pub const SOCK_CLOEXEC: ::c_int = O_CLOEXEC;
-
-pub const S_IFIFO: ::mode_t = 4096;
-pub const S_IFCHR: ::mode_t = 8192;
-pub const S_IFBLK: ::mode_t = 24576;
-pub const S_IFDIR: ::mode_t = 16384;
-pub const S_IFREG: ::mode_t = 32768;
-pub const S_IFLNK: ::mode_t = 40960;
-pub const S_IFSOCK: ::mode_t = 49152;
-pub const S_IFMT: ::mode_t = 61440;
-pub const S_IRWXU: ::mode_t = 448;
-pub const S_IXUSR: ::mode_t = 64;
-pub const S_IWUSR: ::mode_t = 128;
-pub const S_IRUSR: ::mode_t = 256;
-pub const S_IRWXG: ::mode_t = 56;
-pub const S_IXGRP: ::mode_t = 8;
-pub const S_IWGRP: ::mode_t = 16;
-pub const S_IRGRP: ::mode_t = 32;
-pub const S_IRWXO: ::mode_t = 7;
-pub const S_IXOTH: ::mode_t = 1;
-pub const S_IWOTH: ::mode_t = 2;
-pub const S_IROTH: ::mode_t = 4;
-pub const F_OK: ::c_int = 0;
-pub const R_OK: ::c_int = 4;
-pub const W_OK: ::c_int = 2;
-pub const X_OK: ::c_int = 1;
-pub const STDIN_FILENO: ::c_int = 0;
-pub const STDOUT_FILENO: ::c_int = 1;
-pub const STDERR_FILENO: ::c_int = 2;
-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 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 PROT_NONE: ::c_int = 0;
-pub const PROT_READ: ::c_int = 1;
-pub const PROT_WRITE: ::c_int = 2;
-pub const PROT_EXEC: ::c_int = 4;
-
-pub const LC_CTYPE: ::c_int = 0;
-pub const LC_NUMERIC: ::c_int = 1;
-pub const LC_TIME: ::c_int = 2;
-pub const LC_COLLATE: ::c_int = 3;
-pub const LC_MONETARY: ::c_int = 4;
-pub const LC_MESSAGES: ::c_int = 5;
-pub const LC_ALL: ::c_int = 6;
-pub const LC_CTYPE_MASK: ::c_int = (1 << LC_CTYPE);
-pub const LC_NUMERIC_MASK: ::c_int = (1 << LC_NUMERIC);
-pub const LC_TIME_MASK: ::c_int = (1 << LC_TIME);
-pub const LC_COLLATE_MASK: ::c_int = (1 << LC_COLLATE);
-pub const LC_MONETARY_MASK: ::c_int = (1 << LC_MONETARY);
-pub const LC_MESSAGES_MASK: ::c_int = (1 << LC_MESSAGES);
-// LC_ALL_MASK defined per platform
-
-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_FAILED: *mut ::c_void = !0 as *mut ::c_void;
-
-// MS_ flags for msync(2)
-pub const MS_ASYNC: ::c_int = 0x0001;
-pub const MS_INVALIDATE: ::c_int = 0x0002;
-pub const MS_SYNC: ::c_int = 0x0004;
-
-// MS_ flags for mount(2)
-pub const MS_RDONLY: ::c_ulong = 0x01;
-pub const MS_NOSUID: ::c_ulong = 0x02;
-pub const MS_NODEV: ::c_ulong = 0x04;
-pub const MS_NOEXEC: ::c_ulong = 0x08;
-pub const MS_SYNCHRONOUS: ::c_ulong = 0x10;
-pub const MS_REMOUNT: ::c_ulong = 0x20;
-pub const MS_MANDLOCK: ::c_ulong = 0x40;
-pub const MS_DIRSYNC: ::c_ulong = 0x80;
-pub const MS_NOATIME: ::c_ulong = 0x0400;
-pub const MS_NODIRATIME: ::c_ulong = 0x0800;
-pub const MS_BIND: ::c_ulong = 0x1000;
-pub const MS_MOVE: ::c_ulong = 0x2000;
-pub const MS_REC: ::c_ulong = 0x4000;
-pub const MS_SILENT: ::c_ulong = 0x8000;
-pub const MS_POSIXACL: ::c_ulong = 0x010000;
-pub const MS_UNBINDABLE: ::c_ulong = 0x020000;
-pub const MS_PRIVATE: ::c_ulong = 0x040000;
-pub const MS_SLAVE: ::c_ulong = 0x080000;
-pub const MS_SHARED: ::c_ulong = 0x100000;
-pub const MS_RELATIME: ::c_ulong = 0x200000;
-pub const MS_KERNMOUNT: ::c_ulong = 0x400000;
-pub const MS_I_VERSION: ::c_ulong = 0x800000;
-pub const MS_STRICTATIME: ::c_ulong = 0x1000000;
-pub const MS_ACTIVE: ::c_ulong = 0x40000000;
-pub const MS_MGC_VAL: ::c_ulong = 0xc0ed0000;
-pub const MS_MGC_MSK: ::c_ulong = 0xffff0000;
-
-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 ENOTBLK: ::c_int = 15;
-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 EWOULDBLOCK: ::c_int = EAGAIN;
-
-pub const SCM_RIGHTS: ::c_int = 0x01;
-pub const SCM_CREDENTIALS: ::c_int = 0x02;
-
-pub const PROT_GROWSDOWN: ::c_int = 0x1000000;
-pub const PROT_GROWSUP: ::c_int = 0x2000000;
-
-pub const MAP_TYPE: ::c_int = 0x000f;
-
-pub const MADV_NORMAL: ::c_int = 0;
-pub const MADV_RANDOM: ::c_int = 1;
-pub const MADV_SEQUENTIAL: ::c_int = 2;
-pub const MADV_WILLNEED: ::c_int = 3;
-pub const MADV_DONTNEED: ::c_int = 4;
-pub const MADV_FREE: ::c_int = 8;
-pub const MADV_REMOVE: ::c_int = 9;
-pub const MADV_DONTFORK: ::c_int = 10;
-pub const MADV_DOFORK: ::c_int = 11;
-pub const MADV_MERGEABLE: ::c_int = 12;
-pub const MADV_UNMERGEABLE: ::c_int = 13;
-pub const MADV_HUGEPAGE: ::c_int = 14;
-pub const MADV_NOHUGEPAGE: ::c_int = 15;
-pub const MADV_DONTDUMP: ::c_int = 16;
-pub const MADV_DODUMP: ::c_int = 17;
-pub const MADV_HWPOISON: ::c_int = 100;
-
-pub const IFF_UP: ::c_int = 0x1;
-pub const IFF_BROADCAST: ::c_int = 0x2;
-pub const IFF_DEBUG: ::c_int = 0x4;
-pub const IFF_LOOPBACK: ::c_int = 0x8;
-pub const IFF_POINTOPOINT: ::c_int = 0x10;
-pub const IFF_NOTRAILERS: ::c_int = 0x20;
-pub const IFF_RUNNING: ::c_int = 0x40;
-pub const IFF_NOARP: ::c_int = 0x80;
-pub const IFF_PROMISC: ::c_int = 0x100;
-pub const IFF_ALLMULTI: ::c_int = 0x200;
-pub const IFF_MASTER: ::c_int = 0x400;
-pub const IFF_SLAVE: ::c_int = 0x800;
-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 SOL_IP: ::c_int = 0;
-pub const SOL_TCP: ::c_int = 6;
-pub const SOL_UDP: ::c_int = 17;
-pub const SOL_IPV6: ::c_int = 41;
-pub const SOL_ICMPV6: ::c_int = 58;
-pub const SOL_RAW: ::c_int = 255;
-pub const SOL_DECNET: ::c_int = 261;
-pub const SOL_X25: ::c_int = 262;
-pub const SOL_PACKET: ::c_int = 263;
-pub const SOL_ATM: ::c_int = 264;
-pub const SOL_AAL: ::c_int = 265;
-pub const SOL_IRDA: ::c_int = 266;
-pub const SOL_NETBEUI: ::c_int = 267;
-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 SOL_ALG: ::c_int = 279;
-
-pub const AF_UNSPEC: ::c_int = 0;
-pub const AF_UNIX: ::c_int = 1;
-pub const AF_LOCAL: ::c_int = 1;
-pub const AF_INET: ::c_int = 2;
-pub const AF_AX25: ::c_int = 3;
-pub const AF_IPX: ::c_int = 4;
-pub const AF_APPLETALK: ::c_int = 5;
-pub const AF_NETROM: ::c_int = 6;
-pub const AF_BRIDGE: ::c_int = 7;
-pub const AF_ATMPVC: ::c_int = 8;
-pub const AF_X25: ::c_int = 9;
-pub const AF_INET6: ::c_int = 10;
-pub const AF_ROSE: ::c_int = 11;
-pub const AF_DECnet: ::c_int = 12;
-pub const AF_NETBEUI: ::c_int = 13;
-pub const AF_SECURITY: ::c_int = 14;
-pub const AF_KEY: ::c_int = 15;
-pub const AF_NETLINK: ::c_int = 16;
-pub const AF_ROUTE: ::c_int = AF_NETLINK;
-pub const AF_PACKET: ::c_int = 17;
-pub const AF_ASH: ::c_int = 18;
-pub const AF_ECONET: ::c_int = 19;
-pub const AF_ATMSVC: ::c_int = 20;
-pub const AF_RDS: ::c_int = 21;
-pub const AF_SNA: ::c_int = 22;
-pub const AF_IRDA: ::c_int = 23;
-pub const AF_PPPOX: ::c_int = 24;
-pub const AF_WANPIPE: ::c_int = 25;
-pub const AF_LLC: ::c_int = 26;
-pub const AF_CAN: ::c_int = 29;
-pub const AF_TIPC: ::c_int = 30;
-pub const AF_BLUETOOTH: ::c_int = 31;
-pub const AF_IUCV: ::c_int = 32;
-pub const AF_RXRPC: ::c_int = 33;
-pub const AF_ISDN: ::c_int = 34;
-pub const AF_PHONET: ::c_int = 35;
-pub const AF_IEEE802154: ::c_int = 36;
-pub const AF_CAIF: ::c_int = 37;
-pub const AF_ALG: ::c_int = 38;
-
-pub const PF_UNSPEC: ::c_int = AF_UNSPEC;
-pub const PF_UNIX: ::c_int = AF_UNIX;
-pub const PF_LOCAL: ::c_int = AF_LOCAL;
-pub const PF_INET: ::c_int = AF_INET;
-pub const PF_AX25: ::c_int = AF_AX25;
-pub const PF_IPX: ::c_int = AF_IPX;
-pub const PF_APPLETALK: ::c_int = AF_APPLETALK;
-pub const PF_NETROM: ::c_int = AF_NETROM;
-pub const PF_BRIDGE: ::c_int = AF_BRIDGE;
-pub const PF_ATMPVC: ::c_int = AF_ATMPVC;
-pub const PF_X25: ::c_int = AF_X25;
-pub const PF_INET6: ::c_int = AF_INET6;
-pub const PF_ROSE: ::c_int = AF_ROSE;
-pub const PF_DECnet: ::c_int = AF_DECnet;
-pub const PF_NETBEUI: ::c_int = AF_NETBEUI;
-pub const PF_SECURITY: ::c_int = AF_SECURITY;
-pub const PF_KEY: ::c_int = AF_KEY;
-pub const PF_NETLINK: ::c_int = AF_NETLINK;
-pub const PF_ROUTE: ::c_int = AF_ROUTE;
-pub const PF_PACKET: ::c_int = AF_PACKET;
-pub const PF_ASH: ::c_int = AF_ASH;
-pub const PF_ECONET: ::c_int = AF_ECONET;
-pub const PF_ATMSVC: ::c_int = AF_ATMSVC;
-pub const PF_RDS: ::c_int = AF_RDS;
-pub const PF_SNA: ::c_int = AF_SNA;
-pub const PF_IRDA: ::c_int = AF_IRDA;
-pub const PF_PPPOX: ::c_int = AF_PPPOX;
-pub const PF_WANPIPE: ::c_int = AF_WANPIPE;
-pub const PF_LLC: ::c_int = AF_LLC;
-pub const PF_CAN: ::c_int = AF_CAN;
-pub const PF_TIPC: ::c_int = AF_TIPC;
-pub const PF_BLUETOOTH: ::c_int = AF_BLUETOOTH;
-pub const PF_IUCV: ::c_int = AF_IUCV;
-pub const PF_RXRPC: ::c_int = AF_RXRPC;
-pub const PF_ISDN: ::c_int = AF_ISDN;
-pub const PF_PHONET: ::c_int = AF_PHONET;
-pub const PF_IEEE802154: ::c_int = AF_IEEE802154;
-pub const PF_CAIF: ::c_int = AF_CAIF;
-pub const PF_ALG: ::c_int = AF_ALG;
-
-pub const SOMAXCONN: ::c_int = 128;
-
-pub const MSG_OOB: ::c_int = 1;
-pub const MSG_PEEK: ::c_int = 2;
-pub const MSG_DONTROUTE: ::c_int = 4;
-pub const MSG_CTRUNC: ::c_int = 8;
-pub const MSG_TRUNC: ::c_int = 0x20;
-pub const MSG_DONTWAIT: ::c_int = 0x40;
-pub const MSG_EOR: ::c_int = 0x80;
-pub const MSG_WAITALL: ::c_int = 0x100;
-pub const MSG_FIN: ::c_int = 0x200;
-pub const MSG_SYN: ::c_int = 0x400;
-pub const MSG_CONFIRM: ::c_int = 0x800;
-pub const MSG_RST: ::c_int = 0x1000;
-pub const MSG_ERRQUEUE: ::c_int = 0x2000;
-pub const MSG_NOSIGNAL: ::c_int = 0x4000;
-pub const MSG_MORE: ::c_int = 0x8000;
-pub const MSG_WAITFORONE: ::c_int = 0x10000;
-pub const MSG_FASTOPEN: ::c_int = 0x20000000;
-pub const MSG_CMSG_CLOEXEC: ::c_int = 0x40000000;
-
-pub const SCM_TIMESTAMP: ::c_int = SO_TIMESTAMP;
-
-pub const SOCK_RAW: ::c_int = 3;
-pub const SOCK_RDM: ::c_int = 4;
-pub const IP_MULTICAST_IF: ::c_int = 32;
-pub const IP_MULTICAST_TTL: ::c_int = 33;
-pub const IP_MULTICAST_LOOP: ::c_int = 34;
-pub const IP_TOS: ::c_int = 1;
-pub const IP_TTL: ::c_int = 2;
-pub const IP_HDRINCL: ::c_int = 3;
-pub const IP_PKTINFO: ::c_int = 8;
-pub const IP_RECVTOS: ::c_int = 13;
-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 IPV6_RECVTCLASS: ::c_int = 66;
-pub const IPV6_TCLASS: ::c_int = 67;
-
-pub const TCP_NODELAY: ::c_int = 1;
-pub const TCP_MAXSEG: ::c_int = 2;
-pub const TCP_CORK: ::c_int = 3;
-pub const TCP_KEEPIDLE: ::c_int = 4;
-pub const TCP_KEEPINTVL: ::c_int = 5;
-pub const TCP_KEEPCNT: ::c_int = 6;
-pub const TCP_SYNCNT: ::c_int = 7;
-pub const TCP_LINGER2: ::c_int = 8;
-pub const TCP_DEFER_ACCEPT: ::c_int = 9;
-pub const TCP_WINDOW_CLAMP: ::c_int = 10;
-pub const TCP_INFO: ::c_int = 11;
-pub const TCP_QUICKACK: ::c_int = 12;
-pub const TCP_CONGESTION: ::c_int = 13;
-
-pub const SO_DEBUG: ::c_int = 1;
-
-pub const SHUT_RD: ::c_int = 0;
-pub const SHUT_WR: ::c_int = 1;
-pub const SHUT_RDWR: ::c_int = 2;
-
-pub const LOCK_SH: ::c_int = 1;
-pub const LOCK_EX: ::c_int = 2;
-pub const LOCK_NB: ::c_int = 4;
-pub const LOCK_UN: ::c_int = 8;
-
-pub const SS_ONSTACK: ::c_int = 1;
-pub const SS_DISABLE: ::c_int = 2;
-
-pub const PATH_MAX: ::c_int = 4096;
-
-pub const FD_SETSIZE: usize = 1024;
-
-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 EPOLL_CTL_ADD: ::c_int = 1;
-pub const EPOLL_CTL_MOD: ::c_int = 3;
-pub const EPOLL_CTL_DEL: ::c_int = 2;
-
-pub const MNT_DETACH: ::c_int = 0x2;
-pub const MNT_EXPIRE: ::c_int = 0x4;
-
-pub const Q_GETFMT: ::c_int = 0x800004;
-pub const Q_GETINFO: ::c_int = 0x800005;
-pub const Q_SETINFO: ::c_int = 0x800006;
-pub const QIF_BLIMITS: u32 = 1;
-pub const QIF_SPACE: u32 = 2;
-pub const QIF_ILIMITS: u32 = 4;
-pub const QIF_INODES: u32 = 8;
-pub const QIF_BTIME: u32 = 16;
-pub const QIF_ITIME: u32 = 32;
-pub const QIF_LIMITS: u32 = 5;
-pub const QIF_USAGE: u32 = 10;
-pub const QIF_TIMES: u32 = 48;
-pub const QIF_ALL: u32 = 63;
-
-pub const MNT_FORCE: ::c_int = 0x1;
-
-pub const Q_SYNC: ::c_int = 0x800001;
-pub const Q_QUOTAON: ::c_int = 0x800002;
-pub const Q_QUOTAOFF: ::c_int = 0x800003;
-pub const Q_GETQUOTA: ::c_int = 0x800007;
-pub const Q_SETQUOTA: ::c_int = 0x800008;
-
-pub const TCIOFF: ::c_int = 2;
-pub const TCION: ::c_int = 3;
-pub const TCOOFF: ::c_int = 0;
-pub const TCOON: ::c_int = 1;
-pub const TCIFLUSH: ::c_int = 0;
-pub const TCOFLUSH: ::c_int = 1;
-pub const TCIOFLUSH: ::c_int = 2;
-pub const NL0: ::tcflag_t = 0x00000000;
-pub const NL1: ::tcflag_t = 0x00000100;
-pub const TAB0: ::tcflag_t = 0x00000000;
-pub const CR0: ::tcflag_t = 0x00000000;
-pub const FF0: ::tcflag_t = 0x00000000;
-pub const BS0: ::tcflag_t = 0x00000000;
-pub const VT0: ::tcflag_t = 0x00000000;
-pub const VERASE: usize = 2;
-pub const VKILL: usize = 3;
-pub const VINTR: usize = 0;
-pub const VQUIT: usize = 1;
-pub const VLNEXT: usize = 15;
-pub const IGNBRK: ::tcflag_t = 0x00000001;
-pub const BRKINT: ::tcflag_t = 0x00000002;
-pub const IGNPAR: ::tcflag_t = 0x00000004;
-pub const PARMRK: ::tcflag_t = 0x00000008;
-pub const INPCK: ::tcflag_t = 0x00000010;
-pub const ISTRIP: ::tcflag_t = 0x00000020;
-pub const INLCR: ::tcflag_t = 0x00000040;
-pub const IGNCR: ::tcflag_t = 0x00000080;
-pub const ICRNL: ::tcflag_t = 0x00000100;
-pub const IXANY: ::tcflag_t = 0x00000800;
-pub const IMAXBEL: ::tcflag_t = 0x00002000;
-pub const OPOST: ::tcflag_t = 0x1;
-pub const CS5: ::tcflag_t = 0x00000000;
-pub const CRTSCTS: ::tcflag_t = 0x80000000;
-pub const ECHO: ::tcflag_t = 0x00000008;
-pub const OCRNL: ::tcflag_t = 0o000010;
-pub const ONOCR: ::tcflag_t = 0o000020;
-pub const ONLRET: ::tcflag_t = 0o000040;
-pub const OFILL: ::tcflag_t = 0o000100;
-pub const OFDEL: ::tcflag_t = 0o000200;
-
-pub const CLONE_VM: ::c_int = 0x100;
-pub const CLONE_FS: ::c_int = 0x200;
-pub const CLONE_FILES: ::c_int = 0x400;
-pub const CLONE_SIGHAND: ::c_int = 0x800;
-pub const CLONE_PTRACE: ::c_int = 0x2000;
-pub const CLONE_VFORK: ::c_int = 0x4000;
-pub const CLONE_PARENT: ::c_int = 0x8000;
-pub const CLONE_THREAD: ::c_int = 0x10000;
-pub const CLONE_NEWNS: ::c_int = 0x20000;
-pub const CLONE_SYSVSEM: ::c_int = 0x40000;
-pub const CLONE_SETTLS: ::c_int = 0x80000;
-pub const CLONE_PARENT_SETTID: ::c_int = 0x100000;
-pub const CLONE_CHILD_CLEARTID: ::c_int = 0x200000;
-pub const CLONE_DETACHED: ::c_int = 0x400000;
-pub const CLONE_UNTRACED: ::c_int = 0x800000;
-pub const CLONE_CHILD_SETTID: ::c_int = 0x01000000;
-pub const CLONE_NEWUTS: ::c_int = 0x04000000;
-pub const CLONE_NEWIPC: ::c_int = 0x08000000;
-pub const CLONE_NEWUSER: ::c_int = 0x10000000;
-pub const CLONE_NEWPID: ::c_int = 0x20000000;
-pub const CLONE_NEWNET: ::c_int = 0x40000000;
-pub const CLONE_IO: ::c_int = 0x80000000;
-pub const CLONE_NEWCGROUP: ::c_int = 0x02000000;
-
-pub const WNOHANG: ::c_int = 0x00000001;
-pub const WUNTRACED: ::c_int = 0x00000002;
-pub const WSTOPPED: ::c_int = WUNTRACED;
-pub const WEXITED: ::c_int = 0x00000004;
-pub const WCONTINUED: ::c_int = 0x00000008;
-pub const WNOWAIT: ::c_int = 0x01000000;
-
-// Options set using PTRACE_SETOPTIONS.
-pub const PTRACE_O_TRACESYSGOOD: ::c_int = 0x00000001;
-pub const PTRACE_O_TRACEFORK: ::c_int = 0x00000002;
-pub const PTRACE_O_TRACEVFORK: ::c_int = 0x00000004;
-pub const PTRACE_O_TRACECLONE: ::c_int = 0x00000008;
-pub const PTRACE_O_TRACEEXEC: ::c_int = 0x00000010;
-pub const PTRACE_O_TRACEVFORKDONE: ::c_int = 0x00000020;
-pub const PTRACE_O_TRACEEXIT: ::c_int = 0x00000040;
-pub const PTRACE_O_TRACESECCOMP: ::c_int = 0x00000080;
-pub const PTRACE_O_EXITKILL: ::c_int = 0x00100000;
-pub const PTRACE_O_SUSPEND_SECCOMP: ::c_int = 0x00200000;
-pub const PTRACE_O_MASK: ::c_int = 0x003000ff;
-
-// Wait extended result codes for the above trace options.
-pub const PTRACE_EVENT_FORK: ::c_int = 1;
-pub const PTRACE_EVENT_VFORK: ::c_int = 2;
-pub const PTRACE_EVENT_CLONE: ::c_int = 3;
-pub const PTRACE_EVENT_EXEC: ::c_int = 4;
-pub const PTRACE_EVENT_VFORK_DONE: ::c_int = 5;
-pub const PTRACE_EVENT_EXIT: ::c_int = 6;
-pub const PTRACE_EVENT_SECCOMP: ::c_int = 7;
-// PTRACE_EVENT_STOP was added to glibc in 2.26
-// pub const PTRACE_EVENT_STOP: ::c_int = 128;
-
-pub const __WNOTHREAD: ::c_int = 0x20000000;
-pub const __WALL: ::c_int = 0x40000000;
-pub const __WCLONE: ::c_int = 0x80000000;
-
-pub const SPLICE_F_MOVE: ::c_uint = 0x01;
-pub const SPLICE_F_NONBLOCK: ::c_uint = 0x02;
-pub const SPLICE_F_MORE: ::c_uint = 0x04;
-pub const SPLICE_F_GIFT: ::c_uint = 0x08;
-
-pub const RTLD_LOCAL: ::c_int = 0;
-pub const RTLD_LAZY: ::c_int = 1;
-
-pub const POSIX_FADV_NORMAL: ::c_int = 0;
-pub const POSIX_FADV_RANDOM: ::c_int = 1;
-pub const POSIX_FADV_SEQUENTIAL: ::c_int = 2;
-pub const POSIX_FADV_WILLNEED: ::c_int = 3;
-
-pub const AT_FDCWD: ::c_int = -100;
-pub const AT_SYMLINK_NOFOLLOW: ::c_int = 0x100;
-pub const AT_REMOVEDIR: ::c_int = 0x200;
-pub const AT_SYMLINK_FOLLOW: ::c_int = 0x400;
-pub const AT_NO_AUTOMOUNT: ::c_int = 0x800;
-pub const AT_EMPTY_PATH: ::c_int = 0x1000;
-
-pub const LOG_CRON: ::c_int = 9 << 3;
-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 PIPE_BUF: usize = 4096;
-
-pub const SI_LOAD_SHIFT: ::c_uint = 16;
-
-pub const SIGEV_SIGNAL: ::c_int = 0;
-pub const SIGEV_NONE: ::c_int = 1;
-pub const SIGEV_THREAD: ::c_int = 2;
-
-pub const P_ALL: idtype_t = 0;
-pub const P_PID: idtype_t = 1;
-pub const P_PGID: idtype_t = 2;
-
-pub const UTIME_OMIT: c_long = 1073741822;
-pub const UTIME_NOW: c_long = 1073741823;
-
-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 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 IPTOS_ECN_MASK: u8 = 0x03;
-pub const IPTOS_ECN_ECT1: u8 = 0x01;
-pub const IPTOS_ECN_ECT0: u8 = 0x02;
-pub const IPTOS_ECN_CE: u8 = 0x03;
-
-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;
-
-fn CMSG_ALIGN(len: usize) -> usize {
- len + ::mem::size_of::<usize>() - 1 & !(::mem::size_of::<usize>() - 1)
-}
-
-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_DATA(cmsg: *const cmsghdr) -> *mut ::c_uchar {
- cmsg.offset(1) as *mut ::c_uchar
- }
-
- pub fn CMSG_SPACE(length: ::c_uint) -> ::c_uint {
- (CMSG_ALIGN(length as usize) + CMSG_ALIGN(::mem::size_of::<cmsghdr>()))
- as ::c_uint
- }
-
- pub fn CMSG_LEN(length: ::c_uint) -> ::c_uint {
- CMSG_ALIGN(::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;
- (*set).fds_bits[fd / size] &= !(1 << (fd % size));
- return
- }
-
- pub fn FD_ISSET(fd: ::c_int, set: *mut fd_set) -> bool {
- let fd = fd as usize;
- let size = ::mem::size_of_val(&(*set).fds_bits[0]) * 8;
- return ((*set).fds_bits[fd / size] & (1 << (fd % size))) != 0
- }
-
- pub fn FD_SET(fd: ::c_int, set: *mut fd_set) -> () {
- let fd = fd as usize;
- let size = ::mem::size_of_val(&(*set).fds_bits[0]) * 8;
- (*set).fds_bits[fd / size] |= 1 << (fd % size);
- return
- }
-
- pub fn FD_ZERO(set: *mut fd_set) -> () {
- for slot in (*set).fds_bits.iter_mut() {
- *slot = 0;
- }
- }
-
- pub fn WIFSTOPPED(status: ::c_int) -> bool {
- (status & 0xff) == 0x7f
- }
-
- pub fn WSTOPSIG(status: ::c_int) -> ::c_int {
- (status >> 8) & 0xff
- }
-
- pub fn WIFCONTINUED(status: ::c_int) -> bool {
- status == 0xffff
- }
-
- pub fn WIFSIGNALED(status: ::c_int) -> bool {
- ((status & 0x7f) + 1) as i8 >= 2
- }
-
- pub fn WTERMSIG(status: ::c_int) -> ::c_int {
- status & 0x7f
- }
-
- pub fn WIFEXITED(status: ::c_int) -> bool {
- (status & 0x7f) == 0
- }
-
- pub fn WEXITSTATUS(status: ::c_int) -> ::c_int {
- (status >> 8) & 0xff
- }
-
- pub fn WCOREDUMP(status: ::c_int) -> bool {
- (status & 0x80) != 0
- }
-
- 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
- }
-
- pub fn IPTOS_ECN(x: u8) -> u8 {
- x & ::IPTOS_ECN_MASK
- }
-}
-
-extern {
- pub fn sem_destroy(sem: *mut sem_t) -> ::c_int;
- pub fn sem_init(sem: *mut sem_t,
- pshared: ::c_int,
- value: ::c_uint)
- -> ::c_int;
- pub fn fdatasync(fd: ::c_int) -> ::c_int;
- pub fn mincore(addr: *mut ::c_void, len: ::size_t,
- vec: *mut ::c_uchar) -> ::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_settime(clk_id: ::clockid_t, tp: *const ::timespec) -> ::c_int;
- pub fn dirfd(dirp: *mut ::DIR) -> ::c_int;
-
- pub fn pthread_getattr_np(native: ::pthread_t,
- attr: *mut ::pthread_attr_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 memalign(align: ::size_t, size: ::size_t) -> *mut ::c_void;
- pub fn setgroups(ngroups: ::size_t,
- ptr: *const ::gid_t) -> ::c_int;
- pub fn pipe2(fds: *mut ::c_int, flags: ::c_int) -> ::c_int;
- pub fn statfs(path: *const ::c_char, buf: *mut statfs) -> ::c_int;
- pub fn statfs64(path: *const ::c_char, buf: *mut statfs64) -> ::c_int;
- pub fn fstatfs(fd: ::c_int, buf: *mut statfs) -> ::c_int;
- pub fn fstatfs64(fd: ::c_int, buf: *mut statfs64) -> ::c_int;
- pub fn statvfs64(path: *const ::c_char, buf: *mut statvfs64) -> ::c_int;
- pub fn fstatvfs64(fd: ::c_int, buf: *mut statvfs64) -> ::c_int;
- pub fn memrchr(cx: *const ::c_void,
- c: ::c_int,
- n: ::size_t) -> *mut ::c_void;
-
- pub fn posix_fadvise(fd: ::c_int, offset: ::off_t, len: ::off_t,
- advise: ::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 duplocale(base: ::locale_t) -> ::locale_t;
- pub fn freelocale(loc: ::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 creat64(path: *const c_char, mode: mode_t) -> ::c_int;
- pub fn fstat64(fildes: ::c_int, buf: *mut stat64) -> ::c_int;
- pub fn fstatat64(dirfd: ::c_int, pathname: *const c_char,
- buf: *mut stat64, flags: ::c_int) -> ::c_int;
- pub fn ftruncate64(fd: ::c_int, length: off64_t) -> ::c_int;
- pub fn lseek64(fd: ::c_int, offset: off64_t, whence: ::c_int) -> off64_t;
- pub fn lstat64(path: *const c_char, buf: *mut stat64) -> ::c_int;
- pub fn mmap64(addr: *mut ::c_void,
- len: ::size_t,
- prot: ::c_int,
- flags: ::c_int,
- fd: ::c_int,
- offset: off64_t)
- -> *mut ::c_void;
- pub fn open64(path: *const c_char, oflag: ::c_int, ...) -> ::c_int;
- pub fn openat64(fd: ::c_int,
- path: *const c_char,
- oflag: ::c_int, ...) -> ::c_int;
- pub fn pread64(fd: ::c_int, buf: *mut ::c_void, count: ::size_t,
- offset: off64_t) -> ::ssize_t;
- pub fn preadv64(fd: ::c_int,
- iov: *const ::iovec,
- iovcnt: ::c_int,
- offset: ::off64_t) -> ::ssize_t;
- pub fn pwrite64(fd: ::c_int, buf: *const ::c_void, count: ::size_t,
- offset: off64_t) -> ::ssize_t;
- pub fn pwritev64(fd: ::c_int,
- iov: *const ::iovec,
- iovcnt: ::c_int,
- offset: ::off64_t) -> ::ssize_t;
- pub fn readdir64(dirp: *mut ::DIR) -> *mut ::dirent64;
- pub fn readdir64_r(dirp: *mut ::DIR, entry: *mut ::dirent64,
- result: *mut *mut ::dirent64) -> ::c_int;
- 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 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,
- 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 pthread_condattr_setpshared(attr: *mut pthread_condattr_t,
- pshared: ::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_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 ptsname_r(fd: ::c_int,
- buf: *mut ::c_char,
- buflen: ::size_t) -> ::c_int;
- pub fn clearenv() -> ::c_int;
- pub fn waitid(idtype: idtype_t, id: id_t, infop: *mut ::siginfo_t,
- options: ::c_int) -> ::c_int;
- pub fn setreuid(ruid: ::uid_t, euid: ::uid_t) -> ::c_int;
- pub fn setregid(rgid: ::gid_t, egid: ::gid_t) -> ::c_int;
- pub fn getresuid(ruid: *mut ::uid_t, euid: *mut ::uid_t,
- suid: *mut ::uid_t) -> ::c_int;
- pub fn getresgid(rgid: *mut ::gid_t, egid: *mut ::gid_t,
- sgid: *mut ::gid_t) -> ::c_int;
- pub fn acct(filename: *const ::c_char) -> ::c_int;
- pub fn brk(addr: *mut ::c_void) -> ::c_int;
- pub fn sbrk(increment: ::intptr_t) -> *mut ::c_void;
- pub fn vfork() -> ::pid_t;
- 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 wait4(pid: ::pid_t, status: *mut ::c_int, options: ::c_int,
- rusage: *mut ::rusage) -> ::pid_t;
- pub fn openpty(amaster: *mut ::c_int,
- aslave: *mut ::c_int,
- name: *mut ::c_char,
- termp: *const termios,
- winp: *const ::winsize) -> ::c_int;
- pub fn forkpty(amaster: *mut ::c_int,
- name: *mut ::c_char,
- termp: *const termios,
- winp: *const ::winsize) -> ::pid_t;
- pub fn login_tty(fd: ::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 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;
- pub fn uname(buf: *mut ::utsname) -> ::c_int;
-}
-
-cfg_if! {
- if #[cfg(target_os = "emscripten")] {
- mod emscripten;
- pub use self::emscripten::*;
- } else if #[cfg(target_os = "linux")] {
- mod linux;
- pub use self::linux::*;
- } else if #[cfg(target_os = "android")] {
- mod android;
- pub use self::android::*;
- } else {
- // Unknown target_os
- }
-}
diff --git a/libc/src/unix/redox/mod.rs b/libc/src/unix/redox/mod.rs
deleted file mode 100644
index 388918e..0000000
--- a/libc/src/unix/redox/mod.rs
+++ /dev/null
@@ -1,596 +0,0 @@
-pub type c_char = i8;
-pub type c_long = i64;
-pub type c_ulong = u64;
-pub type wchar_t = i32;
-
-pub type blkcnt_t = ::c_ulong;
-pub type blksize_t = ::c_long;
-pub type clock_t = ::c_long;
-pub type clockid_t = ::c_int;
-pub type dev_t = ::c_long;
-pub type fsblkcnt_t = ::c_ulong;
-pub type fsfilcnt_t = ::c_ulong;
-pub type ino_t = ::c_ulong;
-pub type mode_t = ::c_int;
-pub type nfds_t = ::c_ulong;
-pub type nlink_t = ::c_ulong;
-pub type off_t = ::c_long;
-pub type pthread_t = *mut ::c_void;
-pub type pthread_attr_t = *mut ::c_void;
-pub type pthread_cond_t = *mut ::c_void;
-pub type pthread_condattr_t = *mut ::c_void;
-// Must be usize due to libstd/sys_common/thread_local.rs,
-// should technically be *mut ::c_void
-pub type pthread_key_t = usize;
-pub type pthread_mutex_t = *mut ::c_void;
-pub type pthread_mutexattr_t = *mut ::c_void;
-pub type pthread_rwlock_t = *mut ::c_void;
-pub type pthread_rwlockattr_t = *mut ::c_void;
-pub type rlim_t = ::c_ulonglong;
-pub type sa_family_t = u16;
-pub type sem_t = *mut ::c_void;
-pub type sigset_t = ::c_ulong;
-pub type socklen_t = u32;
-pub type speed_t = u32;
-pub type suseconds_t = ::c_int;
-pub type tcflag_t = u32;
-pub type time_t = ::c_long;
-
-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: ::size_t,
- pub ai_canonname: *mut ::c_char,
- pub ai_addr: *mut ::sockaddr,
- pub ai_next: *mut ::addrinfo,
- }
-
- pub struct dirent {
- pub d_ino: ::ino_t,
- pub d_off: ::off_t,
- pub d_reclen: ::c_ushort,
- pub d_type: ::c_uchar,
- pub d_name: [::c_char; 256],
- }
-
- pub struct Dl_info {
- pub dli_fname: *const ::c_char,
- pub dli_fbase: *mut ::c_void,
- pub dli_sname: *const ::c_char,
- pub dli_saddr: *mut ::c_void,
- }
-
- pub struct epoll_event {
- pub events: u32,
- pub u64: u64,
- pub _pad: u64,
- }
-
- pub struct fd_set {
- fds_bits: [::c_ulong; ::FD_SETSIZE / ULONG_SIZE],
- }
-
- pub struct in_addr {
- pub s_addr: ::in_addr_t,
- }
-
- pub struct ip_mreq {
- pub imr_multiaddr: ::in_addr,
- pub imr_interface: ::in_addr,
- }
-
- pub struct lconv {
- pub currency_symbol: *const ::c_char,
- pub decimal_point: *const ::c_char,
- pub frac_digits: ::c_char,
- pub grouping: *const ::c_char,
- pub int_curr_symbol: *const ::c_char,
- pub int_frac_digits: ::c_char,
- pub mon_decimal_point: *const ::c_char,
- pub mon_grouping: *const ::c_char,
- pub mon_thousands_sep: *const ::c_char,
- pub negative_sign: *const ::c_char,
- pub n_cs_precedes: ::c_char,
- pub n_sep_by_space: ::c_char,
- pub n_sign_posn: ::c_char,
- pub positive_sign: *const ::c_char,
- pub p_cs_precedes: ::c_char,
- pub p_sep_by_space: ::c_char,
- pub p_sign_posn: ::c_char,
- pub thousands_sep: *const ::c_char,
- }
-
- pub struct passwd {
- 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 sigaction {
- pub sa_handler: ::sighandler_t,
- pub sa_flags: ::c_ulong,
- pub sa_restorer: ::Option<extern fn()>,
- pub sa_mask: ::sigset_t,
- }
-
- pub struct sockaddr {
- pub sa_family: ::sa_family_t,
- pub sa_data: [::c_char; 14],
- }
-
- pub struct sockaddr_in {
- 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_family: ::sa_family_t,
- pub sin6_port: ::in_port_t,
- pub sin6_flowinfo: u32,
- pub sin6_addr: ::in6_addr,
- pub sin6_scope_id: u32,
- }
-
- pub struct sockaddr_storage {
- pub ss_family: ::sa_family_t,
- __ss_padding: [
- u8;
- 128 -
- ::core::mem::size_of::<sa_family_t>() -
- ::core::mem::size_of::<c_ulong>()
- ],
- __ss_align: ::c_ulong,
- }
-
- 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_nlink: ::nlink_t,
- pub st_mode: ::mode_t,
- pub st_uid: ::uid_t,
- pub st_gid: ::gid_t,
- 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,
- _pad: [::c_char; 24],
- }
-
- 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,
- }
-
- pub struct termios {
- pub c_iflag: ::tcflag_t,
- pub c_oflag: ::tcflag_t,
- pub c_cflag: ::tcflag_t,
- pub c_lflag: ::tcflag_t,
- pub c_line: ::cc_t,
- pub c_cc: [::cc_t; ::NCCS],
- pub c_ispeed: ::speed_t,
- pub c_ospeed: ::speed_t,
- }
-
- 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 tm_gmtoff: ::c_long,
- pub tm_zone: *const ::c_char,
- }
-}
-
-// TODO: relibc {
- pub const RTLD_DEFAULT: *mut ::c_void = 0i64 as *mut ::c_void;
-// }
-
-// dlfcn.h
-
-pub const RTLD_LAZY: ::c_int = 0x0001;
-pub const RTLD_NOW: ::c_int = 0x0002;
-pub const RTLD_GLOBAL: ::c_int = 0x0100;
-pub const RTLD_LOCAL: ::c_int = 0x0000;
-
-// errno.h
-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 ENOTBLK: ::c_int = 15;
-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 ENOSYS: ::c_int = 38;
-pub const EWOULDBLOCK: ::c_int = 41;
-pub const EADDRINUSE: ::c_int = 98;
-pub const EADDRNOTAVAIL: ::c_int = 99;
-pub const ECONNABORTED: ::c_int = 103;
-pub const ECONNRESET: ::c_int = 104;
-pub const ENOTCONN: ::c_int = 107;
-pub const ETIMEDOUT: ::c_int = 110;
-pub const ECONNREFUSED: ::c_int = 111;
-pub const EINPROGRESS: ::c_int = 115;
-
-// fcntl.h
-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;
-// TODO: relibc {
- pub const F_DUPFD_CLOEXEC: ::c_int = ::F_DUPFD;
-// }
-pub const FD_CLOEXEC: ::c_int = 0x0100_0000;
-pub const O_RDONLY: ::c_int = 0x0001_0000;
-pub const O_WRONLY: ::c_int = 0x0002_0000;
-pub const O_RDWR: ::c_int = 0x0003_0000;
-pub const O_ACCMODE: ::c_int = 0x0003_0000;
-pub const O_NONBLOCK: ::c_int = 0x0004_0000;
-pub const O_APPEND: ::c_int = 0x0008_0000;
-pub const O_SHLOCK: ::c_int = 0x0010_0000;
-pub const O_EXLOCK: ::c_int = 0x0020_0000;
-pub const O_ASYNC: ::c_int = 0x0040_0000;
-pub const O_FSYNC: ::c_int = 0x0080_0000;
-pub const O_CLOEXEC: ::c_int = 0x0100_0000;
-pub const O_CREAT: ::c_int = 0x0200_0000;
-pub const O_TRUNC: ::c_int = 0x0400_0000;
-pub const O_EXCL: ::c_int = 0x0800_0000;
-pub const O_DIRECTORY: ::c_int = 0x1000_0000;
-pub const O_PATH: ::c_int = 0x2000_0000;
-pub const O_SYMLINK: ::c_int = 0x4000_0000;
-// Negative to allow it to be used as int
-// TODO: Fix negative values missing from includes
-pub const O_NOFOLLOW: ::c_int = -0x8000_0000;
-
-// netdb.h
-pub const EAI_SYSTEM: ::c_int = -11;
-
-// netinet/in.h
-// TODO: relibc {
- pub const IP_TTL: ::c_int = 2;
- 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 IP_MULTICAST_IF: ::c_int = 32;
- pub const IP_MULTICAST_TTL: ::c_int = 33;
- pub const IP_MULTICAST_LOOP: ::c_int = 34;
- pub const IP_ADD_MEMBERSHIP: ::c_int = 35;
- pub const IP_DROP_MEMBERSHIP: ::c_int = 36;
-// }
-
-// netinet/tcp.h
-pub const TCP_NODELAY: ::c_int = 1;
-// TODO: relibc {
- pub const TCP_KEEPIDLE: ::c_int = 1;
-// }
-
-// poll.h
-pub const POLLIN: ::c_short = 0x001;
-pub const POLLPRI: ::c_short = 0x002;
-pub const POLLOUT: ::c_short = 0x004;
-pub const POLLERR: ::c_short = 0x008;
-pub const POLLHUP: ::c_short = 0x010;
-pub const POLLNVAL: ::c_short = 0x020;
-
-// pthread.h
-pub const PTHREAD_MUTEX_NORMAL: ::c_int = 0;
-pub const PTHREAD_MUTEX_RECURSIVE: ::c_int = 1;
-pub const PTHREAD_MUTEX_INITIALIZER: ::pthread_mutex_t = -1isize as *mut _;
-pub const PTHREAD_COND_INITIALIZER: ::pthread_cond_t = -1isize as *mut _;
-pub const PTHREAD_RWLOCK_INITIALIZER: ::pthread_rwlock_t = -1isize as *mut _;
-pub const PTHREAD_STACK_MIN : ::size_t = 4096;
-
-// signal.h
-pub const SIG_BLOCK: ::c_int = 0;
-pub const SIG_UNBLOCK: ::c_int = 1;
-pub const SIG_SETMASK: ::c_int = 2;
-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 const NSIG: ::c_int = 32;
-
-// sys/epoll.h
-pub const EPOLL_CLOEXEC: ::c_int = 0x0100_0000;
-pub const EPOLL_CTL_ADD: ::c_int = 1;
-pub const EPOLL_CTL_DEL: ::c_int = 2;
-pub const EPOLL_CTL_MOD: ::c_int = 3;
-pub const EPOLLIN: ::c_int = 1;
-pub const EPOLLPRI: ::c_int = 0;
-pub const EPOLLOUT: ::c_int = 2;
-pub const EPOLLRDNORM: ::c_int = 0;
-pub const EPOLLNVAL: ::c_int = 0;
-pub const EPOLLRDBAND: ::c_int = 0;
-pub const EPOLLWRNORM: ::c_int = 0;
-pub const EPOLLWRBAND: ::c_int = 0;
-pub const EPOLLMSG: ::c_int = 0;
-pub const EPOLLERR: ::c_int = 0;
-pub const EPOLLHUP: ::c_int = 0;
-pub const EPOLLRDHUP: ::c_int = 0;
-pub const EPOLLEXCLUSIVE: ::c_int = 0;
-pub const EPOLLWAKEUP: ::c_int = 0;
-pub const EPOLLONESHOT: ::c_int = 0;
-pub const EPOLLET: ::c_int = 0;
-
-// sys/stat.h
-pub const S_IFMT: ::c_int = 0o0_170_000;
-pub const S_IFDIR: ::c_int = 0o040_000;
-pub const S_IFCHR: ::c_int = 0o020_000;
-pub const S_IFBLK: ::c_int = 0o060_000;
-pub const S_IFREG: ::c_int = 0o100_000;
-pub const S_IFIFO: ::c_int = 0o010_000;
-pub const S_IFLNK: ::c_int = 0o120_000;
-pub const S_IFSOCK: ::c_int = 0o140_000;
-pub const S_IRWXU: ::c_int = 0o0_700;
-pub const S_IRUSR: ::c_int = 0o0_400;
-pub const S_IWUSR: ::c_int = 0o0_200;
-pub const S_IXUSR: ::c_int = 0o0_100;
-pub const S_IRWXG: ::c_int = 0o0_070;
-pub const S_IRGRP: ::c_int = 0o0_040;
-pub const S_IWGRP: ::c_int = 0o0_020;
-pub const S_IXGRP: ::c_int = 0o0_010;
-pub const S_IRWXO: ::c_int = 0o0_007;
-pub const S_IROTH: ::c_int = 0o0_004;
-pub const S_IWOTH: ::c_int = 0o0_002;
-pub const S_IXOTH: ::c_int = 0o0_001;
-
-// stdlib.h
-pub const EXIT_SUCCESS: ::c_int = 0;
-pub const EXIT_FAILURE: ::c_int = 1;
-
-// sys/ioctl.h
-// TODO: relibc {
- pub const FIONBIO: ::c_ulong = 0x5421;
- pub const FIOCLEX: ::c_ulong = 0x5451;
-// }
-pub const TCGETS: ::c_ulong = 0x5401;
-pub const TCSETS: ::c_ulong = 0x5402;
-pub const TCFLSH: ::c_ulong = 0x540B;
-pub const TIOCGPGRP: ::c_ulong = 0x540F;
-pub const TIOCSPGRP: ::c_ulong = 0x5410;
-pub const TIOCGWINSZ: ::c_ulong = 0x5413;
-pub const TIOCSWINSZ: ::c_ulong = 0x5414;
-
-// sys/select.h
-pub const FD_SETSIZE: usize = 1024;
-
-// sys/socket.h
-pub const AF_UNIX: ::c_int = 1;
-pub const AF_INET: ::c_int = 2;
-pub const AF_INET6: ::c_int = 10;
-pub const MSG_PEEK: ::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 SO_REUSEADDR: ::c_int = 2;
-pub const SO_ERROR: ::c_int = 4;
-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_LINGER: ::c_int = 13;
-pub const SO_REUSEPORT: ::c_int = 15;
-pub const SO_RCVTIMEO: ::c_int = 20;
-pub const SO_SNDTIMEO: ::c_int = 21;
-pub const SOCK_STREAM: ::c_int = 1;
-pub const SOCK_DGRAM: ::c_int = 2;
-pub const SOL_SOCKET: ::c_int = 1;
-
-// sys/wait.h
-pub const WNOHANG: ::c_int = 1;
-
-// termios.h
-pub const NCCS: usize = 32;
-
-// time.h
-pub const CLOCK_REALTIME: ::c_int = 1;
-pub const CLOCK_MONOTONIC: ::c_int = 4;
-
-// unistd.h
-pub const _SC_PAGESIZE: ::c_int = 30;
-pub const SEEK_SET: ::c_int = 0;
-pub const SEEK_CUR: ::c_int = 1;
-pub const SEEK_END: ::c_int = 2;
-pub const STDIN_FILENO: ::c_int = 0;
-pub const STDOUT_FILENO: ::c_int = 1;
-pub const STDERR_FILENO: ::c_int = 2;
-
-// wait.h
-pub fn WIFSTOPPED(status: ::c_int) -> bool {
- (status & 0xff) == 0x7f
-}
-
-pub fn WSTOPSIG(status: ::c_int) -> ::c_int {
- (status >> 8) & 0xff
-}
-
-pub fn WIFCONTINUED(status: ::c_int) -> bool {
- status == 0xffff
-}
-
-pub fn WIFSIGNALED(status: ::c_int) -> bool {
- ((status & 0x7f) + 1) as i8 >= 2
-}
-
-pub fn WTERMSIG(status: ::c_int) -> ::c_int {
- status & 0x7f
-}
-
-pub fn WIFEXITED(status: ::c_int) -> bool {
- (status & 0x7f) == 0
-}
-
-pub fn WEXITSTATUS(status: ::c_int) -> ::c_int {
- (status >> 8) & 0xff
-}
-
-pub fn WCOREDUMP(status: ::c_int) -> bool {
- (status & 0x80) != 0
-}
-
-// intentionally not public, only used for fd_set
-cfg_if! {
- if #[cfg(target_pointer_width = "32")] {
- const ULONG_SIZE: usize = 32;
- } else if #[cfg(target_pointer_width = "64")] {
- const ULONG_SIZE: usize = 64;
- } else {
- // Unknown target_pointer_width
- }
-}
-
-extern {
- pub fn getrlimit(resource: ::c_int, rlim: *mut ::rlimit) -> ::c_int;
- pub fn setrlimit(resource: ::c_int, rlim: *const ::rlimit) -> ::c_int;
-
- pub fn strerror_r(errnum: ::c_int, buf: *mut c_char,
- buflen: ::size_t) -> ::c_int;
-
- // malloc.h
- pub fn memalign(align: ::size_t, size: ::size_t) -> *mut ::c_void;
-
- // pthread.h
- pub fn pthread_atfork(prepare: ::Option<unsafe extern fn()>,
- parent: ::Option<unsafe extern fn()>,
- child: ::Option<unsafe extern fn()>) -> ::c_int;
- 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_condattr_setclock(attr: *mut pthread_condattr_t,
- clock_id: ::clockid_t) -> ::c_int;
-
- // signal.h
- pub fn pthread_sigmask(how: ::c_int,
- set: *const ::sigset_t,
- oldset: *mut ::sigset_t) -> ::c_int;
-
- // sys/epoll.h
- 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;
-
- // sys/ioctl.h
- pub fn ioctl(fd: ::c_int, request: ::c_ulong, ...) -> ::c_int;
-
- // sys/socket.h
- pub fn bind(socket: ::c_int, address: *const ::sockaddr,
- address_len: ::socklen_t) -> ::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;
-
- // sys/uio.h
- pub fn readv(fd: ::c_int,
- iov: *const ::iovec,
- iovcnt: ::c_int) -> ::ssize_t;
- pub fn writev(fd: ::c_int,
- iov: *const ::iovec,
- iovcnt: ::c_int) -> ::ssize_t;
-
- // time.h
- pub fn gettimeofday(tp: *mut ::timeval,
- tz: *mut ::timezone) -> ::c_int;
- pub fn clock_gettime(clk_id: ::clockid_t, tp: *mut ::timespec) -> ::c_int;
-}
diff --git a/libc/src/unix/solarish/compat.rs b/libc/src/unix/solarish/compat.rs
deleted file mode 100644
index 8631d60..0000000
--- a/libc/src/unix/solarish/compat.rs
+++ /dev/null
@@ -1,21 +0,0 @@
-// Common functions that are unfortunately missing on illumos and
-// Solaris, but often needed by other crates.
-
-use unix::solarish::*;
-
-pub unsafe fn cfmakeraw(termios: *mut ::termios) {
- let mut t = *termios as ::termios;
- t.c_iflag &= !(IMAXBEL|IGNBRK|BRKINT|PARMRK|ISTRIP|INLCR|IGNCR|ICRNL|IXON);
- t.c_oflag &= !OPOST;
- t.c_lflag &= !(ECHO|ECHONL|ICANON|ISIG|IEXTEN);
- t.c_cflag &= !(CSIZE|PARENB);
- t.c_cflag |= CS8;
-}
-
-pub unsafe fn cfsetspeed(termios: *mut ::termios, speed: ::speed_t) -> ::c_int {
- // Neither of these functions on illumos or Solaris actually ever
- // return an error
- ::cfsetispeed(termios, speed);
- ::cfsetospeed(termios, speed);
- 0
-}
diff --git a/libc/src/unix/solarish/mod.rs b/libc/src/unix/solarish/mod.rs
deleted file mode 100644
index 49f76ea..0000000
--- a/libc/src/unix/solarish/mod.rs
+++ /dev/null
@@ -1,2046 +0,0 @@
-pub type c_char = i8;
-pub type c_long = i64;
-pub type c_ulong = u64;
-
-pub type clockid_t = ::c_int;
-pub type blkcnt_t = ::c_long;
-pub type clock_t = ::c_long;
-pub type daddr_t = ::c_long;
-pub type dev_t = ::c_ulong;
-pub type fsblkcnt_t = ::c_ulong;
-pub type fsfilcnt_t = ::c_ulong;
-pub type ino_t = ::c_ulong;
-pub type key_t = ::c_int;
-pub type major_t = ::c_uint;
-pub type minor_t = ::c_uint;
-pub type mode_t = ::c_uint;
-pub type nlink_t = ::c_uint;
-pub type rlim_t = ::c_ulong;
-pub type speed_t = ::c_uint;
-pub type tcflag_t = ::c_uint;
-pub type time_t = ::c_long;
-pub type wchar_t = ::c_int;
-pub type nfds_t = ::c_ulong;
-
-pub type suseconds_t = ::c_long;
-pub type off_t = ::c_long;
-pub type useconds_t = ::c_uint;
-pub type socklen_t = ::c_uint;
-pub type sa_family_t = u16;
-pub type pthread_t = ::c_uint;
-pub type pthread_key_t = ::c_uint;
-pub type blksize_t = ::c_int;
-pub type nl_item = ::c_int;
-pub type id_t = ::c_int;
-pub type idtype_t = ::c_uint;
-
-#[cfg_attr(feature = "extra_traits", derive(Debug))]
-pub enum timezone {}
-impl ::Copy for timezone {}
-impl ::Clone for timezone {
- fn clone(&self) -> timezone { *self }
-}
-
-s! {
- pub struct in_addr {
- pub s_addr: ::in_addr_t,
- }
-
- pub struct ip_mreq {
- pub imr_multiaddr: in_addr,
- pub imr_interface: in_addr,
- }
-
- pub struct sockaddr {
- pub sa_family: sa_family_t,
- pub sa_data: [::c_char; 14],
- }
-
- pub struct sockaddr_in {
- 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_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 __sin6_src_id: u32
- }
-
- pub struct passwd {
- pub pw_name: *mut ::c_char,
- pub pw_passwd: *mut ::c_char,
- pub pw_uid: ::uid_t,
- pub pw_gid: ::gid_t,
- pub pw_age: *mut ::c_char,
- pub pw_comment: *mut ::c_char,
- pub pw_gecos: *mut ::c_char,
- pub pw_dir: *mut ::c_char,
- pub pw_shell: *mut ::c_char
- }
-
- pub struct ifaddrs {
- pub ifa_next: *mut ifaddrs,
- pub ifa_name: *mut ::c_char,
- pub ifa_flags: ::c_ulong,
- pub ifa_addr: *mut ::sockaddr,
- pub ifa_netmask: *mut ::sockaddr,
- pub ifa_dstaddr: *mut ::sockaddr,
- pub ifa_data: *mut ::c_void
- }
-
- 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 msghdr {
- pub msg_name: *mut ::c_void,
- pub msg_namelen: ::socklen_t,
- pub msg_iov: *mut ::iovec,
- pub msg_iovlen: ::c_int,
- pub msg_control: *mut ::c_void,
- pub msg_controllen: ::socklen_t,
- pub msg_flags: ::c_int,
- }
-
- pub struct cmsghdr {
- pub cmsg_len: ::socklen_t,
- pub cmsg_level: ::c_int,
- pub cmsg_type: ::c_int,
- }
-
- pub struct pthread_attr_t {
- __pthread_attrp: *mut ::c_void
- }
-
- pub struct pthread_mutex_t {
- __pthread_mutex_flag1: u16,
- __pthread_mutex_flag2: u8,
- __pthread_mutex_ceiling: u8,
- __pthread_mutex_type: u16,
- __pthread_mutex_magic: u16,
- __pthread_mutex_lock: u64,
- __pthread_mutex_data: u64
- }
-
- pub struct pthread_mutexattr_t {
- __pthread_mutexattrp: *mut ::c_void
- }
-
- pub struct pthread_cond_t {
- __pthread_cond_flag: [u8; 4],
- __pthread_cond_type: u16,
- __pthread_cond_magic: u16,
- __pthread_cond_data: u64
- }
-
- pub struct pthread_condattr_t {
- __pthread_condattrp: *mut ::c_void,
- }
-
- pub struct pthread_rwlock_t {
- __pthread_rwlock_readers: i32,
- __pthread_rwlock_type: u16,
- __pthread_rwlock_magic: u16,
- __pthread_rwlock_mutex: ::pthread_mutex_t,
- __pthread_rwlock_readercv: ::pthread_cond_t,
- __pthread_rwlock_writercv: ::pthread_cond_t
- }
-
- pub struct pthread_rwlockattr_t {
- __pthread_rwlockattrp: *mut ::c_void,
- }
-
- pub struct dirent {
- pub d_ino: ::ino_t,
- pub d_off: ::off_t,
- pub d_reclen: u16,
- pub d_name: [::c_char; 3]
- }
-
- pub struct glob_t {
- pub gl_pathc: ::size_t,
- pub gl_pathv: *mut *mut ::c_char,
- pub gl_offs: ::size_t,
- __unused1: *mut ::c_void,
- __unused2: ::c_int,
- __unused3: ::c_int,
- __unused4: ::c_int,
- __unused5: *mut ::c_void,
- __unused6: *mut ::c_void,
- __unused7: *mut ::c_void,
- __unused8: *mut ::c_void,
- __unused9: *mut ::c_void,
- __unused10: *mut ::c_void,
- }
-
- pub struct addrinfo {
- pub ai_flags: ::c_int,
- pub ai_family: ::c_int,
- pub ai_socktype: ::c_int,
- pub ai_protocol: ::c_int,
- #[cfg(target_arch = "sparc64")]
- __sparcv9_pad: ::c_int,
- pub ai_addrlen: ::socklen_t,
- pub ai_canonname: *mut ::c_char,
- pub ai_addr: *mut ::sockaddr,
- pub ai_next: *mut addrinfo,
- }
-
- pub struct sigset_t {
- bits: [u32; 4],
- }
-
- pub struct sigaction {
- pub sa_flags: ::c_int,
- pub sa_sigaction: ::sighandler_t,
- pub sa_mask: sigset_t,
- }
-
- pub struct sigevent {
- pub sigev_notify: ::c_int,
- pub sigev_signo: ::c_int,
- pub sigev_value: ::sigval,
- pub ss_sp: *mut ::c_void,
- pub sigev_notify_attributes: *const ::pthread_attr_t,
- __sigev_pad2: ::c_int,
- }
-
- pub struct stack_t {
- pub ss_sp: *mut ::c_void,
- pub ss_size: ::size_t,
- pub ss_flags: ::c_int,
- }
-
- pub struct statvfs {
- pub f_bsize: ::c_ulong,
- pub f_frsize: ::c_ulong,
- pub f_blocks: ::fsblkcnt_t,
- pub f_bfree: ::fsblkcnt_t,
- pub f_bavail: ::fsblkcnt_t,
- pub f_files: ::fsfilcnt_t,
- pub f_ffree: ::fsfilcnt_t,
- pub f_favail: ::fsfilcnt_t,
- pub f_fsid: ::c_ulong,
- pub f_basetype: [::c_char; 16],
- pub f_flag: ::c_ulong,
- pub f_namemax: ::c_ulong,
- pub f_fstr: [::c_char; 32]
- }
-
- pub struct sched_param {
- pub sched_priority: ::c_int,
- sched_pad: [::c_int; 8]
- }
-
- pub struct Dl_info {
- pub dli_fname: *const ::c_char,
- pub dli_fbase: *mut ::c_void,
- pub dli_sname: *const ::c_char,
- pub dli_saddr: *mut ::c_void,
- }
-
- 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,
- __unused: [::c_char; 16]
- }
-
- pub struct termios {
- 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; ::NCCS]
- }
-
- 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 sem_t {
- pub sem_count: u32,
- pub sem_type: u16,
- pub sem_magic: u16,
- pub sem_pad1: [u64; 3],
- pub sem_pad2: [u64; 2]
- }
-
- pub struct flock {
- pub l_type: ::c_short,
- pub l_whence: ::c_short,
- pub l_start: ::off_t,
- pub l_len: ::off_t,
- pub l_sysid: ::c_int,
- pub l_pid: ::pid_t,
- pub l_pad: [::c_long; 4]
- }
-
- pub struct if_nameindex {
- pub if_index: ::c_uint,
- pub if_name: *mut ::c_char,
- }
-
- pub struct port_event {
- pub portev_events: ::c_int,
- pub portev_source: ::c_ushort,
- pub portev_pad: ::c_ushort,
- pub portev_object: ::uintptr_t,
- pub portev_user: *mut ::c_void,
- }
-}
-
-s_no_extra_traits! {
- #[cfg_attr(any(target_arch = "x86", target_arch = "x86_64"), repr(packed))]
- pub struct epoll_event {
- pub events: u32,
- pub u64: u64,
- }
-
- pub struct sockaddr_un {
- pub sun_family: sa_family_t,
- pub sun_path: [c_char; 108]
- }
-
- pub struct utsname {
- pub sysname: [::c_char; 257],
- pub nodename: [::c_char; 257],
- pub release: [::c_char; 257],
- pub version: [::c_char; 257],
- pub machine: [::c_char; 257],
- }
-
- pub struct fd_set {
- #[cfg(target_pointer_width = "64")]
- fds_bits: [i64; FD_SETSIZE / 64],
- #[cfg(target_pointer_width = "32")]
- fds_bits: [i32; FD_SETSIZE / 32],
- }
-
- pub struct sockaddr_storage {
- pub ss_family: ::sa_family_t,
- __ss_pad1: [u8; 6],
- __ss_align: i64,
- __ss_pad2: [u8; 240],
- }
-
- pub struct siginfo_t {
- pub si_signo: ::c_int,
- pub si_code: ::c_int,
- pub si_errno: ::c_int,
- pub si_pad: ::c_int,
- pub si_addr: *mut ::c_void,
- __pad: [u8; 232],
- }
-
- pub struct sockaddr_dl {
- pub sdl_family: ::c_ushort,
- pub sdl_index: ::c_ushort,
- pub sdl_type: ::c_uchar,
- pub sdl_nlen: ::c_uchar,
- pub sdl_alen: ::c_uchar,
- pub sdl_slen: ::c_uchar,
- pub sdl_data: [::c_char; 244],
- }
-}
-
-cfg_if! {
- if #[cfg(feature = "extra_traits")] {
- impl PartialEq for epoll_event {
- fn eq(&self, other: &epoll_event) -> bool {
- self.events == other.events
- && self.u64 == other.u64
- }
- }
- impl Eq for epoll_event {}
- impl ::fmt::Debug for epoll_event {
- fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
- let events = self.events;
- let u64 = self.u64;
- f.debug_struct("epoll_event")
- .field("events", &events)
- .field("u64", &u64)
- .finish()
- }
- }
- impl ::hash::Hash for epoll_event {
- fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
- let events = self.events;
- let u64 = self.u64;
- events.hash(state);
- u64.hash(state);
- }
- }
-
- impl PartialEq for sockaddr_un {
- fn eq(&self, other: &sockaddr_un) -> bool {
- self.sun_family == other.sun_family
- && self
- .sun_path
- .iter()
- .zip(other.sun_path.iter())
- .all(|(a, b)| a == b)
- }
- }
- impl Eq for sockaddr_un {}
- impl ::fmt::Debug for sockaddr_un {
- fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
- f.debug_struct("sockaddr_un")
- .field("sun_family", &self.sun_family)
- // FIXME: .field("sun_path", &self.sun_path)
- .finish()
- }
- }
- impl ::hash::Hash for sockaddr_un {
- fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
- self.sun_family.hash(state);
- self.sun_path.hash(state);
- }
- }
-
- impl PartialEq for utsname {
- fn eq(&self, other: &utsname) -> bool {
- self.sysname
- .iter()
- .zip(other.sysname.iter())
- .all(|(a, b)| a == b)
- && self
- .nodename
- .iter()
- .zip(other.nodename.iter())
- .all(|(a, b)| a == b)
- && self
- .release
- .iter()
- .zip(other.release.iter())
- .all(|(a, b)| a == b)
- && self
- .version
- .iter()
- .zip(other.version.iter())
- .all(|(a, b)| a == b)
- && self
- .machine
- .iter()
- .zip(other.machine.iter())
- .all(|(a, b)| a == b)
- }
- }
- impl Eq for utsname {}
- impl ::fmt::Debug for utsname {
- fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
- f.debug_struct("utsname")
- // FIXME: .field("sysname", &self.sysname)
- // FIXME: .field("nodename", &self.nodename)
- // FIXME: .field("release", &self.release)
- // FIXME: .field("version", &self.version)
- // FIXME: .field("machine", &self.machine)
- .finish()
- }
- }
- impl ::hash::Hash for utsname {
- fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
- self.sysname.hash(state);
- self.nodename.hash(state);
- self.release.hash(state);
- self.version.hash(state);
- self.machine.hash(state);
- }
- }
-
- impl PartialEq for fd_set {
- fn eq(&self, other: &fd_set) -> bool {
- self.fds_bits
- .iter()
- .zip(other.fds_bits.iter())
- .all(|(a, b)| a == b)
- }
- }
- impl Eq for fd_set {}
- impl ::fmt::Debug for fd_set {
- fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
- f.debug_struct("fd_set")
- // FIXME: .field("fds_bits", &self.fds_bits)
- .finish()
- }
- }
- impl ::hash::Hash for fd_set {
- fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
- self.fds_bits.hash(state);
- }
- }
-
- impl PartialEq for sockaddr_storage {
- fn eq(&self, other: &sockaddr_storage) -> bool {
- self.ss_family == other.ss_family
- && self.__ss_pad1 == other.__ss_pad1
- && self.__ss_align == other.__ss_align
- && self
- .__ss_pad2
- .iter()
- .zip(other.__ss_pad2.iter())
- .all(|(a, b)| a == b)
- }
- }
- impl Eq for sockaddr_storage {}
- impl ::fmt::Debug for sockaddr_storage {
- fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
- f.debug_struct("sockaddr_storage")
- .field("ss_family", &self.ss_family)
- .field("__ss_pad1", &self.__ss_pad1)
- .field("__ss_align", &self.__ss_align)
- // FIXME: .field("__ss_pad2", &self.__ss_pad2)
- .finish()
- }
- }
- impl ::hash::Hash for sockaddr_storage {
- fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
- self.ss_family.hash(state);
- self.__ss_pad1.hash(state);
- self.__ss_align.hash(state);
- self.__ss_pad2.hash(state);
- }
- }
-
- impl PartialEq for siginfo_t {
- fn eq(&self, other: &siginfo_t) -> bool {
- self.si_signo == other.si_signo
- && self.si_code == other.si_code
- && self.si_errno == other.si_errno
- && self.si_addr == other.si_addr
- && self
- .__pad
- .iter()
- .zip(other.__pad.iter())
- .all(|(a, b)| a == b)
- }
- }
- impl Eq for siginfo_t {}
- impl ::fmt::Debug for siginfo_t {
- fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
- f.debug_struct("siginfo_t")
- .field("si_signo", &self.si_signo)
- .field("si_code", &self.si_code)
- .field("si_errno", &self.si_errno)
- .field("si_addr", &self.si_addr)
- // FIXME: .field("__pad", &self.__pad)
- .finish()
- }
- }
- impl ::hash::Hash for siginfo_t {
- fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
- self.si_signo.hash(state);
- self.si_code.hash(state);
- self.si_errno.hash(state);
- self.si_addr.hash(state);
- self.__pad.hash(state);
- }
- }
-
- impl PartialEq for sockaddr_dl {
- fn eq(&self, other: &sockaddr_dl) -> bool {
- self.sdl_family == other.sdl_family
- && self.sdl_index == other.sdl_index
- && self.sdl_type == other.sdl_type
- && self.sdl_nlen == other.sdl_nlen
- && self.sdl_alen == other.sdl_alen
- && self.sdl_slen == other.sdl_slen
- && self
- .sdl_data
- .iter()
- .zip(other.sdl_data.iter())
- .all(|(a,b)| a == b)
- }
- }
- impl Eq for sockaddr_dl {}
- impl ::fmt::Debug for sockaddr_dl {
- fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
- f.debug_struct("sockaddr_dl")
- .field("sdl_family", &self.sdl_family)
- .field("sdl_index", &self.sdl_index)
- .field("sdl_type", &self.sdl_type)
- .field("sdl_nlen", &self.sdl_nlen)
- .field("sdl_alen", &self.sdl_alen)
- .field("sdl_slen", &self.sdl_slen)
- // FIXME: .field("sdl_data", &self.sdl_data)
- .finish()
- }
- }
- impl ::hash::Hash for sockaddr_dl {
- fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
- self.sdl_family.hash(state);
- self.sdl_index.hash(state);
- self.sdl_type.hash(state);
- self.sdl_nlen.hash(state);
- self.sdl_alen.hash(state);
- self.sdl_slen.hash(state);
- self.sdl_data.hash(state);
- }
- }
- }
-}
-
-pub const LC_CTYPE: ::c_int = 0;
-pub const LC_NUMERIC: ::c_int = 1;
-pub const LC_TIME: ::c_int = 2;
-pub const LC_COLLATE: ::c_int = 3;
-pub const LC_MONETARY: ::c_int = 4;
-pub const LC_MESSAGES: ::c_int = 5;
-pub const LC_ALL: ::c_int = 6;
-pub const LC_CTYPE_MASK: ::c_int = (1 << LC_CTYPE);
-pub const LC_NUMERIC_MASK: ::c_int = (1 << LC_NUMERIC);
-pub const LC_TIME_MASK: ::c_int = (1 << LC_TIME);
-pub const LC_COLLATE_MASK: ::c_int = (1 << LC_COLLATE);
-pub const LC_MONETARY_MASK: ::c_int = (1 << LC_MONETARY);
-pub const LC_MESSAGES_MASK: ::c_int = (1 << LC_MESSAGES);
-pub const LC_ALL_MASK: ::c_int = LC_CTYPE_MASK
- | LC_NUMERIC_MASK
- | LC_TIME_MASK
- | LC_COLLATE_MASK
- | LC_MONETARY_MASK
- | LC_MESSAGES_MASK;
-
-pub const DAY_1: ::nl_item = 1;
-pub const DAY_2: ::nl_item = 2;
-pub const DAY_3: ::nl_item = 3;
-pub const DAY_4: ::nl_item = 4;
-pub const DAY_5: ::nl_item = 5;
-pub const DAY_6: ::nl_item = 6;
-pub const DAY_7: ::nl_item = 7;
-
-pub const ABDAY_1: ::nl_item = 8;
-pub const ABDAY_2: ::nl_item = 9;
-pub const ABDAY_3: ::nl_item = 10;
-pub const ABDAY_4: ::nl_item = 11;
-pub const ABDAY_5: ::nl_item = 12;
-pub const ABDAY_6: ::nl_item = 13;
-pub const ABDAY_7: ::nl_item = 14;
-
-pub const MON_1: ::nl_item = 15;
-pub const MON_2: ::nl_item = 16;
-pub const MON_3: ::nl_item = 17;
-pub const MON_4: ::nl_item = 18;
-pub const MON_5: ::nl_item = 19;
-pub const MON_6: ::nl_item = 20;
-pub const MON_7: ::nl_item = 21;
-pub const MON_8: ::nl_item = 22;
-pub const MON_9: ::nl_item = 23;
-pub const MON_10: ::nl_item = 24;
-pub const MON_11: ::nl_item = 25;
-pub const MON_12: ::nl_item = 26;
-
-pub const ABMON_1: ::nl_item = 27;
-pub const ABMON_2: ::nl_item = 28;
-pub const ABMON_3: ::nl_item = 29;
-pub const ABMON_4: ::nl_item = 30;
-pub const ABMON_5: ::nl_item = 31;
-pub const ABMON_6: ::nl_item = 32;
-pub const ABMON_7: ::nl_item = 33;
-pub const ABMON_8: ::nl_item = 34;
-pub const ABMON_9: ::nl_item = 35;
-pub const ABMON_10: ::nl_item = 36;
-pub const ABMON_11: ::nl_item = 37;
-pub const ABMON_12: ::nl_item = 38;
-
-pub const RADIXCHAR: ::nl_item = 39;
-pub const THOUSEP: ::nl_item = 40;
-pub const YESSTR: ::nl_item = 41;
-pub const NOSTR: ::nl_item = 42;
-pub const CRNCYSTR: ::nl_item = 43;
-
-pub const D_T_FMT: ::nl_item = 44;
-pub const D_FMT: ::nl_item = 45;
-pub const T_FMT: ::nl_item = 46;
-pub const AM_STR: ::nl_item = 47;
-pub const PM_STR: ::nl_item = 48;
-
-pub const CODESET: ::nl_item = 49;
-pub const T_FMT_AMPM: ::nl_item = 50;
-pub const ERA: ::nl_item = 51;
-pub const ERA_D_FMT: ::nl_item = 52;
-pub const ERA_D_T_FMT: ::nl_item = 53;
-pub const ERA_T_FMT: ::nl_item = 54;
-pub const ALT_DIGITS: ::nl_item = 55;
-pub const YESEXPR: ::nl_item = 56;
-pub const NOEXPR: ::nl_item = 57;
-pub const _DATE_FMT: ::nl_item = 58;
-pub const MAXSTRMSG: ::nl_item = 58;
-
-pub const PATH_MAX: ::c_int = 1024;
-
-pub const SA_ONSTACK: ::c_int = 0x00000001;
-pub const SA_RESETHAND: ::c_int = 0x00000002;
-pub const SA_RESTART: ::c_int = 0x00000004;
-pub const SA_SIGINFO: ::c_int = 0x00000008;
-pub const SA_NODEFER: ::c_int = 0x00000010;
-pub const SA_NOCLDWAIT: ::c_int = 0x00010000;
-pub const SA_NOCLDSTOP: ::c_int = 0x00020000;
-
-pub const SS_ONSTACK: ::c_int = 1;
-pub const SS_DISABLE: ::c_int = 2;
-
-pub const FIOCLEX: ::c_int = 0x20006601;
-pub const FIONCLEX: ::c_int = 0x20006602;
-pub const FIONREAD: ::c_int = 0x4004667f;
-pub const FIONBIO: ::c_int = 0x8004667e;
-pub const FIOASYNC: ::c_int = 0x8004667d;
-pub const FIOSETOWN: ::c_int = 0x8004667c;
-pub const FIOGETOWN: ::c_int = 0x4004667b;
-
-pub const SIGCHLD: ::c_int = 18;
-pub const SIGBUS: ::c_int = 10;
-pub const SIGINFO: ::c_int = 41;
-pub const SIG_BLOCK: ::c_int = 1;
-pub const SIG_UNBLOCK: ::c_int = 2;
-pub const SIG_SETMASK: ::c_int = 3;
-
-pub const SIGEV_NONE: ::c_int = 1;
-pub const SIGEV_SIGNAL: ::c_int =2;
-pub const SIGEV_THREAD: ::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;
-
-cfg_if! {
- if #[cfg(target_pointer_width = "64")] {
- pub const FD_SETSIZE: usize = 65536;
- } else {
- pub const FD_SETSIZE: usize = 1024;
- }
-}
-
-pub const ST_RDONLY: ::c_ulong = 1;
-pub const ST_NOSUID: ::c_ulong = 2;
-
-pub const NI_MAXHOST: ::socklen_t = 1025;
-
-pub const EXIT_FAILURE: ::c_int = 1;
-pub const EXIT_SUCCESS: ::c_int = 0;
-pub const RAND_MAX: ::c_int = 32767;
-pub const EOF: ::c_int = -1;
-pub const SEEK_SET: ::c_int = 0;
-pub const SEEK_CUR: ::c_int = 1;
-pub const SEEK_END: ::c_int = 2;
-pub const _IOFBF: ::c_int = 0;
-pub const _IONBF: ::c_int = 4;
-pub const _IOLBF: ::c_int = 64;
-pub const BUFSIZ: ::c_uint = 1024;
-pub const FOPEN_MAX: ::c_uint = 20;
-pub const FILENAME_MAX: ::c_uint = 1024;
-pub const L_tmpnam: ::c_uint = 25;
-pub const TMP_MAX: ::c_uint = 17576;
-
-pub const O_RDONLY: ::c_int = 0;
-pub const O_WRONLY: ::c_int = 1;
-pub const O_RDWR: ::c_int = 2;
-pub const O_NDELAY: ::c_int = 0x04;
-pub const O_APPEND: ::c_int = 8;
-pub const O_DSYNC: ::c_int = 0x40;
-pub const O_CREAT: ::c_int = 256;
-pub const O_EXCL: ::c_int = 1024;
-pub const O_NOCTTY: ::c_int = 2048;
-pub const O_TRUNC: ::c_int = 512;
-pub const O_NOFOLLOW: ::c_int = 0x200000;
-pub const O_SEARCH: ::c_int = 0x200000;
-pub const O_EXEC: ::c_int = 0x400000;
-pub const O_CLOEXEC: ::c_int = 0x800000;
-pub const O_ACCMODE: ::c_int = 0x600003;
-pub const S_IFIFO: mode_t = 4096;
-pub const S_IFCHR: mode_t = 8192;
-pub const S_IFBLK: mode_t = 24576;
-pub const S_IFDIR: mode_t = 16384;
-pub const S_IFREG: mode_t = 32768;
-pub const S_IFLNK: mode_t = 40960;
-pub const S_IFSOCK: mode_t = 49152;
-pub const S_IFMT: mode_t = 61440;
-pub const S_IEXEC: mode_t = 64;
-pub const S_IWRITE: mode_t = 128;
-pub const S_IREAD: mode_t = 256;
-pub const S_IRWXU: mode_t = 448;
-pub const S_IXUSR: mode_t = 64;
-pub const S_IWUSR: mode_t = 128;
-pub const S_IRUSR: mode_t = 256;
-pub const S_IRWXG: mode_t = 56;
-pub const S_IXGRP: mode_t = 8;
-pub const S_IWGRP: mode_t = 16;
-pub const S_IRGRP: mode_t = 32;
-pub const S_IRWXO: mode_t = 7;
-pub const S_IXOTH: mode_t = 1;
-pub const S_IWOTH: mode_t = 2;
-pub const S_IROTH: mode_t = 4;
-pub const F_OK: ::c_int = 0;
-pub const R_OK: ::c_int = 4;
-pub const W_OK: ::c_int = 2;
-pub const X_OK: ::c_int = 1;
-pub const STDIN_FILENO: ::c_int = 0;
-pub const STDOUT_FILENO: ::c_int = 1;
-pub const STDERR_FILENO: ::c_int = 2;
-pub const F_LOCK: ::c_int = 1;
-pub const F_TEST: ::c_int = 3;
-pub const F_TLOCK: ::c_int = 2;
-pub const F_ULOCK: ::c_int = 0;
-pub const F_DUPFD_CLOEXEC: ::c_int = 37;
-pub const F_SETLK: ::c_int = 6;
-pub const F_SETLKW: ::c_int = 7;
-pub const F_GETLK: ::c_int = 14;
-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 SIGSYS: ::c_int = 12;
-pub const SIGPIPE: ::c_int = 13;
-pub const SIGALRM: ::c_int = 14;
-pub const SIGTERM: ::c_int = 15;
-pub const SIGUSR1: ::c_int = 16;
-pub const SIGUSR2: ::c_int = 17;
-pub const SIGPWR: ::c_int = 19;
-pub const SIGWINCH: ::c_int = 20;
-pub const SIGURG: ::c_int = 21;
-pub const SIGPOLL: ::c_int = 22;
-pub const SIGIO: ::c_int = SIGPOLL;
-pub const SIGSTOP: ::c_int = 23;
-pub const SIGTSTP: ::c_int = 24;
-pub const SIGCONT: ::c_int = 25;
-pub const SIGTTIN: ::c_int = 26;
-pub const SIGTTOU: ::c_int = 27;
-pub const SIGVTALRM: ::c_int = 28;
-pub const SIGPROF: ::c_int = 29;
-pub const SIGXCPU: ::c_int = 30;
-pub const SIGXFSZ: ::c_int = 31;
-
-pub const WNOHANG: ::c_int = 0x40;
-pub const WUNTRACED: ::c_int = 0x04;
-
-pub const WEXITED: ::c_int = 0x01;
-pub const WTRAPPED: ::c_int = 0x02;
-pub const WSTOPPED: ::c_int = WUNTRACED;
-pub const WCONTINUED: ::c_int = 0x08;
-pub const WNOWAIT: ::c_int = 0x80;
-
-pub const AT_FDCWD: ::c_int = 0xffd19553;
-pub const AT_SYMLINK_NOFOLLOW: ::c_int = 0x1000;
-
-pub const P_PID: idtype_t = 0;
-pub const P_PPID: idtype_t = 1;
-pub const P_PGID: idtype_t = 2;
-pub const P_SID: idtype_t = 3;
-pub const P_CID: idtype_t = 4;
-pub const P_UID: idtype_t = 5;
-pub const P_GID: idtype_t = 6;
-pub const P_ALL: idtype_t = 7;
-pub const P_LWPID: idtype_t = 8;
-pub const P_TASKID: idtype_t = 9;
-pub const P_PROJID: idtype_t = 10;
-pub const P_POOLID: idtype_t = 11;
-pub const P_ZONEID: idtype_t = 12;
-pub const P_CTID: idtype_t = 13;
-pub const P_CPUID: idtype_t = 14;
-pub const P_PSETID: idtype_t = 15;
-
-pub const PROT_NONE: ::c_int = 0;
-pub const PROT_READ: ::c_int = 1;
-pub const PROT_WRITE: ::c_int = 2;
-pub const PROT_EXEC: ::c_int = 4;
-
-pub const MAP_FILE: ::c_int = 0;
-pub const MAP_SHARED: ::c_int = 0x0001;
-pub const MAP_PRIVATE: ::c_int = 0x0002;
-pub const MAP_FIXED: ::c_int = 0x0010;
-pub const MAP_NORESERVE: ::c_int = 0x40;
-pub const MAP_ANON: ::c_int = 0x0100;
-pub const MAP_RENAME: ::c_int = 0x20;
-pub const MAP_ALIGN: ::c_int = 0x200;
-pub const MAP_TEXT: ::c_int = 0x400;
-pub const MAP_INITDATA: ::c_int = 0x800;
-pub const MAP_FAILED: *mut ::c_void = !0 as *mut ::c_void;
-
-pub const MCL_CURRENT: ::c_int = 0x0001;
-pub const MCL_FUTURE: ::c_int = 0x0002;
-
-pub const MS_SYNC: ::c_int = 0x0004;
-pub const MS_ASYNC: ::c_int = 0x0001;
-pub const MS_INVALIDATE: ::c_int = 0x0002;
-pub const MS_INVALCURPROC: ::c_int = 0x0008;
-
-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 ENOTBLK: ::c_int = 15;
-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 ENOMSG: ::c_int = 35;
-pub const EIDRM: ::c_int = 36;
-pub const ECHRNG: ::c_int = 37;
-pub const EL2NSYNC: ::c_int = 38;
-pub const EL3HLT: ::c_int = 39;
-pub const EL3RST: ::c_int = 40;
-pub const ELNRNG: ::c_int = 41;
-pub const EUNATCH: ::c_int = 42;
-pub const ENOCSI: ::c_int = 43;
-pub const EL2HLT: ::c_int = 44;
-pub const EDEADLK: ::c_int = 45;
-pub const ENOLCK: ::c_int = 46;
-pub const ECANCELED: ::c_int = 47;
-pub const ENOTSUP: ::c_int = 48;
-pub const EDQUOT: ::c_int = 49;
-pub const EBADE: ::c_int = 50;
-pub const EBADR: ::c_int = 51;
-pub const EXFULL: ::c_int = 52;
-pub const ENOANO: ::c_int = 53;
-pub const EBADRQC: ::c_int = 54;
-pub const EBADSLT: ::c_int = 55;
-pub const EDEADLOCK: ::c_int = 56;
-pub const EBFONT: ::c_int = 57;
-pub const EOWNERDEAD: ::c_int = 58;
-pub const ENOTRECOVERABLE: ::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 ELOCKUNMAPPED: ::c_int = 72;
-pub const ENOTACTIVE: ::c_int = 73;
-pub const EMULTIHOP: ::c_int = 74;
-pub const EADI: ::c_int = 75;
-pub const EBADMSG: ::c_int = 77;
-pub const ENAMETOOLONG: ::c_int = 78;
-pub const EOVERFLOW: ::c_int = 79;
-pub const ENOTUNIQ: ::c_int = 80;
-pub const EBADFD: ::c_int = 81;
-pub const EREMCHG: ::c_int = 82;
-pub const ELIBACC: ::c_int = 83;
-pub const ELIBBAD: ::c_int = 84;
-pub const ELIBSCN: ::c_int = 85;
-pub const ELIBMAX: ::c_int = 86;
-pub const ELIBEXEC: ::c_int = 87;
-pub const EILSEQ: ::c_int = 88;
-pub const ENOSYS: ::c_int = 89;
-pub const ELOOP: ::c_int = 90;
-pub const ERESTART: ::c_int = 91;
-pub const ESTRPIPE: ::c_int = 92;
-pub const ENOTEMPTY: ::c_int = 93;
-pub const EUSERS: ::c_int = 94;
-pub const ENOTSOCK: ::c_int = 95;
-pub const EDESTADDRREQ: ::c_int = 96;
-pub const EMSGSIZE: ::c_int = 97;
-pub const EPROTOTYPE: ::c_int = 98;
-pub const ENOPROTOOPT: ::c_int = 99;
-pub const EPROTONOSUPPORT: ::c_int = 120;
-pub const ESOCKTNOSUPPORT: ::c_int = 121;
-pub const EOPNOTSUPP: ::c_int = 122;
-pub const EPFNOSUPPORT: ::c_int = 123;
-pub const EAFNOSUPPORT: ::c_int = 124;
-pub const EADDRINUSE: ::c_int = 125;
-pub const EADDRNOTAVAIL: ::c_int = 126;
-pub const ENETDOWN: ::c_int = 127;
-pub const ENETUNREACH: ::c_int = 128;
-pub const ENETRESET: ::c_int = 129;
-pub const ECONNABORTED: ::c_int = 130;
-pub const ECONNRESET: ::c_int = 131;
-pub const ENOBUFS: ::c_int = 132;
-pub const EISCONN: ::c_int = 133;
-pub const ENOTCONN: ::c_int = 134;
-pub const ESHUTDOWN: ::c_int = 143;
-pub const ETOOMANYREFS: ::c_int = 144;
-pub const ETIMEDOUT: ::c_int = 145;
-pub const ECONNREFUSED: ::c_int = 146;
-pub const EHOSTDOWN: ::c_int = 147;
-pub const EHOSTUNREACH: ::c_int = 148;
-pub const EWOULDBLOCK: ::c_int = EAGAIN;
-pub const EALREADY: ::c_int = 149;
-pub const EINPROGRESS: ::c_int = 150;
-pub const ESTALE: ::c_int = 151;
-
-pub const EAI_AGAIN: ::c_int = 2;
-pub const EAI_BADFLAGS: ::c_int = 3;
-pub const EAI_FAIL: ::c_int = 4;
-pub const EAI_FAMILY: ::c_int = 5;
-pub const EAI_MEMORY: ::c_int = 6;
-pub const EAI_NODATA: ::c_int = 7;
-pub const EAI_NONAME: ::c_int = 8;
-pub const EAI_SERVICE: ::c_int = 9;
-pub const EAI_SOCKTYPE: ::c_int = 10;
-pub const EAI_SYSTEM: ::c_int = 11;
-pub const EAI_OVERFLOW: ::c_int = 12;
-
-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 SIGTRAP: ::c_int = 5;
-
-pub const GLOB_APPEND : ::c_int = 32;
-pub const GLOB_DOOFFS : ::c_int = 16;
-pub const GLOB_ERR : ::c_int = 1;
-pub const GLOB_MARK : ::c_int = 2;
-pub const GLOB_NOCHECK : ::c_int = 8;
-pub const GLOB_NOSORT : ::c_int = 4;
-pub const GLOB_NOESCAPE: ::c_int = 64;
-
-pub const GLOB_NOSPACE : ::c_int = -2;
-pub const GLOB_ABORTED : ::c_int = -1;
-pub const GLOB_NOMATCH : ::c_int = -3;
-
-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 POLLNORM: ::c_short = 0x0040;
-pub const POLLRDNORM: ::c_short = 0x0040;
-pub const POLLWRNORM: ::c_short = 0x4; /* POLLOUT */
-pub const POLLRDBAND: ::c_short = 0x0080;
-pub const POLLWRBAND: ::c_short = 0x0100;
-
-pub const POSIX_MADV_NORMAL: ::c_int = 0;
-pub const POSIX_MADV_RANDOM: ::c_int = 1;
-pub const POSIX_MADV_SEQUENTIAL: ::c_int = 2;
-pub const POSIX_MADV_WILLNEED: ::c_int = 3;
-pub const POSIX_MADV_DONTNEED: ::c_int = 4;
-
-pub const PTHREAD_CREATE_JOINABLE: ::c_int = 0;
-pub const PTHREAD_CREATE_DETACHED: ::c_int = 0x40;
-pub const PTHREAD_PROCESS_SHARED: ::c_int = 1;
-pub const PTHREAD_PROCESS_PRIVATE: ::c_ushort = 0;
-pub const PTHREAD_STACK_MIN: ::size_t = 4096;
-
-pub const SIGSTKSZ: ::size_t = 8192;
-
-// https://illumos.org/man/3c/clock_gettime
-// https://github.com/illumos/illumos-gate/
-// blob/HEAD/usr/src/lib/libc/amd64/sys/__clock_gettime.s
-// clock_gettime(3c) doesn't seem to accept anything other than CLOCK_REALTIME
-// or __CLOCK_REALTIME0
-//
-// https://github.com/illumos/illumos-gate/
-// blob/HEAD/usr/src/uts/common/sys/time_impl.h
-// Confusing! CLOCK_HIGHRES==CLOCK_MONOTONIC==4
-// __CLOCK_REALTIME0==0 is an obsoleted version of CLOCK_REALTIME==3
-pub const CLOCK_REALTIME: ::clockid_t = 3;
-pub const CLOCK_MONOTONIC: ::clockid_t = 4;
-pub const TIMER_RELTIME: ::c_int = 0;
-pub const TIMER_ABSTIME: ::c_int = 1;
-
-pub const RLIMIT_CPU: ::c_int = 0;
-pub const RLIMIT_FSIZE: ::c_int = 1;
-pub const RLIMIT_DATA: ::c_int = 2;
-pub const RLIMIT_STACK: ::c_int = 3;
-pub const RLIMIT_CORE: ::c_int = 4;
-pub const RLIMIT_NOFILE: ::c_int = 5;
-pub const RLIMIT_VMEM: ::c_int = 6;
-pub const RLIMIT_AS: ::c_int = RLIMIT_VMEM;
-
-pub const RLIM_NLIMITS: rlim_t = 7;
-pub const RLIM_INFINITY: rlim_t = 0x7fffffff;
-
-pub const RUSAGE_SELF: ::c_int = 0;
-pub const RUSAGE_CHILDREN: ::c_int = -1;
-
-pub const MADV_NORMAL: ::c_int = 0;
-pub const MADV_RANDOM: ::c_int = 1;
-pub const MADV_SEQUENTIAL: ::c_int = 2;
-pub const MADV_WILLNEED: ::c_int = 3;
-pub const MADV_DONTNEED: ::c_int = 4;
-pub const MADV_FREE: ::c_int = 5;
-
-pub const AF_UNSPEC: ::c_int = 0;
-pub const AF_UNIX: ::c_int = 1;
-pub const AF_LOCAL: ::c_int = 0;
-pub const AF_FILE: ::c_int = 0;
-pub const AF_INET: ::c_int = 2;
-pub const AF_IMPLINK: ::c_int = 3;
-pub const AF_PUP: ::c_int = 4;
-pub const AF_CHAOS: ::c_int = 5;
-pub const AF_NS: ::c_int = 6;
-pub const AF_NBS: ::c_int = 7;
-pub const AF_ECMA: ::c_int = 8;
-pub const AF_DATAKIT: ::c_int = 9;
-pub const AF_CCITT: ::c_int = 10;
-pub const AF_SNA: ::c_int = 11;
-pub const AF_DECnet: ::c_int = 12;
-pub const AF_DLI: ::c_int = 13;
-pub const AF_LAT: ::c_int = 14;
-pub const AF_HYLINK: ::c_int = 15;
-pub const AF_APPLETALK: ::c_int = 16;
-pub const AF_NIT: ::c_int = 17;
-pub const AF_802: ::c_int = 18;
-pub const AF_OSI: ::c_int = 19;
-pub const AF_X25: ::c_int = 20;
-pub const AF_OSINET: ::c_int = 21;
-pub const AF_GOSIP: ::c_int = 22;
-pub const AF_IPX: ::c_int = 23;
-pub const AF_ROUTE: ::c_int = 24;
-pub const AF_LINK: ::c_int = 25;
-pub const AF_INET6: ::c_int = 26;
-pub const AF_KEY: ::c_int = 27;
-pub const AF_NCA: ::c_int = 28;
-pub const AF_POLICY: ::c_int = 29;
-pub const AF_INET_OFFLOAD: ::c_int = 30;
-pub const AF_TRILL: ::c_int = 31;
-pub const AF_PACKET: ::c_int = 32;
-pub const AF_LX_NETLINK: ::c_int = 33;
-
-#[doc(hidden)]
-#[deprecated(
- since = "0.2.55",
- note = "If you are using this report to: \
- https://github.com/rust-lang/libc/issues/665"
-)]
-pub const AF_MAX: ::c_int = 33;
-pub const SOCK_DGRAM: ::c_int = 1;
-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;
-pub const IP_HDRINCL: ::c_int = 2;
-pub const IP_ADD_MEMBERSHIP: ::c_int = 19;
-pub const IP_DROP_MEMBERSHIP: ::c_int = 20;
-pub const IPV6_JOIN_GROUP: ::c_int = 9;
-pub const IPV6_LEAVE_GROUP: ::c_int = 10;
-
-pub const TCP_NODELAY: ::c_int = 1;
-pub const TCP_KEEPIDLE: ::c_int = 34;
-pub const SOL_SOCKET: ::c_int = 0xffff;
-pub const SO_DEBUG: ::c_int = 0x01;
-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_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_TIMESTAMP: ::c_int = 0x1013;
-
-pub const SCM_RIGHTS: ::c_int = 0x1010;
-pub const SCM_UCRED: ::c_int = 0x1012;
-pub const SCM_TIMESTAMP: ::c_int = SO_TIMESTAMP;
-
-pub const MSG_OOB: ::c_int = 0x1;
-pub const MSG_PEEK: ::c_int = 0x2;
-pub const MSG_DONTROUTE: ::c_int = 0x4;
-pub const MSG_EOR: ::c_int = 0x8;
-pub const MSG_CTRUNC: ::c_int = 0x10;
-pub const MSG_TRUNC: ::c_int = 0x20;
-pub const MSG_WAITALL: ::c_int = 0x40;
-pub const MSG_DONTWAIT: ::c_int = 0x80;
-pub const MSG_NOTIFICATION: ::c_int = 0x100;
-pub const MSG_NOSIGNAL: ::c_int = 0x200;
-pub const MSG_DUPCTRL: ::c_int = 0x800;
-pub const MSG_XPG4_2: ::c_int = 0x8000;
-pub const MSG_MAXIOVLEN: ::c_int = 16;
-
-// https://docs.oracle.com/cd/E23824_01/html/821-1475/if-7p.html
-pub const IFF_UP: ::c_int = 0x0000000001; // Address is up
-pub const IFF_BROADCAST: ::c_int = 0x0000000002; // Broadcast address valid
-pub const IFF_DEBUG: ::c_int = 0x0000000004; // Turn on debugging
-pub const IFF_LOOPBACK: ::c_int = 0x0000000008; // Loopback net
-pub const IFF_POINTOPOINT: ::c_int = 0x0000000010; // Interface is p-to-p
-pub const IFF_NOTRAILERS: ::c_int = 0x0000000020; // Avoid use of trailers
-pub const IFF_RUNNING: ::c_int = 0x0000000040; // Resources allocated
-pub const IFF_NOARP: ::c_int = 0x0000000080; // No address res. protocol
-pub const IFF_PROMISC: ::c_int = 0x0000000100; // Receive all packets
-pub const IFF_ALLMULTI: ::c_int = 0x0000000200; // Receive all multicast pkts
-pub const IFF_INTELLIGENT: ::c_int = 0x0000000400; // Protocol code on board
-pub const IFF_MULTICAST: ::c_int = 0x0000000800; // Supports multicast
-// Multicast using broadcst. add.
-pub const IFF_MULTI_BCAST: ::c_int = 0x0000001000;
-pub const IFF_UNNUMBERED: ::c_int = 0x0000002000; // Non-unique address
-pub const IFF_DHCPRUNNING: ::c_int = 0x0000004000; // DHCP controls interface
-pub const IFF_PRIVATE: ::c_int = 0x0000008000; // Do not advertise
-pub const IFF_NOXMIT: ::c_int = 0x0000010000; // Do not transmit pkts
-// No address - just on-link subnet
-pub const IFF_NOLOCAL: ::c_int = 0x0000020000;
-pub const IFF_DEPRECATED: ::c_int = 0x0000040000; // Address is deprecated
-pub const IFF_ADDRCONF: ::c_int = 0x0000080000; // Addr. from stateless addrconf
-pub const IFF_ROUTER: ::c_int = 0x0000100000; // Router on interface
-pub const IFF_NONUD: ::c_int = 0x0000200000; // No NUD on interface
-pub const IFF_ANYCAST: ::c_int = 0x0000400000; // Anycast address
-pub const IFF_NORTEXCH: ::c_int = 0x0000800000; // Don't xchange rout. info
-pub const IFF_IPV4: ::c_int = 0x0001000000; // IPv4 interface
-pub const IFF_IPV6: ::c_int = 0x0002000000; // IPv6 interface
-pub const IFF_NOFAILOVER: ::c_int = 0x0008000000; // in.mpathd test address
-pub const IFF_FAILED: ::c_int = 0x0010000000; // Interface has failed
-pub const IFF_STANDBY: ::c_int = 0x0020000000; // Interface is a hot-spare
-pub const IFF_INACTIVE: ::c_int = 0x0040000000; // Functioning but not used
-pub const IFF_OFFLINE: ::c_int = 0x0080000000; // Interface is offline
-// If CoS marking is supported
-pub const IFF_COS_ENABLED: ::c_longlong = 0x0200000000;
-pub const IFF_PREFERRED: ::c_longlong = 0x0400000000; // Prefer as source addr.
-pub const IFF_TEMPORARY: ::c_longlong = 0x0800000000; // RFC3041
-pub const IFF_FIXEDMTU: ::c_longlong = 0x1000000000; // MTU set with SIOCSLIFMTU
-pub const IFF_VIRTUAL: ::c_longlong = 0x2000000000; // Cannot send/receive pkts
-pub const IFF_DUPLICATE: ::c_longlong = 0x4000000000; // Local address in use
-pub const IFF_IPMP: ::c_longlong = 0x8000000000; // IPMP IP interface
-
-pub const SHUT_RD: ::c_int = 0;
-pub const SHUT_WR: ::c_int = 1;
-pub const SHUT_RDWR: ::c_int = 2;
-
-pub const LOCK_SH: ::c_int = 1;
-pub const LOCK_EX: ::c_int = 2;
-pub const LOCK_NB: ::c_int = 4;
-pub const LOCK_UN: ::c_int = 8;
-
-pub const F_RDLCK: ::c_short = 1;
-pub const F_WRLCK: ::c_short = 2;
-pub const F_UNLCK: ::c_short = 3;
-
-pub const O_SYNC: ::c_int = 16;
-pub const O_NONBLOCK: ::c_int = 128;
-
-pub const IPPROTO_RAW: ::c_int = 255;
-
-pub const _PC_LINK_MAX: ::c_int = 1;
-pub const _PC_MAX_CANON: ::c_int = 2;
-pub const _PC_MAX_INPUT: ::c_int = 3;
-pub const _PC_NAME_MAX: ::c_int = 4;
-pub const _PC_PATH_MAX: ::c_int = 5;
-pub const _PC_PIPE_BUF: ::c_int = 6;
-pub const _PC_NO_TRUNC: ::c_int = 7;
-pub const _PC_VDISABLE: ::c_int = 8;
-pub const _PC_CHOWN_RESTRICTED: ::c_int = 9;
-pub const _PC_ASYNC_IO: ::c_int = 10;
-pub const _PC_PRIO_IO: ::c_int = 11;
-pub const _PC_SYNC_IO: ::c_int = 12;
-pub const _PC_ALLOC_SIZE_MIN: ::c_int = 13;
-pub const _PC_REC_INCR_XFER_SIZE: ::c_int = 14;
-pub const _PC_REC_MAX_XFER_SIZE: ::c_int = 15;
-pub const _PC_REC_MIN_XFER_SIZE: ::c_int = 16;
-pub const _PC_REC_XFER_ALIGN: ::c_int = 17;
-pub const _PC_SYMLINK_MAX: ::c_int = 18;
-pub const _PC_2_SYMLINKS: ::c_int = 19;
-pub const _PC_ACL_ENABLED: ::c_int = 20;
-pub const _PC_MIN_HOLE_SIZE: ::c_int = 21;
-pub const _PC_CASE_BEHAVIOR: ::c_int = 22;
-pub const _PC_SATTR_ENABLED: ::c_int = 23;
-pub const _PC_SATTR_EXISTS: ::c_int = 24;
-pub const _PC_ACCESS_FILTERING: ::c_int = 25;
-pub const _PC_TIMESTAMP_RESOLUTION: ::c_int = 26;
-pub const _PC_FILESIZEBITS: ::c_int = 67;
-pub const _PC_XATTR_ENABLED: ::c_int = 100;
-pub const _PC_LAST: ::c_int = 101;
-pub const _PC_XATTR_EXISTS: ::c_int = 101;
-
-pub const _SC_ARG_MAX: ::c_int = 1;
-pub const _SC_CHILD_MAX: ::c_int = 2;
-pub const _SC_CLK_TCK: ::c_int = 3;
-pub const _SC_NGROUPS_MAX: ::c_int = 4;
-pub const _SC_OPEN_MAX: ::c_int = 5;
-pub const _SC_JOB_CONTROL: ::c_int = 6;
-pub const _SC_SAVED_IDS: ::c_int = 7;
-pub const _SC_VERSION: ::c_int = 8;
-pub const _SC_PASS_MAX: ::c_int = 9;
-pub const _SC_LOGNAME_MAX: ::c_int = 10;
-pub const _SC_PAGESIZE: ::c_int = 11;
-pub const _SC_PAGE_SIZE: ::c_int = _SC_PAGESIZE;
-pub const _SC_XOPEN_VERSION: ::c_int = 12;
-pub const _SC_NPROCESSORS_CONF: ::c_int = 14;
-pub const _SC_NPROCESSORS_ONLN: ::c_int = 15;
-pub const _SC_STREAM_MAX: ::c_int = 16;
-pub const _SC_TZNAME_MAX: ::c_int = 17;
-pub const _SC_AIO_LISTIO_MAX: ::c_int = 18;
-pub const _SC_AIO_MAX: ::c_int = 19;
-pub const _SC_AIO_PRIO_DELTA_MAX: ::c_int = 20;
-pub const _SC_ASYNCHRONOUS_IO: ::c_int = 21;
-pub const _SC_DELAYTIMER_MAX: ::c_int = 22;
-pub const _SC_FSYNC: ::c_int = 23;
-pub const _SC_MAPPED_FILES: ::c_int = 24;
-pub const _SC_MEMLOCK: ::c_int = 25;
-pub const _SC_MEMLOCK_RANGE: ::c_int = 26;
-pub const _SC_MEMORY_PROTECTION: ::c_int = 27;
-pub const _SC_MESSAGE_PASSING: ::c_int = 28;
-pub const _SC_MQ_OPEN_MAX: ::c_int = 29;
-pub const _SC_MQ_PRIO_MAX: ::c_int = 30;
-pub const _SC_PRIORITIZED_IO: ::c_int = 31;
-pub const _SC_PRIORITY_SCHEDULING: ::c_int = 32;
-pub const _SC_REALTIME_SIGNALS: ::c_int = 33;
-pub const _SC_RTSIG_MAX: ::c_int = 34;
-pub const _SC_SEMAPHORES: ::c_int = 35;
-pub const _SC_SEM_NSEMS_MAX: ::c_int = 36;
-pub const _SC_SEM_VALUE_MAX: ::c_int = 37;
-pub const _SC_SHARED_MEMORY_OBJECTS: ::c_int = 38;
-pub const _SC_SIGQUEUE_MAX: ::c_int = 39;
-pub const _SC_SIGRT_MIN: ::c_int = 40;
-pub const _SC_SIGRT_MAX: ::c_int = 41;
-pub const _SC_SYNCHRONIZED_IO: ::c_int = 42;
-pub const _SC_TIMERS: ::c_int = 43;
-pub const _SC_TIMER_MAX: ::c_int = 44;
-pub const _SC_2_C_BIND: ::c_int = 45;
-pub const _SC_2_C_DEV: ::c_int = 46;
-pub const _SC_2_C_VERSION: ::c_int = 47;
-pub const _SC_2_FORT_DEV: ::c_int = 48;
-pub const _SC_2_FORT_RUN: ::c_int = 49;
-pub const _SC_2_LOCALEDEF: ::c_int = 50;
-pub const _SC_2_SW_DEV: ::c_int = 51;
-pub const _SC_2_UPE: ::c_int = 52;
-pub const _SC_2_VERSION: ::c_int = 53;
-pub const _SC_BC_BASE_MAX: ::c_int = 54;
-pub const _SC_BC_DIM_MAX: ::c_int = 55;
-pub const _SC_BC_SCALE_MAX: ::c_int = 56;
-pub const _SC_BC_STRING_MAX: ::c_int = 57;
-pub const _SC_COLL_WEIGHTS_MAX: ::c_int = 58;
-pub const _SC_EXPR_NEST_MAX: ::c_int = 59;
-pub const _SC_LINE_MAX: ::c_int = 60;
-pub const _SC_RE_DUP_MAX: ::c_int = 61;
-pub const _SC_XOPEN_CRYPT: ::c_int = 62;
-pub const _SC_XOPEN_ENH_I18N: ::c_int = 63;
-pub const _SC_XOPEN_SHM: ::c_int = 64;
-pub const _SC_2_CHAR_TERM: ::c_int = 66;
-pub const _SC_XOPEN_XCU_VERSION: ::c_int = 67;
-pub const _SC_ATEXIT_MAX: ::c_int = 76;
-pub const _SC_IOV_MAX: ::c_int = 77;
-pub const _SC_XOPEN_UNIX: ::c_int = 78;
-pub const _SC_T_IOV_MAX: ::c_int = 79;
-pub const _SC_PHYS_PAGES: ::c_int = 500;
-pub const _SC_AVPHYS_PAGES: ::c_int = 501;
-pub const _SC_COHER_BLKSZ: ::c_int = 503;
-pub const _SC_SPLIT_CACHE: ::c_int = 504;
-pub const _SC_ICACHE_SZ: ::c_int = 505;
-pub const _SC_DCACHE_SZ: ::c_int = 506;
-pub const _SC_ICACHE_LINESZ: ::c_int = 507;
-pub const _SC_DCACHE_LINESZ: ::c_int = 508;
-pub const _SC_ICACHE_BLKSZ: ::c_int = 509;
-pub const _SC_DCACHE_BLKSZ: ::c_int = 510;
-pub const _SC_DCACHE_TBLKSZ: ::c_int = 511;
-pub const _SC_ICACHE_ASSOC: ::c_int = 512;
-pub const _SC_DCACHE_ASSOC: ::c_int = 513;
-pub const _SC_MAXPID: ::c_int = 514;
-pub const _SC_STACK_PROT: ::c_int = 515;
-pub const _SC_NPROCESSORS_MAX: ::c_int = 516;
-pub const _SC_CPUID_MAX: ::c_int = 517;
-pub const _SC_EPHID_MAX: ::c_int = 518;
-pub const _SC_THREAD_DESTRUCTOR_ITERATIONS: ::c_int = 568;
-pub const _SC_GETGR_R_SIZE_MAX: ::c_int = 569;
-pub const _SC_GETPW_R_SIZE_MAX: ::c_int = 570;
-pub const _SC_LOGIN_NAME_MAX: ::c_int = 571;
-pub const _SC_THREAD_KEYS_MAX: ::c_int = 572;
-pub const _SC_THREAD_STACK_MIN: ::c_int = 573;
-pub const _SC_THREAD_THREADS_MAX: ::c_int = 574;
-pub const _SC_TTY_NAME_MAX: ::c_int = 575;
-pub const _SC_THREADS: ::c_int = 576;
-pub const _SC_THREAD_ATTR_STACKADDR: ::c_int = 577;
-pub const _SC_THREAD_ATTR_STACKSIZE: ::c_int = 578;
-pub const _SC_THREAD_PRIORITY_SCHEDULING: ::c_int = 579;
-pub const _SC_THREAD_PRIO_INHERIT: ::c_int = 580;
-pub const _SC_THREAD_PRIO_PROTECT: ::c_int = 581;
-pub const _SC_THREAD_PROCESS_SHARED: ::c_int = 582;
-pub const _SC_THREAD_SAFE_FUNCTIONS: ::c_int = 583;
-pub const _SC_XOPEN_LEGACY: ::c_int = 717;
-pub const _SC_XOPEN_REALTIME: ::c_int = 718;
-pub const _SC_XOPEN_REALTIME_THREADS: ::c_int = 719;
-pub const _SC_XBS5_ILP32_OFF32: ::c_int = 720;
-pub const _SC_XBS5_ILP32_OFFBIG: ::c_int = 721;
-pub const _SC_XBS5_LP64_OFF64: ::c_int = 722;
-pub const _SC_XBS5_LPBIG_OFFBIG: ::c_int = 723;
-pub const _SC_2_PBS: ::c_int = 724;
-pub const _SC_2_PBS_ACCOUNTING: ::c_int = 725;
-pub const _SC_2_PBS_CHECKPOINT: ::c_int = 726;
-pub const _SC_2_PBS_LOCATE: ::c_int = 728;
-pub const _SC_2_PBS_MESSAGE: ::c_int = 729;
-pub const _SC_2_PBS_TRACK: ::c_int = 730;
-pub const _SC_ADVISORY_INFO: ::c_int = 731;
-pub const _SC_BARRIERS: ::c_int = 732;
-pub const _SC_CLOCK_SELECTION: ::c_int = 733;
-pub const _SC_CPUTIME: ::c_int = 734;
-pub const _SC_HOST_NAME_MAX: ::c_int = 735;
-pub const _SC_MONOTONIC_CLOCK: ::c_int = 736;
-pub const _SC_READER_WRITER_LOCKS: ::c_int = 737;
-pub const _SC_REGEXP: ::c_int = 738;
-pub const _SC_SHELL: ::c_int = 739;
-pub const _SC_SPAWN: ::c_int = 740;
-pub const _SC_SPIN_LOCKS: ::c_int = 741;
-pub const _SC_SPORADIC_SERVER: ::c_int = 742;
-pub const _SC_SS_REPL_MAX: ::c_int = 743;
-pub const _SC_SYMLOOP_MAX: ::c_int = 744;
-pub const _SC_THREAD_CPUTIME: ::c_int = 745;
-pub const _SC_THREAD_SPORADIC_SERVER: ::c_int = 746;
-pub const _SC_TIMEOUTS: ::c_int = 747;
-pub const _SC_TRACE: ::c_int = 748;
-pub const _SC_TRACE_EVENT_FILTER: ::c_int = 749;
-pub const _SC_TRACE_EVENT_NAME_MAX: ::c_int = 750;
-pub const _SC_TRACE_INHERIT: ::c_int = 751;
-pub const _SC_TRACE_LOG: ::c_int = 752;
-pub const _SC_TRACE_NAME_MAX: ::c_int = 753;
-pub const _SC_TRACE_SYS_MAX: ::c_int = 754;
-pub const _SC_TRACE_USER_EVENT_MAX: ::c_int = 755;
-pub const _SC_TYPED_MEMORY_OBJECTS: ::c_int = 756;
-pub const _SC_V6_ILP32_OFF32: ::c_int = 757;
-pub const _SC_V6_ILP32_OFFBIG: ::c_int = 758;
-pub const _SC_V6_LP64_OFF64: ::c_int = 759;
-pub const _SC_V6_LPBIG_OFFBIG: ::c_int = 760;
-pub const _SC_XOPEN_STREAMS: ::c_int = 761;
-pub const _SC_IPV6: ::c_int = 762;
-pub const _SC_RAW_SOCKETS: ::c_int = 763;
-
-pub const _MUTEX_MAGIC: u16 = 0x4d58; // MX
-pub const _COND_MAGIC: u16 = 0x4356; // CV
-pub const _RWL_MAGIC: u16 = 0x5257; // RW
-
-pub const NCCS: usize = 19;
-
-pub const LOG_CRON: ::c_int = 15 << 3;
-
-pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t {
- __pthread_mutex_flag1: 0,
- __pthread_mutex_flag2: 0,
- __pthread_mutex_ceiling: 0,
- __pthread_mutex_type: PTHREAD_PROCESS_PRIVATE,
- __pthread_mutex_magic: _MUTEX_MAGIC,
- __pthread_mutex_lock: 0,
- __pthread_mutex_data: 0
-};
-pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = pthread_cond_t {
- __pthread_cond_flag: [0; 4],
- __pthread_cond_type: PTHREAD_PROCESS_PRIVATE,
- __pthread_cond_magic: _COND_MAGIC,
- __pthread_cond_data: 0
-};
-pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = pthread_rwlock_t {
- __pthread_rwlock_readers: 0,
- __pthread_rwlock_type: PTHREAD_PROCESS_PRIVATE,
- __pthread_rwlock_magic: _RWL_MAGIC,
- __pthread_rwlock_mutex: PTHREAD_MUTEX_INITIALIZER,
- __pthread_rwlock_readercv: PTHREAD_COND_INITIALIZER,
- __pthread_rwlock_writercv: PTHREAD_COND_INITIALIZER
-};
-pub const PTHREAD_MUTEX_NORMAL: ::c_int = 0;
-pub const PTHREAD_MUTEX_ERRORCHECK: ::c_int = 2;
-pub const PTHREAD_MUTEX_RECURSIVE: ::c_int = 4;
-pub const PTHREAD_MUTEX_DEFAULT: ::c_int = PTHREAD_MUTEX_NORMAL;
-
-pub const RTLD_NEXT: *mut ::c_void = -1isize as *mut ::c_void;
-pub const RTLD_DEFAULT: *mut ::c_void = -2isize as *mut ::c_void;
-pub const RTLD_SELF: *mut ::c_void = -3isize as *mut ::c_void;
-pub const RTLD_PROBE: *mut ::c_void = -4isize as *mut ::c_void;
-
-pub const RTLD_LAZY: ::c_int = 0x1;
-pub const RTLD_NOW: ::c_int = 0x2;
-pub const RTLD_NOLOAD: ::c_int = 0x4;
-pub const RTLD_GLOBAL: ::c_int = 0x100;
-pub const RTLD_LOCAL: ::c_int = 0x0;
-pub const RTLD_PARENT: ::c_int = 0x200;
-pub const RTLD_GROUP: ::c_int = 0x400;
-pub const RTLD_WORLD: ::c_int = 0x800;
-pub const RTLD_NODELETE: ::c_int = 0x1000;
-pub const RTLD_FIRST: ::c_int = 0x2000;
-pub const RTLD_CONFGEN: ::c_int = 0x10000;
-
-pub const PORT_SOURCE_AIO: ::c_int = 1;
-pub const PORT_SOURCE_TIMER: ::c_int = 2;
-pub const PORT_SOURCE_USER: ::c_int = 3;
-pub const PORT_SOURCE_FD: ::c_int = 4;
-pub const PORT_SOURCE_ALERT: ::c_int = 5;
-pub const PORT_SOURCE_MQ: ::c_int = 6;
-pub const PORT_SOURCE_FILE: ::c_int = 7;
-pub const PORT_SOURCE_POSTWAIT: ::c_int = 8;
-pub const PORT_SOURCE_SIGNAL: ::c_int = 9;
-
-const _TIOC: ::c_int = ('T' as i32) << 8;
-const tIOC: ::c_int = ('t' as i32) << 8;
-pub const TCGETA: ::c_int = (_TIOC|1);
-pub const TCSETA: ::c_int = (_TIOC|2);
-pub const TCSETAW: ::c_int = (_TIOC|3);
-pub const TCSETAF: ::c_int = (_TIOC|4);
-pub const TCSBRK: ::c_int = (_TIOC|5);
-pub const TCXONC: ::c_int = (_TIOC|6);
-pub const TCFLSH: ::c_int = (_TIOC|7);
-pub const TCDSET: ::c_int = (_TIOC|32);
-pub const TCGETS: ::c_int = (_TIOC|13);
-pub const TCSETS: ::c_int = (_TIOC|14);
-pub const TCSANOW: ::c_int = (_TIOC|14);
-pub const TCSETSW: ::c_int = (_TIOC|15);
-pub const TCSADRAIN: ::c_int = (_TIOC|15);
-pub const TCSETSF: ::c_int = (_TIOC|16);
-pub const TCSAFLUSH: ::c_int = (_TIOC|16);
-pub const TCIFLUSH: ::c_int = 0;
-pub const TCOFLUSH: ::c_int = 1;
-pub const TCIOFLUSH: ::c_int = 2;
-pub const TCOOFF: ::c_int = 0;
-pub const TCOON: ::c_int = 1;
-pub const TCIOFF: ::c_int = 2;
-pub const TCION: ::c_int = 3;
-pub const TIOC: ::c_int = _TIOC;
-pub const TIOCKBON: ::c_int = (_TIOC|8);
-pub const TIOCKBOF: ::c_int = (_TIOC|9);
-pub const TIOCGWINSZ: ::c_int = (_TIOC|104);
-pub const TIOCSWINSZ: ::c_int = (_TIOC|103);
-pub const TIOCGSOFTCAR: ::c_int = (_TIOC|105);
-pub const TIOCSSOFTCAR: ::c_int = (_TIOC|106);
-pub const TIOCSETLD: ::c_int = (_TIOC|123);
-pub const TIOCGETLD: ::c_int = (_TIOC|124);
-pub const TIOCGPPS: ::c_int = (_TIOC|125);
-pub const TIOCSPPS: ::c_int = (_TIOC|126);
-pub const TIOCGPPSEV: ::c_int = (_TIOC|127);
-pub const TIOCGETD: ::c_int = (tIOC|0);
-pub const TIOCSETD: ::c_int = (tIOC|1);
-pub const TIOCHPCL: ::c_int = (tIOC|2);
-pub const TIOCGETP: ::c_int = (tIOC|8);
-pub const TIOCSETP: ::c_int = (tIOC|9);
-pub const TIOCSETN: ::c_int = (tIOC|10);
-pub const TIOCEXCL: ::c_int = (tIOC|13);
-pub const TIOCNXCL: ::c_int = (tIOC|14);
-pub const TIOCFLUSH: ::c_int = (tIOC|16);
-pub const TIOCSETC: ::c_int = (tIOC|17);
-pub const TIOCGETC: ::c_int = (tIOC|18);
-pub const TIOCLBIS: ::c_int = (tIOC|127);
-pub const TIOCLBIC: ::c_int = (tIOC|126);
-pub const TIOCLSET: ::c_int = (tIOC|125);
-pub const TIOCLGET: ::c_int = (tIOC|124);
-pub const TIOCSBRK: ::c_int = (tIOC|123);
-pub const TIOCCBRK: ::c_int = (tIOC|122);
-pub const TIOCSDTR: ::c_int = (tIOC|121);
-pub const TIOCCDTR: ::c_int = (tIOC|120);
-pub const TIOCSLTC: ::c_int = (tIOC|117);
-pub const TIOCGLTC: ::c_int = (tIOC|116);
-pub const TIOCOUTQ: ::c_int = (tIOC|115);
-pub const TIOCNOTTY: ::c_int = (tIOC|113);
-pub const TIOCSCTTY: ::c_int = (tIOC|132);
-pub const TIOCSTOP: ::c_int = (tIOC|111);
-pub const TIOCSTART: ::c_int = (tIOC|110);
-pub const TIOCSILOOP: ::c_int = (tIOC|109);
-pub const TIOCCILOOP: ::c_int = (tIOC|108);
-pub const TIOCGPGRP: ::c_int = (tIOC|20);
-pub const TIOCSPGRP: ::c_int = (tIOC|21);
-pub const TIOCGSID: ::c_int = (tIOC|22);
-pub const TIOCSTI: ::c_int = (tIOC|23);
-pub const TIOCMSET: ::c_int = (tIOC|26);
-pub const TIOCMBIS: ::c_int = (tIOC|27);
-pub const TIOCMBIC: ::c_int = (tIOC|28);
-pub const TIOCMGET: ::c_int = (tIOC|29);
-pub const TIOCREMOTE: ::c_int = (tIOC|30);
-pub const TIOCSIGNAL: ::c_int = (tIOC|31);
-
-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;
-
-/* termios */
-pub const B0: speed_t = 0;
-pub const B50: speed_t = 1;
-pub const B75: speed_t = 2;
-pub const B110: speed_t = 3;
-pub const B134: speed_t = 4;
-pub const B150: speed_t = 5;
-pub const B200: speed_t = 6;
-pub const B300: speed_t = 7;
-pub const B600: speed_t = 8;
-pub const B1200: speed_t = 9;
-pub const B1800: speed_t = 10;
-pub const B2400: speed_t = 11;
-pub const B4800: speed_t = 12;
-pub const B9600: speed_t = 13;
-pub const B19200: speed_t = 14;
-pub const B38400: speed_t = 15;
-pub const B57600: speed_t = 16;
-pub const B76800: speed_t = 17;
-pub const B115200: speed_t = 18;
-pub const B153600: speed_t = 19;
-pub const B230400: speed_t = 20;
-pub const B307200: speed_t = 21;
-pub const B460800: speed_t = 22;
-pub const B921600: speed_t = 23;
-pub const CSTART: ::tcflag_t = 021;
-pub const CSTOP: ::tcflag_t = 023;
-pub const CSWTCH: ::tcflag_t = 032;
-pub const CSIZE: ::tcflag_t = 0o000060;
-pub const CS5: ::tcflag_t = 0;
-pub const CS6: ::tcflag_t = 0o000020;
-pub const CS7: ::tcflag_t = 0o000040;
-pub const CS8: ::tcflag_t = 0o000060;
-pub const CSTOPB: ::tcflag_t = 0o000100;
-pub const ECHO: ::tcflag_t = 0o000010;
-pub const ECHOE: ::tcflag_t = 0o000020;
-pub const ECHOK: ::tcflag_t = 0o000040;
-pub const ECHONL: ::tcflag_t = 0o000100;
-pub const ECHOCTL: ::tcflag_t = 0o001000;
-pub const ECHOPRT: ::tcflag_t = 0o002000;
-pub const ECHOKE: ::tcflag_t = 0o004000;
-pub const EXTPROC: ::tcflag_t = 0o200000;
-pub const IGNBRK: ::tcflag_t = 0o000001;
-pub const BRKINT: ::tcflag_t = 0o000002;
-pub const IGNPAR: ::tcflag_t = 0o000004;
-pub const PARMRK: ::tcflag_t = 0o000010;
-pub const INPCK: ::tcflag_t = 0o000020;
-pub const ISTRIP: ::tcflag_t = 0o000040;
-pub const INLCR: ::tcflag_t = 0o000100;
-pub const IGNCR: ::tcflag_t = 0o000200;
-pub const ICRNL: ::tcflag_t = 0o000400;
-pub const IXON: ::tcflag_t = 0o002000;
-pub const IXOFF: ::tcflag_t = 0o010000;
-pub const IXANY: ::tcflag_t = 0o004000;
-pub const IMAXBEL: ::tcflag_t = 0o020000;
-pub const OPOST: ::tcflag_t = 0o000001;
-pub const ONLCR: ::tcflag_t = 0o000004;
-pub const OCRNL: ::tcflag_t = 0o000010;
-pub const ONOCR: ::tcflag_t = 0o000020;
-pub const ONLRET: ::tcflag_t = 0o000040;
-pub const CREAD: ::tcflag_t = 0o000200;
-pub const PARENB: ::tcflag_t = 0o000400;
-pub const PARODD: ::tcflag_t = 0o001000;
-pub const HUPCL: ::tcflag_t = 0o002000;
-pub const CLOCAL: ::tcflag_t = 0o004000;
-pub const CRTSCTS: ::tcflag_t = 0o20000000000;
-pub const ISIG: ::tcflag_t = 0o000001;
-pub const ICANON: ::tcflag_t = 0o000002;
-pub const IEXTEN: ::tcflag_t = 0o100000;
-pub const TOSTOP: ::tcflag_t = 0o000400;
-pub const FLUSHO: ::tcflag_t = 0o020000;
-pub const PENDIN: ::tcflag_t = 0o040000;
-pub const NOFLSH: ::tcflag_t = 0o000200;
-pub const VINTR: usize = 0;
-pub const VQUIT: usize = 1;
-pub const VERASE: usize = 2;
-pub const VKILL: usize = 3;
-pub const VEOF: usize = 4;
-pub const VEOL: usize = 5;
-pub const VEOL2: usize = 6;
-pub const VMIN: usize = 4;
-pub const VTIME: usize = 5;
-pub const VSWTCH: usize = 7;
-pub const VSTART: usize = 8;
-pub const VSTOP: usize = 9;
-pub const VSUSP: usize = 10;
-pub const VDSUSP: usize = 11;
-pub const VREPRINT: usize = 12;
-pub const VDISCARD: usize = 13;
-pub const VWERASE: usize = 14;
-pub const VLNEXT: usize = 15;
-pub const VSTATUS: usize = 16;
-pub const VERASE2: usize = 17;
-
-f! {
- 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;
- (*set).fds_bits[fd / bits] &= !(1 << (fd % bits));
- return
- }
-
- pub fn FD_ISSET(fd: ::c_int, set: *mut fd_set) -> bool {
- let bits = ::mem::size_of_val(&(*set).fds_bits[0]) * 8;
- let fd = fd as usize;
- return ((*set).fds_bits[fd / bits] & (1 << (fd % bits))) != 0
- }
-
- pub fn FD_SET(fd: ::c_int, set: *mut fd_set) -> () {
- let bits = ::mem::size_of_val(&(*set).fds_bits[0]) * 8;
- let fd = fd as usize;
- (*set).fds_bits[fd / bits] |= 1 << (fd % bits);
- return
- }
-
- pub fn FD_ZERO(set: *mut fd_set) -> () {
- for slot in (*set).fds_bits.iter_mut() {
- *slot = 0;
- }
- }
-
- pub fn WIFEXITED(status: ::c_int) -> bool {
- (status & 0xFF) == 0
- }
-
- pub fn WEXITSTATUS(status: ::c_int) -> ::c_int {
- (status >> 8) & 0xFF
- }
-
- pub fn WTERMSIG(status: ::c_int) -> ::c_int {
- status & 0x7F
- }
-
- pub fn WIFCONTINUED(status: ::c_int) -> bool {
- (status & 0xffff) == 0xffff
- }
-
- pub fn WSTOPSIG(status: ::c_int) -> ::c_int {
- (status & 0xff00) >> 8
- }
-
- pub fn WIFSIGNALED(status: ::c_int) -> bool {
- ((status & 0xff) > 0) && (status & 0xff00 == 0)
- }
-
- pub fn WIFSTOPPED(status: ::c_int) -> bool {
- ((status & 0xff) == 0x7f) && ((status & 0xff00) != 0)
- }
-
- pub fn WCOREDUMP(status: ::c_int) -> bool {
- (status & 0x80) != 0
- }
-}
-
-extern {
- pub fn getrlimit(resource: ::c_int, rlim: *mut ::rlimit) -> ::c_int;
- pub fn setrlimit(resource: ::c_int, rlim: *const ::rlimit) -> ::c_int;
-
- pub fn strerror_r(errnum: ::c_int, buf: *mut c_char,
- buflen: ::size_t) -> ::c_int;
-
- pub fn sem_destroy(sem: *mut sem_t) -> ::c_int;
- pub fn sem_init(sem: *mut sem_t,
- pshared: ::c_int,
- value: ::c_uint)
- -> ::c_int;
-
- pub fn abs(i: ::c_int) -> ::c_int;
- pub fn acct(filename: *const ::c_char) -> ::c_int;
- pub fn atof(s: *const ::c_char) -> ::c_double;
- pub fn dirfd(dirp: *mut ::DIR) -> ::c_int;
- pub fn labs(i: ::c_long) -> ::c_long;
- pub fn rand() -> ::c_int;
- pub fn srand(seed: ::c_uint);
-
- pub fn gettimeofday(tp: *mut ::timeval,
- tz: *mut ::c_void) -> ::c_int;
- pub fn getifaddrs(ifap: *mut *mut ::ifaddrs) -> ::c_int;
- pub fn freeifaddrs(ifa: *mut ::ifaddrs);
-
- pub fn stack_getbounds(sp: *mut ::stack_t) -> ::c_int;
- pub fn mincore(addr: *const ::c_void, len: ::size_t,
- vec: *mut c_char) -> ::c_int;
- pub fn initgroups(name: *const ::c_char, basegid: ::gid_t) -> ::c_int;
- pub fn setgroups(ngroups: ::c_int,
- ptr: *const ::gid_t) -> ::c_int;
- 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,
- flags: ::c_int,
- rqtp: *const ::timespec,
- rmtp: *mut ::timespec) -> ::c_int;
- pub fn clock_settime(clk_id: ::clockid_t, tp: *const ::timespec) -> ::c_int;
- pub fn getnameinfo(sa: *const ::sockaddr,
- salen: ::socklen_t,
- host: *mut ::c_char,
- hostlen: ::socklen_t,
- serv: *mut ::c_char,
- sevlen: ::socklen_t,
- flags: ::c_int) -> ::c_int;
- pub fn setpwent();
- pub fn endpwent();
- pub fn getpwent() -> *mut passwd;
- pub fn fdatasync(fd: ::c_int) -> ::c_int;
- pub fn nl_langinfo_l(item: ::nl_item, locale: ::locale_t) -> *mut ::c_char;
- pub fn duplocale(base: ::locale_t) -> ::locale_t;
- pub fn freelocale(loc: ::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 getprogname() -> *const ::c_char;
- pub fn setprogname(name: *const ::c_char);
- pub fn getloadavg(loadavg: *mut ::c_double, nelem: ::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 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 sethostname(name: *const ::c_char, len: ::c_int) -> ::c_int;
- pub fn if_nameindex() -> *mut if_nameindex;
- pub fn if_freenameindex(ptr: *mut if_nameindex);
- pub fn pthread_create(native: *mut ::pthread_t,
- attr: *const ::pthread_attr_t,
- f: extern fn(*mut ::c_void) -> *mut ::c_void,
- value: *mut ::c_void) -> ::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 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,
- options: ::c_int) -> ::c_int;
-
- 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;
-
- pub fn globfree(pglob: *mut ::glob_t);
-
- pub fn posix_madvise(addr: *mut ::c_void, len: ::size_t, advice: ::c_int)
- -> ::c_int;
-
- pub fn shm_open(name: *const ::c_char, oflag: ::c_int, mode: ::mode_t)
- -> ::c_int;
- pub fn shm_unlink(name: *const ::c_char) -> ::c_int;
-
- pub fn seekdir(dirp: *mut ::DIR, loc: ::c_long);
-
- pub fn telldir(dirp: *mut ::DIR) -> ::c_long;
- pub fn madvise(addr: *mut ::c_void, len: ::size_t, advice: ::c_int)
- -> ::c_int;
-
- pub fn msync(addr: *mut ::c_void, len: ::size_t, flags: ::c_int) -> ::c_int;
-
- pub fn memalign(align: ::size_t, size: ::size_t) -> *mut ::c_void;
-
- 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 mkstemps(template: *mut ::c_char, suffixlen: ::c_int) -> ::c_int;
- pub fn futimesat(fd: ::c_int, path: *const ::c_char,
- times: *const ::timeval) -> ::c_int;
- pub fn utimensat(dirfd: ::c_int, path: *const ::c_char,
- times: *const ::timespec, flag: ::c_int) -> ::c_int;
- pub fn nl_langinfo(item: ::nl_item) -> *mut ::c_char;
-
- #[cfg_attr(target_os = "illumos", link_name = "__xnet_bind")]
- 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;
-
- #[cfg_attr(target_os = "illumos", link_name = "__xnet_sendmsg")]
- pub fn sendmsg(fd: ::c_int,
- msg: *const ::msghdr,
- flags: ::c_int) -> ::ssize_t;
- #[cfg_attr(target_os = "illumos", link_name = "__xnet_recvmsg")]
- pub fn recvmsg(fd: ::c_int, msg: *mut ::msghdr, flags: ::c_int)
- -> ::ssize_t;
-
- pub fn port_create() -> ::c_int;
- pub fn port_associate(port: ::c_int, source: ::c_int, object: ::uintptr_t,
- events: ::c_int, user: *mut ::c_void) -> ::c_int;
- pub fn port_dissociate(port: ::c_int, source: ::c_int, object: ::uintptr_t)
- -> ::c_int;
- pub fn port_get(port: ::c_int, pe: *mut port_event,
- timeout: *mut ::timespec) -> ::c_int;
- pub fn port_getn(port: ::c_int, pe_list: *mut port_event, max: ::c_uint,
- nget: *mut ::c_uint, timeout: *mut ::timespec)
- -> ::c_int;
- pub fn fexecve(fd: ::c_int, argv: *const *const ::c_char,
- envp: *const *const ::c_char)
- -> ::c_int;
- #[cfg_attr(any(target_os = "solaris", target_os = "illumos"),
- link_name = "__posix_getgrgid_r")]
- pub fn getgrgid_r(gid: ::gid_t,
- grp: *mut ::group,
- buf: *mut ::c_char,
- buflen: ::size_t,
- result: *mut *mut ::group) -> ::c_int;
- pub fn sigaltstack(ss: *const stack_t,
- oss: *mut stack_t) -> ::c_int;
- pub fn sem_close(sem: *mut sem_t) -> ::c_int;
- pub fn getdtablesize() -> ::c_int;
-
- // The epoll functions are actually only present on illumos. However,
- // there are things using epoll on illumos (built using the
- // x86_64-sun-solaris target) which would break until the illumos target is
- // present in rustc.
- 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(any(target_os = "solaris", target_os = "illumos"),
- link_name = "__posix_getgrnam_r")]
- pub fn getgrnam_r(name: *const ::c_char,
- grp: *mut ::group,
- buf: *mut ::c_char,
- buflen: ::size_t,
- result: *mut *mut ::group) -> ::c_int;
- pub fn pthread_sigmask(how: ::c_int, set: *const sigset_t,
- oldset: *mut sigset_t) -> ::c_int;
- pub fn sem_open(name: *const ::c_char, oflag: ::c_int, ...) -> *mut sem_t;
- pub fn getgrnam(name: *const ::c_char) -> *mut ::group;
- pub fn pthread_kill(thread: ::pthread_t, sig: ::c_int) -> ::c_int;
- pub fn sem_unlink(name: *const ::c_char) -> ::c_int;
- pub fn daemon(nochdir: ::c_int, noclose: ::c_int) -> ::c_int;
- #[cfg_attr(any(target_os = "solaris", target_os = "illumos"),
- link_name = "__posix_getpwnam_r")]
- pub fn getpwnam_r(name: *const ::c_char,
- pwd: *mut passwd,
- buf: *mut ::c_char,
- buflen: ::size_t,
- result: *mut *mut passwd) -> ::c_int;
- #[cfg_attr(any(target_os = "solaris", target_os = "illumos"),
- link_name = "__posix_getpwuid_r")]
- pub fn getpwuid_r(uid: ::uid_t,
- pwd: *mut passwd,
- buf: *mut ::c_char,
- buflen: ::size_t,
- result: *mut *mut passwd) -> ::c_int;
- #[cfg_attr(any(target_os = "solaris", target_os = "illumos"),
- 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(any(target_os = "solaris", target_os = "illumos"),
- 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(any(target_os = "solaris", target_os = "illumos"),
- link_name = "__posix_sigwait")]
- pub fn sigwait(set: *const sigset_t,
- sig: *mut ::c_int) -> ::c_int;
- pub fn pthread_atfork(prepare: ::Option<unsafe extern fn()>,
- parent: ::Option<unsafe extern fn()>,
- child: ::Option<unsafe extern fn()>) -> ::c_int;
- pub fn getgrgid(gid: ::gid_t) -> *mut ::group;
- pub fn setgrent();
- pub fn endgrent();
- pub fn getgrent() -> *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;
- pub fn uname(buf: *mut ::utsname) -> ::c_int;
- pub fn pipe2(fds: *mut ::c_int, flags: ::c_int) -> ::c_int;
-}
-
-mod compat;
-pub use self::compat::*;
diff --git a/libc/src/unix/uclibc/align.rs b/libc/src/unix/uclibc/align.rs
deleted file mode 100644
index 3307c9d..0000000
--- a/libc/src/unix/uclibc/align.rs
+++ /dev/null
@@ -1,66 +0,0 @@
-macro_rules! expand_align {
- () => {
- s! {
- #[cfg_attr(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(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 {
- size: [u8; ::__SIZEOF_PTHREAD_MUTEXATTR_T],
- }
-
- #[repr(align(4))]
- pub struct pthread_condattr_t {
- size: [u8; ::__SIZEOF_PTHREAD_CONDATTR_T],
- }
- }
-
- s_no_extra_traits! {
- #[repr(align(8))]
- #[allow(missing_debug_implementations)]
- pub struct pthread_cond_t {
- size: [u8; ::__SIZEOF_PTHREAD_COND_T],
- }
-
- #[cfg_attr(all(target_pointer_width = "32",
- any(target_arch = "mips",
- target_arch = "arm",
- target_arch = "powerpc")),
- repr(align(4)))]
- #[cfg_attr(any(target_pointer_width = "64",
- not(any(target_arch = "mips",
- target_arch = "arm",
- target_arch = "powerpc"))),
- repr(align(8)))]
- #[allow(missing_debug_implementations)]
- pub struct pthread_mutex_t {
- size: [u8; ::__SIZEOF_PTHREAD_MUTEX_T],
- }
-
- #[cfg_attr(all(target_pointer_width = "32",
- any(target_arch = "mips",
- target_arch = "arm",
- target_arch = "powerpc")),
- repr(align(4)))]
- #[cfg_attr(any(target_pointer_width = "64",
- not(any(target_arch = "mips",
- target_arch = "arm",
- target_arch = "powerpc"))),
- repr(align(8)))]
- #[allow(missing_debug_implementations)]
- pub struct pthread_rwlock_t {
- size: [u8; ::__SIZEOF_PTHREAD_RWLOCK_T],
- }
- }
- }
-}
diff --git a/libc/src/unix/uclibc/arm/align.rs b/libc/src/unix/uclibc/arm/align.rs
deleted file mode 100644
index 4a0e074..0000000
--- a/libc/src/unix/uclibc/arm/align.rs
+++ /dev/null
@@ -1,13 +0,0 @@
-s! {
- // FIXME this is actually a union
- #[cfg_attr(target_pointer_width = "32",
- repr(align(4)))]
- #[cfg_attr(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],
- }
-}
diff --git a/libc/src/unix/uclibc/arm/mod.rs b/libc/src/unix/uclibc/arm/mod.rs
deleted file mode 100644
index 1651285..0000000
--- a/libc/src/unix/uclibc/arm/mod.rs
+++ /dev/null
@@ -1,687 +0,0 @@
-pub type c_char = u8;
-pub type wchar_t = ::c_uint;
-pub type c_long = i32;
-pub type c_ulong = u32;
-pub type time_t = ::c_long;
-
-pub type clock_t = ::c_long;
-pub type fsblkcnt_t = ::c_ulong;
-pub type fsfilcnt_t = ::c_ulong;
-pub type ino_t = ::c_ulong;
-pub type off_t = ::c_long;
-pub type pthread_t = ::c_ulong;
-pub type rlim_t = ::c_ulong;
-pub type suseconds_t = ::c_long;
-
-pub type nlink_t = ::c_uint;
-pub type blksize_t = ::c_long;
-pub type blkcnt_t = ::c_long;
-
-s! {
- pub struct cmsghdr {
- pub cmsg_len: ::size_t,
- pub cmsg_level: ::c_int,
- pub cmsg_type: ::c_int,
- }
-
- pub struct msghdr {
- pub msg_name: *mut ::c_void,
- pub msg_namelen: ::socklen_t,
- pub msg_iov: *mut ::iovec,
- pub msg_iovlen: ::c_int,
- pub msg_control: *mut ::c_void,
- pub msg_controllen: ::socklen_t,
- pub msg_flags: ::c_int,
- }
-
- pub struct pthread_attr_t {
- __size: [::c_long; 9],
- }
-
- pub struct stat {
- pub st_dev: ::c_ulonglong,
- pub __pad1: ::c_ushort,
- 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: ::c_ulonglong,
- pub __pad2: ::c_ushort,
- pub st_size: ::off_t,
- pub st_blksize: ::blksize_t,
- pub st_blocks: ::blkcnt_t,
- pub st_atim: ::timespec,
- pub st_mtim: ::timespec,
- pub st_ctim: ::timespec,
- pub __unused4: ::c_ulong,
- pub __unused5: ::c_ulong,
- }
-
- pub struct stat64
- {
- pub st_dev: ::c_ulonglong,
- pub __pad1: ::c_uint,
- 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: ::c_ulonglong,
- pub __pad2: ::c_uint,
- pub st_size: ::off64_t,
- pub st_blksize: ::blksize_t,
- pub st_blocks: ::blkcnt64_t,
- pub st_atim: ::timespec,
- pub st_mtim: ::timespec,
- pub st_ctim: ::timespec,
- pub st_ino: ::ino64_t,
- }
-
- pub struct flock {
- pub l_type: ::c_short,
- pub l_whence: ::c_short,
- pub l_start: ::off_t,
- pub l_len: ::off_t,
- pub l_pid: ::pid_t,
- }
-
- pub struct statfs {
- pub f_type: ::c_int,
- pub f_bsize: ::c_int,
- 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_int,
- pub f_frsize: ::c_int,
- pub f_spare: [::c_int; 5],
- }
-
- pub struct sigset_t {
- __val: [::c_ulong; 2],
- }
-
- pub struct sigaction {
- pub sa_sigaction: ::sighandler_t,
- // uClibc defines sa_flags as `unsigned long int`,
- // but nix crate expects `int`
- pub sa_flags: ::c_int,
- pub sa_restorer: *mut ::c_void,
- pub sa_mask: sigset_t,
- }
-
- pub struct termios {
- pub c_iflag: ::tcflag_t,
- pub c_oflag: ::tcflag_t,
- pub c_cflag: ::tcflag_t,
- pub c_lflag: ::tcflag_t,
- pub c_line: ::cc_t,
- pub c_cc: [::cc_t; ::NCCS],
- pub c_ispeed: ::speed_t,
- pub c_ospeed: ::speed_t,
- }
-
- pub struct siginfo_t {
- pub si_signo: ::c_int,
- pub si_errno: ::c_int,
- pub si_code: ::c_int,
- pub _pad: [::c_int; 29],
- }
-
- pub struct stack_t {
- pub ss_sp: *mut ::c_void,
- ss_flags: ::c_int,
- ss_size: ::size_t,
- }
-
- pub struct ipc_perm {
- pub __key: ::key_t,
- pub uid: ::uid_t,
- pub gid: ::gid_t,
- pub cuid: ::uid_t,
- pub cgid: ::gid_t,
- pub mode: ::c_ushort,
- pub __pad1: ::c_ushort,
- pub __seq: ::c_ushort,
- pub __pad2: ::c_ushort,
- pub __unused1: ::c_ulong,
- pub __unused2: ::c_ulong,
- }
-
- pub struct msqid_ds {
- pub msg_perm: ::ipc_perm,
- pub msg_stime: ::time_t,
- pub __unused1: ::c_ulong,
- pub msg_rtime: ::time_t,
- pub __unused2: ::c_ulong,
- pub msg_ctime: ::time_t,
- pub __unused3: ::c_ulong,
- pub __msg_cbytes: ::c_ulong,
- pub msg_qnum: ::msgqnum_t,
- pub msg_qbytes: ::msglen_t,
- pub msg_lspid: ::pid_t,
- pub msg_lrpid: ::pid_t,
- pub __unused4: ::c_ulong,
- pub __unused5: ::c_ulong,
- }
-
- pub struct shmid_ds {
- pub shm_perm: ::ipc_perm,
- pub shm_segsz: ::size_t,
- pub shm_atime: ::time_t,
- pub __unused1: ::c_ulong,
- pub shm_dtime: ::time_t,
- pub __unused2: ::c_ulong,
- pub shm_ctime: ::time_t,
- pub __unused3: ::c_ulong,
- pub shm_cpid: ::pid_t,
- pub shm_lpid: ::pid_t,
- pub shm_nattch: ::shmatt_t,
- pub __unused4: ::c_ulong,
- pub __unused5: ::c_ulong,
- }
-
- pub struct ucred {
- pub pid: ::pid_t,
- pub uid: ::uid_t,
- pub gid: ::gid_t,
- }
-
-}
-
-pub const O_CLOEXEC: ::c_int = 0o2000000;
-pub const RLIM_INFINITY: rlim_t = !0;
-pub const __SIZEOF_PTHREAD_ATTR_T: usize = 36;
-pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 24;
-pub const __SIZEOF_PTHREAD_MUTEXATTR_T: usize = 4;
-pub const __SIZEOF_PTHREAD_COND_COMPAT_T: usize = 12;
-pub const __SIZEOF_PTHREAD_CONDATTR_T: usize = 4;
-pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 32;
-pub const __SIZEOF_PTHREAD_RWLOCKATTR_T: usize = 8;
-pub const __SIZEOF_PTHREAD_BARRIER_T: usize = 20;
-pub const __SIZEOF_PTHREAD_BARRIERATTR_T: usize = 4;
-pub const NCCS: usize = 32;
-
-// I wasn't able to find those constants
-// in uclibc build environment for armv7
-pub const AIO_ALLDONE: ::c_int = 2; // from linux/mod.rs
-pub const AIO_CANCELED: ::c_int = 0; // from linux/mod.rs
-pub const AIO_NOTCANCELED: ::c_int = 1; // from linux/mod.rs
-pub const CLONE_NEWCGROUP: ::c_int = 0x02000000; // from linux/mod.rs
-pub const EPOLLEXCLUSIVE: ::c_int = 0x10000000; // from linux/mod.rs
-pub const EPOLLWAKEUP: ::c_int = 0x20000000; // from linux/other/mod.rs
-pub const EXTPROC: ::tcflag_t = 0o200000; // from asm-generic/termbits.h
-pub const F_GETPIPE_SZ: ::c_int = 1032; // from notbsd/mod.rs
-pub const F_SETPIPE_SZ: ::c_int = 1031; // from notbsd/mod.rs
-pub const LIO_NOP: ::c_int = 2; // from linux/mod.rs
-pub const LIO_NOWAIT: ::c_int = 1; // from linux/mod.rs
-pub const LIO_READ: ::c_int = 0; // from linux/mod.rs
-pub const LIO_WAIT: ::c_int = 0; // from linux/mod.rs
-pub const LIO_WRITE: ::c_int = 1; // from linux/mod.rs
-pub const MAP_HUGETLB: ::c_int = 0x040000; // from linux/other/mod.rs
-pub const O_TMPFILE: ::c_int = 0o20000000 | O_DIRECTORY;
-pub const RB_KEXEC: ::c_int = 0x45584543u32 as i32; // from linux/mod.rs
-pub const RB_SW_SUSPEND: ::c_int = 0xd000fce2u32 as i32; // from linux/mod.rs
-pub const SO_BUSY_POLL: ::c_int = 46; // from src/unix/notbsd/mod.rs
-pub const SO_PEEK_OFF: ::c_int = 42; // from src/unix/notbsd/mod.rs
-pub const SO_REUSEPORT: ::c_int = 15; // from src/unix/notbsd/mod.rs
-pub const SOL_NETLINK: ::c_int = 270; // from src/unix/notbsd/mod.rs
-pub const _POSIX_VDISABLE: ::cc_t = 0; // from linux/mod.rs
-pub const AT_EMPTY_PATH: ::c_int = 0x1000; // from notbsd/mod.rs
-
-// autogenerated constants with hand tuned types
-pub const AT_NO_AUTOMOUNT: ::c_int = 0x800;
-pub const B0: ::speed_t = 0;
-pub const B1000000: ::speed_t = 0x1008;
-pub const B110: ::speed_t = 0x3;
-pub const B115200: ::speed_t = 0x1002;
-pub const B1152000: ::speed_t = 0x1009;
-pub const B1200: ::speed_t = 0x9;
-pub const B134: ::speed_t = 0x4;
-pub const B150: ::speed_t = 0x5;
-pub const B1500000: ::speed_t = 0x100a;
-pub const B1800: ::speed_t = 0xa;
-pub const B19200: ::speed_t = 0xe;
-pub const B200: ::speed_t = 0x6;
-pub const B2000000: ::speed_t = 0x100b;
-pub const B230400: ::speed_t = 0x1003;
-pub const B2400: ::speed_t = 0xb;
-pub const B2500000: ::speed_t = 0x100c;
-pub const B300: ::speed_t = 0x7;
-pub const B3000000: ::speed_t = 0x100d;
-pub const B3500000: ::speed_t = 0x100e;
-pub const B38400: ::speed_t = 0xf;
-pub const B4000000: ::speed_t = 0x100f;
-pub const B460800: ::speed_t = 0x1004;
-pub const B4800: ::speed_t = 0xc;
-pub const B50: ::speed_t = 0x1;
-pub const B500000: ::speed_t = 0x1005;
-pub const B57600: ::speed_t = 0x1001;
-pub const B576000: ::speed_t = 0x1006;
-pub const B600: ::speed_t = 0x8;
-pub const B75: ::speed_t = 0x2;
-pub const B921600: ::speed_t = 0x1007;
-pub const B9600: ::speed_t = 0xd;
-pub const BS1: ::c_int = 0x2000;
-pub const BSDLY: ::c_int = 0x2000;
-pub const CBAUD: ::tcflag_t = 0x100f;
-pub const CBAUDEX: ::tcflag_t = 0x1000;
-pub const CIBAUD: ::tcflag_t = 0x100f0000;
-pub const CLOCAL: ::tcflag_t = 0x800;
-pub const CMSPAR: ::tcflag_t = 0x40000000;
-pub const CPU_SETSIZE: ::c_int = 0x400;
-pub const CR1: ::c_int = 0x200;
-pub const CR2: ::c_int = 0x400;
-pub const CR3: ::c_int = 0x600;
-pub const CRDLY: ::c_int = 0x600;
-pub const CREAD: ::tcflag_t = 0x80;
-pub const CS6: ::tcflag_t = 0x10;
-pub const CS7: ::tcflag_t = 0x20;
-pub const CS8: ::tcflag_t = 0x30;
-pub const CSIZE: ::tcflag_t = 0x30;
-pub const CSTOPB: ::tcflag_t = 0x40;
-pub const EADDRINUSE: ::c_int = 0x62;
-pub const EADDRNOTAVAIL: ::c_int = 0x63;
-pub const EADV: ::c_int = 0x44;
-pub const EAFNOSUPPORT: ::c_int = 0x61;
-pub const EALREADY: ::c_int = 0x72;
-pub const EBADE: ::c_int = 0x34;
-pub const EBADFD: ::c_int = 0x4d;
-pub const EBADMSG: ::c_int = 0x4a;
-pub const EBADR: ::c_int = 0x35;
-pub const EBADRQC: ::c_int = 0x38;
-pub const EBADSLT: ::c_int = 0x39;
-pub const EBFONT: ::c_int = 0x3b;
-pub const ECANCELED: ::c_int = 0x7d;
-pub const ECHOCTL: ::tcflag_t = 0x200;
-pub const ECHOE: ::tcflag_t = 0x10;
-pub const ECHOK: ::tcflag_t = 0x20;
-pub const ECHOKE: ::tcflag_t = 0x800;
-pub const ECHONL: ::tcflag_t = 0x40;
-pub const ECHOPRT: ::tcflag_t = 0x400;
-pub const ECHRNG: ::c_int = 0x2c;
-pub const ECOMM: ::c_int = 0x46;
-pub const ECONNABORTED: ::c_int = 0x67;
-pub const ECONNREFUSED: ::c_int = 0x6f;
-pub const ECONNRESET: ::c_int = 0x68;
-pub const EDEADLK: ::c_int = 0x23;
-pub const EDESTADDRREQ: ::c_int = 0x59;
-pub const EDOTDOT: ::c_int = 0x49;
-pub const EDQUOT: ::c_int = 0x7a;
-pub const EFD_CLOEXEC: ::c_int = 0x80000;
-pub const EFD_NONBLOCK: ::c_int = 0x800;
-pub const EHOSTDOWN: ::c_int = 0x70;
-pub const EHOSTUNREACH: ::c_int = 0x71;
-pub const EHWPOISON: ::c_int = 0x85;
-pub const EIDRM: ::c_int = 0x2b;
-pub const EILSEQ: ::c_int = 0x54;
-pub const EINPROGRESS: ::c_int = 0x73;
-pub const EISCONN: ::c_int = 0x6a;
-pub const EISNAM: ::c_int = 0x78;
-pub const EKEYEXPIRED: ::c_int = 0x7f;
-pub const EKEYREJECTED: ::c_int = 0x81;
-pub const EKEYREVOKED: ::c_int = 0x80;
-pub const EL2HLT: ::c_int = 0x33;
-pub const EL2NSYNC: ::c_int = 0x2d;
-pub const EL3HLT: ::c_int = 0x2e;
-pub const EL3RST: ::c_int = 0x2f;
-pub const ELIBACC: ::c_int = 0x4f;
-pub const ELIBBAD: ::c_int = 0x50;
-pub const ELIBEXEC: ::c_int = 0x53;
-pub const ELIBMAX: ::c_int = 0x52;
-pub const ELIBSCN: ::c_int = 0x51;
-pub const ELNRNG: ::c_int = 0x30;
-pub const ELOOP: ::c_int = 0x28;
-pub const EMEDIUMTYPE: ::c_int = 0x7c;
-pub const EMSGSIZE: ::c_int = 0x5a;
-pub const EMULTIHOP: ::c_int = 0x48;
-pub const ENAMETOOLONG: ::c_int = 0x24;
-pub const ENAVAIL: ::c_int = 0x77;
-pub const ENETDOWN: ::c_int = 0x64;
-pub const ENETRESET: ::c_int = 0x66;
-pub const ENETUNREACH: ::c_int = 0x65;
-pub const ENOANO: ::c_int = 0x37;
-pub const ENOBUFS: ::c_int = 0x69;
-pub const ENOCSI: ::c_int = 0x32;
-pub const ENODATA: ::c_int = 0x3d;
-pub const ENOKEY: ::c_int = 0x7e;
-pub const ENOLCK: ::c_int = 0x25;
-pub const ENOLINK: ::c_int = 0x43;
-pub const ENOMEDIUM: ::c_int = 0x7b;
-pub const ENOMSG: ::c_int = 0x2a;
-pub const ENONET: ::c_int = 0x40;
-pub const ENOPKG: ::c_int = 0x41;
-pub const ENOPROTOOPT: ::c_int = 0x5c;
-pub const ENOSR: ::c_int = 0x3f;
-pub const ENOSTR: ::c_int = 0x3c;
-pub const ENOSYS: ::c_int = 0x26;
-pub const ENOTCONN: ::c_int = 0x6b;
-pub const ENOTEMPTY: ::c_int = 0x27;
-pub const ENOTNAM: ::c_int = 0x76;
-pub const ENOTRECOVERABLE: ::c_int = 0x83;
-pub const ENOTSOCK: ::c_int = 0x58;
-pub const ENOTUNIQ: ::c_int = 0x4c;
-pub const EOPNOTSUPP: ::c_int = 0x5f;
-pub const EOVERFLOW: ::c_int = 0x4b;
-pub const EOWNERDEAD: ::c_int = 0x82;
-pub const EPFNOSUPPORT: ::c_int = 0x60;
-pub const EPOLL_CLOEXEC: ::c_int = 0x80000;
-pub const EPROTO: ::c_int = 0x47;
-pub const EPROTONOSUPPORT: ::c_int = 0x5d;
-pub const EPROTOTYPE: ::c_int = 0x5b;
-pub const EREMCHG: ::c_int = 0x4e;
-pub const EREMOTE: ::c_int = 0x42;
-pub const EREMOTEIO: ::c_int = 0x79;
-pub const ERESTART: ::c_int = 0x55;
-pub const ERFKILL: ::c_int = 0x84;
-pub const ESHUTDOWN: ::c_int = 0x6c;
-pub const ESOCKTNOSUPPORT: ::c_int = 0x5e;
-pub const ESRMNT: ::c_int = 0x45;
-pub const ESTALE: ::c_int = 0x74;
-pub const ESTRPIPE: ::c_int = 0x56;
-pub const ETIME: ::c_int = 0x3e;
-pub const ETIMEDOUT: ::c_int = 0x6e;
-pub const ETOOMANYREFS: ::c_int = 0x6d;
-pub const EUCLEAN: ::c_int = 0x75;
-pub const EUNATCH: ::c_int = 0x31;
-pub const EUSERS: ::c_int = 0x57;
-pub const EXFULL: ::c_int = 0x36;
-pub const FF1: ::c_int = 0x8000;
-pub const FFDLY: ::c_int = 0x8000;
-pub const FIONBIO: ::c_ulong = 0x5421;
-pub const FIOCLEX: ::c_ulong = 0x5451;
-pub const FLUSHO: ::tcflag_t = 0x1000;
-pub const F_GETLK: ::c_int = 0x5;
-pub const F_SETLK: ::c_int = 0x6;
-pub const F_SETLKW: ::c_int = 0x7;
-pub const HUPCL: ::tcflag_t = 0x400;
-pub const ICANON: ::tcflag_t = 0x2;
-pub const IEXTEN: ::tcflag_t = 0x8000;
-pub const IPV6_MULTICAST_HOPS: ::c_int = 0x12;
-pub const IPV6_MULTICAST_IF: ::c_int = 0x11;
-pub const IPV6_UNICAST_HOPS: ::c_int = 0x10;
-pub const IP_MULTICAST_IF: ::c_int = 0x20;
-pub const ISIG: ::tcflag_t = 0x1;
-pub const IUTF8: ::tcflag_t = 0x4000;
-pub const IXOFF: ::tcflag_t = 0x1000;
-pub const IXON: ::tcflag_t = 0x400;
-pub const MAP_ANON: ::c_int = 0x20;
-pub const MAP_ANONYMOUS: ::c_int = 0x20;
-pub const MAP_DENYWRITE: ::c_int = 0x800;
-pub const MAP_EXECUTABLE: ::c_int = 0x1000;
-pub const MAP_GROWSDOWN: ::c_int = 0x100;
-pub const MAP_LOCKED: ::c_int = 0x2000;
-pub const MAP_NONBLOCK: ::c_int = 0x10000;
-pub const MAP_NORESERVE: ::c_int = 0x4000;
-pub const MAP_POPULATE: ::c_int = 0x8000;
-pub const MAP_STACK: ::c_int = 0x20000;
-pub const MS_ACTIVE: u32 = 0x40000000;
-pub const MS_DIRSYNC: u32 = 0x80;
-pub const MS_I_VERSION: u32 = 0x800000;
-pub const MS_KERNMOUNT: u32 = 0x400000;
-pub const MS_MOVE: u32 = 0x2000;
-pub const MS_POSIXACL: u32 = 0x10000;
-pub const MS_PRIVATE: u32 = 0x40000;
-pub const MS_REC: u32 = 0x4000;
-pub const MS_RELATIME: u32 = 0x200000;
-pub const MS_SHARED: u32 = 0x100000;
-pub const MS_SILENT: u32 = 0x8000;
-pub const MS_SLAVE: u32 = 0x80000;
-pub const MS_STRICTATIME: u32 = 0x1000000;
-pub const MS_UNBINDABLE: u32 = 0x20000;
-pub const NLDLY: ::tcflag_t = 0x100;
-pub const NOFLSH: ::tcflag_t = 0x80;
-pub const OCRNL: ::c_int = 0x8;
-pub const OFDEL: ::c_int = 0x80;
-pub const OFILL: ::c_int = 0x40;
-pub const OLCUC: ::tcflag_t = 0x2;
-pub const ONLCR: ::tcflag_t = 0x4;
-pub const ONLRET: ::tcflag_t = 0x20;
-pub const ONOCR: ::tcflag_t = 0x10;
-pub const O_ACCMODE: ::c_int = 0x3;
-pub const O_APPEND: ::c_int = 0x400;
-pub const O_CREAT: ::c_int = 0x40;
-pub const O_DIRECT: ::c_int = 0x10000;
-pub const O_DIRECTORY: ::c_int = 0x4000;
-pub const O_DSYNC: ::c_int = 0x1000;
-pub const O_EXCL: ::c_int = 0x80;
-pub const O_NDELAY: ::c_int = 0x800;
-pub const O_NOCTTY: ::c_int = 0x100;
-pub const O_NOFOLLOW: ::c_int = 0x8000;
-pub const O_NONBLOCK: ::c_int = 0x800;
-pub const O_SYNC: ::c_int = 0o10000;
-pub const O_TRUNC: ::c_int = 0x200;
-pub const PARENB: ::tcflag_t = 0x100;
-pub const PARODD: ::tcflag_t = 0x200;
-pub const PENDIN: ::tcflag_t = 0x4000;
-pub const POLLRDBAND: ::c_short = 0x80;
-pub const POLLRDNORM: ::c_short = 0x40;
-pub const POLLWRBAND: ::c_short = 0x200;
-pub const POLLWRNORM: ::c_short = 0x100;
-pub const QIF_ALL: u32 = 0x3f;
-pub const QIF_BLIMITS: u32 = 0x1;
-pub const QIF_BTIME: u32 = 0x10;
-pub const QIF_ILIMITS: u32 = 0x4;
-pub const QIF_INODES: u32 = 0x8;
-pub const QIF_ITIME: u32 = 0x20;
-pub const QIF_LIMITS: u32 = 0x5;
-pub const QIF_SPACE: u32 = 0x2;
-pub const QIF_TIMES: u32 = 0x30;
-pub const QIF_USAGE: u32 = 0xa;
-pub const SA_NOCLDSTOP: ::c_int = 0x1;
-pub const SA_NOCLDWAIT: ::c_int = 0x2;
-pub const SA_NODEFER: ::c_int = 0x40000000;
-pub const SA_ONSTACK: ::c_int = 0x8000000;
-pub const SA_RESETHAND: ::c_int = 0x80000000;
-pub const SA_RESTART: ::c_int = 0x10000000;
-pub const SA_SIGINFO: ::c_int = 0x4;
-pub const SFD_CLOEXEC: ::c_int = 0x80000;
-pub const SFD_NONBLOCK: ::c_int = 0x800;
-pub const SIGBUS: ::c_int = 0x7;
-pub const SIGCHLD: ::c_int = 0x11;
-pub const SIGCONT: ::c_int = 0x12;
-pub const SIGIO: ::c_int = 0x1d;
-pub const SIGPROF: ::c_int = 0x1b;
-pub const SIGPWR: ::c_int = 0x1e;
-pub const SIGSTKFLT: ::c_int = 0x10;
-pub const SIGSTOP: ::c_int = 0x13;
-pub const SIGSYS: ::c_int = 0x1f;
-pub const SIGTSTP: ::c_int = 0x14;
-pub const SIGTTIN: ::c_int = 0x15;
-pub const SIGTTOU: ::c_int = 0x16;
-pub const SIGURG: ::c_int = 0x17;
-pub const SIGUSR1: ::c_int = 0xa;
-pub const SIGUSR2: ::c_int = 0xc;
-pub const SIGVTALRM: ::c_int = 0x1a;
-pub const SIGWINCH: ::c_int = 0x1c;
-pub const SIGXCPU: ::c_int = 0x18;
-pub const SIGXFSZ: ::c_int = 0x19;
-pub const SIG_BLOCK: ::c_int = 0;
-pub const SIG_SETMASK: ::c_int = 0x2;
-pub const SIG_UNBLOCK: ::c_int = 0x1;
-pub const SOCK_DGRAM: ::c_int = 0x2;
-pub const SOCK_NONBLOCK: ::c_int = 0o0004000;
-pub const SOCK_SEQPACKET: ::c_int = 0x5;
-pub const SOCK_STREAM: ::c_int = 0x1;
-pub const SOL_SOCKET: ::c_int = 0x1;
-pub const SO_ACCEPTCONN: ::c_int = 0x1e;
-pub const SO_BINDTODEVICE: ::c_int = 0x19;
-pub const SO_BROADCAST: ::c_int = 0x6;
-pub const SO_BSDCOMPAT: ::c_int = 0xe;
-pub const SO_DOMAIN: ::c_int = 0x27;
-pub const SO_DONTROUTE: ::c_int = 0x5;
-pub const SO_ERROR: ::c_int = 0x4;
-pub const SO_KEEPALIVE: ::c_int = 0x9;
-pub const SO_LINGER: ::c_int = 0xd;
-pub const SO_MARK: ::c_int = 0x24;
-pub const SO_OOBINLINE: ::c_int = 0xa;
-pub const SO_PASSCRED: ::c_int = 0x10;
-pub const SO_PEERCRED: ::c_int = 0x11;
-pub const SO_PRIORITY: ::c_int = 0xc;
-pub const SO_PROTOCOL: ::c_int = 0x26;
-pub const SO_RCVBUF: ::c_int = 0x8;
-pub const SO_RCVLOWAT: ::c_int = 0x12;
-pub const SO_RCVTIMEO: ::c_int = 0x14;
-pub const SO_REUSEADDR: ::c_int = 0x2;
-pub const SO_RXQ_OVFL: ::c_int = 0x28;
-pub const SO_SNDBUF: ::c_int = 0x7;
-pub const SO_SNDBUFFORCE: ::c_int = 0x20;
-pub const SO_SNDLOWAT: ::c_int = 0x13;
-pub const SO_SNDTIMEO: ::c_int = 0x15;
-pub const SO_TIMESTAMP: ::c_int = 0x1d;
-pub const SO_TYPE: ::c_int = 0x3;
-pub const SYS_gettid: ::c_int = 0xe0;
-pub const TAB1: ::c_int = 0x800;
-pub const TAB2: ::c_int = 0x1000;
-pub const TAB3: ::c_int = 0x1800;
-pub const TABDLY: ::c_int = 0x1800;
-pub const TCSADRAIN: ::c_int = 0x1;
-pub const TCSAFLUSH: ::c_int = 0x2;
-pub const TCSANOW: ::c_int = 0;
-pub const TOSTOP: ::tcflag_t = 0x100;
-pub const VDISCARD: usize = 0xd;
-pub const VEOF: usize = 0x4;
-pub const VEOL: usize = 0xb;
-pub const VEOL2: usize = 0x10;
-pub const VMIN: usize = 0x6;
-pub const VREPRINT: usize = 0xc;
-pub const VSTART: usize = 0x8;
-pub const VSTOP: usize = 0x9;
-pub const VSUSP: usize = 0xa;
-pub const VSWTC: usize = 0x7;
-pub const VT1: ::c_int = 0x4000;
-pub const VTDLY: ::c_int = 0x4000;
-pub const VTIME: usize = 0x5;
-pub const VWERASE: usize = 0xe;
-pub const XTABS: ::tcflag_t = 0x1800;
-pub const _PC_2_SYMLINKS: ::c_int = 0x14;
-pub const _PC_ALLOC_SIZE_MIN: ::c_int = 0x12;
-pub const _PC_ASYNC_IO: ::c_int = 0xa;
-pub const _PC_FILESIZEBITS: ::c_int = 0xd;
-pub const _PC_PRIO_IO: ::c_int = 0xb;
-pub const _PC_REC_INCR_XFER_SIZE: ::c_int = 0xe;
-pub const _PC_REC_MAX_XFER_SIZE: ::c_int = 0xf;
-pub const _PC_REC_MIN_XFER_SIZE: ::c_int = 0x10;
-pub const _PC_REC_XFER_ALIGN: ::c_int = 0x11;
-pub const _PC_SYMLINK_MAX: ::c_int = 0x13;
-pub const _PC_SYNC_IO: ::c_int = 0x9;
-pub const _SC_2_PBS: ::c_int = 0xa8;
-pub const _SC_2_PBS_ACCOUNTING: ::c_int = 0xa9;
-pub const _SC_2_PBS_CHECKPOINT: ::c_int = 0xaf;
-pub const _SC_2_PBS_LOCATE: ::c_int = 0xaa;
-pub const _SC_2_PBS_MESSAGE: ::c_int = 0xab;
-pub const _SC_2_PBS_TRACK: ::c_int = 0xac;
-pub const _SC_ADVISORY_INFO: ::c_int = 0x84;
-pub const _SC_BARRIERS: ::c_int = 0x85;
-pub const _SC_CLOCK_SELECTION: ::c_int = 0x89;
-pub const _SC_CPUTIME: ::c_int = 0x8a;
-pub const _SC_IPV6: ::c_int = 0xeb;
-pub const _SC_MONOTONIC_CLOCK: ::c_int = 0x95;
-pub const _SC_RAW_SOCKETS: ::c_int = 0xec;
-pub const _SC_READER_WRITER_LOCKS: ::c_int = 0x99;
-pub const _SC_REGEXP: ::c_int = 0x9b;
-pub const _SC_SHELL: ::c_int = 0x9d;
-pub const _SC_SPAWN: ::c_int = 0x9f;
-pub const _SC_SPIN_LOCKS: ::c_int = 0x9a;
-pub const _SC_SPORADIC_SERVER: ::c_int = 0xa0;
-pub const _SC_SS_REPL_MAX: ::c_int = 0xf1;
-pub const _SC_SYMLOOP_MAX: ::c_int = 0xad;
-pub const _SC_THREAD_CPUTIME: ::c_int = 0x8b;
-pub const _SC_THREAD_PROCESS_SHARED: ::c_int = 0x52;
-pub const _SC_THREAD_ROBUST_PRIO_INHERIT: ::c_int = 0xf7;
-pub const _SC_THREAD_ROBUST_PRIO_PROTECT: ::c_int = 0xf8;
-pub const _SC_THREAD_SPORADIC_SERVER: ::c_int = 0xa1;
-pub const _SC_TIMEOUTS: ::c_int = 0xa4;
-pub const _SC_TRACE: ::c_int = 0xb5;
-pub const _SC_TRACE_EVENT_FILTER: ::c_int = 0xb6;
-pub const _SC_TRACE_EVENT_NAME_MAX: ::c_int = 0xf2;
-pub const _SC_TRACE_INHERIT: ::c_int = 0xb7;
-pub const _SC_TRACE_LOG: ::c_int = 0xb8;
-pub const _SC_TRACE_NAME_MAX: ::c_int = 0xf3;
-pub const _SC_TRACE_SYS_MAX: ::c_int = 0xf4;
-pub const _SC_TRACE_USER_EVENT_MAX: ::c_int = 0xf5;
-pub const _SC_TYPED_MEMORY_OBJECTS: ::c_int = 0xa5;
-pub const _SC_V6_ILP32_OFF32: ::c_int = 0xb0;
-pub const _SC_V6_ILP32_OFFBIG: ::c_int = 0xb1;
-pub const _SC_V6_LP64_OFF64: ::c_int = 0xb2;
-pub const _SC_V6_LPBIG_OFFBIG: ::c_int = 0xb3;
-pub const _SC_XOPEN_STREAMS: ::c_int = 0xf6;
-
-fn CMSG_ALIGN(len: usize) -> usize {
- len + ::mem::size_of::<usize>() - 1 & !(::mem::size_of::<usize>() - 1)
-}
-
-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_DATA(cmsg: *const cmsghdr) -> *mut ::c_uchar {
- cmsg.offset(1) as *mut ::c_uchar
- }
-
- pub fn CMSG_SPACE(length: ::c_uint) -> ::c_uint {
- (CMSG_ALIGN(length as usize) + CMSG_ALIGN(::mem::size_of::<cmsghdr>()))
- as ::c_uint
- }
-
- pub fn CMSG_LEN(length: ::c_uint) -> ::c_uint {
- CMSG_ALIGN(::mem::size_of::<cmsghdr>()) as ::c_uint + length
- }
-
- pub fn CMSG_NXTHDR(mhdr: *const msghdr,
- cmsg: *const cmsghdr) -> *mut cmsghdr {
- if ((*cmsg).cmsg_len as usize) < ::mem::size_of::<cmsghdr>() {
- return 0 as *mut cmsghdr;
- };
- let next = (cmsg as usize +
- CMSG_ALIGN((*cmsg).cmsg_len as usize))
- as *mut cmsghdr;
- let max = (*mhdr).msg_control as usize
- + (*mhdr).msg_controllen as usize;
- if (next.offset(1)) as usize > max ||
- next as usize + CMSG_ALIGN((*next).cmsg_len as usize) > max
- {
- 0 as *mut cmsghdr
- } else {
- next as *mut cmsghdr
- }
- }
-
-}
-
-extern {
- pub fn ioctl(fd: ::c_int, request: ::c_ulong, ...) -> ::c_int;
- pub fn openpty(amaster: *mut ::c_int,
- aslave: *mut ::c_int,
- name: *mut ::c_char,
- termp: *mut termios,
- winp: *mut ::winsize) -> ::c_int;
- pub fn setns(fd: ::c_int, nstype: ::c_int) -> ::c_int;
- pub fn pwritev(fd: ::c_int,
- iov: *const ::iovec,
- iovcnt: ::c_int,
- offset: ::off_t) -> ::ssize_t;
- pub fn preadv(fd: ::c_int,
- iov: *const ::iovec,
- iovcnt: ::c_int,
- offset: ::off_t) -> ::ssize_t;
-}
-
-cfg_if! {
- if #[cfg(libc_align)] {
- mod align;
- pub use self::align::*;
- } else {
- mod no_align;
- pub use self::no_align::*;
- }
-}
diff --git a/libc/src/unix/uclibc/arm/no_align.rs b/libc/src/unix/uclibc/arm/no_align.rs
deleted file mode 100644
index e32bf67..0000000
--- a/libc/src/unix/uclibc/arm/no_align.rs
+++ /dev/null
@@ -1,10 +0,0 @@
-s! {
- // FIXME this is actually a union
- pub struct sem_t {
- #[cfg(target_pointer_width = "32")]
- __size: [::c_char; 16],
- #[cfg(target_pointer_width = "64")]
- __size: [::c_char; 32],
- __align: [::c_long; 0],
- }
-}
diff --git a/libc/src/unix/uclibc/mips/mips32/align.rs b/libc/src/unix/uclibc/mips/mips32/align.rs
deleted file mode 100644
index 4a0e074..0000000
--- a/libc/src/unix/uclibc/mips/mips32/align.rs
+++ /dev/null
@@ -1,13 +0,0 @@
-s! {
- // FIXME this is actually a union
- #[cfg_attr(target_pointer_width = "32",
- repr(align(4)))]
- #[cfg_attr(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],
- }
-}
diff --git a/libc/src/unix/uclibc/mips/mips32/mod.rs b/libc/src/unix/uclibc/mips/mips32/mod.rs
deleted file mode 100644
index 410ab70..0000000
--- a/libc/src/unix/uclibc/mips/mips32/mod.rs
+++ /dev/null
@@ -1,627 +0,0 @@
-pub type c_char = i8;
-pub type c_long = i32;
-pub type c_ulong = u32;
-pub type clock_t = i32;
-pub type time_t = i32;
-pub type suseconds_t = i32;
-pub type wchar_t = i32;
-pub type off_t = i32;
-pub type ino_t = u32;
-pub type blkcnt_t = i32;
-pub type blksize_t = i32;
-pub type nlink_t = u32;
-pub type fsblkcnt_t = ::c_ulong;
-pub type fsfilcnt_t = ::c_ulong;
-pub type rlim_t = c_ulong;
-
-s! {
- pub struct stat {
- pub st_dev: ::dev_t,
- st_pad1: [::c_long; 2],
- 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_pad2: [::c_long; 1],
- pub st_size: ::off_t,
- st_pad3: ::c_long,
- 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,
- st_pad5: [::c_long; 14],
- }
-
- pub struct stat64 {
- pub st_dev: ::dev_t,
- st_pad1: [::c_long; 2],
- pub st_ino: ::ino64_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_pad2: [::c_long; 2],
- pub st_size: ::off64_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,
- st_pad3: ::c_long,
- pub st_blocks: ::blkcnt64_t,
- st_pad5: [::c_long; 14],
- }
-
- pub struct pthread_attr_t {
- __size: [u32; 9]
- }
-
- pub struct sigaction {
- pub sa_flags: ::c_uint,
- pub sa_sigaction: ::sighandler_t,
- pub sa_mask: sigset_t,
- _restorer: *mut ::c_void,
- }
-
- pub struct stack_t {
- pub ss_sp: *mut ::c_void,
- pub ss_size: ::size_t,
- pub ss_flags: ::c_int,
- }
-
- pub struct sigset_t {
- __val: [::c_ulong; 4],
- }
-
- pub struct siginfo_t {
- pub si_signo: ::c_int,
- pub si_code: ::c_int,
- pub si_errno: ::c_int,
- pub _pad: [::c_int; 29],
- }
-
- pub struct glob64_t {
- pub gl_pathc: ::size_t,
- pub gl_pathv: *mut *mut ::c_char,
- pub gl_offs: ::size_t,
- pub gl_flags: ::c_int,
-
- __unused1: *mut ::c_void,
- __unused2: *mut ::c_void,
- __unused3: *mut ::c_void,
- __unused4: *mut ::c_void,
- __unused5: *mut ::c_void,
- }
-
- pub struct ipc_perm {
- pub __key: ::key_t,
- pub uid: ::uid_t,
- pub gid: ::gid_t,
- pub cuid: ::uid_t,
- pub cgid: ::gid_t,
- pub mode: ::c_uint,
- pub __seq: ::c_ushort,
- __pad1: ::c_ushort,
- __unused1: ::c_ulong,
- __unused2: ::c_ulong
- }
-
- pub struct shmid_ds {
- pub shm_perm: ::ipc_perm,
- pub shm_segsz: ::size_t,
- pub shm_atime: ::time_t,
- pub shm_dtime: ::time_t,
- pub shm_ctime: ::time_t,
- pub shm_cpid: ::pid_t,
- pub shm_lpid: ::pid_t,
- pub shm_nattch: ::shmatt_t,
- __unused4: ::c_ulong,
- __unused5: ::c_ulong
- }
-
- pub struct msqid_ds {
- pub msg_perm: ::ipc_perm,
- #[cfg(target_endian = "big")]
- __glibc_reserved1: ::c_ulong,
- pub msg_stime: ::time_t,
- #[cfg(target_endian = "little")]
- __glibc_reserved1: ::c_ulong,
- #[cfg(target_endian = "big")]
- __glibc_reserved2: ::c_ulong,
- pub msg_rtime: ::time_t,
- #[cfg(target_endian = "little")]
- __glibc_reserved2: ::c_ulong,
- #[cfg(target_endian = "big")]
- __glibc_reserved3: ::c_ulong,
- pub msg_ctime: ::time_t,
- #[cfg(target_endian = "little")]
- __glibc_reserved3: ::c_ulong,
- __msg_cbytes: ::c_ulong,
- pub msg_qnum: ::msgqnum_t,
- pub msg_qbytes: ::msglen_t,
- pub msg_lspid: ::pid_t,
- pub msg_lrpid: ::pid_t,
- __glibc_reserved4: ::c_ulong,
- __glibc_reserved5: ::c_ulong,
- }
-
- pub struct statfs {
- pub f_type: ::c_long,
- pub f_bsize: ::c_long,
- pub f_frsize: ::c_long,
- pub f_blocks: ::fsblkcnt_t,
- pub f_bfree: ::fsblkcnt_t,
- pub f_files: ::fsblkcnt_t,
- pub f_ffree: ::fsblkcnt_t,
- pub f_bavail: ::fsblkcnt_t,
- pub f_fsid: ::fsid_t,
-
- pub f_namelen: ::c_long,
- f_spare: [::c_long; 6],
- }
-
- pub struct msghdr {
- pub msg_name: *mut ::c_void,
- pub msg_namelen: ::socklen_t,
- pub msg_iov: *mut ::iovec,
- pub msg_iovlen: ::c_int,
- pub msg_control: *mut ::c_void,
- pub msg_controllen: ::size_t,
- pub msg_flags: ::c_int,
- }
-
- pub struct cmsghdr {
- pub cmsg_len: ::size_t,
- pub cmsg_level: ::c_int,
- pub cmsg_type: ::c_int,
- }
-
- pub struct termios {
- pub c_iflag: ::tcflag_t,
- pub c_oflag: ::tcflag_t,
- pub c_cflag: ::tcflag_t,
- pub c_lflag: ::tcflag_t,
- pub c_line: ::cc_t,
- pub c_cc: [::cc_t; ::NCCS],
- }
-
- pub struct flock {
- pub l_type: ::c_short,
- pub l_whence: ::c_short,
- pub l_start: ::off_t,
- pub l_len: ::off_t,
- pub l_sysid: ::c_long,
- pub l_pid: ::pid_t,
- pad: [::c_long; 4],
- }
-
- pub struct sysinfo {
- pub uptime: ::c_long,
- pub loads: [::c_ulong; 3],
- pub totalram: ::c_ulong,
- pub freeram: ::c_ulong,
- pub sharedram: ::c_ulong,
- pub bufferram: ::c_ulong,
- pub totalswap: ::c_ulong,
- pub freeswap: ::c_ulong,
- pub procs: ::c_ushort,
- pub pad: ::c_ushort,
- pub totalhigh: ::c_ulong,
- pub freehigh: ::c_ulong,
- pub mem_unit: ::c_uint,
- pub _f: [::c_char; 8],
- }
-}
-
-pub const __SIZEOF_PTHREAD_CONDATTR_T: usize = 4;
-pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 24;
-pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 32;
-pub const __SIZEOF_PTHREAD_MUTEXATTR_T: usize = 4;
-
-pub const RLIM_INFINITY: ::rlim_t = 0x7fffffff;
-
-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_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_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_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_symlink: ::c_long = 4000 + 83;
-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_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_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_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 {
- pub fn sysctl(name: *mut ::c_int,
- namelen: ::c_int,
- oldp: *mut ::c_void,
- oldlenp: *mut ::size_t,
- newp: *mut ::c_void,
- newlen: ::size_t)
- -> ::c_int;
- pub fn ioctl(fd: ::c_int, request: ::c_ulong, ...) -> ::c_int;
- pub fn backtrace(buf: *mut *mut ::c_void,
- sz: ::c_int) -> ::c_int;
- pub fn glob64(pattern: *const ::c_char,
- flags: ::c_int,
- errfunc: ::Option<extern fn(epath: *const ::c_char,
- errno: ::c_int)
- -> ::c_int>,
- pglob: *mut glob64_t) -> ::c_int;
- pub fn globfree64(pglob: *mut glob64_t);
- pub fn ptrace(request: ::c_uint, ...) -> ::c_long;
- pub fn pthread_attr_getaffinity_np(attr: *const ::pthread_attr_t,
- cpusetsize: ::size_t,
- cpuset: *mut ::cpu_set_t) -> ::c_int;
- pub fn pthread_attr_setaffinity_np(attr: *mut ::pthread_attr_t,
- cpusetsize: ::size_t,
- cpuset: *const ::cpu_set_t) -> ::c_int;
-}
-
-cfg_if! {
- if #[cfg(libc_align)] {
- mod align;
- pub use self::align::*;
- } else {
- mod no_align;
- pub use self::no_align::*;
- }
-}
diff --git a/libc/src/unix/uclibc/mips/mips32/no_align.rs b/libc/src/unix/uclibc/mips/mips32/no_align.rs
deleted file mode 100644
index e32bf67..0000000
--- a/libc/src/unix/uclibc/mips/mips32/no_align.rs
+++ /dev/null
@@ -1,10 +0,0 @@
-s! {
- // FIXME this is actually a union
- pub struct sem_t {
- #[cfg(target_pointer_width = "32")]
- __size: [::c_char; 16],
- #[cfg(target_pointer_width = "64")]
- __size: [::c_char; 32],
- __align: [::c_long; 0],
- }
-}
diff --git a/libc/src/unix/uclibc/mips/mips64/align.rs b/libc/src/unix/uclibc/mips/mips64/align.rs
deleted file mode 100644
index 21e2190..0000000
--- a/libc/src/unix/uclibc/mips/mips64/align.rs
+++ /dev/null
@@ -1,10 +0,0 @@
-s! {
- // FIXME this is actually a union
- #[cfg_attr(target_pointer_width = "32",
- repr(align(4)))]
- #[cfg_attr(target_pointer_width = "64",
- repr(align(8)))]
- pub struct sem_t {
- __size: [::c_char; 32],
- }
-}
diff --git a/libc/src/unix/uclibc/mips/mips64/mod.rs b/libc/src/unix/uclibc/mips/mips64/mod.rs
deleted file mode 100644
index d80762e..0000000
--- a/libc/src/unix/uclibc/mips/mips64/mod.rs
+++ /dev/null
@@ -1,213 +0,0 @@
-pub type blkcnt_t = i64;
-pub type blksize_t = i64;
-pub type c_char = i8;
-pub type c_long = i64;
-pub type c_ulong = u64;
-pub type fsblkcnt_t = ::c_ulong;
-pub type fsfilcnt_t = ::c_ulong;
-pub type ino_t = u64;
-pub type nlink_t = u64;
-pub type off_t = i64;
-pub type rlim_t = ::c_ulong;
-pub type suseconds_t = i64;
-pub type time_t = i64;
-pub type wchar_t = i32;
-
-s! {
- pub struct stat {
- pub st_dev: ::c_ulong,
- st_pad1: [::c_long; 2],
- 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: ::c_ulong,
- st_pad2: [::c_ulong; 1],
- pub st_size: ::off_t,
- st_pad3: ::c_long,
- 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,
- st_pad4: ::c_long,
- pub st_blocks: ::blkcnt_t,
- st_pad5: [::c_long; 7],
- }
-
- pub struct stat64 {
- pub st_dev: ::c_ulong,
- st_pad1: [::c_long; 2],
- pub st_ino: ::ino64_t,
- pub st_mode: ::mode_t,
- pub st_nlink: ::nlink_t,
- pub st_uid: ::uid_t,
- pub st_gid: ::gid_t,
- pub st_rdev: ::c_ulong,
- st_pad2: [::c_long; 2],
- pub st_size: ::off64_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,
- st_pad3: ::c_long,
- pub st_blocks: ::blkcnt64_t,
- st_pad5: [::c_long; 7],
- }
-
- pub struct pthread_attr_t {
- __size: [::c_ulong; 7]
- }
-
- pub struct sigaction {
- pub sa_flags: ::c_int,
- pub sa_sigaction: ::sighandler_t,
- pub sa_mask: sigset_t,
- _restorer: *mut ::c_void,
- }
-
- pub struct stack_t {
- pub ss_sp: *mut ::c_void,
- pub ss_size: ::size_t,
- pub ss_flags: ::c_int,
- }
-
- pub struct sigset_t {
- __size: [::c_ulong; 16],
- }
-
- pub struct siginfo_t {
- pub si_signo: ::c_int,
- pub si_code: ::c_int,
- pub si_errno: ::c_int,
- _pad: ::c_int,
- _pad2: [::c_long; 14],
- }
-
- pub struct ipc_perm {
- pub __key: ::key_t,
- pub uid: ::uid_t,
- pub gid: ::gid_t,
- pub cuid: ::uid_t,
- pub cgid: ::gid_t,
- pub mode: ::c_uint,
- pub __seq: ::c_ushort,
- __pad1: ::c_ushort,
- __unused1: ::c_ulong,
- __unused2: ::c_ulong
- }
-
- pub struct shmid_ds {
- pub shm_perm: ::ipc_perm,
- pub shm_segsz: ::size_t,
- pub shm_atime: ::time_t,
- pub shm_dtime: ::time_t,
- pub shm_ctime: ::time_t,
- pub shm_cpid: ::pid_t,
- pub shm_lpid: ::pid_t,
- pub shm_nattch: ::shmatt_t,
- __unused4: ::c_ulong,
- __unused5: ::c_ulong
- }
-
- pub struct msqid_ds {
- pub msg_perm: ::ipc_perm,
- pub msg_stime: ::time_t,
- pub msg_rtime: ::time_t,
- 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,
- __glibc_reserved4: ::c_ulong,
- __glibc_reserved5: ::c_ulong,
- }
-
- pub struct statfs {
- pub f_type: ::c_long,
- pub f_bsize: ::c_long,
- pub f_frsize: ::c_long,
- pub f_blocks: ::fsblkcnt_t,
- pub f_bfree: ::fsblkcnt_t,
- pub f_files: ::fsblkcnt_t,
- pub f_ffree: ::fsblkcnt_t,
- pub f_bavail: ::fsblkcnt_t,
- pub f_fsid: ::fsid_t,
-
- pub f_namelen: ::c_long,
- f_spare: [::c_long; 6],
- }
-
- pub struct msghdr {
- pub msg_name: *mut ::c_void,
- pub msg_namelen: ::socklen_t,
- pub msg_iov: *mut ::iovec,
- pub msg_iovlen: ::size_t,
- pub msg_control: *mut ::c_void,
- pub msg_controllen: ::size_t,
- pub msg_flags: ::c_int,
- }
-
- pub struct cmsghdr {
- pub cmsg_len: ::size_t,
- pub cmsg_level: ::c_int,
- pub cmsg_type: ::c_int,
- }
-
- pub struct termios {
- pub c_iflag: ::tcflag_t,
- pub c_oflag: ::tcflag_t,
- pub c_cflag: ::tcflag_t,
- pub c_lflag: ::tcflag_t,
- pub c_line: ::cc_t,
- pub c_cc: [::cc_t; ::NCCS],
- }
-
- pub struct sysinfo {
- pub uptime: ::c_long,
- pub loads: [::c_ulong; 3],
- pub totalram: ::c_ulong,
- pub freeram: ::c_ulong,
- pub sharedram: ::c_ulong,
- pub bufferram: ::c_ulong,
- pub totalswap: ::c_ulong,
- pub freeswap: ::c_ulong,
- pub procs: ::c_ushort,
- pub pad: ::c_ushort,
- pub totalhigh: ::c_ulong,
- pub freehigh: ::c_ulong,
- pub mem_unit: ::c_uint,
- pub _f: [::c_char; 0],
- }
-}
-
-pub const __SIZEOF_PTHREAD_CONDATTR_T: usize = 4;
-pub const __SIZEOF_PTHREAD_MUTEXATTR_T: usize = 4;
-pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 40;
-pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 56;
-
-pub const RLIM_INFINITY: ::rlim_t = 0xffff_ffff_ffff_ffff;
-
-pub const SYS_gettid: ::c_long = 5178; // Valid for n64
-
-#[link(name = "util")]
-extern {
- pub fn ioctl(fd: ::c_int, request: ::c_ulong, ...) -> ::c_int;
-}
-
-cfg_if! {
- if #[cfg(libc_align)] {
- mod align;
- pub use self::align::*;
- } else {
- mod no_align;
- pub use self::no_align::*;
- }
-}
diff --git a/libc/src/unix/uclibc/mips/mips64/no_align.rs b/libc/src/unix/uclibc/mips/mips64/no_align.rs
deleted file mode 100644
index ee57ea8..0000000
--- a/libc/src/unix/uclibc/mips/mips64/no_align.rs
+++ /dev/null
@@ -1,8 +0,0 @@
-s! {
- // FIXME this is actually a union
- pub struct sem_t {
- __size: [::c_char; 32],
- __align: [::c_long; 0],
- }
-}
-
diff --git a/libc/src/unix/uclibc/mips/mod.rs b/libc/src/unix/uclibc/mips/mod.rs
deleted file mode 100644
index fa4b0cb..0000000
--- a/libc/src/unix/uclibc/mips/mod.rs
+++ /dev/null
@@ -1,478 +0,0 @@
-pub type pthread_t = ::c_ulong;
-
-pub const SFD_CLOEXEC: ::c_int = 0x080000;
-
-pub const NCCS: usize = 32;
-
-pub const O_TRUNC: ::c_int = 512;
-
-pub const O_CLOEXEC: ::c_int = 0x80000;
-
-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 EDOTDOT: ::c_int = 73;
-
-pub const SA_NODEFER: ::c_int = 0x40000000;
-pub const SA_RESETHAND: ::c_int = 0x80000000;
-pub const SA_RESTART: ::c_int = 0x10000000;
-pub const SA_NOCLDSTOP: ::c_int = 0x00000001;
-
-pub const EPOLL_CLOEXEC: ::c_int = 0x80000;
-
-pub const EFD_CLOEXEC: ::c_int = 0x80000;
-
-pub const BUFSIZ: ::c_uint = 4096;
-pub const TMP_MAX: ::c_uint = 238328;
-pub const FOPEN_MAX: ::c_uint = 16;
-pub const POSIX_FADV_DONTNEED: ::c_int = 4;
-pub const POSIX_FADV_NOREUSE: ::c_int = 5;
-pub const POSIX_MADV_DONTNEED: ::c_int = 4;
-pub const _SC_2_C_VERSION: ::c_int = 96;
-pub const O_ACCMODE: ::c_int = 3;
-pub const O_DIRECT: ::c_int = 0x8000;
-pub const O_DIRECTORY: ::c_int = 0x10000;
-pub const O_NOFOLLOW: ::c_int = 0x20000;
-pub const ST_RELATIME: ::c_ulong = 4096;
-pub const NI_MAXHOST: ::socklen_t = 1025;
-
-pub const RLIMIT_NOFILE: ::c_int = 5;
-pub const RLIMIT_AS: ::c_int = 6;
-pub const RLIMIT_RSS: ::c_int = 7;
-pub const RLIMIT_NPROC: ::c_int = 8;
-pub const RLIMIT_MEMLOCK: ::c_int = 9;
-pub const RLIMIT_NLIMITS: ::c_int = 15;
-
-pub const O_APPEND: ::c_int = 8;
-pub const O_CREAT: ::c_int = 256;
-pub const O_EXCL: ::c_int = 1024;
-pub const O_NOCTTY: ::c_int = 2048;
-pub const O_NONBLOCK: ::c_int = 128;
-pub const O_SYNC: ::c_int = 0x10;
-pub const O_RSYNC: ::c_int = 0x10;
-pub const O_DSYNC: ::c_int = 0x10;
-pub const O_FSYNC: ::c_int = 0x10;
-pub const O_ASYNC: ::c_int = 0x1000;
-pub const O_NDELAY: ::c_int = 0x80;
-
-pub const SOCK_NONBLOCK: ::c_int = 128;
-
-pub const EDEADLK: ::c_int = 45;
-pub const ENAMETOOLONG: ::c_int = 78;
-pub const ENOLCK: ::c_int = 46;
-pub const ENOSYS: ::c_int = 89;
-pub const ENOTEMPTY: ::c_int = 93;
-pub const ELOOP: ::c_int = 90;
-pub const ENOMSG: ::c_int = 35;
-pub const EIDRM: ::c_int = 36;
-pub const ECHRNG: ::c_int = 37;
-pub const EL2NSYNC: ::c_int = 38;
-pub const EL3HLT: ::c_int = 39;
-pub const EL3RST: ::c_int = 40;
-pub const ELNRNG: ::c_int = 41;
-pub const EUNATCH: ::c_int = 42;
-pub const ENOCSI: ::c_int = 43;
-pub const EL2HLT: ::c_int = 44;
-pub const EBADE: ::c_int = 50;
-pub const EBADR: ::c_int = 51;
-pub const EXFULL: ::c_int = 52;
-pub const ENOANO: ::c_int = 53;
-pub const EBADRQC: ::c_int = 54;
-pub const EBADSLT: ::c_int = 55;
-pub const EDEADLOCK: ::c_int = 56;
-pub const EMULTIHOP: ::c_int = 74;
-pub const EOVERFLOW: ::c_int = 79;
-pub const ENOTUNIQ: ::c_int = 80;
-pub const EBADFD: ::c_int = 81;
-pub const EBADMSG: ::c_int = 77;
-pub const EREMCHG: ::c_int = 82;
-pub const ELIBACC: ::c_int = 83;
-pub const ELIBBAD: ::c_int = 84;
-pub const ELIBSCN: ::c_int = 85;
-pub const ELIBMAX: ::c_int = 86;
-pub const ELIBEXEC: ::c_int = 87;
-pub const EILSEQ: ::c_int = 88;
-pub const ERESTART: ::c_int = 91;
-pub const ESTRPIPE: ::c_int = 92;
-pub const EUSERS: ::c_int = 94;
-pub const ENOTSOCK: ::c_int = 95;
-pub const EDESTADDRREQ: ::c_int = 96;
-pub const EMSGSIZE: ::c_int = 97;
-pub const EPROTOTYPE: ::c_int = 98;
-pub const ENOPROTOOPT: ::c_int = 99;
-pub const EPROTONOSUPPORT: ::c_int = 120;
-pub const ESOCKTNOSUPPORT: ::c_int = 121;
-pub const EOPNOTSUPP: ::c_int = 122;
-pub const ENOTSUP: ::c_int = EOPNOTSUPP;
-pub const EPFNOSUPPORT: ::c_int = 123;
-pub const EAFNOSUPPORT: ::c_int = 124;
-pub const EADDRINUSE: ::c_int = 125;
-pub const EADDRNOTAVAIL: ::c_int = 126;
-pub const ENETDOWN: ::c_int = 127;
-pub const ENETUNREACH: ::c_int = 128;
-pub const ENETRESET: ::c_int = 129;
-pub const ECONNABORTED: ::c_int = 130;
-pub const ECONNRESET: ::c_int = 131;
-pub const ENOBUFS: ::c_int = 132;
-pub const EISCONN: ::c_int = 133;
-pub const ENOTCONN: ::c_int = 134;
-pub const ESHUTDOWN: ::c_int = 143;
-pub const ETOOMANYREFS: ::c_int = 144;
-pub const ETIMEDOUT: ::c_int = 145;
-pub const ECONNREFUSED: ::c_int = 146;
-pub const EHOSTDOWN: ::c_int = 147;
-pub const EHOSTUNREACH: ::c_int = 148;
-pub const EALREADY: ::c_int = 149;
-pub const EINPROGRESS: ::c_int = 150;
-pub const ESTALE: ::c_int = 151;
-pub const EUCLEAN: ::c_int = 135;
-pub const ENOTNAM: ::c_int = 137;
-pub const ENAVAIL: ::c_int = 138;
-pub const EISNAM: ::c_int = 139;
-pub const EREMOTEIO: ::c_int = 140;
-pub const EDQUOT: ::c_int = 1133;
-pub const ENOMEDIUM: ::c_int = 159;
-pub const EMEDIUMTYPE: ::c_int = 160;
-pub const ECANCELED: ::c_int = 158;
-pub const ENOKEY: ::c_int = 161;
-pub const EKEYEXPIRED: ::c_int = 162;
-pub const EKEYREVOKED: ::c_int = 163;
-pub const EKEYREJECTED: ::c_int = 164;
-pub const EOWNERDEAD: ::c_int = 165;
-pub const ENOTRECOVERABLE: ::c_int = 166;
-pub const ERFKILL: ::c_int = 167;
-
-pub const MAP_NORESERVE: ::c_int = 0x400;
-pub const MAP_ANON: ::c_int = 0x800;
-pub const MAP_ANONYMOUS: ::c_int = 0x800;
-pub const MAP_GROWSDOWN: ::c_int = 0x1000;
-pub const MAP_DENYWRITE: ::c_int = 0x2000;
-pub const MAP_EXECUTABLE: ::c_int = 0x4000;
-pub const MAP_LOCKED: ::c_int = 0x8000;
-pub const MAP_POPULATE: ::c_int = 0x10000;
-pub const MAP_NONBLOCK: ::c_int = 0x20000;
-pub const MAP_STACK: ::c_int = 0x40000;
-
-pub const SOCK_STREAM: ::c_int = 2;
-pub const SOCK_DGRAM: ::c_int = 1;
-pub const SOCK_SEQPACKET: ::c_int = 5;
-
-pub const SOL_SOCKET: ::c_int = 0xffff;
-
-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_LINGER: ::c_int = 0x0080;
-pub const SO_OOBINLINE: ::c_int = 0x0100;
-pub const SO_REUSEPORT: ::c_int = 0x0200;
-pub const SO_TYPE: ::c_int = 0x1008;
-pub const SO_STYLE: ::c_int = SO_TYPE;
-pub const SO_ERROR: ::c_int = 0x1007;
-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_ACCEPTCONN: ::c_int = 0x1009;
-pub const SO_PROTOCOL: ::c_int = 0x1028;
-pub const SO_DOMAIN: ::c_int = 0x1029;
-pub const SO_NO_CHECK: ::c_int = 11;
-pub const SO_PRIORITY: ::c_int = 12;
-pub const SO_BSDCOMPAT: ::c_int = 14;
-pub const SO_PASSCRED: ::c_int = 17;
-pub const SO_PEERCRED: ::c_int = 18;
-pub const SO_SECURITY_AUTHENTICATION: ::c_int = 22;
-pub const SO_SECURITY_ENCRYPTION_TRANSPORT: ::c_int = 23;
-pub const SO_SECURITY_ENCRYPTION_NETWORK: ::c_int = 24;
-pub const SO_BINDTODEVICE: ::c_int = 25;
-pub const SO_ATTACH_FILTER: ::c_int = 26;
-pub const SO_DETACH_FILTER: ::c_int = 27;
-pub const SO_GET_FILTER: ::c_int = SO_ATTACH_FILTER;
-pub const SO_PEERNAME: ::c_int = 28;
-pub const SO_TIMESTAMP: ::c_int = 29;
-pub const SCM_TIMESTAMP: ::c_int = SO_TIMESTAMP;
-pub const SO_PEERSEC: ::c_int = 30;
-pub const SO_SNDBUFFORCE: ::c_int = 31;
-pub const SO_RCVBUFFORCE: ::c_int = 33;
-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;
-pub const SO_PEEK_OFF: ::c_int = 42;
-pub const SO_NOFCS: ::c_int = 43;
-pub const SO_LOCK_FILTER: ::c_int = 44;
-pub const SO_SELECT_ERR_QUEUE: ::c_int = 45;
-pub const SO_BUSY_POLL: ::c_int = 46;
-pub const SO_MAX_PACING_RATE: ::c_int = 47;
-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_uint = 0x08000000;
-pub const SA_SIGINFO: ::c_uint = 0x00000008;
-pub const SA_NOCLDWAIT: ::c_int = 0x00010000;
-
-pub const SIGCHLD: ::c_int = 18;
-pub const SIGBUS: ::c_int = 10;
-pub const SIGTTIN: ::c_int = 26;
-pub const SIGTTOU: ::c_int = 27;
-pub const SIGXCPU: ::c_int = 30;
-pub const SIGXFSZ: ::c_int = 31;
-pub const SIGVTALRM: ::c_int = 28;
-pub const SIGPROF: ::c_int = 29;
-pub const SIGWINCH: ::c_int = 20;
-pub const SIGUSR1: ::c_int = 16;
-pub const SIGUSR2: ::c_int = 17;
-pub const SIGCONT: ::c_int = 25;
-pub const SIGSTOP: ::c_int = 23;
-pub const SIGTSTP: ::c_int = 24;
-pub const SIGURG: ::c_int = 21;
-pub const SIGIO: ::c_int = 22;
-pub const SIGSYS: ::c_int = 12;
-pub const SIGPOLL: ::c_int = 22;
-pub const SIGPWR: ::c_int = 19;
-pub const SIG_SETMASK: ::c_int = 3;
-pub const SIG_BLOCK: ::c_int = 0x1;
-pub const SIG_UNBLOCK: ::c_int = 0x2;
-
-pub const POLLRDNORM: ::c_short = 0x040;
-pub const POLLWRNORM: ::c_short = 0x004;
-pub const POLLRDBAND: ::c_short = 0x080;
-pub const POLLWRBAND: ::c_short = 0x100;
-
-pub const PTHREAD_STACK_MIN: ::size_t = 16384;
-
-pub const ADFS_SUPER_MAGIC: ::c_long = 0x0000adf5;
-pub const AFFS_SUPER_MAGIC: ::c_long = 0x0000adff;
-pub const CODA_SUPER_MAGIC: ::c_long = 0x73757245;
-pub const CRAMFS_MAGIC: ::c_long = 0x28cd3d45;
-pub const EFS_SUPER_MAGIC: ::c_long = 0x00414a53;
-pub const EXT2_SUPER_MAGIC: ::c_long = 0x0000ef53;
-pub const EXT3_SUPER_MAGIC: ::c_long = 0x0000ef53;
-pub const EXT4_SUPER_MAGIC: ::c_long = 0x0000ef53;
-pub const HPFS_SUPER_MAGIC: ::c_long = 0xf995e849;
-pub const HUGETLBFS_MAGIC: ::c_long = 0x958458f6;
-pub const ISOFS_SUPER_MAGIC: ::c_long = 0x00009660;
-pub const JFFS2_SUPER_MAGIC: ::c_long = 0x000072b6;
-pub const MINIX_SUPER_MAGIC: ::c_long = 0x0000137f;
-pub const MINIX_SUPER_MAGIC2: ::c_long = 0x0000138f;
-pub const MINIX2_SUPER_MAGIC: ::c_long = 0x00002468;
-pub const MINIX2_SUPER_MAGIC2: ::c_long = 0x00002478;
-pub const MSDOS_SUPER_MAGIC: ::c_long = 0x00004d44;
-pub const NCP_SUPER_MAGIC: ::c_long = 0x0000564c;
-pub const NFS_SUPER_MAGIC: ::c_long = 0x00006969;
-pub const OPENPROM_SUPER_MAGIC: ::c_long = 0x00009fa1;
-pub const PROC_SUPER_MAGIC: ::c_long = 0x00009fa0;
-pub const QNX4_SUPER_MAGIC: ::c_long = 0x0000002f;
-pub const REISERFS_SUPER_MAGIC: ::c_long = 0x52654973;
-pub const SMB_SUPER_MAGIC: ::c_long = 0x0000517b;
-pub const TMPFS_MAGIC: ::c_long = 0x01021994;
-pub const USBDEVICE_SUPER_MAGIC: ::c_long = 0x00009fa2;
-
-pub const VEOF: usize = 16;
-pub const VEOL: usize = 17;
-pub const VEOL2: usize = 6;
-pub const VMIN: usize = 4;
-pub const IEXTEN: ::tcflag_t = 0x00000100;
-pub const TOSTOP: ::tcflag_t = 0x00008000;
-pub const FLUSHO: ::tcflag_t = 0x00002000;
-pub const IUTF8: ::tcflag_t = 0x00004000;
-pub const TCSANOW: ::c_int = 0x540e;
-pub const TCSADRAIN: ::c_int = 0x540f;
-pub const TCSAFLUSH: ::c_int = 0x5410;
-
-pub const CPU_SETSIZE: ::c_int = 0x400;
-
-pub const PTRACE_TRACEME: ::c_uint = 0;
-pub const PTRACE_PEEKTEXT: ::c_uint = 1;
-pub const PTRACE_PEEKDATA: ::c_uint = 2;
-pub const PTRACE_PEEKUSER: ::c_uint = 3;
-pub const PTRACE_POKETEXT: ::c_uint = 4;
-pub const PTRACE_POKEDATA: ::c_uint = 5;
-pub const PTRACE_POKEUSER: ::c_uint = 6;
-pub const PTRACE_CONT: ::c_uint = 7;
-pub const PTRACE_KILL: ::c_uint = 8;
-pub const PTRACE_SINGLESTEP: ::c_uint = 9;
-pub const PTRACE_ATTACH: ::c_uint = 16;
-pub const PTRACE_DETACH: ::c_uint = 17;
-pub const PTRACE_SYSCALL: ::c_uint = 24;
-pub const PTRACE_SETOPTIONS: ::c_uint = 0x4200;
-pub const PTRACE_GETEVENTMSG: ::c_uint = 0x4201;
-pub const PTRACE_GETSIGINFO: ::c_uint = 0x4202;
-pub const PTRACE_SETSIGINFO: ::c_uint = 0x4203;
-pub const PTRACE_GETFPREGS: ::c_uint = 14;
-pub const PTRACE_SETFPREGS: ::c_uint = 15;
-pub const PTRACE_GETFPXREGS: ::c_uint = 18;
-pub const PTRACE_SETFPXREGS: ::c_uint = 19;
-pub const PTRACE_GETREGS: ::c_uint = 12;
-pub const PTRACE_SETREGS: ::c_uint = 13;
-
-pub const EFD_NONBLOCK: ::c_int = 0x80;
-
-pub const F_GETLK: ::c_int = 14;
-pub const F_GETOWN: ::c_int = 23;
-pub const F_SETOWN: ::c_int = 24;
-pub const F_SETLK: ::c_int = 6;
-pub const F_SETLKW: ::c_int = 7;
-
-pub const SFD_NONBLOCK: ::c_int = 0x80;
-
-pub const TCGETS: ::c_ulong = 0x540d;
-pub const TCSETS: ::c_ulong = 0x540e;
-pub const TCSETSW: ::c_ulong = 0x540f;
-pub const TCSETSF: ::c_ulong = 0x5410;
-pub const TCGETA: ::c_ulong = 0x5401;
-pub const TCSETA: ::c_ulong = 0x5402;
-pub const TCSETAW: ::c_ulong = 0x5403;
-pub const TCSETAF: ::c_ulong = 0x5404;
-pub const TCSBRK: ::c_ulong = 0x5405;
-pub const TCXONC: ::c_ulong = 0x5406;
-pub const TCFLSH: ::c_ulong = 0x5407;
-pub const TIOCGSOFTCAR: ::c_ulong = 0x5481;
-pub const TIOCSSOFTCAR: ::c_ulong = 0x5482;
-pub const TIOCINQ: ::c_ulong = 0x467f;
-pub const TIOCLINUX: ::c_ulong = 0x5483;
-pub const TIOCGSERIAL: ::c_ulong = 0x5484;
-pub const TIOCEXCL: ::c_ulong = 0x740d;
-pub const TIOCNXCL: ::c_ulong = 0x740e;
-pub const TIOCSCTTY: ::c_ulong = 0x5480;
-pub const TIOCGPGRP: ::c_ulong = 0x40047477;
-pub const TIOCSPGRP: ::c_ulong = 0x80047476;
-pub const TIOCOUTQ: ::c_ulong = 0x7472;
-pub const TIOCSTI: ::c_ulong = 0x5472;
-pub const TIOCGWINSZ: ::c_ulong = 0x40087468;
-pub const TIOCSWINSZ: ::c_ulong = 0x80087467;
-pub const TIOCMGET: ::c_ulong = 0x741d;
-pub const TIOCMBIS: ::c_ulong = 0x741b;
-pub const TIOCMBIC: ::c_ulong = 0x741c;
-pub const TIOCMSET: ::c_ulong = 0x741a;
-pub const FIONREAD: ::c_ulong = 0x467f;
-pub const TIOCCONS: ::c_ulong = 0x80047478;
-
-pub const RTLD_DEEPBIND: ::c_int = 0x10;
-pub const RTLD_GLOBAL: ::c_int = 0x4;
-pub const RTLD_NOLOAD: ::c_int = 0x8;
-
-pub const LINUX_REBOOT_MAGIC1: ::c_int = 0xfee1dead;
-pub const LINUX_REBOOT_MAGIC2: ::c_int = 672274793;
-pub const LINUX_REBOOT_MAGIC2A: ::c_int = 85072278;
-pub const LINUX_REBOOT_MAGIC2B: ::c_int = 369367448;
-pub const LINUX_REBOOT_MAGIC2C: ::c_int = 537993216;
-
-pub const LINUX_REBOOT_CMD_RESTART: ::c_int = 0x01234567;
-pub const LINUX_REBOOT_CMD_HALT: ::c_int = 0xCDEF0123;
-pub const LINUX_REBOOT_CMD_CAD_ON: ::c_int = 0x89ABCDEF;
-pub const LINUX_REBOOT_CMD_CAD_OFF: ::c_int = 0x00000000;
-pub const LINUX_REBOOT_CMD_POWER_OFF: ::c_int = 0x4321FEDC;
-pub const LINUX_REBOOT_CMD_RESTART2: ::c_int = 0xA1B2C3D4;
-pub const LINUX_REBOOT_CMD_SW_SUSPEND: ::c_int = 0xD000FCE2;
-pub const LINUX_REBOOT_CMD_KEXEC: ::c_int = 0x45584543;
-
-pub const MCL_CURRENT: ::c_int = 0x0001;
-pub const MCL_FUTURE: ::c_int = 0x0002;
-
-pub const SIGSTKSZ: ::size_t = 8192;
-pub const CBAUD: ::tcflag_t = 0o0010017;
-pub const TAB1: ::tcflag_t = 0x00000800;
-pub const TAB2: ::tcflag_t = 0x00001000;
-pub const TAB3: ::tcflag_t = 0x00001800;
-pub const CR1: ::tcflag_t = 0x00000200;
-pub const CR2: ::tcflag_t = 0x00000400;
-pub const CR3: ::tcflag_t = 0x00000600;
-pub const FF1: ::tcflag_t = 0x00008000;
-pub const BS1: ::tcflag_t = 0x00002000;
-pub const VT1: ::tcflag_t = 0x00004000;
-pub const VWERASE: usize = 14;
-pub const VREPRINT: usize = 12;
-pub const VSUSP: usize = 10;
-pub const VSTART: usize = 8;
-pub const VSTOP: usize = 9;
-pub const VDISCARD: usize = 13;
-pub const VTIME: usize = 5;
-pub const IXON: ::tcflag_t = 0x00000400;
-pub const IXOFF: ::tcflag_t = 0x00001000;
-pub const ONLCR: ::tcflag_t = 0x4;
-pub const CSIZE: ::tcflag_t = 0x00000030;
-pub const CS6: ::tcflag_t = 0x00000010;
-pub const CS7: ::tcflag_t = 0x00000020;
-pub const CS8: ::tcflag_t = 0x00000030;
-pub const CSTOPB: ::tcflag_t = 0x00000040;
-pub const CREAD: ::tcflag_t = 0x00000080;
-pub const PARENB: ::tcflag_t = 0x00000100;
-pub const PARODD: ::tcflag_t = 0x00000200;
-pub const HUPCL: ::tcflag_t = 0x00000400;
-pub const CLOCAL: ::tcflag_t = 0x00000800;
-pub const ECHOKE: ::tcflag_t = 0x00000800;
-pub const ECHOE: ::tcflag_t = 0x00000010;
-pub const ECHOK: ::tcflag_t = 0x00000020;
-pub const ECHONL: ::tcflag_t = 0x00000040;
-pub const ECHOPRT: ::tcflag_t = 0x00000400;
-pub const ECHOCTL: ::tcflag_t = 0x00000200;
-pub const ISIG: ::tcflag_t = 0x00000001;
-pub const ICANON: ::tcflag_t = 0x00000002;
-pub const PENDIN: ::tcflag_t = 0x00004000;
-pub const NOFLSH: ::tcflag_t = 0x00000080;
-
-pub const B0: ::speed_t = 0o000000;
-pub const B50: ::speed_t = 0o000001;
-pub const B75: ::speed_t = 0o000002;
-pub const B110: ::speed_t = 0o000003;
-pub const B134: ::speed_t = 0o000004;
-pub const B150: ::speed_t = 0o000005;
-pub const B200: ::speed_t = 0o000006;
-pub const B300: ::speed_t = 0o000007;
-pub const B600: ::speed_t = 0o000010;
-pub const B1200: ::speed_t = 0o000011;
-pub const B1800: ::speed_t = 0o000012;
-pub const B2400: ::speed_t = 0o000013;
-pub const B4800: ::speed_t = 0o000014;
-pub const B9600: ::speed_t = 0o000015;
-pub const B19200: ::speed_t = 0o000016;
-pub const B38400: ::speed_t = 0o000017;
-pub const EXTA: ::speed_t = B19200;
-pub const EXTB: ::speed_t = B38400;
-pub const B57600: ::speed_t = 0o010001;
-pub const B115200: ::speed_t = 0o010002;
-pub const B230400: ::speed_t = 0o010003;
-pub const B460800: ::speed_t = 0o010004;
-pub const B500000: ::speed_t = 0o010005;
-pub const B576000: ::speed_t = 0o010006;
-pub const B921600: ::speed_t = 0o010007;
-pub const B1000000: ::speed_t = 0o010010;
-pub const B1152000: ::speed_t = 0o010011;
-pub const B1500000: ::speed_t = 0o010012;
-pub const B2000000: ::speed_t = 0o010013;
-pub const B2500000: ::speed_t = 0o010014;
-pub const B3000000: ::speed_t = 0o010015;
-pub const B3500000: ::speed_t = 0o010016;
-pub const B4000000: ::speed_t = 0o010017;
-
-cfg_if! {
- if #[cfg(target_arch = "mips")] {
- mod mips32;
- pub use self::mips32::*;
- } else if #[cfg(target_arch = "mips64")] {
- mod mips64;
- pub use self::mips64::*;
- } else {
- // Unknown target_arch
- }
-}
diff --git a/libc/src/unix/uclibc/mod.rs b/libc/src/unix/uclibc/mod.rs
deleted file mode 100644
index 568e0bc..0000000
--- a/libc/src/unix/uclibc/mod.rs
+++ /dev/null
@@ -1,1997 +0,0 @@
-pub type sa_family_t = u16;
-pub type pthread_key_t = ::c_uint;
-pub type speed_t = ::c_uint;
-pub type tcflag_t = ::c_uint;
-pub type loff_t = ::c_longlong;
-pub type clockid_t = ::c_int;
-pub type key_t = ::c_int;
-pub type id_t = ::c_uint;
-pub type useconds_t = u32;
-pub type dev_t = u64;
-pub type socklen_t = u32;
-pub type mode_t = u32;
-pub type ino64_t = u64;
-pub type off64_t = i64;
-pub type blkcnt64_t = i64;
-pub type rlim64_t = u64;
-pub type shmatt_t = ::c_ulong;
-pub type mqd_t = ::c_int;
-pub type msgqnum_t = ::c_ulong;
-pub type msglen_t = ::c_ulong;
-pub type nfds_t = ::c_ulong;
-pub type nl_item = ::c_int;
-pub type idtype_t = ::c_uint;
-
-#[cfg_attr(feature = "extra_traits", derive(Debug))]
-pub enum fpos64_t {} // TODO: fill this out with a struct
-impl ::Copy for fpos64_t {}
-impl ::Clone for fpos64_t {
- fn clone(&self) -> fpos64_t { *self }
-}
-
-#[cfg_attr(feature = "extra_traits", derive(Debug))]
-pub enum timezone {}
-impl ::Copy for timezone {}
-impl ::Clone for timezone {
- fn clone(&self) -> timezone { *self }
-}
-
-s! {
- pub struct in_addr {
- pub s_addr: ::in_addr_t,
- }
-
- pub struct ip_mreq {
- pub imr_multiaddr: in_addr,
- pub imr_interface: in_addr,
- }
-
- pub struct sockaddr {
- pub sa_family: sa_family_t,
- pub sa_data: [::c_char; 14],
- }
-
- pub struct sockaddr_in {
- pub sin_family: sa_family_t,
- pub sin_port: ::in_port_t,
- pub sin_addr: ::in_addr,
- pub sin_zero: [u8; 8],
- }
-
- pub struct sockaddr_in6 {
- 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 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 sockaddr_ll {
- pub sll_family: ::c_ushort,
- pub sll_protocol: ::c_ushort,
- pub sll_ifindex: ::c_int,
- pub sll_hatype: ::c_ushort,
- pub sll_pkttype: ::c_uchar,
- pub sll_halen: ::c_uchar,
- pub sll_addr: [::c_uchar; 8]
- }
-
- pub struct fd_set {
- fds_bits: [::c_ulong; FD_SETSIZE / ULONG_SIZE],
- }
-
- 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 tm_gmtoff: ::c_long,
- pub tm_zone: *const ::c_char,
- }
-
- pub struct sched_param {
- pub sched_priority: ::c_int,
- }
-
- pub struct Dl_info {
- pub dli_fname: *const ::c_char,
- pub dli_fbase: *mut ::c_void,
- pub dli_sname: *const ::c_char,
- pub dli_saddr: *mut ::c_void,
- }
-
- 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 sigevent {
- 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 struct rlimit64 {
- pub rlim_cur: rlim64_t,
- pub rlim_max: rlim64_t,
- }
-
- pub struct glob_t {
- pub gl_pathc: ::size_t,
- pub gl_pathv: *mut *mut c_char,
- pub gl_offs: ::size_t,
- pub gl_flags: ::c_int,
-
- __unused1: *mut ::c_void,
- __unused2: *mut ::c_void,
- __unused3: *mut ::c_void,
- __unused4: *mut ::c_void,
- __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
- }
-
- pub struct pthread_rwlockattr_t {
- __lockkind: ::c_int,
- __pshared: ::c_int,
- }
-
- pub struct passwd {
- 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 spwd {
- pub sp_namp: *mut ::c_char,
- pub sp_pwdp: *mut ::c_char,
- pub sp_lstchg: ::c_long,
- pub sp_min: ::c_long,
- pub sp_max: ::c_long,
- pub sp_warn: ::c_long,
- pub sp_inact: ::c_long,
- pub sp_expire: ::c_long,
- 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(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 dqblk {
- pub dqb_bhardlimit: u32,
- pub dqb_bsoftlimit: u32,
- pub dqb_curblocks: u32,
- pub dqb_ihardlimit: u32,
- pub dqb_isoftlimit: u32,
- pub dqb_curinodes: u32,
- pub dqb_btime: ::time_t,
- pub dqb_itime: ::time_t,
- }
-
- pub struct signalfd_siginfo {
- pub ssi_signo: u32,
- pub ssi_errno: i32,
- pub ssi_code: i32,
- pub ssi_pid: u32,
- pub ssi_uid: u32,
- pub ssi_fd: i32,
- pub ssi_tid: u32,
- pub ssi_band: u32,
- pub ssi_overrun: u32,
- pub ssi_trapno: u32,
- pub ssi_status: i32,
- pub ssi_int: i32,
- pub ssi_ptr: u64,
- pub ssi_utime: u64,
- pub ssi_stime: u64,
- pub ssi_addr: u64,
- pub ssi_addr_lsb: u16,
- _pad2: u16,
- pub ssi_syscall: i32,
- pub ssi_call_addr: u64,
- pub ssi_arch: u32,
- _pad: [u8; 28],
- }
-
- pub struct fsid_t {
- __val: [::c_int; 2],
- }
-
- pub struct cpu_set_t {
- #[cfg(target_pointer_width = "32")]
- bits: [u32; 32],
- #[cfg(target_pointer_width = "64")]
- bits: [u64; 16],
- }
-
- pub struct if_nameindex {
- pub if_index: ::c_uint,
- pub if_name: *mut ::c_char,
- }
-
- // System V IPC
- pub struct msginfo {
- pub msgpool: ::c_int,
- pub msgmap: ::c_int,
- pub msgmax: ::c_int,
- pub msgmnb: ::c_int,
- pub msgmni: ::c_int,
- pub msgssz: ::c_int,
- pub msgtql: ::c_int,
- pub msgseg: ::c_ushort,
- }
-}
-
-s_no_extra_traits! {
- #[cfg_attr(
- any(target_arch = "x86", target_arch = "x86_64"),
- repr(packed)
- )]
- #[allow(missing_debug_implementations)]
- pub struct epoll_event {
- pub events: u32,
- pub u64: u64,
- }
-
- #[allow(missing_debug_implementations)]
- pub struct sockaddr_un {
- pub sun_family: sa_family_t,
- pub sun_path: [::c_char; 108]
- }
-
- #[allow(missing_debug_implementations)]
- pub struct sockaddr_storage {
- pub ss_family: sa_family_t,
- __ss_align: ::size_t,
- #[cfg(target_pointer_width = "32")]
- __ss_pad2: [u8; 128 - 2 * 4],
- #[cfg(target_pointer_width = "64")]
- __ss_pad2: [u8; 128 - 2 * 8],
- }
-
- #[allow(missing_debug_implementations)]
- pub struct utsname {
- pub sysname: [::c_char; 65],
- pub nodename: [::c_char; 65],
- pub release: [::c_char; 65],
- pub version: [::c_char; 65],
- pub machine: [::c_char; 65],
- pub domainname: [::c_char; 65]
- }
-
- #[allow(missing_debug_implementations)]
- pub struct dirent {
- pub d_ino: ::ino_t,
- pub d_off: ::off_t,
- pub d_reclen: ::c_ushort,
- pub d_type: ::c_uchar,
- pub d_name: [::c_char; 256],
- }
-
- #[allow(missing_debug_implementations)]
- pub struct dirent64 {
- pub d_ino: ::ino64_t,
- pub d_off: ::off64_t,
- pub d_reclen: ::c_ushort,
- pub d_type: ::c_uchar,
- pub d_name: [::c_char; 256],
- }
-
- pub struct mq_attr {
- pub mq_flags: ::c_long,
- pub mq_maxmsg: ::c_long,
- pub mq_msgsize: ::c_long,
- pub mq_curmsgs: ::c_long,
- pad: [::c_long; 4]
- }
-
- pub struct sockaddr_nl {
- pub nl_family: ::sa_family_t,
- nl_pad: ::c_ushort,
- pub nl_pid: u32,
- pub nl_groups: u32
- }
-}
-
-cfg_if! {
- if #[cfg(feature = "extra_traits")] {
- impl PartialEq for mq_attr {
- fn eq(&self, other: &mq_attr) -> bool {
- self.mq_flags == other.mq_flags &&
- self.mq_maxmsg == other.mq_maxmsg &&
- self.mq_msgsize == other.mq_msgsize &&
- self.mq_curmsgs == other.mq_curmsgs
- }
- }
- impl Eq for mq_attr {}
- impl ::fmt::Debug for mq_attr {
- fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
- f.debug_struct("mq_attr")
- .field("mq_flags", &self.mq_flags)
- .field("mq_maxmsg", &self.mq_maxmsg)
- .field("mq_msgsize", &self.mq_msgsize)
- .field("mq_curmsgs", &self.mq_curmsgs)
- .finish()
- }
- }
- impl ::hash::Hash for mq_attr {
- fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
- self.mq_flags.hash(state);
- self.mq_maxmsg.hash(state);
- self.mq_msgsize.hash(state);
- self.mq_curmsgs.hash(state);
- }
- }
-
- impl PartialEq for sockaddr_nl {
- fn eq(&self, other: &sockaddr_nl) -> bool {
- self.nl_family == other.nl_family &&
- self.nl_pid == other.nl_pid &&
- self.nl_groups == other.nl_groups
- }
- }
- impl Eq for sockaddr_nl {}
- impl ::fmt::Debug for sockaddr_nl {
- fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
- f.debug_struct("sockaddr_nl")
- .field("nl_family", &self.nl_family)
- .field("nl_pid", &self.nl_pid)
- .field("nl_groups", &self.nl_groups)
- .finish()
- }
- }
- impl ::hash::Hash for sockaddr_nl {
- fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
- self.nl_family.hash(state);
- self.nl_pid.hash(state);
- self.nl_groups.hash(state);
- }
- }
- }
-}
-
-// intentionally not public, only used for fd_set
-cfg_if! {
- if #[cfg(target_pointer_width = "32")] {
- const ULONG_SIZE: usize = 32;
- } else if #[cfg(target_pointer_width = "64")] {
- const ULONG_SIZE: usize = 64;
- } else {
- // Unknown target_pointer_width
- }
-}
-
-pub const EXIT_FAILURE: ::c_int = 1;
-pub const EXIT_SUCCESS: ::c_int = 0;
-pub const RAND_MAX: ::c_int = 2147483647;
-pub const EOF: ::c_int = -1;
-pub const SEEK_SET: ::c_int = 0;
-pub const SEEK_CUR: ::c_int = 1;
-pub const SEEK_END: ::c_int = 2;
-pub const _IOFBF: ::c_int = 0;
-pub const _IONBF: ::c_int = 2;
-pub const _IOLBF: ::c_int = 1;
-
-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;
-
-// Linux-specific fcntls
-pub const F_SETLEASE: ::c_int = 1024;
-pub const F_GETLEASE: ::c_int = 1025;
-pub const F_NOTIFY: ::c_int = 1026;
-pub const F_DUPFD_CLOEXEC: ::c_int = 1030;
-
-// TODO(#235): Include file sealing fcntls once we have a way to verify them.
-
-pub const SIGTRAP: ::c_int = 5;
-
-pub const PTHREAD_CREATE_JOINABLE: ::c_int = 0;
-pub const PTHREAD_CREATE_DETACHED: ::c_int = 1;
-
-pub const CLOCK_REALTIME: ::clockid_t = 0;
-pub const CLOCK_MONOTONIC: ::clockid_t = 1;
-pub const CLOCK_PROCESS_CPUTIME_ID: ::clockid_t = 2;
-pub const CLOCK_THREAD_CPUTIME_ID: ::clockid_t = 3;
-// TODO(#247) Someday our Travis shall have glibc 2.21 (released in Sep
-// 2014.) See also musl/mod.rs
-// pub const CLOCK_SGI_CYCLE: ::clockid_t = 10;
-// pub const CLOCK_TAI: ::clockid_t = 11;
-pub const TIMER_ABSTIME: ::c_int = 1;
-
-pub const RLIMIT_CPU: ::c_int = 0;
-pub const RLIMIT_FSIZE: ::c_int = 1;
-pub const RLIMIT_DATA: ::c_int = 2;
-pub const RLIMIT_STACK: ::c_int = 3;
-pub const RLIMIT_CORE: ::c_int = 4;
-pub const RLIMIT_LOCKS: ::c_int = 10;
-pub const RLIMIT_SIGPENDING: ::c_int = 11;
-pub const RLIMIT_MSGQUEUE: ::c_int = 12;
-pub const RLIMIT_NICE: ::c_int = 13;
-pub const RLIMIT_RTPRIO: ::c_int = 14;
-
-pub const RUSAGE_SELF: ::c_int = 0;
-
-pub const O_RDONLY: ::c_int = 0;
-pub const O_WRONLY: ::c_int = 1;
-pub const O_RDWR: ::c_int = 2;
-
-pub const SOCK_CLOEXEC: ::c_int = O_CLOEXEC;
-
-pub const S_IFIFO: ::mode_t = 4096;
-pub const S_IFCHR: ::mode_t = 8192;
-pub const S_IFBLK: ::mode_t = 24576;
-pub const S_IFDIR: ::mode_t = 16384;
-pub const S_IFREG: ::mode_t = 32768;
-pub const S_IFLNK: ::mode_t = 40960;
-pub const S_IFSOCK: ::mode_t = 49152;
-pub const S_IFMT: ::mode_t = 61440;
-pub const S_IRWXU: ::mode_t = 448;
-pub const S_IXUSR: ::mode_t = 64;
-pub const S_IWUSR: ::mode_t = 128;
-pub const S_IRUSR: ::mode_t = 256;
-pub const S_IRWXG: ::mode_t = 56;
-pub const S_IXGRP: ::mode_t = 8;
-pub const S_IWGRP: ::mode_t = 16;
-pub const S_IRGRP: ::mode_t = 32;
-pub const S_IRWXO: ::mode_t = 7;
-pub const S_IXOTH: ::mode_t = 1;
-pub const S_IWOTH: ::mode_t = 2;
-pub const S_IROTH: ::mode_t = 4;
-pub const F_OK: ::c_int = 0;
-pub const R_OK: ::c_int = 4;
-pub const W_OK: ::c_int = 2;
-pub const X_OK: ::c_int = 1;
-pub const STDIN_FILENO: ::c_int = 0;
-pub const STDOUT_FILENO: ::c_int = 1;
-pub const STDERR_FILENO: ::c_int = 2;
-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 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 PROT_NONE: ::c_int = 0;
-pub const PROT_READ: ::c_int = 1;
-pub const PROT_WRITE: ::c_int = 2;
-pub const PROT_EXEC: ::c_int = 4;
-
-pub const LC_CTYPE: ::c_int = 0;
-pub const LC_NUMERIC: ::c_int = 1;
-pub const LC_MONETARY: ::c_int = 2;
-pub const LC_TIME: ::c_int = 3;
-pub const LC_COLLATE: ::c_int = 4;
-pub const LC_MESSAGES: ::c_int = 5;
-pub const LC_ALL: ::c_int = 6;
-pub const LC_CTYPE_MASK: ::c_int = (1 << LC_CTYPE);
-pub const LC_NUMERIC_MASK: ::c_int = (1 << LC_NUMERIC);
-pub const LC_TIME_MASK: ::c_int = (1 << LC_TIME);
-pub const LC_COLLATE_MASK: ::c_int = (1 << LC_COLLATE);
-pub const LC_MONETARY_MASK: ::c_int = (1 << LC_MONETARY);
-pub const LC_MESSAGES_MASK: ::c_int = (1 << LC_MESSAGES);
-// LC_ALL_MASK defined per platform
-
-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_FAILED: *mut ::c_void = !0 as *mut ::c_void;
-
-// MS_ flags for msync(2)
-pub const MS_ASYNC: ::c_int = 0x0001;
-pub const MS_INVALIDATE: ::c_int = 0x0002;
-pub const MS_SYNC: ::c_int = 0x0004;
-
-// MS_ flags for mount(2)
-pub const MS_RDONLY: ::c_ulong = 0x01;
-pub const MS_NOSUID: ::c_ulong = 0x02;
-pub const MS_NODEV: ::c_ulong = 0x04;
-pub const MS_NOEXEC: ::c_ulong = 0x08;
-pub const MS_SYNCHRONOUS: ::c_ulong = 0x10;
-pub const MS_REMOUNT: ::c_ulong = 0x20;
-pub const MS_MANDLOCK: ::c_ulong = 0x40;
-pub const MS_NOATIME: ::c_ulong = 0x0400;
-pub const MS_NODIRATIME: ::c_ulong = 0x0800;
-pub const MS_BIND: ::c_ulong = 0x1000;
-pub const MS_NOUSER: ::c_ulong = 0x80000000;
-pub const MS_MGC_VAL: ::c_ulong = 0xc0ed0000;
-pub const MS_MGC_MSK: ::c_ulong = 0xffff0000;
-pub const MS_RMT_MASK: ::c_ulong = 0x800051;
-
-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 ENOTBLK: ::c_int = 15;
-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 EWOULDBLOCK: ::c_int = EAGAIN;
-
-pub const SCM_RIGHTS: ::c_int = 0x01;
-pub const SCM_CREDENTIALS: ::c_int = 0x02;
-
-// netinet/in.h
-// NOTE: These are in addition to the constants defined in src/unix/mod.rs
-
-// IPPROTO_IP defined in src/unix/mod.rs
-/// Hop-by-hop option header
-pub const IPPROTO_HOPOPTS: ::c_int = 0;
-// IPPROTO_ICMP defined in src/unix/mod.rs
-/// group mgmt protocol
-pub const IPPROTO_IGMP: ::c_int = 2;
-/// for compatibility
-pub const IPPROTO_IPIP: ::c_int = 4;
-// IPPROTO_TCP defined in src/unix/mod.rs
-/// exterior gateway protocol
-pub const IPPROTO_EGP: ::c_int = 8;
-/// pup
-pub const IPPROTO_PUP: ::c_int = 12;
-// IPPROTO_UDP defined in src/unix/mod.rs
-/// xns idp
-pub const IPPROTO_IDP: ::c_int = 22;
-/// tp-4 w/ class negotiation
-pub const IPPROTO_TP: ::c_int = 29;
-/// DCCP
-pub const IPPROTO_DCCP: ::c_int = 33;
-// IPPROTO_IPV6 defined in src/unix/mod.rs
-/// IP6 routing header
-pub const IPPROTO_ROUTING: ::c_int = 43;
-/// IP6 fragmentation header
-pub const IPPROTO_FRAGMENT: ::c_int = 44;
-/// resource reservation
-pub const IPPROTO_RSVP: ::c_int = 46;
-/// General Routing Encap.
-pub const IPPROTO_GRE: ::c_int = 47;
-/// IP6 Encap Sec. Payload
-pub const IPPROTO_ESP: ::c_int = 50;
-/// IP6 Auth Header
-pub const IPPROTO_AH: ::c_int = 51;
-// IPPROTO_ICMPV6 defined in src/unix/mod.rs
-/// IP6 no next header
-pub const IPPROTO_NONE: ::c_int = 59;
-/// IP6 destination option
-pub const IPPROTO_DSTOPTS: ::c_int = 60;
-pub const IPPROTO_MTP: ::c_int = 92;
-pub const IPPROTO_BEETPH: ::c_int = 94;
-/// encapsulation header
-pub const IPPROTO_ENCAP: ::c_int = 98;
-/// Protocol indep. multicast
-pub const IPPROTO_PIM: ::c_int = 103;
-/// IP Payload Comp. Protocol
-pub const IPPROTO_COMP: ::c_int = 108;
-/// SCTP
-pub const IPPROTO_SCTP: ::c_int = 132;
-pub const IPPROTO_MH: ::c_int = 135;
-pub const IPPROTO_UDPLITE: ::c_int = 136;
-pub const IPPROTO_MPLS: ::c_int = 137;
-/// raw IP packet
-pub const IPPROTO_RAW: ::c_int = 255;
-pub const IPPROTO_MAX: ::c_int = 256;
-
-pub const PROT_GROWSDOWN: ::c_int = 0x1000000;
-pub const PROT_GROWSUP: ::c_int = 0x2000000;
-
-pub const MAP_TYPE: ::c_int = 0x000f;
-
-pub const MADV_NORMAL: ::c_int = 0;
-pub const MADV_RANDOM: ::c_int = 1;
-pub const MADV_SEQUENTIAL: ::c_int = 2;
-pub const MADV_WILLNEED: ::c_int = 3;
-pub const MADV_DONTNEED: ::c_int = 4;
-pub const MADV_REMOVE: ::c_int = 9;
-pub const MADV_DONTFORK: ::c_int = 10;
-pub const MADV_DOFORK: ::c_int = 11;
-pub const MADV_MERGEABLE: ::c_int = 12;
-pub const MADV_UNMERGEABLE: ::c_int = 13;
-pub const MADV_HWPOISON: ::c_int = 100;
-
-// https://github.com/kraj/uClibc/blob/master/include/net/if.h#L44
-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.
-// Not supported
-pub const IFF_ALLMULTI: ::c_int = 0x200; // Receive all multicast packets.
-pub const IFF_MASTER: ::c_int = 0x400; // Master of a load balancer.
-pub const IFF_SLAVE: ::c_int = 0x800; // Slave of a load balancer.
-pub const IFF_MULTICAST: ::c_int = 0x1000; // Supports multicast.
-pub const IFF_PORTSEL: ::c_int = 0x2000; // Can set media type.
-pub const IFF_AUTOMEDIA: ::c_int = 0x4000; // Auto media select active.
-// Dialup device with changing addresses.
-pub const IFF_DYNAMIC: ::c_int = 0x8000;
-
-pub const SOL_IP: ::c_int = 0;
-pub const SOL_TCP: ::c_int = 6;
-pub const SOL_IPV6: ::c_int = 41;
-pub const SOL_ICMPV6: ::c_int = 58;
-pub const SOL_RAW: ::c_int = 255;
-pub const SOL_DECNET: ::c_int = 261;
-pub const SOL_X25: ::c_int = 262;
-pub const SOL_PACKET: ::c_int = 263;
-pub const SOL_ATM: ::c_int = 264;
-pub const SOL_AAL: ::c_int = 265;
-pub const SOL_IRDA: ::c_int = 266;
-
-pub const AF_UNSPEC: ::c_int = 0;
-pub const AF_UNIX: ::c_int = 1;
-pub const AF_LOCAL: ::c_int = 1;
-pub const AF_INET: ::c_int = 2;
-pub const AF_AX25: ::c_int = 3;
-pub const AF_IPX: ::c_int = 4;
-pub const AF_APPLETALK: ::c_int = 5;
-pub const AF_NETROM: ::c_int = 6;
-pub const AF_BRIDGE: ::c_int = 7;
-pub const AF_ATMPVC: ::c_int = 8;
-pub const AF_X25: ::c_int = 9;
-pub const AF_INET6: ::c_int = 10;
-pub const AF_ROSE: ::c_int = 11;
-pub const AF_DECnet: ::c_int = 12;
-pub const AF_NETBEUI: ::c_int = 13;
-pub const AF_SECURITY: ::c_int = 14;
-pub const AF_KEY: ::c_int = 15;
-pub const AF_NETLINK: ::c_int = 16;
-pub const AF_ROUTE: ::c_int = AF_NETLINK;
-pub const AF_PACKET: ::c_int = 17;
-pub const AF_ASH: ::c_int = 18;
-pub const AF_ECONET: ::c_int = 19;
-pub const AF_ATMSVC: ::c_int = 20;
-pub const AF_SNA: ::c_int = 22;
-pub const AF_IRDA: ::c_int = 23;
-pub const AF_PPPOX: ::c_int = 24;
-pub const AF_WANPIPE: ::c_int = 25;
-pub const AF_LLC: ::c_int = 26;
-pub const AF_CAN: ::c_int = 29;
-pub const AF_TIPC: ::c_int = 30;
-pub const AF_BLUETOOTH: ::c_int = 31;
-pub const AF_IUCV: ::c_int = 32;
-pub const AF_RXRPC: ::c_int = 33;
-pub const AF_ISDN: ::c_int = 34;
-pub const AF_PHONET: ::c_int = 35;
-pub const AF_IEEE802154: ::c_int = 36;
-pub const AF_CAIF: ::c_int = 37;
-pub const AF_ALG: ::c_int = 38;
-
-pub const PF_UNSPEC: ::c_int = AF_UNSPEC;
-pub const PF_UNIX: ::c_int = AF_UNIX;
-pub const PF_LOCAL: ::c_int = AF_LOCAL;
-pub const PF_INET: ::c_int = AF_INET;
-pub const PF_AX25: ::c_int = AF_AX25;
-pub const PF_IPX: ::c_int = AF_IPX;
-pub const PF_APPLETALK: ::c_int = AF_APPLETALK;
-pub const PF_NETROM: ::c_int = AF_NETROM;
-pub const PF_BRIDGE: ::c_int = AF_BRIDGE;
-pub const PF_ATMPVC: ::c_int = AF_ATMPVC;
-pub const PF_X25: ::c_int = AF_X25;
-pub const PF_INET6: ::c_int = AF_INET6;
-pub const PF_ROSE: ::c_int = AF_ROSE;
-pub const PF_DECnet: ::c_int = AF_DECnet;
-pub const PF_NETBEUI: ::c_int = AF_NETBEUI;
-pub const PF_SECURITY: ::c_int = AF_SECURITY;
-pub const PF_KEY: ::c_int = AF_KEY;
-pub const PF_NETLINK: ::c_int = AF_NETLINK;
-pub const PF_ROUTE: ::c_int = AF_ROUTE;
-pub const PF_PACKET: ::c_int = AF_PACKET;
-pub const PF_ASH: ::c_int = AF_ASH;
-pub const PF_ECONET: ::c_int = AF_ECONET;
-pub const PF_ATMSVC: ::c_int = AF_ATMSVC;
-pub const PF_SNA: ::c_int = AF_SNA;
-pub const PF_IRDA: ::c_int = AF_IRDA;
-pub const PF_PPPOX: ::c_int = AF_PPPOX;
-pub const PF_WANPIPE: ::c_int = AF_WANPIPE;
-pub const PF_LLC: ::c_int = AF_LLC;
-pub const PF_CAN: ::c_int = AF_CAN;
-pub const PF_TIPC: ::c_int = AF_TIPC;
-pub const PF_BLUETOOTH: ::c_int = AF_BLUETOOTH;
-pub const PF_IUCV: ::c_int = AF_IUCV;
-pub const PF_RXRPC: ::c_int = AF_RXRPC;
-pub const PF_ISDN: ::c_int = AF_ISDN;
-pub const PF_PHONET: ::c_int = AF_PHONET;
-pub const PF_IEEE802154: ::c_int = AF_IEEE802154;
-pub const PF_CAIF: ::c_int = AF_CAIF;
-pub const PF_ALG: ::c_int = AF_ALG;
-
-pub const SOMAXCONN: ::c_int = 128;
-
-pub const MSG_OOB: ::c_int = 1;
-pub const MSG_PEEK: ::c_int = 2;
-pub const MSG_DONTROUTE: ::c_int = 4;
-pub const MSG_CTRUNC: ::c_int = 8;
-pub const MSG_TRUNC: ::c_int = 0x20;
-pub const MSG_DONTWAIT: ::c_int = 0x40;
-pub const MSG_EOR: ::c_int = 0x80;
-pub const MSG_WAITALL: ::c_int = 0x100;
-pub const MSG_FIN: ::c_int = 0x200;
-pub const MSG_SYN: ::c_int = 0x400;
-pub const MSG_CONFIRM: ::c_int = 0x800;
-pub const MSG_RST: ::c_int = 0x1000;
-pub const MSG_ERRQUEUE: ::c_int = 0x2000;
-pub const MSG_NOSIGNAL: ::c_int = 0x4000;
-pub const MSG_MORE: ::c_int = 0x8000;
-pub const MSG_WAITFORONE: ::c_int = 0x10000;
-pub const MSG_CMSG_CLOEXEC: ::c_int = 0x40000000;
-
-pub const SOCK_RAW: ::c_int = 3;
-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_ADD_MEMBERSHIP: ::c_int = 35;
-pub const IP_DROP_MEMBERSHIP: ::c_int = 36;
-pub const IPV6_ADD_MEMBERSHIP: ::c_int = 20;
-pub const IPV6_DROP_MEMBERSHIP: ::c_int = 21;
-
-pub const IPV6_JOIN_GROUP: ::c_int = 20;
-pub const IPV6_LEAVE_GROUP: ::c_int = 21;
-
-pub const TCP_NODELAY: ::c_int = 1;
-pub const TCP_MAXSEG: ::c_int = 2;
-pub const TCP_CORK: ::c_int = 3;
-pub const TCP_KEEPIDLE: ::c_int = 4;
-pub const TCP_KEEPINTVL: ::c_int = 5;
-pub const TCP_KEEPCNT: ::c_int = 6;
-pub const TCP_SYNCNT: ::c_int = 7;
-pub const TCP_LINGER2: ::c_int = 8;
-pub const TCP_DEFER_ACCEPT: ::c_int = 9;
-pub const TCP_WINDOW_CLAMP: ::c_int = 10;
-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;
-pub const SHUT_WR: ::c_int = 1;
-pub const SHUT_RDWR: ::c_int = 2;
-
-pub const LOCK_SH: ::c_int = 1;
-pub const LOCK_EX: ::c_int = 2;
-pub const LOCK_NB: ::c_int = 4;
-pub const LOCK_UN: ::c_int = 8;
-
-pub const SS_ONSTACK: ::c_int = 1;
-pub const SS_DISABLE: ::c_int = 2;
-
-pub const PATH_MAX: ::c_int = 4096;
-
-pub const FD_SETSIZE: usize = 1024;
-
-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 EPOLL_CTL_ADD: ::c_int = 1;
-pub const EPOLL_CTL_MOD: ::c_int = 3;
-pub const EPOLL_CTL_DEL: ::c_int = 2;
-
-pub const MNT_DETACH: ::c_int = 0x2;
-pub const MNT_EXPIRE: ::c_int = 0x4;
-
-pub const MNT_FORCE: ::c_int = 0x1;
-
-pub const Q_SYNC: ::c_int = 0x600;
-pub const Q_QUOTAON: ::c_int = 0x100;
-pub const Q_QUOTAOFF: ::c_int = 0x200;
-pub const Q_GETQUOTA: ::c_int = 0x300;
-pub const Q_SETQUOTA: ::c_int = 0x400;
-
-pub const TCIOFF: ::c_int = 2;
-pub const TCION: ::c_int = 3;
-pub const TCOOFF: ::c_int = 0;
-pub const TCOON: ::c_int = 1;
-pub const TCIFLUSH: ::c_int = 0;
-pub const TCOFLUSH: ::c_int = 1;
-pub const TCIOFLUSH: ::c_int = 2;
-pub const NL0: ::tcflag_t = 0x00000000;
-pub const NL1: ::tcflag_t = 0x00000100;
-pub const TAB0: ::tcflag_t = 0x00000000;
-pub const CR0: ::tcflag_t = 0x00000000;
-pub const FF0: ::tcflag_t = 0x00000000;
-pub const BS0: ::tcflag_t = 0x00000000;
-pub const VT0: ::tcflag_t = 0x00000000;
-pub const VERASE: usize = 2;
-pub const VKILL: usize = 3;
-pub const VINTR: usize = 0;
-pub const VQUIT: usize = 1;
-pub const VLNEXT: usize = 15;
-pub const IGNBRK: ::tcflag_t = 0x00000001;
-pub const BRKINT: ::tcflag_t = 0x00000002;
-pub const IGNPAR: ::tcflag_t = 0x00000004;
-pub const PARMRK: ::tcflag_t = 0x00000008;
-pub const INPCK: ::tcflag_t = 0x00000010;
-pub const ISTRIP: ::tcflag_t = 0x00000020;
-pub const INLCR: ::tcflag_t = 0x00000040;
-pub const IGNCR: ::tcflag_t = 0x00000080;
-pub const ICRNL: ::tcflag_t = 0x00000100;
-pub const IXANY: ::tcflag_t = 0x00000800;
-pub const IMAXBEL: ::tcflag_t = 0x00002000;
-pub const OPOST: ::tcflag_t = 0x1;
-pub const CS5: ::tcflag_t = 0x00000000;
-pub const CRTSCTS: ::tcflag_t = 0x80000000;
-pub const ECHO: ::tcflag_t = 0x00000008;
-
-pub const CLONE_VM: ::c_int = 0x100;
-pub const CLONE_FS: ::c_int = 0x200;
-pub const CLONE_FILES: ::c_int = 0x400;
-pub const CLONE_SIGHAND: ::c_int = 0x800;
-pub const CLONE_PTRACE: ::c_int = 0x2000;
-pub const CLONE_VFORK: ::c_int = 0x4000;
-pub const CLONE_PARENT: ::c_int = 0x8000;
-pub const CLONE_THREAD: ::c_int = 0x10000;
-pub const CLONE_NEWNS: ::c_int = 0x20000;
-pub const CLONE_SYSVSEM: ::c_int = 0x40000;
-pub const CLONE_SETTLS: ::c_int = 0x80000;
-pub const CLONE_PARENT_SETTID: ::c_int = 0x100000;
-pub const CLONE_CHILD_CLEARTID: ::c_int = 0x200000;
-pub const CLONE_DETACHED: ::c_int = 0x400000;
-pub const CLONE_UNTRACED: ::c_int = 0x800000;
-pub const CLONE_CHILD_SETTID: ::c_int = 0x01000000;
-pub const CLONE_NEWUTS: ::c_int = 0x04000000;
-pub const CLONE_NEWIPC: ::c_int = 0x08000000;
-pub const CLONE_NEWUSER: ::c_int = 0x10000000;
-pub const CLONE_NEWPID: ::c_int = 0x20000000;
-pub const CLONE_NEWNET: ::c_int = 0x40000000;
-pub const CLONE_IO: ::c_int = 0x80000000;
-
-pub const WNOHANG: ::c_int = 0x00000001;
-pub const WUNTRACED: ::c_int = 0x00000002;
-pub const WSTOPPED: ::c_int = WUNTRACED;
-pub const WEXITED: ::c_int = 0x00000004;
-pub const WCONTINUED: ::c_int = 0x00000008;
-pub const WNOWAIT: ::c_int = 0x01000000;
-
-pub const __WNOTHREAD: ::c_int = 0x20000000;
-pub const __WALL: ::c_int = 0x40000000;
-pub const __WCLONE: ::c_int = 0x80000000;
-
-pub const SPLICE_F_MOVE: ::c_uint = 0x01;
-pub const SPLICE_F_NONBLOCK: ::c_uint = 0x02;
-pub const SPLICE_F_MORE: ::c_uint = 0x04;
-pub const SPLICE_F_GIFT: ::c_uint = 0x08;
-
-pub const RTLD_LOCAL: ::c_int = 0;
-pub const RTLD_LAZY: ::c_int = 1;
-
-pub const POSIX_FADV_NORMAL: ::c_int = 0;
-pub const POSIX_FADV_RANDOM: ::c_int = 1;
-pub const POSIX_FADV_SEQUENTIAL: ::c_int = 2;
-pub const POSIX_FADV_WILLNEED: ::c_int = 3;
-
-pub const AT_FDCWD: ::c_int = -100;
-pub const AT_SYMLINK_NOFOLLOW: ::c_int = 0x100;
-pub const AT_REMOVEDIR: ::c_int = 0x200;
-pub const AT_SYMLINK_FOLLOW: ::c_int = 0x400;
-
-pub const LOG_CRON: ::c_int = 9 << 3;
-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 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 PIPE_BUF: usize = 4096;
-
-pub const SI_LOAD_SHIFT: ::c_uint = 16;
-
-pub const SIGEV_SIGNAL: ::c_int = 0;
-pub const SIGEV_NONE: ::c_int = 1;
-pub const SIGEV_THREAD: ::c_int = 2;
-
-pub const P_ALL: idtype_t = 0;
-pub const P_PID: idtype_t = 1;
-pub const P_PGID: idtype_t = 2;
-
-pub const UTIME_OMIT: c_long = 1073741822;
-pub const UTIME_NOW: c_long = 1073741823;
-
-pub const L_tmpnam: ::c_uint = 20;
-pub const _PC_LINK_MAX: ::c_int = 0;
-pub const _PC_MAX_CANON: ::c_int = 1;
-pub const _PC_MAX_INPUT: ::c_int = 2;
-pub const _PC_NAME_MAX: ::c_int = 3;
-pub const _PC_PATH_MAX: ::c_int = 4;
-pub const _PC_PIPE_BUF: ::c_int = 5;
-pub const _PC_CHOWN_RESTRICTED: ::c_int = 6;
-pub const _PC_NO_TRUNC: ::c_int = 7;
-pub const _PC_VDISABLE: ::c_int = 8;
-
-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_STREAM_MAX: ::c_int = 5;
-pub const _SC_TZNAME_MAX: ::c_int = 6;
-pub const _SC_JOB_CONTROL: ::c_int = 7;
-pub const _SC_SAVED_IDS: ::c_int = 8;
-pub const _SC_REALTIME_SIGNALS: ::c_int = 9;
-pub const _SC_PRIORITY_SCHEDULING: ::c_int = 10;
-pub const _SC_TIMERS: ::c_int = 11;
-pub const _SC_ASYNCHRONOUS_IO: ::c_int = 12;
-pub const _SC_PRIORITIZED_IO: ::c_int = 13;
-pub const _SC_SYNCHRONIZED_IO: ::c_int = 14;
-pub const _SC_FSYNC: ::c_int = 15;
-pub const _SC_MAPPED_FILES: ::c_int = 16;
-pub const _SC_MEMLOCK: ::c_int = 17;
-pub const _SC_MEMLOCK_RANGE: ::c_int = 18;
-pub const _SC_MEMORY_PROTECTION: ::c_int = 19;
-pub const _SC_MESSAGE_PASSING: ::c_int = 20;
-pub const _SC_SEMAPHORES: ::c_int = 21;
-pub const _SC_SHARED_MEMORY_OBJECTS: ::c_int = 22;
-pub const _SC_AIO_LISTIO_MAX: ::c_int = 23;
-pub const _SC_AIO_MAX: ::c_int = 24;
-pub const _SC_AIO_PRIO_DELTA_MAX: ::c_int = 25;
-pub const _SC_DELAYTIMER_MAX: ::c_int = 26;
-pub const _SC_MQ_OPEN_MAX: ::c_int = 27;
-pub const _SC_MQ_PRIO_MAX: ::c_int = 28;
-pub const _SC_VERSION: ::c_int = 29;
-pub const _SC_PAGESIZE: ::c_int = 30;
-pub const _SC_PAGE_SIZE: ::c_int = _SC_PAGESIZE;
-pub const _SC_RTSIG_MAX: ::c_int = 31;
-pub const _SC_SEM_NSEMS_MAX: ::c_int = 32;
-pub const _SC_SEM_VALUE_MAX: ::c_int = 33;
-pub const _SC_SIGQUEUE_MAX: ::c_int = 34;
-pub const _SC_TIMER_MAX: ::c_int = 35;
-pub const _SC_BC_BASE_MAX: ::c_int = 36;
-pub const _SC_BC_DIM_MAX: ::c_int = 37;
-pub const _SC_BC_SCALE_MAX: ::c_int = 38;
-pub const _SC_BC_STRING_MAX: ::c_int = 39;
-pub const _SC_COLL_WEIGHTS_MAX: ::c_int = 40;
-pub const _SC_EXPR_NEST_MAX: ::c_int = 42;
-pub const _SC_LINE_MAX: ::c_int = 43;
-pub const _SC_RE_DUP_MAX: ::c_int = 44;
-pub const _SC_2_VERSION: ::c_int = 46;
-pub const _SC_2_C_BIND: ::c_int = 47;
-pub const _SC_2_C_DEV: ::c_int = 48;
-pub const _SC_2_FORT_DEV: ::c_int = 49;
-pub const _SC_2_FORT_RUN: ::c_int = 50;
-pub const _SC_2_SW_DEV: ::c_int = 51;
-pub const _SC_2_LOCALEDEF: ::c_int = 52;
-pub const _SC_IOV_MAX: ::c_int = 60;
-pub const _SC_THREADS: ::c_int = 67;
-pub const _SC_THREAD_SAFE_FUNCTIONS: ::c_int = 68;
-pub const _SC_GETGR_R_SIZE_MAX: ::c_int = 69;
-pub const _SC_GETPW_R_SIZE_MAX: ::c_int = 70;
-pub const _SC_LOGIN_NAME_MAX: ::c_int = 71;
-pub const _SC_TTY_NAME_MAX: ::c_int = 72;
-pub const _SC_THREAD_DESTRUCTOR_ITERATIONS: ::c_int = 73;
-pub const _SC_THREAD_KEYS_MAX: ::c_int = 74;
-pub const _SC_THREAD_STACK_MIN: ::c_int = 75;
-pub const _SC_THREAD_THREADS_MAX: ::c_int = 76;
-pub const _SC_THREAD_ATTR_STACKADDR: ::c_int = 77;
-pub const _SC_THREAD_ATTR_STACKSIZE: ::c_int = 78;
-pub const _SC_THREAD_PRIORITY_SCHEDULING: ::c_int = 79;
-pub const _SC_THREAD_PRIO_INHERIT: ::c_int = 80;
-pub const _SC_THREAD_PRIO_PROTECT: ::c_int = 81;
-pub const _SC_NPROCESSORS_ONLN: ::c_int = 84;
-pub const _SC_ATEXIT_MAX: ::c_int = 87;
-pub const _SC_XOPEN_VERSION: ::c_int = 89;
-pub const _SC_XOPEN_XCU_VERSION: ::c_int = 90;
-pub const _SC_XOPEN_UNIX: ::c_int = 91;
-pub const _SC_XOPEN_CRYPT: ::c_int = 92;
-pub const _SC_XOPEN_ENH_I18N: ::c_int = 93;
-pub const _SC_XOPEN_SHM: ::c_int = 94;
-pub const _SC_2_CHAR_TERM: ::c_int = 95;
-pub const _SC_2_UPE: ::c_int = 97;
-pub const _SC_XBS5_ILP32_OFF32: ::c_int = 125;
-pub const _SC_XBS5_ILP32_OFFBIG: ::c_int = 126;
-pub const _SC_XBS5_LPBIG_OFFBIG: ::c_int = 128;
-pub const _SC_XOPEN_LEGACY: ::c_int = 129;
-pub const _SC_XOPEN_REALTIME: ::c_int = 130;
-pub const _SC_XOPEN_REALTIME_THREADS: ::c_int = 131;
-pub const _SC_HOST_NAME_MAX: ::c_int = 180;
-
-pub const RLIM_SAVED_MAX: ::rlim_t = RLIM_INFINITY;
-pub const RLIM_SAVED_CUR: ::rlim_t = RLIM_INFINITY;
-
-pub const GLOB_ERR: ::c_int = 1 << 0;
-pub const GLOB_MARK: ::c_int = 1 << 1;
-pub const GLOB_NOSORT: ::c_int = 1 << 2;
-pub const GLOB_DOOFFS: ::c_int = 1 << 3;
-pub const GLOB_NOCHECK: ::c_int = 1 << 4;
-pub const GLOB_APPEND: ::c_int = 1 << 5;
-pub const GLOB_NOESCAPE: ::c_int = 1 << 6;
-
-pub const GLOB_NOSPACE: ::c_int = 1;
-pub const GLOB_ABORTED: ::c_int = 2;
-pub const GLOB_NOMATCH: ::c_int = 3;
-
-pub const POSIX_MADV_NORMAL: ::c_int = 0;
-pub const POSIX_MADV_RANDOM: ::c_int = 1;
-pub const POSIX_MADV_SEQUENTIAL: ::c_int = 2;
-pub const POSIX_MADV_WILLNEED: ::c_int = 3;
-
-pub const S_IEXEC: mode_t = 64;
-pub const S_IWRITE: mode_t = 128;
-pub const S_IREAD: mode_t = 256;
-
-pub const F_LOCK: ::c_int = 1;
-pub const F_TEST: ::c_int = 3;
-pub const F_TLOCK: ::c_int = 2;
-pub const F_ULOCK: ::c_int = 0;
-
-pub const ST_RDONLY: ::c_ulong = 1;
-pub const ST_NOSUID: ::c_ulong = 2;
-pub const ST_NODEV: ::c_ulong = 4;
-pub const ST_NOEXEC: ::c_ulong = 8;
-pub const ST_SYNCHRONOUS: ::c_ulong = 16;
-pub const ST_MANDLOCK: ::c_ulong = 64;
-pub const ST_WRITE: ::c_ulong = 128;
-pub const ST_APPEND: ::c_ulong = 256;
-pub const ST_IMMUTABLE: ::c_ulong = 512;
-pub const ST_NOATIME: ::c_ulong = 1024;
-pub const ST_NODIRATIME: ::c_ulong = 2048;
-
-pub const RTLD_NEXT: *mut ::c_void = -1i64 as *mut ::c_void;
-pub const RTLD_DEFAULT: *mut ::c_void = 0i64 as *mut ::c_void;
-pub const RTLD_NODELETE: ::c_int = 0x1000;
-pub const RTLD_NOW: ::c_int = 0x2;
-
-pub const TCP_MD5SIG: ::c_int = 14;
-
-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;
-pub const PTHREAD_MUTEX_DEFAULT: ::c_int = PTHREAD_MUTEX_NORMAL;
-pub const __SIZEOF_PTHREAD_COND_T: usize = 48;
-
-pub const SCHED_OTHER: ::c_int = 0;
-pub const SCHED_FIFO: ::c_int = 1;
-pub const SCHED_RR: ::c_int = 2;
-pub const SCHED_BATCH: ::c_int = 3;
-pub const SCHED_IDLE: ::c_int = 5;
-
-// System V IPC
-pub const IPC_PRIVATE: ::key_t = 0;
-
-pub const IPC_CREAT: ::c_int = 0o1000;
-pub const IPC_EXCL: ::c_int = 0o2000;
-pub const IPC_NOWAIT: ::c_int = 0o4000;
-
-pub const IPC_RMID: ::c_int = 0;
-pub const IPC_SET: ::c_int = 1;
-pub const IPC_STAT: ::c_int = 2;
-pub const IPC_INFO: ::c_int = 3;
-pub const MSG_STAT: ::c_int = 11;
-pub const MSG_INFO: ::c_int = 12;
-
-pub const MSG_NOERROR: ::c_int = 0o10000;
-pub const MSG_EXCEPT: ::c_int = 0o20000;
-
-pub const SHM_R: ::c_int = 0o400;
-pub const SHM_W: ::c_int = 0o200;
-
-pub const SHM_RDONLY: ::c_int = 0o10000;
-pub const SHM_RND: ::c_int = 0o20000;
-pub const SHM_REMAP: ::c_int = 0o40000;
-
-pub const SHM_LOCK: ::c_int = 11;
-pub const SHM_UNLOCK: ::c_int = 12;
-
-pub const SHM_HUGETLB: ::c_int = 0o4000;
-pub const SHM_NORESERVE: ::c_int = 0o10000;
-
-pub const EPOLLRDHUP: ::c_int = 0x2000;
-pub const EPOLLONESHOT: ::c_int = 0x40000000;
-
-pub const QFMT_VFS_OLD: ::c_int = 1;
-pub const QFMT_VFS_V0: ::c_int = 2;
-
-pub const EFD_SEMAPHORE: ::c_int = 0x1;
-
-pub const LOG_NFACILITIES: ::c_int = 24;
-
-pub const SEM_FAILED: *mut ::sem_t = 0 as *mut sem_t;
-
-pub const RB_AUTOBOOT: ::c_int = 0x01234567u32 as i32;
-pub const RB_HALT_SYSTEM: ::c_int = 0xcdef0123u32 as i32;
-pub const RB_ENABLE_CAD: ::c_int = 0x89abcdefu32 as i32;
-pub const RB_DISABLE_CAD: ::c_int = 0x00000000u32 as i32;
-pub const RB_POWER_OFF: ::c_int = 0x4321fedcu32 as i32;
-
-pub const AI_PASSIVE: ::c_int = 0x0001;
-pub const AI_CANONNAME: ::c_int = 0x0002;
-pub const AI_NUMERICHOST: ::c_int = 0x0004;
-pub const AI_V4MAPPED: ::c_int = 0x0008;
-pub const AI_ALL: ::c_int = 0x0010;
-pub const AI_ADDRCONFIG: ::c_int = 0x0020;
-
-pub const AI_NUMERICSERV: ::c_int = 0x0400;
-
-pub const EAI_BADFLAGS: ::c_int = -1;
-pub const EAI_NONAME: ::c_int = -2;
-pub const EAI_AGAIN: ::c_int = -3;
-pub const EAI_FAIL: ::c_int = -4;
-pub const EAI_FAMILY: ::c_int = -6;
-pub const EAI_SOCKTYPE: ::c_int = -7;
-pub const EAI_SERVICE: ::c_int = -8;
-pub const EAI_MEMORY: ::c_int = -10;
-pub const EAI_OVERFLOW: ::c_int = -12;
-
-pub const NI_NUMERICHOST: ::c_int = 1;
-pub const NI_NUMERICSERV: ::c_int = 2;
-pub const NI_NOFQDN: ::c_int = 4;
-pub const NI_NAMEREQD: ::c_int = 8;
-pub const NI_DGRAM: ::c_int = 16;
-
-pub const SYNC_FILE_RANGE_WAIT_BEFORE: ::c_uint = 1;
-pub const SYNC_FILE_RANGE_WRITE: ::c_uint = 2;
-pub const SYNC_FILE_RANGE_WAIT_AFTER: ::c_uint = 4;
-
-pub const EAI_SYSTEM: ::c_int = -11;
-
-pub const MREMAP_MAYMOVE: ::c_int = 1;
-pub const MREMAP_FIXED: ::c_int = 2;
-
-pub const PR_SET_PDEATHSIG: ::c_int = 1;
-pub const PR_GET_PDEATHSIG: ::c_int = 2;
-
-pub const PR_GET_DUMPABLE: ::c_int = 3;
-pub const PR_SET_DUMPABLE: ::c_int = 4;
-
-pub const PR_GET_UNALIGN: ::c_int = 5;
-pub const PR_SET_UNALIGN: ::c_int = 6;
-pub const PR_UNALIGN_NOPRINT: ::c_int = 1;
-pub const PR_UNALIGN_SIGBUS: ::c_int = 2;
-
-pub const PR_GET_KEEPCAPS: ::c_int = 7;
-pub const PR_SET_KEEPCAPS: ::c_int = 8;
-
-pub const PR_GET_FPEMU: ::c_int = 9;
-pub const PR_SET_FPEMU: ::c_int = 10;
-pub const PR_FPEMU_NOPRINT: ::c_int = 1;
-pub const PR_FPEMU_SIGFPE: ::c_int = 2;
-
-pub const PR_GET_FPEXC: ::c_int = 11;
-pub const PR_SET_FPEXC: ::c_int = 12;
-pub const PR_FP_EXC_SW_ENABLE: ::c_int = 0x80;
-pub const PR_FP_EXC_DIV: ::c_int = 0x010000;
-pub const PR_FP_EXC_OVF: ::c_int = 0x020000;
-pub const PR_FP_EXC_UND: ::c_int = 0x040000;
-pub const PR_FP_EXC_RES: ::c_int = 0x080000;
-pub const PR_FP_EXC_INV: ::c_int = 0x100000;
-pub const PR_FP_EXC_DISABLED: ::c_int = 0;
-pub const PR_FP_EXC_NONRECOV: ::c_int = 1;
-pub const PR_FP_EXC_ASYNC: ::c_int = 2;
-pub const PR_FP_EXC_PRECISE: ::c_int = 3;
-
-pub const PR_GET_TIMING: ::c_int = 13;
-pub const PR_SET_TIMING: ::c_int = 14;
-pub const PR_TIMING_STATISTICAL: ::c_int = 0;
-pub const PR_TIMING_TIMESTAMP: ::c_int = 1;
-
-pub const PR_SET_NAME: ::c_int = 15;
-pub const PR_GET_NAME: ::c_int = 16;
-
-pub const PR_GET_ENDIAN: ::c_int = 19;
-pub const PR_SET_ENDIAN: ::c_int = 20;
-pub const PR_ENDIAN_BIG: ::c_int = 0;
-pub const PR_ENDIAN_LITTLE: ::c_int = 1;
-pub const PR_ENDIAN_PPC_LITTLE: ::c_int = 2;
-
-pub const PR_GET_SECCOMP: ::c_int = 21;
-pub const PR_SET_SECCOMP: ::c_int = 22;
-
-pub const PR_CAPBSET_READ: ::c_int = 23;
-pub const PR_CAPBSET_DROP: ::c_int = 24;
-
-pub const PR_GET_TSC: ::c_int = 25;
-pub const PR_SET_TSC: ::c_int = 26;
-pub const PR_TSC_ENABLE: ::c_int = 1;
-pub const PR_TSC_SIGSEGV: ::c_int = 2;
-
-pub const PR_GET_SECUREBITS: ::c_int = 27;
-pub const PR_SET_SECUREBITS: ::c_int = 28;
-
-pub const PR_SET_TIMERSLACK: ::c_int = 29;
-pub const PR_GET_TIMERSLACK: ::c_int = 30;
-
-pub const PR_TASK_PERF_EVENTS_DISABLE: ::c_int = 31;
-pub const PR_TASK_PERF_EVENTS_ENABLE: ::c_int = 32;
-
-pub const PR_MCE_KILL: ::c_int = 33;
-pub const PR_MCE_KILL_CLEAR: ::c_int = 0;
-pub const PR_MCE_KILL_SET: ::c_int = 1;
-
-pub const PR_MCE_KILL_LATE: ::c_int = 0;
-pub const PR_MCE_KILL_EARLY: ::c_int = 1;
-pub const PR_MCE_KILL_DEFAULT: ::c_int = 2;
-
-pub const PR_MCE_KILL_GET: ::c_int = 34;
-
-pub const PR_SET_MM: ::c_int = 35;
-pub const PR_SET_MM_START_CODE: ::c_int = 1;
-pub const PR_SET_MM_END_CODE: ::c_int = 2;
-pub const PR_SET_MM_START_DATA: ::c_int = 3;
-pub const PR_SET_MM_END_DATA: ::c_int = 4;
-pub const PR_SET_MM_START_STACK: ::c_int = 5;
-pub const PR_SET_MM_START_BRK: ::c_int = 6;
-pub const PR_SET_MM_BRK: ::c_int = 7;
-pub const PR_SET_MM_ARG_START: ::c_int = 8;
-pub const PR_SET_MM_ARG_END: ::c_int = 9;
-pub const PR_SET_MM_ENV_START: ::c_int = 10;
-pub const PR_SET_MM_ENV_END: ::c_int = 11;
-pub const PR_SET_MM_AUXV: ::c_int = 12;
-pub const PR_SET_MM_EXE_FILE: ::c_int = 13;
-pub const PR_SET_MM_MAP: ::c_int = 14;
-pub const PR_SET_MM_MAP_SIZE: ::c_int = 15;
-
-pub const PR_SET_PTRACER: ::c_int = 0x59616d61;
-
-pub const PR_SET_CHILD_SUBREAPER: ::c_int = 36;
-pub const PR_GET_CHILD_SUBREAPER: ::c_int = 37;
-
-pub const PR_SET_NO_NEW_PRIVS: ::c_int = 38;
-pub const PR_GET_NO_NEW_PRIVS: ::c_int = 39;
-
-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;
-pub const ABDAY_4: ::nl_item = 0x303;
-pub const ABDAY_5: ::nl_item = 0x304;
-pub const ABDAY_6: ::nl_item = 0x305;
-pub const ABDAY_7: ::nl_item = 0x306;
-
-pub const DAY_1: ::nl_item = 0x307;
-pub const DAY_2: ::nl_item = 0x308;
-pub const DAY_3: ::nl_item = 0x309;
-pub const DAY_4: ::nl_item = 0x30A;
-pub const DAY_5: ::nl_item = 0x30B;
-pub const DAY_6: ::nl_item = 0x30C;
-pub const DAY_7: ::nl_item = 0x30D;
-
-pub const ABMON_1: ::nl_item = 0x30E;
-pub const ABMON_2: ::nl_item = 0x30F;
-pub const ABMON_3: ::nl_item = 0x310;
-pub const ABMON_4: ::nl_item = 0x311;
-pub const ABMON_5: ::nl_item = 0x312;
-pub const ABMON_6: ::nl_item = 0x313;
-pub const ABMON_7: ::nl_item = 0x314;
-pub const ABMON_8: ::nl_item = 0x315;
-pub const ABMON_9: ::nl_item = 0x316;
-pub const ABMON_10: ::nl_item = 0x317;
-pub const ABMON_11: ::nl_item = 0x318;
-pub const ABMON_12: ::nl_item = 0x319;
-
-pub const MON_1: ::nl_item = 0x31A;
-pub const MON_2: ::nl_item = 0x31B;
-pub const MON_3: ::nl_item = 0x31C;
-pub const MON_4: ::nl_item = 0x31D;
-pub const MON_5: ::nl_item = 0x31E;
-pub const MON_6: ::nl_item = 0x31F;
-pub const MON_7: ::nl_item = 0x320;
-pub const MON_8: ::nl_item = 0x321;
-pub const MON_9: ::nl_item = 0x322;
-pub const MON_10: ::nl_item = 0x323;
-pub const MON_11: ::nl_item = 0x324;
-pub const MON_12: ::nl_item = 0x325;
-
-pub const AM_STR: ::nl_item = 0x326;
-pub const PM_STR: ::nl_item = 0x327;
-
-pub const D_T_FMT: ::nl_item = 0x328;
-pub const D_FMT: ::nl_item = 0x329;
-pub const T_FMT: ::nl_item = 0x32A;
-pub const T_FMT_AMPM: ::nl_item = 0x32B;
-
-pub const ERA: ::nl_item = 0x32C;
-pub const ERA_D_FMT: ::nl_item = 0x32E;
-pub const ALT_DIGITS: ::nl_item = 0x32F;
-pub const ERA_D_T_FMT: ::nl_item = 0x330;
-pub const ERA_T_FMT: ::nl_item = 0x331;
-
-pub const CODESET: ::nl_item = 10;
-
-pub const CRNCYSTR: ::nl_item = 0x215;
-
-pub const RADIXCHAR: ::nl_item = 0x100;
-pub const THOUSEP: ::nl_item = 0x101;
-
-pub const NOEXPR: ::nl_item = 0x501;
-pub const YESSTR: ::nl_item = 0x502;
-pub const NOSTR: ::nl_item = 0x503;
-
-pub const FILENAME_MAX: ::c_uint = 4095;
-
-#[deprecated(
- since = "0.2.55",
- note = "If you are using this report to: \
- https://github.com/rust-lang/libc/issues/665"
-)]
-pub const AF_MAX: ::c_int = 39;
-
-f! {
- 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;
- (*set).fds_bits[fd / size] &= !(1 << (fd % size));
- return
- }
-
- pub fn FD_ISSET(fd: ::c_int, set: *mut fd_set) -> bool {
- let fd = fd as usize;
- let size = ::mem::size_of_val(&(*set).fds_bits[0]) * 8;
- return ((*set).fds_bits[fd / size] & (1 << (fd % size))) != 0
- }
-
- pub fn FD_SET(fd: ::c_int, set: *mut fd_set) -> () {
- let fd = fd as usize;
- let size = ::mem::size_of_val(&(*set).fds_bits[0]) * 8;
- (*set).fds_bits[fd / size] |= 1 << (fd % size);
- return
- }
-
- pub fn FD_ZERO(set: *mut fd_set) -> () {
- for slot in (*set).fds_bits.iter_mut() {
- *slot = 0;
- }
- }
-
- pub fn WIFSTOPPED(status: ::c_int) -> bool {
- (status & 0xff) == 0x7f
- }
-
- pub fn WSTOPSIG(status: ::c_int) -> ::c_int {
- (status >> 8) & 0xff
- }
-
- pub fn WIFCONTINUED(status: ::c_int) -> bool {
- status == 0xffff
- }
-
- pub fn WIFSIGNALED(status: ::c_int) -> bool {
- ((status & 0x7f) + 1) as i8 >= 2
- }
-
- pub fn WTERMSIG(status: ::c_int) -> ::c_int {
- status & 0x7f
- }
-
- pub fn WIFEXITED(status: ::c_int) -> bool {
- (status & 0x7f) == 0
- }
-
- pub fn WEXITSTATUS(status: ::c_int) -> ::c_int {
- (status >> 8) & 0xff
- }
-
- pub fn WCOREDUMP(status: ::c_int) -> bool {
- (status & 0x80) != 0
- }
-
- pub fn CPU_ZERO(cpuset: &mut cpu_set_t) -> () {
- for slot in cpuset.bits.iter_mut() {
- *slot = 0;
- }
- }
-
- pub fn CPU_SET(cpu: usize, cpuset: &mut cpu_set_t) -> () {
- let size_in_bits
- = 8 * ::mem::size_of_val(&cpuset.bits[0]); // 32, 64 etc
- let (idx, offset) = (cpu / size_in_bits, cpu % size_in_bits);
- cpuset.bits[idx] |= 1 << offset;
- ()
- }
-
- pub fn CPU_CLR(cpu: usize, cpuset: &mut cpu_set_t) -> () {
- let size_in_bits
- = 8 * ::mem::size_of_val(&cpuset.bits[0]); // 32, 64 etc
- let (idx, offset) = (cpu / size_in_bits, cpu % size_in_bits);
- cpuset.bits[idx] &= !(1 << offset);
- ()
- }
-
- pub fn CPU_ISSET(cpu: usize, cpuset: &cpu_set_t) -> bool {
- let size_in_bits = 8 * ::mem::size_of_val(&cpuset.bits[0]);
- let (idx, offset) = (cpu / size_in_bits, cpu % size_in_bits);
- 0 != (cpuset.bits[idx] & (1 << offset))
- }
-
- pub fn CPU_EQUAL(set1: &cpu_set_t, set2: &cpu_set_t) -> bool {
- set1.bits == set2.bits
- }
-
- pub fn QCMD(cmd: ::c_int, type_: ::c_int) -> ::c_int {
- (cmd << 8) | (type_ & 0x00ff)
- }
-}
-
-extern {
- #[cfg_attr(target_os = "linux",
- link_name = "__xpg_strerror_r")]
- pub fn strerror_r(errnum: ::c_int, buf: *mut c_char,
- buflen: ::size_t) -> ::c_int;
-
- pub fn sem_destroy(sem: *mut sem_t) -> ::c_int;
- pub fn sem_init(sem: *mut sem_t,
- pshared: ::c_int,
- value: ::c_uint)
- -> ::c_int;
-
- 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 gettimeofday(tp: *mut ::timeval,
- tz: *mut ::timezone) -> ::c_int;
- pub fn mincore(addr: *mut ::c_void, len: ::size_t,
- vec: *mut ::c_uchar) -> ::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,
- flags: ::c_int,
- rqtp: *const ::timespec,
- rmtp: *mut ::timespec) -> ::c_int;
- pub fn clock_settime(clk_id: ::clockid_t, tp: *const ::timespec) -> ::c_int;
- pub fn prctl(option: ::c_int, ...) -> ::c_int;
- pub fn pthread_getattr_np(native: ::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 memalign(align: ::size_t, size: ::size_t) -> *mut ::c_void;
- pub fn setgroups(ngroups: ::size_t,
- ptr: *const ::gid_t) -> ::c_int;
- pub fn initgroups(user: *const ::c_char, group: ::gid_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 sched_get_priority_max(policy: ::c_int) -> ::c_int;
- pub fn sched_get_priority_min(policy: ::c_int) -> ::c_int;
- pub fn epoll_create(size: ::c_int) -> ::c_int;
- pub fn epoll_create1(flags: ::c_int) -> ::c_int;
- pub fn epoll_ctl(epfd: ::c_int,
- op: ::c_int,
- fd: ::c_int,
- event: *mut ::epoll_event) -> ::c_int;
- pub fn epoll_wait(epfd: ::c_int,
- events: *mut ::epoll_event,
- maxevents: ::c_int,
- timeout: ::c_int) -> ::c_int;
- pub fn pipe2(fds: *mut ::c_int, flags: ::c_int) -> ::c_int;
- pub fn mount(src: *const ::c_char,
- target: *const ::c_char,
- fstype: *const ::c_char,
- flags: ::c_ulong,
- data: *const ::c_void) -> ::c_int;
- pub fn umount(target: *const ::c_char) -> ::c_int;
- pub fn umount2(target: *const ::c_char, flags: ::c_int) -> ::c_int;
- pub fn clone(cb: extern fn(*mut ::c_void) -> ::c_int,
- child_stack: *mut ::c_void,
- flags: ::c_int,
- arg: *mut ::c_void, ...) -> ::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 memrchr(cx: *const ::c_void,
- c: ::c_int,
- n: ::size_t) -> *mut ::c_void;
- pub fn syscall(num: ::c_long, ...) -> ::c_long;
- pub fn sendfile(out_fd: ::c_int,
- in_fd: ::c_int,
- offset: *mut off_t,
- count: ::size_t) -> ::ssize_t;
- pub fn splice(fd_in: ::c_int,
- off_in: *mut ::loff_t,
- fd_out: ::c_int,
- off_out: *mut ::loff_t,
- len: ::size_t,
- flags: ::c_uint) -> ::ssize_t;
- pub fn tee(fd_in: ::c_int,
- fd_out: ::c_int,
- len: ::size_t,
- flags: ::c_uint) -> ::ssize_t;
- pub fn vmsplice(fd: ::c_int,
- iov: *const ::iovec,
- nr_segs: ::size_t,
- flags: ::c_uint) -> ::ssize_t;
-
- pub fn posix_fadvise(fd: ::c_int, offset: ::off_t, len: ::off_t,
- advise: ::c_int) -> ::c_int;
- pub fn getrlimit(resource: ::c_int, rlim: *mut ::rlimit) -> ::c_int;
- pub fn setrlimit(resource: ::c_int, rlim: *const ::rlimit) -> ::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 duplocale(base: ::locale_t) -> ::locale_t;
- pub fn freelocale(loc: ::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 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;
- pub fn lstat64(path: *const c_char, buf: *mut stat64) -> ::c_int;
- pub fn mmap64(addr: *mut ::c_void,
- len: ::size_t,
- prot: ::c_int,
- flags: ::c_int,
- fd: ::c_int,
- offset: off64_t)
- -> *mut ::c_void;
- pub fn open64(path: *const c_char, oflag: ::c_int, ...) -> ::c_int;
- pub fn openat64(fd: ::c_int,
- path: *const c_char,
- oflag: ::c_int, ...) -> ::c_int;
- pub fn pread64(fd: ::c_int, buf: *mut ::c_void, count: ::size_t,
- offset: off64_t) -> ::ssize_t;
- pub fn pwrite64(fd: ::c_int, buf: *const ::c_void, count: ::size_t,
- offset: off64_t) -> ::ssize_t;
- pub fn readdir64(dirp: *mut ::DIR) -> *mut ::dirent64;
- pub fn readdir64_r(dirp: *mut ::DIR, entry: *mut ::dirent64,
- result: *mut *mut ::dirent64) -> ::c_int;
- pub fn setrlimit64(resource: ::c_int, rlim: *const rlimit64) -> ::c_int;
- 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 eventfd(init: ::c_uint, flags: ::c_int) -> ::c_int;
-
- pub fn mknodat(dirfd: ::c_int, pathname: *const ::c_char,
- mode: ::mode_t, dev: dev_t) -> ::c_int;
- pub fn ppoll(fds: *mut ::pollfd,
- nfds: nfds_t,
- timeout: *const ::timespec,
- sigmask: *const sigset_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 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 sched_getaffinity(pid: ::pid_t,
- cpusetsize: ::size_t,
- cpuset: *mut cpu_set_t) -> ::c_int;
- pub fn sched_setaffinity(pid: ::pid_t,
- cpusetsize: ::size_t,
- cpuset: *const cpu_set_t) -> ::c_int;
- 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,
- abstime: *const ::timespec) -> ::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_getkind_np(attr: *const pthread_rwlockattr_t,
- val: *mut ::c_int) -> ::c_int;
- pub fn pthread_rwlockattr_setkind_np(attr: *mut pthread_rwlockattr_t,
- val: ::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 ptsname_r(fd: ::c_int,
- buf: *mut ::c_char,
- buflen: ::size_t) -> ::c_int;
- pub fn clearenv() -> ::c_int;
- pub fn waitid(idtype: idtype_t, id: id_t, infop: *mut ::siginfo_t,
- options: ::c_int) -> ::c_int;
-
- pub fn lutimes(file: *const ::c_char, times: *const ::timeval) -> ::c_int;
-
- pub fn setpwent();
- pub fn endpwent();
- pub fn getpwent() -> *mut passwd;
- 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,
- mode: mode_t) -> ::c_int;
-
- // System V IPC
- pub fn shmget(key: ::key_t, size: ::size_t, shmflg: ::c_int) -> ::c_int;
- 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;
- pub fn shmctl(shmid: ::c_int,
- cmd: ::c_int,
- buf: *mut ::shmid_ds) -> ::c_int;
- pub fn ftok(pathname: *const ::c_char, proj_id: ::c_int) -> ::key_t;
- pub fn msgctl(msqid: ::c_int, cmd: ::c_int, buf: *mut msqid_ds) -> ::c_int;
- pub fn msgget(key: ::key_t, msgflg: ::c_int) -> ::c_int;
- pub fn msgrcv(msqid: ::c_int, msgp: *mut ::c_void, msgsz: ::size_t,
- msgtyp: ::c_long, msgflg: ::c_int) -> ::ssize_t;
- pub fn msgsnd(msqid: ::c_int, msgp: *const ::c_void, msgsz: ::size_t,
- msgflg: ::c_int) -> ::c_int;
-
- pub fn mprotect(addr: *mut ::c_void, len: ::size_t, prot: ::c_int)
- -> ::c_int;
- pub fn __errno_location() -> *mut ::c_int;
-
- pub fn fopen64(filename: *const c_char,
- mode: *const c_char) -> *mut ::FILE;
- pub fn freopen64(filename: *const c_char, mode: *const c_char,
- file: *mut ::FILE) -> *mut ::FILE;
- pub fn tmpfile64() -> *mut ::FILE;
- pub fn fgetpos64(stream: *mut ::FILE, ptr: *mut fpos64_t) -> ::c_int;
- pub fn fsetpos64(stream: *mut ::FILE, ptr: *const fpos64_t) -> ::c_int;
- pub fn fseeko64(stream: *mut ::FILE,
- offset: ::off64_t,
- whence: ::c_int) -> ::c_int;
- pub fn ftello64(stream: *mut ::FILE) -> ::off64_t;
- 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,
- value: *mut ::c_void, size: ::size_t) -> ::ssize_t;
- pub fn lgetxattr(path: *const c_char, name: *const c_char,
- value: *mut ::c_void, size: ::size_t) -> ::ssize_t;
- pub fn fgetxattr(filedes: ::c_int, name: *const c_char,
- value: *mut ::c_void, size: ::size_t) -> ::ssize_t;
- pub fn setxattr(path: *const c_char, name: *const c_char,
- value: *const ::c_void, size: ::size_t,
- flags: ::c_int) -> ::c_int;
- pub fn lsetxattr(path: *const c_char, name: *const c_char,
- value: *const ::c_void, size: ::size_t,
- flags: ::c_int) -> ::c_int;
- pub fn fsetxattr(filedes: ::c_int, name: *const c_char,
- value: *const ::c_void, size: ::size_t,
- flags: ::c_int) -> ::c_int;
- pub fn listxattr(path: *const c_char, list: *mut c_char,
- size: ::size_t) -> ::ssize_t;
- pub fn llistxattr(path: *const c_char, list: *mut c_char,
- size: ::size_t) -> ::ssize_t;
- pub fn flistxattr(filedes: ::c_int, list: *mut c_char,
- size: ::size_t) -> ::ssize_t;
- pub fn removexattr(path: *const c_char, name: *const c_char) -> ::c_int;
- pub fn lremovexattr(path: *const c_char, name: *const c_char) -> ::c_int;
- pub fn fremovexattr(filedes: ::c_int, name: *const c_char) -> ::c_int;
- pub fn signalfd(fd: ::c_int,
- mask: *const ::sigset_t,
- flags: ::c_int) -> ::c_int;
- pub fn quotactl(cmd: ::c_int,
- special: *const ::c_char,
- id: ::c_int,
- data: *mut ::c_char) -> ::c_int;
- pub fn mq_open(name: *const ::c_char, oflag: ::c_int, ...) -> ::mqd_t;
- pub fn mq_close(mqd: ::mqd_t) -> ::c_int;
- pub fn mq_unlink(name: *const ::c_char) -> ::c_int;
- pub fn mq_receive(mqd: ::mqd_t,
- msg_ptr: *mut ::c_char,
- msg_len: ::size_t,
- msq_prio: *mut ::c_uint) -> ::ssize_t;
- pub fn mq_send(mqd: ::mqd_t,
- msg_ptr: *const ::c_char,
- msg_len: ::size_t,
- msq_prio: ::c_uint) -> ::c_int;
- pub fn mq_getattr(mqd: ::mqd_t, attr: *mut ::mq_attr) -> ::c_int;
- pub fn mq_setattr(mqd: ::mqd_t,
- newattr: *const ::mq_attr,
- oldattr: *mut ::mq_attr) -> ::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 sethostname(name: *const ::c_char, len: ::size_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 nl_langinfo_l(item: ::nl_item, locale: ::locale_t) -> *mut ::c_char;
- pub fn prlimit(pid: ::pid_t, resource: ::c_int, new_limit: *const ::rlimit,
- old_limit: *mut ::rlimit) -> ::c_int;
- pub fn prlimit64(pid: ::pid_t,
- resource: ::c_int,
- new_limit: *const ::rlimit64,
- old_limit: *mut ::rlimit64) -> ::c_int;
- pub fn reboot(how_to: ::c_int) -> ::c_int;
- pub fn setfsgid(gid: ::gid_t) -> ::c_int;
- pub fn setfsuid(uid: ::uid_t) -> ::c_int;
- pub fn setresgid(rgid: ::gid_t, egid: ::gid_t, sgid: ::gid_t) -> ::c_int;
- pub fn setresuid(ruid: ::uid_t, euid: ::uid_t, suid: ::uid_t) -> ::c_int;
-
- // Not available now on Android
- pub fn mkfifoat(dirfd: ::c_int, pathname: *const ::c_char,
- mode: ::mode_t) -> ::c_int;
- pub fn if_nameindex() -> *mut if_nameindex;
- pub fn if_freenameindex(ptr: *mut if_nameindex);
- 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,
- flags: ::c_int,
- ...) -> *mut ::c_void;
-
- 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;
- pub fn globfree(pglob: *mut ::glob_t);
-
- pub fn shm_unlink(name: *const ::c_char) -> ::c_int;
-
- 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;
-
- pub fn msync(addr: *mut ::c_void, len: ::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;
- 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;
- #[cfg_attr(target_os = "solaris", link_name = "__posix_getgrgid_r")]
- pub fn getgrgid_r(gid: ::gid_t,
- grp: *mut ::group,
- buf: *mut ::c_char,
- buflen: ::size_t,
- result: *mut *mut ::group) -> ::c_int;
- #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
- link_name = "sigaltstack$UNIX2003")]
- #[cfg_attr(target_os = "netbsd", link_name = "__sigaltstack14")]
- pub fn sigaltstack(ss: *const stack_t,
- oss: *mut stack_t) -> ::c_int;
- pub fn sem_close(sem: *mut sem_t) -> ::c_int;
- pub fn getdtablesize() -> ::c_int;
- #[cfg_attr(target_os = "solaris", link_name = "__posix_getgrnam_r")]
- pub fn getgrnam_r(name: *const ::c_char,
- grp: *mut ::group,
- buf: *mut ::c_char,
- buflen: ::size_t,
- result: *mut *mut ::group) -> ::c_int;
- #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
- link_name = "pthread_sigmask$UNIX2003")]
- pub fn pthread_sigmask(how: ::c_int, set: *const sigset_t,
- oldset: *mut sigset_t) -> ::c_int;
- pub fn sem_open(name: *const ::c_char, oflag: ::c_int, ...) -> *mut sem_t;
- pub fn getgrnam(name: *const ::c_char) -> *mut ::group;
- pub fn pthread_kill(thread: ::pthread_t, sig: ::c_int) -> ::c_int;
- pub fn sem_unlink(name: *const ::c_char) -> ::c_int;
- pub fn daemon(nochdir: ::c_int, noclose: ::c_int) -> ::c_int;
- #[cfg_attr(target_os = "netbsd", link_name = "__getpwnam_r50")]
- #[cfg_attr(target_os = "solaris", link_name = "__posix_getpwnam_r")]
- pub fn getpwnam_r(name: *const ::c_char,
- pwd: *mut passwd,
- buf: *mut ::c_char,
- buflen: ::size_t,
- result: *mut *mut passwd) -> ::c_int;
- #[cfg_attr(target_os = "netbsd", link_name = "__getpwuid_r50")]
- #[cfg_attr(target_os = "solaris", link_name = "__posix_getpwuid_r")]
- pub fn getpwuid_r(uid: ::uid_t,
- pwd: *mut passwd,
- buf: *mut ::c_char,
- buflen: ::size_t,
- result: *mut *mut passwd) -> ::c_int;
- #[cfg_attr(all(target_os = "macos", target_arch ="x86"),
- link_name = "sigwait$UNIX2003")]
- #[cfg_attr(target_os = "solaris", link_name = "__posix_sigwait")]
- pub fn sigwait(set: *const sigset_t,
- sig: *mut ::c_int) -> ::c_int;
- pub fn pthread_atfork(prepare: ::Option<unsafe extern fn()>,
- parent: ::Option<unsafe extern fn()>,
- child: ::Option<unsafe extern fn()>) -> ::c_int;
- pub fn pthread_create(native: *mut ::pthread_t,
- attr: *const ::pthread_attr_t,
- f: extern fn(*mut ::c_void) -> *mut ::c_void,
- value: *mut ::c_void) -> ::c_int;
- pub fn getgrgid(gid: ::gid_t) -> *mut ::group;
- #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
- link_name = "popen$UNIX2003")]
- pub fn popen(command: *const c_char,
- mode: *const c_char) -> *mut ::FILE;
- pub fn uname(buf: *mut ::utsname) -> ::c_int;
-}
-
-cfg_if! {
- if #[cfg(any(target_arch = "mips", target_arch = "mips64"))] {
- mod mips;
- pub use self::mips::*;
- } else if #[cfg(target_arch = "x86_64")] {
- mod x86_64;
- pub use self::x86_64::*;
- } else if #[cfg(target_arch = "arm")] {
- mod arm;
- pub use self::arm::*;
- } else {
- pub use unsupported_target;
- }
-}
-
-cfg_if! {
- if #[cfg(libc_align)] {
- #[macro_use]
- mod align;
- } else {
- #[macro_use]
- mod no_align;
- }
-}
-
-expand_align!();
diff --git a/libc/src/unix/uclibc/no_align.rs b/libc/src/unix/uclibc/no_align.rs
deleted file mode 100644
index a73dbde..0000000
--- a/libc/src/unix/uclibc/no_align.rs
+++ /dev/null
@@ -1,53 +0,0 @@
-macro_rules! expand_align {
- () => {
- s! {
- pub struct pthread_mutex_t {
- #[cfg(any(target_arch = "mips",
- target_arch = "arm",
- target_arch = "powerpc"))]
- __align: [::c_long; 0],
- #[cfg(any(libc_align,
- target_arch = "mips",
- target_arch = "arm",
- target_arch = "powerpc"))]
- __align: [::c_longlong; 0],
- size: [u8; ::__SIZEOF_PTHREAD_MUTEX_T],
- }
-
- pub struct pthread_rwlock_t {
- #[cfg(any(target_arch = "mips",
- target_arch = "arm",
- target_arch = "powerpc"))]
- __align: [::c_long; 0],
- #[cfg(not(any(
- target_arch = "mips",
- target_arch = "arm",
- target_arch = "powerpc")))]
- __align: [::c_longlong; 0],
- size: [u8; ::__SIZEOF_PTHREAD_RWLOCK_T],
- }
-
- 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",
- target_arch = "mips64", target_arch = "s390x",
- target_arch = "sparc64")))]
- __align: [::c_long; 0],
- size: [u8; ::__SIZEOF_PTHREAD_MUTEXATTR_T],
- }
-
- pub struct pthread_cond_t {
- __align: [::c_longlong; 0],
- size: [u8; ::__SIZEOF_PTHREAD_COND_T],
- }
-
- pub struct pthread_condattr_t {
- __align: [::c_int; 0],
- size: [u8; ::__SIZEOF_PTHREAD_CONDATTR_T],
- }
- }
- }
-}
diff --git a/libc/src/unix/uclibc/x86_64/align.rs b/libc/src/unix/uclibc/x86_64/align.rs
deleted file mode 100644
index 8d4bbd5..0000000
--- a/libc/src/unix/uclibc/x86_64/align.rs
+++ /dev/null
@@ -1,77 +0,0 @@
-macro_rules! expand_align {
- () => {
- s! {
- #[cfg_attr(target_pointer_width = "32",
- repr(align(4)))]
- #[cfg_attr(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_attr(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(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
- size: [u8; ::__SIZEOF_PTHREAD_MUTEXATTR_T],
- }
-
- #[repr(align(4))]
- pub struct pthread_condattr_t { // ToDo
- size: [u8; ::__SIZEOF_PTHREAD_CONDATTR_T],
- }
- }
-
- s_no_extra_traits! {
- #[cfg_attr(all(target_pointer_width = "32",
- any(target_arch = "mips",
- target_arch = "arm",
- target_arch = "powerpc")),
- repr(align(4)))]
- #[cfg_attr(all(any(target_pointer_width = "64",
- not(any(target_arch = "mips",
- target_arch = "arm",
- target_arch = "powerpc")))),
- repr(align(8)))]
- #[allow(missing_debug_implementations)]
- pub struct pthread_mutex_t { // ToDo
- size: [u8; ::__SIZEOF_PTHREAD_MUTEX_T],
- }
-
- #[repr(align(8))]
- #[allow(missing_debug_implementations)]
- pub struct pthread_cond_t { // ToDo
- size: [u8; ::__SIZEOF_PTHREAD_COND_T],
- }
-
- #[cfg_attr(all(target_pointer_width = "32",
- any(target_arch = "mips",
- target_arch = "arm",
- target_arch = "powerpc")),
- repr(align(4)))]
- #[cfg_attr(any(target_pointer_width = "64",
- not(any(target_arch = "mips",
- target_arch = "arm",
- target_arch = "powerpc"))),
- repr(align(8)))]
- #[allow(missing_debug_implementations)]
- pub struct pthread_rwlock_t { // ToDo
- size: [u8; ::__SIZEOF_PTHREAD_RWLOCK_T],
- }
- }
- }
-}
diff --git a/libc/src/unix/uclibc/x86_64/l4re.rs b/libc/src/unix/uclibc/x86_64/l4re.rs
deleted file mode 100644
index 16ec0ef..0000000
--- a/libc/src/unix/uclibc/x86_64/l4re.rs
+++ /dev/null
@@ -1,48 +0,0 @@
-/// L4Re specifics
-/// This module contains definitions required by various L4Re libc backends.
-/// Some of them are formally not part of the libc, but are a dependency of the
-/// 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.
- pub struct l4_sched_cpu_set_t {
- // from the L4Re docs
- /// Combination of granularity and offset.
- ///
- /// The granularity defines how many CPUs each bit in map describes.
- /// The offset is the numer of the first CPU described by the first
- /// bit in the bitmap.
- /// offset must be a multiple of 2^graularity.
- ///
- /// | MSB | LSB |
- /// | ---------------- | ------------------- |
- /// | 8bit granularity | 24bit offset .. |
- gran_offset: l4_umword_t ,
- /// Bitmap of CPUs.
- map: l4_umword_t ,
- }
-}
-
-#[cfg(target_os = "l4re")]
-#[allow(missing_debug_implementations)]
-pub struct pthread_attr_t {
- pub __detachstate: ::c_int,
- pub __schedpolicy: ::c_int,
- pub __schedparam: super::__sched_param,
- pub __inheritsched: ::c_int,
- pub __scope: ::c_int,
- pub __guardsize: ::size_t,
- pub __stackaddr_set: ::c_int,
- pub __stackaddr: *mut ::c_void, // better don't use it
- pub __stacksize: ::size_t,
- // L4Re specifics
- pub affinity: l4_sched_cpu_set_t,
- pub create_flags: ::c_uint,
-}
-
-// L4Re requires a min stack size of 64k; that isn't defined in uClibc, but
-// somewhere in the core libraries. uClibc wants 16k, but that's not enough.
-pub const PTHREAD_STACK_MIN: usize = 65536;
diff --git a/libc/src/unix/uclibc/x86_64/mod.rs b/libc/src/unix/uclibc/x86_64/mod.rs
deleted file mode 100644
index a8bb079..0000000
--- a/libc/src/unix/uclibc/x86_64/mod.rs
+++ /dev/null
@@ -1,312 +0,0 @@
-//! Definitions for uclibc on 64bit systems
-pub type blkcnt_t = i64;
-pub type blksize_t = i64;
-pub type clock_t = i64;
-pub type c_char = u8;
-pub type c_long = i64;
-pub type c_ulong = u64;
-pub type fsblkcnt_t = ::c_ulong;
-pub type fsfilcnt_t = ::c_ulong;
-pub type fsword_t = ::c_long;
-pub type ino_t = ::c_ulong;
-pub type nlink_t = ::c_uint;
-pub type off_t = ::c_long;
-pub type rlim_t = c_ulong;
-pub type rlim64_t = u64;
-// [uClibc docs] Note stat64 has the same shape as stat for x86-64.
-pub type stat64 = stat;
-pub type suseconds_t = ::c_long;
-pub type time_t = ::c_int;
-pub type wchar_t = ::c_int;
-
-s! {
- pub struct ipc_perm {
- pub __key: ::key_t,
- pub uid: ::uid_t,
- pub gid: ::gid_t,
- pub cuid: ::uid_t,
- pub cgid: ::gid_t,
- pub mode: ::c_ushort, // read / write
- __pad1: ::c_ushort,
- pub __seq: ::c_ushort,
- __pad2: ::c_ushort,
- __unused1: ::c_ulong,
- __unused2: ::c_ulong
- }
-
- #[cfg(not(target_os = "l4re"))]
- pub struct pthread_attr_t {
- __detachstate: ::c_int,
- __schedpolicy: ::c_int,
- __schedparam: __sched_param,
- __inheritsched: ::c_int,
- __scope: ::c_int,
- __guardsize: ::size_t,
- __stackaddr_set: ::c_int,
- __stackaddr: *mut ::c_void, // better don't use it
- __stacksize: ::size_t,
- }
-
- pub struct __sched_param {
- __sched_priority: ::c_int,
- }
-
- pub struct siginfo_t {
- si_signo: ::c_int, // signal number
- si_errno: ::c_int, // if not zero: error value of signal, see errno.h
- si_code: ::c_int, // signal code
- pub _pad: [::c_int; 28], // unported union
- _align: [usize; 0],
- }
-
- pub struct shmid_ds {
- pub shm_perm: ::ipc_perm,
- pub shm_segsz: ::size_t, // segment size in bytes
- pub shm_atime: ::time_t, // time of last shmat()
- pub shm_dtime: ::time_t,
- pub shm_ctime: ::time_t,
- pub shm_cpid: ::pid_t,
- pub shm_lpid: ::pid_t,
- pub shm_nattch: ::shmatt_t,
- __unused1: ::c_ulong,
- __unused2: ::c_ulong
- }
-
- pub struct msqid_ds {
- pub msg_perm: ::ipc_perm,
- pub msg_stime: ::time_t,
- pub msg_rtime: ::time_t,
- 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,
- __ignored1: ::c_ulong,
- __ignored2: ::c_ulong,
- }
-
- pub struct sockaddr {
- pub sa_family: ::sa_family_t,
- pub sa_data: [::c_char; 14],
- }
-
- pub struct sockaddr_in {
- pub sin_family: ::sa_family_t,
- pub sin_port: ::in_port_t,
- pub sin_addr: ::in_addr,
- pub sin_zero: [u8; 8],
- }
-
- pub struct sockaddr_in6 {
- 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,
- }
-
- // ------------------------------------------------------------
- // definitions below are *unverified* and might **break** the software
-// pub struct in_addr {
-// pub s_addr: in_addr_t,
-// }
-//
-// pub struct in6_addr {
-// pub s6_addr: [u8; 16],
-// #[cfg(not(libc_align))]
-// __align: [u32; 0],
-// }
-
- pub struct stat {
- pub st_dev: ::c_ulong,
- pub st_ino: ::ino_t,
- // According to uclibc/libc/sysdeps/linux/x86_64/bits/stat.h, order of
- // nlink and mode are swapped on 64 bit systems.
- pub st_nlink: ::nlink_t,
- pub st_mode: ::mode_t,
- pub st_uid: ::uid_t,
- pub st_gid: ::gid_t,
- pub st_rdev: ::c_ulong, // dev_t
- pub st_size: off_t, // file size
- pub st_blksize: ::blksize_t,
- pub st_blocks: ::blkcnt_t,
- pub st_atime: ::time_t,
- pub st_atime_nsec: ::c_ulong,
- pub st_mtime: ::time_t,
- pub st_mtime_nsec: ::c_ulong,
- pub st_ctime: ::time_t,
- pub st_ctime_nsec: ::c_ulong,
- st_pad4: [::c_long; 3]
- }
-
- pub struct sigaction {
- pub sa_handler: ::sighandler_t,
- pub sa_flags: ::c_ulong,
- pub sa_restorer: *mut ::c_void,
- pub sa_mask: ::sigset_t,
- }
-
- pub struct stack_t { // ToDo
- pub ss_sp: *mut ::c_void,
- pub ss_flags: ::c_int,
- pub ss_size: ::size_t
- }
-
- pub struct statfs { // ToDo
- pub f_type: fsword_t,
- pub f_bsize: fsword_t,
- pub f_blocks: ::fsblkcnt_t,
- pub f_bfree: ::fsblkcnt_t,
- pub f_bavail: ::fsblkcnt_t,
- pub f_files: ::fsfilcnt_t,
- pub f_ffree: ::fsfilcnt_t,
- pub f_fsid: ::fsid_t,
- pub f_namelen: fsword_t,
- pub f_frsize: fsword_t,
- f_spare: [fsword_t; 5],
- }
-
- pub struct msghdr { // ToDo
- pub msg_name: *mut ::c_void,
- pub msg_namelen: ::socklen_t,
- pub msg_iov: *mut ::iovec,
- pub msg_iovlen: ::size_t,
- pub msg_control: *mut ::c_void,
- pub msg_controllen: ::size_t,
- pub msg_flags: ::c_int,
- }
-
- pub struct termios { // ToDo
- pub c_iflag: ::tcflag_t,
- pub c_oflag: ::tcflag_t,
- pub c_cflag: ::tcflag_t,
- pub c_lflag: ::tcflag_t,
- pub c_line: ::cc_t,
- pub c_cc: [::cc_t; ::NCCS],
- }
-
- pub struct sigset_t { // ToDo
- __val: [::c_ulong; 16],
- }
-
- pub struct sysinfo { // ToDo
- pub uptime: ::c_long,
- pub loads: [::c_ulong; 3],
- pub totalram: ::c_ulong,
- pub freeram: ::c_ulong,
- pub sharedram: ::c_ulong,
- pub bufferram: ::c_ulong,
- pub totalswap: ::c_ulong,
- pub freeswap: ::c_ulong,
- pub procs: ::c_ushort,
- pub pad: ::c_ushort,
- pub totalhigh: ::c_ulong,
- pub freehigh: ::c_ulong,
- pub mem_unit: ::c_uint,
- pub _f: [::c_char; 0],
- }
-
- pub struct glob_t { // ToDo
- pub gl_pathc: ::size_t,
- pub gl_pathv: *mut *mut c_char,
- pub gl_offs: ::size_t,
- pub gl_flags: ::c_int,
- __unused1: *mut ::c_void,
- __unused2: *mut ::c_void,
- __unused3: *mut ::c_void,
- __unused4: *mut ::c_void,
- __unused5: *mut ::c_void,
- }
-
- pub struct rlimit64 { // ToDo
- pub rlim_cur: rlim64_t,
- pub rlim_max: rlim64_t,
- }
-
- pub struct cpu_set_t { // ToDo
- #[cfg(target_pointer_width = "32")]
- bits: [u32; 32],
- #[cfg(target_pointer_width = "64")]
- bits: [u64; 16],
- }
-
- pub struct fsid_t { // ToDo
- __val: [::c_int; 2],
- }
-}
-
-s_no_extra_traits! {
- #[allow(missing_debug_implementations)]
- pub struct dirent {
- pub d_ino: ::ino64_t,
- pub d_off: ::off64_t,
- pub d_reclen: u16,
- pub d_type: u8,
- pub d_name: [::c_char; 256],
- }
- #[allow(missing_debug_implementations)]
- pub struct dirent64 {
- pub d_ino: ::ino64_t,
- pub d_off: ::off64_t,
- pub d_reclen: u16,
- pub d_type: u8,
- pub d_name: [::c_char; 256],
- }
-}
-
-// constants
-pub const EADDRINUSE: ::c_int = 98; // Address already in use
-pub const EADDRNOTAVAIL: ::c_int = 99; // Cannot assign requested address
-pub const ECONNABORTED: ::c_int = 103; // Software caused connection abort
-pub const ECONNREFUSED: ::c_int = 111; // Connection refused
-pub const ECONNRESET: ::c_int = 104; // Connection reset by peer
-pub const EDEADLK: ::c_int = 35; // Resource deadlock would occur
-pub const ENOSYS: ::c_int = 38; // Function not implemented
-pub const ENOTCONN: ::c_int = 107; // Transport endpoint is not connected
-pub const ETIMEDOUT: ::c_int = 110; // connection timed out
-pub const O_APPEND: ::c_int = 02000;
-pub const O_ACCMODE: ::c_int = 0003;
-pub const O_CLOEXEC: ::c_int = 0x80000;
-pub const O_CREAT: ::c_int = 0100;
-pub const O_DIRECTORY: ::c_int = 0200000;
-pub const O_EXCL: ::c_int = 0200;
-pub const O_NONBLOCK: ::c_int = 04000;
-pub const O_TRUNC: ::c_int = 01000;
-pub const NCCS: usize = 32;
-pub const SIG_SETMASK: ::c_int = 2; // Set the set of blocked signals
-pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 40;
-pub const __SIZEOF_PTHREAD_MUTEXATTR_T: usize = 4;
-pub const SO_BROADCAST: ::c_int = 6;
-pub const SOCK_DGRAM: ::c_int = 2; // connectionless, unreliable datagrams
-pub const SOCK_STREAM: ::c_int = 1; // …/common/bits/socket_type.h
-pub const SO_ERROR: ::c_int = 4;
-pub const SOL_SOCKET: ::c_int = 1;
-pub const SO_RCVTIMEO: ::c_int = 20;
-pub const SO_REUSEADDR: ::c_int = 2;
-pub const SO_SNDTIMEO: ::c_int = 21;
-pub const RLIM_INFINITY: u64 = 0xffffffffffffffff;
-pub const __SIZEOF_PTHREAD_COND_T: usize = 48;
-pub const __SIZEOF_PTHREAD_CONDATTR_T: usize = 4;
-pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 56;
-
-cfg_if! {
- if #[cfg(target_os = "l4re")] {
- mod l4re;
- pub use self::l4re::*;
- } else {
- mod other;
- pub use other::*;
- }
-}
-
-cfg_if! {
- if #[cfg(libc_align)] {
- #[macro_use]
- mod align;
- } else {
- #[macro_use]
- mod no_align;
- }
-}
-expand_align!();
diff --git a/libc/src/unix/uclibc/x86_64/no_align.rs b/libc/src/unix/uclibc/x86_64/no_align.rs
deleted file mode 100644
index 422d78f..0000000
--- a/libc/src/unix/uclibc/x86_64/no_align.rs
+++ /dev/null
@@ -1,59 +0,0 @@
-macro_rules! expand_align {
- () => {
- s! {
- pub struct sem_t { // ToDo
- #[cfg(target_pointer_width = "32")]
- __size: [::c_char; 16],
- #[cfg(target_pointer_width = "64")]
- __size: [::c_char; 32],
- __align: [::c_long; 0],
- }
-
- pub struct pthread_mutex_t { // ToDo
- #[cfg(any(target_arch = "mips",
- target_arch = "arm",
- target_arch = "powerpc"))]
- __align: [::c_long; 0],
- #[cfg(not(any(target_arch = "mips",
- target_arch = "arm",
- target_arch = "powerpc")))]
- __align: [::c_longlong; 0],
- size: [u8; ::__SIZEOF_PTHREAD_MUTEX_T],
- }
-
- 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",
- target_arch = "mips64", target_arch = "s390x",
- target_arch = "sparc64")))]
- __align: [::c_long; 0],
- size: [u8; ::__SIZEOF_PTHREAD_MUTEXATTR_T],
- }
-
- pub struct pthread_cond_t { // ToDo
- __align: [::c_longlong; 0],
- size: [u8; ::__SIZEOF_PTHREAD_COND_T],
- }
-
- pub struct pthread_condattr_t { // ToDo
- __align: [::c_int; 0],
- size: [u8; ::__SIZEOF_PTHREAD_CONDATTR_T],
- }
-
- pub struct pthread_rwlock_t { // ToDo
- #[cfg(any(target_arch = "mips",
- target_arch = "arm",
- target_arch = "powerpc"))]
- __align: [::c_long; 0],
- #[cfg(not(any(target_arch = "mips",
- target_arch = "arm",
- target_arch = "powerpc")))]
- __align: [::c_longlong; 0],
- size: [u8; ::__SIZEOF_PTHREAD_RWLOCK_T],
- }
- }
- }
-}
diff --git a/libc/src/unix/uclibc/x86_64/other.rs b/libc/src/unix/uclibc/x86_64/other.rs
deleted file mode 100644
index 481577c..0000000
--- a/libc/src/unix/uclibc/x86_64/other.rs
+++ /dev/null
@@ -1,5 +0,0 @@
-// Thestyle checker discourages the use of #[cfg], so this has to go into a
-// separate module
-pub type pthread_t = ::c_ulong;
-
-pub const PTHREAD_STACK_MIN: usize = 16384;
diff --git a/libc/src/wasi.rs b/libc/src/wasi.rs
deleted file mode 100644
index 95a0837..0000000
--- a/libc/src/wasi.rs
+++ /dev/null
@@ -1,1328 +0,0 @@
-pub use ffi::c_void;
-
-pub type c_char = i8;
-pub type c_uchar = u8;
-pub type c_int = i32;
-pub type c_uint = u32;
-pub type c_short = i16;
-pub type c_ushort = u16;
-pub type c_long = i32;
-pub type c_ulong = u32;
-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 ssize_t = isize;
-pub type ptrdiff_t = isize;
-pub type intptr_t = isize;
-pub type uintptr_t = usize;
-pub type off_t = i64;
-pub type pid_t = i32;
-pub type clock_t = c_longlong;
-pub type time_t = c_longlong;
-pub type c_double = f64;
-pub type c_float = f32;
-pub type ino_t = u64;
-pub type sigset_t = c_uchar;
-pub type suseconds_t = c_longlong;
-pub type mode_t = u32;
-pub type dev_t = u64;
-pub type uid_t = u32;
-pub type gid_t = u32;
-pub type nlink_t = u64;
-pub type blksize_t = c_long;
-pub type blkcnt_t = i64;
-pub type nfds_t = c_ulong;
-
-pub type __wasi_advice_t = u8;
-pub type __wasi_clockid_t = u32;
-pub type __wasi_device_t = u64;
-pub type __wasi_dircookie_t = u64;
-pub type __wasi_errno_t = u16;
-pub type __wasi_eventrwflags_t = u16;
-pub type __wasi_eventtype_t = u8;
-pub type __wasi_exitcode_t = u32;
-pub type __wasi_fd_t = u32;
-pub type __wasi_fdflags_t = u16;
-pub type __wasi_filedelta_t = i64;
-pub type __wasi_filesize_t = u64;
-pub type __wasi_filetype_t = u8;
-pub type __wasi_fstflags_t = u16;
-pub type __wasi_inode_t = u64;
-pub type __wasi_linkcount_t = u32;
-pub type __wasi_lookupflags_t = u32;
-pub type __wasi_oflags_t = u16;
-pub type __wasi_riflags_t = u16;
-pub type __wasi_rights_t = u64;
-pub type __wasi_roflags_t = u16;
-pub type __wasi_sdflags_t = u8;
-pub type __wasi_siflags_t = u16;
-pub type __wasi_signal_t = u8;
-pub type __wasi_subclockflags_t = u16;
-pub type __wasi_timestamp_t = u64;
-pub type __wasi_userdata_t = u64;
-pub type __wasi_whence_t = u8;
-pub type __wasi_preopentype_t = u8;
-
-#[allow(missing_copy_implementations)]
-#[cfg_attr(feature = "extra_traits", derive(Debug))]
-pub enum FILE {}
-#[allow(missing_copy_implementations)]
-#[cfg_attr(feature = "extra_traits", derive(Debug))]
-pub enum DIR {}
-#[allow(missing_copy_implementations)]
-#[cfg_attr(feature = "extra_traits", derive(Debug))]
-pub enum __locale_struct {}
-
-pub type locale_t = *mut __locale_struct;
-
-s! {
- #[repr(align(8))]
- pub struct fpos_t {
- data: [u8; 16],
- }
-
- 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 __tm_gmtoff: c_int,
- pub __tm_zone: *const c_char,
- pub __tm_nsec: c_int,
- }
-
- pub struct timeval {
- pub tv_sec: time_t,
- pub tv_usec: suseconds_t,
- }
-
- pub struct timespec {
- pub tv_sec: time_t,
- pub tv_nsec: c_long,
- }
-
- 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 itimerspec {
- pub it_interval: timespec,
- pub it_value: timespec,
- }
-
- pub struct iovec {
- pub iov_base: *mut c_void,
- pub iov_len: size_t,
- }
-
- 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 pollfd {
- pub fd: c_int,
- pub events: c_short,
- pub revents: c_short,
- }
-
- pub struct rusage {
- pub ru_utime: timeval,
- pub ru_stime: timeval,
- }
-
- 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_uint,
- pub st_rdev: dev_t,
- pub st_size: off_t,
- pub st_blksize: blksize_t,
- pub st_blocks: blkcnt_t,
- pub st_atim: timespec,
- pub st_mtim: timespec,
- pub st_ctim: timespec,
- __reserved: [c_longlong; 3],
- }
-
- pub struct __wasi_dirent_t {
- pub d_next: __wasi_dircookie_t,
- pub d_ino: __wasi_inode_t,
- pub d_namlen: u32,
- pub d_type: __wasi_filetype_t,
- }
-
- pub struct __wasi_event_u_fd_readwrite_t {
- pub nbytes: __wasi_filesize_t,
- pub flags: __wasi_eventrwflags_t,
- }
-
- pub struct __wasi_fdstat_t {
- pub fs_filetype: __wasi_filetype_t,
- pub fs_flags: __wasi_fdflags_t,
- pub fs_rights_base: __wasi_rights_t,
- pub fs_rights_inheriting: __wasi_rights_t,
- }
-
- pub struct __wasi_filestat_t {
- pub st_dev: __wasi_device_t,
- pub st_ino: __wasi_inode_t,
- pub st_filetype: __wasi_filetype_t,
- pub st_nlink: __wasi_linkcount_t,
- pub st_size: __wasi_filesize_t,
- pub st_atim: __wasi_timestamp_t,
- pub st_mtim: __wasi_timestamp_t,
- pub st_ctim: __wasi_timestamp_t,
- }
-
- pub struct __wasi_ciovec_t {
- pub buf: *const ::c_void,
- pub buf_len: size_t,
- }
-
- pub struct __wasi_iovec_t {
- pub buf: *mut ::c_void,
- pub buf_len: size_t,
- }
-
- pub struct __wasi_subscription_u_clock_t {
- pub identifier: __wasi_userdata_t,
- pub clock_id: __wasi_clockid_t,
- pub timeout: __wasi_timestamp_t,
- pub precision: __wasi_timestamp_t,
- pub flags: __wasi_subclockflags_t,
- }
-
- pub struct __wasi_subscription_u_fd_readwrite_t {
- pub fd: __wasi_fd_t,
- }
-
- pub struct __wasi_prestat_u_dir_t {
- pub pr_name_len: size_t,
- }
-}
-
-s_no_extra_traits! {
- #[allow(missing_debug_implementations)]
- pub struct __wasi_subscription_t {
- pub userdata: __wasi_userdata_t,
- pub type_: __wasi_eventtype_t,
- pub u: __wasi_subscription_u,
- }
-
- #[allow(missing_debug_implementations)]
- pub struct __wasi_event_t {
- pub userdata: __wasi_userdata_t,
- pub error: __wasi_errno_t,
- pub type_: __wasi_eventtype_t,
- pub u: __wasi_event_u,
- }
-
- #[allow(missing_debug_implementations)]
- pub union __wasi_event_u {
- pub fd_readwrite: __wasi_event_u_fd_readwrite_t,
- _bindgen_union_align: [u64; 2],
- }
-
- #[allow(missing_debug_implementations)]
- pub union __wasi_subscription_u {
- pub clock: __wasi_subscription_u_clock_t,
- pub fd_readwrite:
- __wasi_subscription_u_fd_readwrite_t,
- _bindgen_union_align: [u64; 5],
- }
-
- #[allow(missing_debug_implementations)]
- pub struct __wasi_prestat_t {
- pub pr_type: __wasi_preopentype_t,
- pub u: __wasi_prestat_u,
- }
-
- #[allow(missing_debug_implementations)]
- pub union __wasi_prestat_u {
- pub dir: __wasi_prestat_u_dir_t,
- }
-
-}
-
-// Declare dirent outside of s! so that it doesn't implement Copy, Eq, Hash,
-// etc., since it contains a flexible array member with a dynamic size.
-#[repr(C)]
-#[allow(missing_copy_implementations)]
-#[cfg_attr(feature = "extra_traits", derive(Debug))]
-pub struct dirent {
- pub d_ino: ino_t,
- pub d_type: c_uchar,
- /// d_name is declared in WASI libc as a flexible array member, which
- /// can't be directly expressed in Rust. As an imperfect workaround,
- /// declare it as a zero-length array instead.
- pub d_name: [c_char; 0],
-}
-
-pub const EXIT_SUCCESS: c_int = 0;
-pub const EXIT_FAILURE: c_int = 1;
-pub const STDIN_FILENO: c_int = 0;
-pub const STDOUT_FILENO: c_int = 1;
-pub const STDERR_FILENO: c_int = 2;
-pub const SEEK_SET: c_int = 2;
-pub const SEEK_CUR: c_int = 0;
-pub const SEEK_END: c_int = 1;
-pub const _IOFBF: c_int = 0;
-pub const _IONBF: c_int = 2;
-pub const _IOLBF: c_int = 1;
-pub const FD_SETSIZE: size_t = 1024;
-pub const O_APPEND: c_int = __WASI_FDFLAG_APPEND as c_int;
-pub const O_DSYNC: c_int = __WASI_FDFLAG_DSYNC as c_int;
-pub const O_NONBLOCK: c_int = __WASI_FDFLAG_NONBLOCK as c_int;
-pub const O_RSYNC: c_int = __WASI_FDFLAG_RSYNC as c_int;
-pub const O_SYNC: c_int = __WASI_FDFLAG_SYNC as c_int;
-pub const O_CREAT: c_int = (__WASI_O_CREAT as c_int) << 12;
-pub const O_DIRECTORY: c_int = (__WASI_O_DIRECTORY as c_int) << 12;
-pub const O_EXCL: c_int = (__WASI_O_EXCL as c_int) << 12;
-pub const O_TRUNC: c_int = (__WASI_O_TRUNC as c_int) << 12;
-pub const O_NOFOLLOW: c_int = 0x01000000;
-pub const O_EXEC: c_int = 0x02000000;
-pub const O_RDONLY: c_int = 0x04000000;
-pub const O_SEARCH: c_int = 0x08000000;
-pub const O_WRONLY: c_int = 0x10000000;
-pub const O_RDWR: c_int = O_WRONLY | O_RDONLY;
-pub const O_ACCMODE: c_int = O_EXEC | O_RDWR | O_SEARCH;
-pub const POSIX_FADV_DONTNEED: c_int = __WASI_ADVICE_DONTNEED as c_int;
-pub const POSIX_FADV_NOREUSE: c_int = __WASI_ADVICE_NOREUSE as c_int;
-pub const POSIX_FADV_NORMAL: c_int = __WASI_ADVICE_NORMAL as c_int;
-pub const POSIX_FADV_RANDOM: c_int = __WASI_ADVICE_RANDOM as c_int;
-pub const POSIX_FADV_SEQUENTIAL: c_int = __WASI_ADVICE_SEQUENTIAL as c_int;
-pub const POSIX_FADV_WILLNEED: c_int = __WASI_ADVICE_WILLNEED as c_int;
-pub const AT_EACCESS: c_int = 0x0;
-pub const AT_SYMLINK_NOFOLLOW: c_int = 0x1;
-pub const AT_SYMLINK_FOLLOW: c_int = 0x2;
-pub const AT_REMOVEDIR: c_int = 0x4;
-
-pub const E2BIG: c_int = __WASI_E2BIG as c_int;
-pub const EACCES: c_int = __WASI_EACCES as c_int;
-pub const EADDRINUSE: c_int = __WASI_EADDRINUSE as c_int;
-pub const EADDRNOTAVAIL: c_int = __WASI_EADDRNOTAVAIL as c_int;
-pub const EAFNOSUPPORT: c_int = __WASI_EAFNOSUPPORT as c_int;
-pub const EAGAIN: c_int = __WASI_EAGAIN as c_int;
-pub const EALREADY: c_int = __WASI_EALREADY as c_int;
-pub const EBADF: c_int = __WASI_EBADF as c_int;
-pub const EBADMSG: c_int = __WASI_EBADMSG as c_int;
-pub const EBUSY: c_int = __WASI_EBUSY as c_int;
-pub const ECANCELED: c_int = __WASI_ECANCELED as c_int;
-pub const ECHILD: c_int = __WASI_ECHILD as c_int;
-pub const ECONNABORTED: c_int = __WASI_ECONNABORTED as c_int;
-pub const ECONNREFUSED: c_int = __WASI_ECONNREFUSED as c_int;
-pub const ECONNRESET: c_int = __WASI_ECONNRESET as c_int;
-pub const EDEADLK: c_int = __WASI_EDEADLK as c_int;
-pub const EDESTADDRREQ: c_int = __WASI_EDESTADDRREQ as c_int;
-pub const EDOM: c_int = __WASI_EDOM as c_int;
-pub const EDQUOT: c_int = __WASI_EDQUOT as c_int;
-pub const EEXIST: c_int = __WASI_EEXIST as c_int;
-pub const EFAULT: c_int = __WASI_EFAULT as c_int;
-pub const EFBIG: c_int = __WASI_EFBIG as c_int;
-pub const EHOSTUNREACH: c_int = __WASI_EHOSTUNREACH as c_int;
-pub const EIDRM: c_int = __WASI_EIDRM as c_int;
-pub const EILSEQ: c_int = __WASI_EILSEQ as c_int;
-pub const EINPROGRESS: c_int = __WASI_EINPROGRESS as c_int;
-pub const EINTR: c_int = __WASI_EINTR as c_int;
-pub const EINVAL: c_int = __WASI_EINVAL as c_int;
-pub const EIO: c_int = __WASI_EIO as c_int;
-pub const EISCONN: c_int = __WASI_EISCONN as c_int;
-pub const EISDIR: c_int = __WASI_EISDIR as c_int;
-pub const ELOOP: c_int = __WASI_ELOOP as c_int;
-pub const EMFILE: c_int = __WASI_EMFILE as c_int;
-pub const EMLINK: c_int = __WASI_EMLINK as c_int;
-pub const EMSGSIZE: c_int = __WASI_EMSGSIZE as c_int;
-pub const EMULTIHOP: c_int = __WASI_EMULTIHOP as c_int;
-pub const ENAMETOOLONG: c_int = __WASI_ENAMETOOLONG as c_int;
-pub const ENETDOWN: c_int = __WASI_ENETDOWN as c_int;
-pub const ENETRESET: c_int = __WASI_ENETRESET as c_int;
-pub const ENETUNREACH: c_int = __WASI_ENETUNREACH as c_int;
-pub const ENFILE: c_int = __WASI_ENFILE as c_int;
-pub const ENOBUFS: c_int = __WASI_ENOBUFS as c_int;
-pub const ENODEV: c_int = __WASI_ENODEV as c_int;
-pub const ENOENT: c_int = __WASI_ENOENT as c_int;
-pub const ENOEXEC: c_int = __WASI_ENOEXEC as c_int;
-pub const ENOLCK: c_int = __WASI_ENOLCK as c_int;
-pub const ENOLINK: c_int = __WASI_ENOLINK as c_int;
-pub const ENOMEM: c_int = __WASI_ENOMEM as c_int;
-pub const ENOMSG: c_int = __WASI_ENOMSG as c_int;
-pub const ENOPROTOOPT: c_int = __WASI_ENOPROTOOPT as c_int;
-pub const ENOSPC: c_int = __WASI_ENOSPC as c_int;
-pub const ENOSYS: c_int = __WASI_ENOSYS as c_int;
-pub const ENOTCONN: c_int = __WASI_ENOTCONN as c_int;
-pub const ENOTDIR: c_int = __WASI_ENOTDIR as c_int;
-pub const ENOTEMPTY: c_int = __WASI_ENOTEMPTY as c_int;
-pub const ENOTRECOVERABLE: c_int = __WASI_ENOTRECOVERABLE as c_int;
-pub const ENOTSOCK: c_int = __WASI_ENOTSOCK as c_int;
-pub const ENOTSUP: c_int = __WASI_ENOTSUP as c_int;
-pub const ENOTTY: c_int = __WASI_ENOTTY as c_int;
-pub const ENXIO: c_int = __WASI_ENXIO as c_int;
-pub const EOVERFLOW: c_int = __WASI_EOVERFLOW as c_int;
-pub const EOWNERDEAD: c_int = __WASI_EOWNERDEAD as c_int;
-pub const EPERM: c_int = __WASI_EPERM as c_int;
-pub const EPIPE: c_int = __WASI_EPIPE as c_int;
-pub const EPROTO: c_int = __WASI_EPROTO as c_int;
-pub const EPROTONOSUPPORT: c_int = __WASI_EPROTONOSUPPORT as c_int;
-pub const EPROTOTYPE: c_int = __WASI_EPROTOTYPE as c_int;
-pub const ERANGE: c_int = __WASI_ERANGE as c_int;
-pub const EROFS: c_int = __WASI_EROFS as c_int;
-pub const ESPIPE: c_int = __WASI_ESPIPE as c_int;
-pub const ESRCH: c_int = __WASI_ESRCH as c_int;
-pub const ESTALE: c_int = __WASI_ESTALE as c_int;
-pub const ETIMEDOUT: c_int = __WASI_ETIMEDOUT as c_int;
-pub const ETXTBSY: c_int = __WASI_ETXTBSY as c_int;
-pub const EXDEV: c_int = __WASI_EXDEV as c_int;
-pub const ENOTCAPABLE: c_int = __WASI_ENOTCAPABLE as c_int;
-pub const EOPNOTSUPP: c_int = ENOTSUP;
-pub const EWOULDBLOCK: c_int = EAGAIN;
-
-pub const __WASI_ADVICE_NORMAL: u8 = 0;
-pub const __WASI_ADVICE_SEQUENTIAL: u8 = 1;
-pub const __WASI_ADVICE_RANDOM: u8 = 2;
-pub const __WASI_ADVICE_WILLNEED: u8 = 3;
-pub const __WASI_ADVICE_DONTNEED: u8 = 4;
-pub const __WASI_ADVICE_NOREUSE: u8 = 5;
-pub const __WASI_CLOCK_REALTIME: u32 = 0;
-pub const __WASI_CLOCK_MONOTONIC: u32 = 1;
-pub const __WASI_CLOCK_PROCESS_CPUTIME_ID: u32 = 2;
-pub const __WASI_CLOCK_THREAD_CPUTIME_ID: u32 = 3;
-pub const __WASI_DIRCOOKIE_START: u64 = 0;
-pub const __WASI_ESUCCESS: u16 = 0;
-pub const __WASI_E2BIG: u16 = 1;
-pub const __WASI_EACCES: u16 = 2;
-pub const __WASI_EADDRINUSE: u16 = 3;
-pub const __WASI_EADDRNOTAVAIL: u16 = 4;
-pub const __WASI_EAFNOSUPPORT: u16 = 5;
-pub const __WASI_EAGAIN: u16 = 6;
-pub const __WASI_EALREADY: u16 = 7;
-pub const __WASI_EBADF: u16 = 8;
-pub const __WASI_EBADMSG: u16 = 9;
-pub const __WASI_EBUSY: u16 = 10;
-pub const __WASI_ECANCELED: u16 = 11;
-pub const __WASI_ECHILD: u16 = 12;
-pub const __WASI_ECONNABORTED: u16 = 13;
-pub const __WASI_ECONNREFUSED: u16 = 14;
-pub const __WASI_ECONNRESET: u16 = 15;
-pub const __WASI_EDEADLK: u16 = 16;
-pub const __WASI_EDESTADDRREQ: u16 = 17;
-pub const __WASI_EDOM: u16 = 18;
-pub const __WASI_EDQUOT: u16 = 19;
-pub const __WASI_EEXIST: u16 = 20;
-pub const __WASI_EFAULT: u16 = 21;
-pub const __WASI_EFBIG: u16 = 22;
-pub const __WASI_EHOSTUNREACH: u16 = 23;
-pub const __WASI_EIDRM: u16 = 24;
-pub const __WASI_EILSEQ: u16 = 25;
-pub const __WASI_EINPROGRESS: u16 = 26;
-pub const __WASI_EINTR: u16 = 27;
-pub const __WASI_EINVAL: u16 = 28;
-pub const __WASI_EIO: u16 = 29;
-pub const __WASI_EISCONN: u16 = 30;
-pub const __WASI_EISDIR: u16 = 31;
-pub const __WASI_ELOOP: u16 = 32;
-pub const __WASI_EMFILE: u16 = 33;
-pub const __WASI_EMLINK: u16 = 34;
-pub const __WASI_EMSGSIZE: u16 = 35;
-pub const __WASI_EMULTIHOP: u16 = 36;
-pub const __WASI_ENAMETOOLONG: u16 = 37;
-pub const __WASI_ENETDOWN: u16 = 38;
-pub const __WASI_ENETRESET: u16 = 39;
-pub const __WASI_ENETUNREACH: u16 = 40;
-pub const __WASI_ENFILE: u16 = 41;
-pub const __WASI_ENOBUFS: u16 = 42;
-pub const __WASI_ENODEV: u16 = 43;
-pub const __WASI_ENOENT: u16 = 44;
-pub const __WASI_ENOEXEC: u16 = 45;
-pub const __WASI_ENOLCK: u16 = 46;
-pub const __WASI_ENOLINK: u16 = 47;
-pub const __WASI_ENOMEM: u16 = 48;
-pub const __WASI_ENOMSG: u16 = 49;
-pub const __WASI_ENOPROTOOPT: u16 = 50;
-pub const __WASI_ENOSPC: u16 = 51;
-pub const __WASI_ENOSYS: u16 = 52;
-pub const __WASI_ENOTCONN: u16 = 53;
-pub const __WASI_ENOTDIR: u16 = 54;
-pub const __WASI_ENOTEMPTY: u16 = 55;
-pub const __WASI_ENOTRECOVERABLE: u16 = 56;
-pub const __WASI_ENOTSOCK: u16 = 57;
-pub const __WASI_ENOTSUP: u16 = 58;
-pub const __WASI_ENOTTY: u16 = 59;
-pub const __WASI_ENXIO: u16 = 60;
-pub const __WASI_EOVERFLOW: u16 = 61;
-pub const __WASI_EOWNERDEAD: u16 = 62;
-pub const __WASI_EPERM: u16 = 63;
-pub const __WASI_EPIPE: u16 = 64;
-pub const __WASI_EPROTO: u16 = 65;
-pub const __WASI_EPROTONOSUPPORT: u16 = 66;
-pub const __WASI_EPROTOTYPE: u16 = 67;
-pub const __WASI_ERANGE: u16 = 68;
-pub const __WASI_EROFS: u16 = 69;
-pub const __WASI_ESPIPE: u16 = 70;
-pub const __WASI_ESRCH: u16 = 71;
-pub const __WASI_ESTALE: u16 = 72;
-pub const __WASI_ETIMEDOUT: u16 = 73;
-pub const __WASI_ETXTBSY: u16 = 74;
-pub const __WASI_EXDEV: u16 = 75;
-pub const __WASI_ENOTCAPABLE: u16 = 76;
-pub const __WASI_EVENT_FD_READWRITE_HANGUP: u16 = 0x0001;
-pub const __WASI_EVENTTYPE_CLOCK: u8 = 0;
-pub const __WASI_EVENTTYPE_FD_READ: u8 = 1;
-pub const __WASI_EVENTTYPE_FD_WRITE: u8 = 2;
-pub const __WASI_FDFLAG_APPEND: u16 = 0x0001;
-pub const __WASI_FDFLAG_DSYNC: u16 = 0x0002;
-pub const __WASI_FDFLAG_NONBLOCK: u16 = 0x0004;
-pub const __WASI_FDFLAG_RSYNC: u16 = 0x0008;
-pub const __WASI_FDFLAG_SYNC: u16 = 0x0010;
-pub const __WASI_FILETYPE_UNKNOWN: u8 = 0;
-pub const __WASI_FILETYPE_BLOCK_DEVICE: u8 = 1;
-pub const __WASI_FILETYPE_CHARACTER_DEVICE: u8 = 2;
-pub const __WASI_FILETYPE_DIRECTORY: u8 = 3;
-pub const __WASI_FILETYPE_REGULAR_FILE: u8 = 4;
-pub const __WASI_FILETYPE_SOCKET_DGRAM: u8 = 5;
-pub const __WASI_FILETYPE_SOCKET_STREAM: u8 = 6;
-pub const __WASI_FILETYPE_SYMBOLIC_LINK: u8 = 7;
-pub const __WASI_FILESTAT_SET_ATIM: u16 = 0x0001;
-pub const __WASI_FILESTAT_SET_ATIM_NOW: u16 = 0x0002;
-pub const __WASI_FILESTAT_SET_MTIM: u16 = 0x0004;
-pub const __WASI_FILESTAT_SET_MTIM_NOW: u16 = 0x0008;
-pub const __WASI_LOOKUP_SYMLINK_FOLLOW: u32 = 0x00000001;
-pub const __WASI_O_CREAT: u16 = 0x0001;
-pub const __WASI_O_DIRECTORY: u16 = 0x0002;
-pub const __WASI_O_EXCL: u16 = 0x0004;
-pub const __WASI_O_TRUNC: u16 = 0x0008;
-pub const __WASI_PREOPENTYPE_DIR: u8 = 0;
-pub const __WASI_SOCK_RECV_PEEK: u16 = 0x0001;
-pub const __WASI_SOCK_RECV_WAITALL: u16 = 0x0002;
-pub const __WASI_RIGHT_FD_DATASYNC: u64 = 0x0000000000000001;
-pub const __WASI_RIGHT_FD_READ: u64 = 0x0000000000000002;
-pub const __WASI_RIGHT_FD_SEEK: u64 = 0x0000000000000004;
-pub const __WASI_RIGHT_FD_FDSTAT_SET_FLAGS: u64 = 0x0000000000000008;
-pub const __WASI_RIGHT_FD_SYNC: u64 = 0x0000000000000010;
-pub const __WASI_RIGHT_FD_TELL: u64 = 0x0000000000000020;
-pub const __WASI_RIGHT_FD_WRITE: u64 = 0x0000000000000040;
-pub const __WASI_RIGHT_FD_ADVISE: u64 = 0x0000000000000080;
-pub const __WASI_RIGHT_FD_ALLOCATE: u64 = 0x0000000000000100;
-pub const __WASI_RIGHT_PATH_CREATE_DIRECTORY: u64 = 0x0000000000000200;
-pub const __WASI_RIGHT_PATH_CREATE_FILE: u64 = 0x0000000000000400;
-pub const __WASI_RIGHT_PATH_LINK_SOURCE: u64 = 0x0000000000000800;
-pub const __WASI_RIGHT_PATH_LINK_TARGET: u64 = 0x0000000000001000;
-pub const __WASI_RIGHT_PATH_OPEN: u64 = 0x0000000000002000;
-pub const __WASI_RIGHT_FD_READDIR: u64 = 0x0000000000004000;
-pub const __WASI_RIGHT_PATH_READLINK: u64 = 0x0000000000008000;
-pub const __WASI_RIGHT_PATH_RENAME_SOURCE: u64 = 0x0000000000010000;
-pub const __WASI_RIGHT_PATH_RENAME_TARGET: u64 = 0x0000000000020000;
-pub const __WASI_RIGHT_PATH_FILESTAT_GET: u64 = 0x0000000000040000;
-pub const __WASI_RIGHT_PATH_FILESTAT_SET_SIZE: u64 = 0x0000000000080000;
-pub const __WASI_RIGHT_PATH_FILESTAT_SET_TIMES: u64 = 0x0000000000100000;
-pub const __WASI_RIGHT_FD_FILESTAT_GET: u64 = 0x0000000000200000;
-pub const __WASI_RIGHT_FD_FILESTAT_SET_SIZE: u64 = 0x0000000000400000;
-pub const __WASI_RIGHT_FD_FILESTAT_SET_TIMES: u64 = 0x0000000000800000;
-pub const __WASI_RIGHT_PATH_SYMLINK: u64 = 0x0000000001000000;
-pub const __WASI_RIGHT_PATH_REMOVE_DIRECTORY: u64 = 0x0000000002000000;
-pub const __WASI_RIGHT_PATH_UNLINK_FILE: u64 = 0x0000000004000000;
-pub const __WASI_RIGHT_POLL_FD_READWRITE: u64 = 0x0000000008000000;
-pub const __WASI_RIGHT_SOCK_SHUTDOWN: u64 = 0x0000000010000000;
-pub const __WASI_SOCK_RECV_DATA_TRUNCATED: u16 = 0x0001;
-pub const __WASI_SHUT_RD: u8 = 0x01;
-pub const __WASI_SHUT_WR: u8 = 0x02;
-pub const __WASI_SIGHUP: u8 = 1;
-pub const __WASI_SIGINT: u8 = 2;
-pub const __WASI_SIGQUIT: u8 = 3;
-pub const __WASI_SIGILL: u8 = 4;
-pub const __WASI_SIGTRAP: u8 = 5;
-pub const __WASI_SIGABRT: u8 = 6;
-pub const __WASI_SIGBUS: u8 = 7;
-pub const __WASI_SIGFPE: u8 = 8;
-pub const __WASI_SIGKILL: u8 = 9;
-pub const __WASI_SIGUSR1: u8 = 10;
-pub const __WASI_SIGSEGV: u8 = 11;
-pub const __WASI_SIGUSR2: u8 = 12;
-pub const __WASI_SIGPIPE: u8 = 13;
-pub const __WASI_SIGALRM: u8 = 14;
-pub const __WASI_SIGTERM: u8 = 15;
-pub const __WASI_SIGCHLD: u8 = 16;
-pub const __WASI_SIGCONT: u8 = 17;
-pub const __WASI_SIGSTOP: u8 = 18;
-pub const __WASI_SIGTSTP: u8 = 19;
-pub const __WASI_SIGTTIN: u8 = 20;
-pub const __WASI_SIGTTOU: u8 = 21;
-pub const __WASI_SIGURG: u8 = 22;
-pub const __WASI_SIGXCPU: u8 = 23;
-pub const __WASI_SIGXFSZ: u8 = 24;
-pub const __WASI_SIGVTALRM: u8 = 25;
-pub const __WASI_SIGPROF: u8 = 26;
-pub const __WASI_SIGWINCH: u8 = 27;
-pub const __WASI_SIGPOLL: u8 = 28;
-pub const __WASI_SIGPWR: u8 = 29;
-pub const __WASI_SIGSYS: u8 = 30;
-pub const __WASI_SUBSCRIPTION_CLOCK_ABSTIME: u16 = 0x0001;
-pub const __WASI_WHENCE_CUR: u8 = 0;
-pub const __WASI_WHENCE_END: u8 = 1;
-pub const __WASI_WHENCE_SET: u8 = 2;
-
-#[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 {
- pub fn _Exit(code: c_int) -> !;
- pub fn _exit(code: c_int) -> !;
- pub fn abort() -> !;
- pub fn aligned_alloc(a: size_t, b: size_t) -> *mut c_void;
- pub fn calloc(amt: size_t, amt2: size_t) -> *mut c_void;
- pub fn exit(code: c_int) -> !;
- pub fn free(ptr: *mut c_void);
- pub fn getenv(s: *const c_char) -> *mut c_char;
- pub fn malloc(amt: size_t) -> *mut c_void;
- pub fn malloc_usable_size(ptr: *mut c_void) -> size_t;
- pub fn sbrk(increment: ::intptr_t) -> *mut ::c_void;
- pub fn rand() -> c_int;
- pub fn read(fd: c_int, ptr: *mut c_void, size: size_t) -> ssize_t;
- pub fn realloc(ptr: *mut c_void, amt: size_t) -> *mut c_void;
- pub fn setenv(k: *const c_char, v: *const c_char, a: c_int) -> c_int;
- pub fn unsetenv(k: *const c_char) -> c_int;
- pub fn clearenv() -> ::c_int;
- pub fn write(fd: c_int, ptr: *const c_void, size: size_t) -> ssize_t;
- pub static mut environ: *mut *mut c_char;
- pub fn fopen(a: *const c_char, b: *const c_char) -> *mut FILE;
- pub fn freopen(
- a: *const c_char,
- b: *const c_char,
- f: *mut FILE,
- ) -> *mut FILE;
- pub fn fclose(f: *mut FILE) -> c_int;
- pub fn remove(a: *const c_char) -> c_int;
- pub fn rename(a: *const c_char, b: *const c_char) -> c_int;
- pub fn feof(f: *mut FILE) -> c_int;
- pub fn ferror(f: *mut FILE) -> c_int;
- pub fn fflush(f: *mut FILE) -> c_int;
- pub fn clearerr(f: *mut FILE);
- pub fn fseek(f: *mut FILE, b: c_long, c: c_int) -> c_int;
- pub fn ftell(f: *mut FILE) -> c_long;
- pub fn rewind(f: *mut FILE);
- pub fn fgetpos(f: *mut FILE, pos: *mut fpos_t) -> c_int;
- pub fn fsetpos(f: *mut FILE, pos: *const fpos_t) -> c_int;
- pub fn fread(
- buf: *mut c_void,
- a: size_t,
- b: size_t,
- f: *mut FILE,
- ) -> size_t;
- pub fn fwrite(
- buf: *const c_void,
- a: size_t,
- b: size_t,
- f: *mut FILE,
- ) -> size_t;
- pub fn fgetc(f: *mut FILE) -> c_int;
- pub fn getc(f: *mut FILE) -> c_int;
- pub fn getchar() -> c_int;
- pub fn ungetc(a: c_int, f: *mut FILE) -> c_int;
- pub fn fputc(a: c_int, f: *mut FILE) -> c_int;
- pub fn putc(a: c_int, f: *mut FILE) -> c_int;
- pub fn putchar(a: c_int) -> c_int;
- pub fn fputs(a: *const c_char, f: *mut FILE) -> c_int;
- pub fn puts(a: *const c_char) -> c_int;
- pub fn perror(a: *const c_char);
- pub fn srand(a: c_uint);
- pub fn atexit(a: extern fn()) -> c_int;
- pub fn at_quick_exit(a: extern fn()) -> c_int;
- pub fn quick_exit(a: c_int) -> !;
- pub fn posix_memalign(a: *mut *mut c_void, b: size_t, c: size_t) -> c_int;
- pub fn rand_r(a: *mut c_uint) -> c_int;
- pub fn random() -> c_long;
- pub fn srandom(a: c_uint);
- pub fn putenv(a: *mut c_char) -> c_int;
- pub fn clock() -> clock_t;
- pub fn time(a: *mut time_t) -> time_t;
- pub fn difftime(a: time_t, b: time_t) -> c_double;
- pub fn mktime(a: *mut tm) -> time_t;
- pub fn strftime(
- a: *mut c_char,
- b: size_t,
- c: *const c_char,
- d: *const tm,
- ) -> size_t;
- pub fn gmtime(a: *const time_t) -> *mut tm;
- pub fn gmtime_r(a: *const time_t, b: *mut tm) -> *mut tm;
- pub fn localtime_r(a: *const time_t, b: *mut tm) -> *mut tm;
- pub fn asctime_r(a: *const tm, b: *mut c_char) -> *mut c_char;
- pub fn ctime_r(a: *const time_t, b: *mut c_char) -> *mut c_char;
-
- pub fn nanosleep(a: *const timespec, b: *mut timespec) -> c_int;
- // pub fn clock_getres(a: clockid_t, b: *mut timespec) -> c_int;
- // pub fn clock_gettime(a: clockid_t, b: *mut timespec) -> c_int;
- // pub fn clock_nanosleep(
- // a: clockid_t,
- // a2: c_int,
- // b: *const timespec,
- // c: *mut timespec,
- // ) -> c_int;
-
- 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 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 fgets(buf: *mut c_char, n: c_int, stream: *mut FILE)
- -> *mut c_char;
- pub fn atoi(s: *const c_char) -> c_int;
- pub fn atof(s: *const c_char) -> c_double;
- 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 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 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 fprintf(
- stream: *mut ::FILE,
- format: *const ::c_char,
- ...
- ) -> ::c_int;
- pub fn printf(format: *const ::c_char, ...) -> ::c_int;
- pub fn snprintf(
- s: *mut ::c_char,
- n: ::size_t,
- format: *const ::c_char,
- ...
- ) -> ::c_int;
- pub fn sprintf(s: *mut ::c_char, format: *const ::c_char, ...) -> ::c_int;
- pub fn fscanf(
- stream: *mut ::FILE,
- format: *const ::c_char,
- ...
- ) -> ::c_int;
- pub fn scanf(format: *const ::c_char, ...) -> ::c_int;
- pub fn sscanf(s: *const ::c_char, format: *const ::c_char, ...)
- -> ::c_int;
- pub fn getchar_unlocked() -> ::c_int;
- pub fn putchar_unlocked(c: ::c_int) -> ::c_int;
-
- pub fn shutdown(socket: ::c_int, how: ::c_int) -> ::c_int;
- pub fn fstat(fildes: ::c_int, buf: *mut stat) -> ::c_int;
- pub fn mkdir(path: *const c_char, mode: mode_t) -> ::c_int;
- pub fn stat(path: *const c_char, buf: *mut stat) -> ::c_int;
- pub fn fdopen(fd: ::c_int, mode: *const c_char) -> *mut ::FILE;
- pub fn fileno(stream: *mut ::FILE) -> ::c_int;
- pub fn open(path: *const c_char, oflag: ::c_int, ...) -> ::c_int;
- pub fn creat(path: *const c_char, mode: mode_t) -> ::c_int;
- pub fn fcntl(fd: ::c_int, cmd: ::c_int, ...) -> ::c_int;
- pub fn opendir(dirname: *const c_char) -> *mut ::DIR;
- pub fn fdopendir(fd: ::c_int) -> *mut ::DIR;
- pub fn readdir(dirp: *mut ::DIR) -> *mut ::dirent;
- pub fn closedir(dirp: *mut ::DIR) -> ::c_int;
- pub fn rewinddir(dirp: *mut ::DIR);
- pub fn dirfd(dirp: *mut ::DIR) -> ::c_int;
-
- pub fn openat(
- dirfd: ::c_int,
- pathname: *const ::c_char,
- flags: ::c_int,
- ...
- ) -> ::c_int;
- 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,
- newdirfd: ::c_int,
- newpath: *const ::c_char,
- flags: ::c_int,
- ) -> ::c_int;
- pub fn mkdirat(
- dirfd: ::c_int,
- pathname: *const ::c_char,
- mode: ::mode_t,
- ) -> ::c_int;
- pub fn readlinkat(
- dirfd: ::c_int,
- pathname: *const ::c_char,
- buf: *mut ::c_char,
- bufsiz: ::size_t,
- ) -> ::ssize_t;
- pub fn renameat(
- olddirfd: ::c_int,
- oldpath: *const ::c_char,
- newdirfd: ::c_int,
- newpath: *const ::c_char,
- ) -> ::c_int;
- pub fn symlinkat(
- target: *const ::c_char,
- newdirfd: ::c_int,
- linkpath: *const ::c_char,
- ) -> ::c_int;
- pub fn unlinkat(
- dirfd: ::c_int,
- pathname: *const ::c_char,
- flags: ::c_int,
- ) -> ::c_int;
-
- pub fn access(path: *const c_char, amode: ::c_int) -> ::c_int;
- pub fn close(fd: ::c_int) -> ::c_int;
- pub fn fpathconf(filedes: ::c_int, name: ::c_int) -> c_long;
- pub fn getopt(
- argc: ::c_int,
- argv: *const *mut c_char,
- optstr: *const c_char,
- ) -> ::c_int;
- pub fn isatty(fd: ::c_int) -> ::c_int;
- pub fn link(src: *const c_char, dst: *const c_char) -> ::c_int;
- pub fn lseek(fd: ::c_int, offset: off_t, whence: ::c_int) -> off_t;
- pub fn pathconf(path: *const c_char, name: ::c_int) -> c_long;
- pub fn pause() -> ::c_int;
- pub fn rmdir(path: *const c_char) -> ::c_int;
- pub fn sleep(secs: ::c_uint) -> ::c_uint;
- pub fn unlink(c: *const c_char) -> ::c_int;
- pub fn pread(
- fd: ::c_int,
- buf: *mut ::c_void,
- count: ::size_t,
- offset: off_t,
- ) -> ::ssize_t;
- pub fn pwrite(
- fd: ::c_int,
- buf: *const ::c_void,
- count: ::size_t,
- offset: off_t,
- ) -> ::ssize_t;
-
- pub fn lstat(path: *const c_char, buf: *mut stat) -> ::c_int;
-
- pub fn fsync(fd: ::c_int) -> ::c_int;
- pub fn fdatasync(fd: ::c_int) -> ::c_int;
-
- 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 getrusage(resource: ::c_int, usage: *mut rusage) -> ::c_int;
-
- pub fn gettimeofday(tp: *mut ::timeval, tz: *mut ::c_void) -> ::c_int;
- pub fn times(buf: *mut ::tms) -> ::clock_t;
-
- pub fn strerror_r(
- errnum: ::c_int,
- buf: *mut c_char,
- buflen: ::size_t,
- ) -> ::c_int;
-
- pub fn usleep(secs: ::c_uint) -> ::c_int;
- pub fn send(
- socket: ::c_int,
- buf: *const ::c_void,
- len: ::size_t,
- flags: ::c_int,
- ) -> ::ssize_t;
- pub fn recv(
- socket: ::c_int,
- buf: *mut ::c_void,
- len: ::size_t,
- flags: ::c_int,
- ) -> ::ssize_t;
- pub fn poll(fds: *mut pollfd, nfds: nfds_t, timeout: ::c_int) -> ::c_int;
- pub fn setlocale(
- category: ::c_int,
- locale: *const ::c_char,
- ) -> *mut ::c_char;
- pub fn localeconv() -> *mut lconv;
-
- pub fn readlink(
- path: *const c_char,
- buf: *mut c_char,
- bufsz: ::size_t,
- ) -> ::ssize_t;
-
- pub fn timegm(tm: *mut ::tm) -> time_t;
-
- pub fn sysconf(name: ::c_int) -> ::c_long;
-
- pub fn fseeko(
- stream: *mut ::FILE,
- offset: ::off_t,
- whence: ::c_int,
- ) -> ::c_int;
- pub fn ftello(stream: *mut ::FILE) -> ::off_t;
- pub fn posix_fallocate(
- fd: ::c_int,
- offset: ::off_t,
- len: ::off_t,
- ) -> ::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;
-
- pub fn faccessat(
- dirfd: ::c_int,
- pathname: *const ::c_char,
- mode: ::c_int,
- flags: ::c_int,
- ) -> ::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 pwritev(
- fd: ::c_int,
- iov: *const ::iovec,
- iovcnt: ::c_int,
- offset: ::off_t,
- ) -> ::ssize_t;
- pub fn preadv(
- fd: ::c_int,
- iov: *const ::iovec,
- iovcnt: ::c_int,
- offset: ::off_t,
- ) -> ::ssize_t;
- pub fn posix_fadvise(
- fd: ::c_int,
- offset: ::off_t,
- len: ::off_t,
- advise: ::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 getentropy(buf: *mut ::c_void, buflen: ::size_t) -> ::c_int;
- pub fn memrchr(
- cx: *const ::c_void,
- c: ::c_int,
- n: ::size_t,
- ) -> *mut ::c_void;
- pub fn abs(i: c_int) -> c_int;
- pub fn labs(i: c_long) -> c_long;
- pub fn duplocale(base: ::locale_t) -> ::locale_t;
- pub fn freelocale(loc: ::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 sched_yield() -> ::c_int;
-
- pub fn __wasilibc_register_preopened_fd(
- fd: c_int,
- path: *const c_char,
- ) -> c_int;
- pub fn __wasilibc_fd_renumber(fd: c_int, newfd: c_int) -> c_int;
- pub fn __wasilibc_unlinkat(fd: c_int, path: *const c_char) -> c_int;
- pub fn __wasilibc_rmdirat(fd: c_int, path: *const c_char) -> c_int;
- pub fn __wasilibc_init_preopen();
- pub fn __wasilibc_find_relpath(
- path: *const c_char,
- rights_base: __wasi_rights_t,
- rights_inheriting: __wasi_rights_t,
- relative_path: *mut *const c_char,
- ) -> c_int;
- pub fn __wasilibc_tell(fd: c_int) -> ::off_t;
-
- pub fn arc4random() -> u32;
- pub fn arc4random_buf(a: *mut c_void, b: size_t);
- pub fn arc4random_uniform(a: u32) -> u32;
-}
-
-#[link(wasm_import_module = "wasi_unstable")]
-extern {
- #[link_name = "clock_res_get"]
- pub fn __wasi_clock_res_get(
- clock_id: __wasi_clockid_t,
- resolution: *mut __wasi_timestamp_t,
- ) -> __wasi_errno_t;
- #[link_name = "clock_time_get"]
- pub fn __wasi_clock_time_get(
- clock_id: __wasi_clockid_t,
- precision: __wasi_timestamp_t,
- time: *mut __wasi_timestamp_t,
- ) -> __wasi_errno_t;
- #[link_name = "fd_close"]
- pub fn __wasi_fd_close(fd: __wasi_fd_t) -> __wasi_errno_t;
- #[link_name = "fd_datasync"]
- pub fn __wasi_fd_datasync(fd: __wasi_fd_t) -> __wasi_errno_t;
- #[link_name = "fd_pread"]
- pub fn __wasi_fd_pread(
- fd: __wasi_fd_t,
- iovs: *const __wasi_iovec_t,
- iovs_len: size_t,
- offset: __wasi_filesize_t,
- nread: *mut size_t,
- ) -> __wasi_errno_t;
- #[link_name = "fd_pwrite"]
- pub fn __wasi_fd_pwrite(
- fd: __wasi_fd_t,
- iovs: *const __wasi_ciovec_t,
- iovs_len: size_t,
- offset: __wasi_filesize_t,
- nwritten: *mut size_t,
- ) -> __wasi_errno_t;
- #[link_name = "fd_read"]
- pub fn __wasi_fd_read(
- fd: __wasi_fd_t,
- iovs: *const __wasi_iovec_t,
- iovs_len: size_t,
- nread: *mut size_t,
- ) -> __wasi_errno_t;
- #[link_name = "fd_renumber"]
- pub fn __wasi_fd_renumber(
- from: __wasi_fd_t,
- to: __wasi_fd_t,
- ) -> __wasi_errno_t;
- #[link_name = "fd_seek"]
- pub fn __wasi_fd_seek(
- fd: __wasi_fd_t,
- offset: __wasi_filedelta_t,
- whence: __wasi_whence_t,
- newoffset: *mut __wasi_filesize_t,
- ) -> __wasi_errno_t;
- #[link_name = "fd_tell"]
- pub fn __wasi_fd_tell(
- fd: __wasi_fd_t,
- newoffset: *mut __wasi_filesize_t,
- ) -> __wasi_errno_t;
- #[link_name = "fd_fdstat_get"]
- pub fn __wasi_fd_fdstat_get(
- fd: __wasi_fd_t,
- buf: *mut __wasi_fdstat_t,
- ) -> __wasi_errno_t;
- #[link_name = "fd_fdstat_set_flags"]
- pub fn __wasi_fd_fdstat_set_flags(
- fd: __wasi_fd_t,
- flags: __wasi_fdflags_t,
- ) -> __wasi_errno_t;
- #[link_name = "fd_fdstat_set_rights"]
- pub fn __wasi_fd_fdstat_set_rights(
- fd: __wasi_fd_t,
- fs_rights_base: __wasi_rights_t,
- fs_rights_inheriting: __wasi_rights_t,
- ) -> __wasi_errno_t;
- #[link_name = "fd_sync"]
- pub fn __wasi_fd_sync(fd: __wasi_fd_t) -> __wasi_errno_t;
- #[link_name = "fd_write"]
- pub fn __wasi_fd_write(
- fd: __wasi_fd_t,
- iovs: *const __wasi_ciovec_t,
- iovs_len: size_t,
- nwritten: *mut size_t,
- ) -> __wasi_errno_t;
- #[link_name = "fd_advise"]
- pub fn __wasi_fd_advise(
- fd: __wasi_fd_t,
- offset: __wasi_filesize_t,
- len: __wasi_filesize_t,
- advice: __wasi_advice_t,
- ) -> __wasi_errno_t;
- #[link_name = "fd_allocate"]
- pub fn __wasi_fd_allocate(
- fd: __wasi_fd_t,
- offset: __wasi_filesize_t,
- len: __wasi_filesize_t,
- ) -> __wasi_errno_t;
- #[link_name = "path_create_directory"]
- pub fn __wasi_path_create_directory(
- fd: __wasi_fd_t,
- path: *const ::c_char,
- path_len: size_t,
- ) -> __wasi_errno_t;
- #[link_name = "path_link"]
- pub fn __wasi_path_link(
- old_fd: __wasi_fd_t,
- old_flags: __wasi_lookupflags_t,
- old_path: *const ::c_char,
- old_path_len: size_t,
- new_fd: __wasi_fd_t,
- new_path: *const ::c_char,
- new_path_len: size_t,
- ) -> __wasi_errno_t;
- #[link_name = "path_open"]
- pub fn __wasi_path_open(
- dirfd: __wasi_fd_t,
- dirflags: __wasi_lookupflags_t,
- path: *const ::c_char,
- path_len: size_t,
- oflags: __wasi_oflags_t,
- fs_rights_base: __wasi_rights_t,
- fs_rights_inheriting: __wasi_rights_t,
- fs_flags: __wasi_fdflags_t,
- fd: *mut __wasi_fd_t,
- ) -> __wasi_errno_t;
- #[link_name = "fd_readdir"]
- pub fn __wasi_fd_readdir(
- fd: __wasi_fd_t,
- buf: *mut ::c_void,
- buf_len: size_t,
- cookie: __wasi_dircookie_t,
- bufused: *mut size_t,
- ) -> __wasi_errno_t;
- #[link_name = "path_readlink"]
- pub fn __wasi_path_readlink(
- fd: __wasi_fd_t,
- path: *const ::c_char,
- path_len: size_t,
- buf: *mut ::c_char,
- buf_len: size_t,
- bufused: *mut size_t,
- ) -> __wasi_errno_t;
- #[link_name = "path_rename"]
- pub fn __wasi_path_rename(
- old_fd: __wasi_fd_t,
- old_path: *const ::c_char,
- old_path_len: size_t,
- new_fd: __wasi_fd_t,
- new_path: *const ::c_char,
- new_path_len: size_t,
- ) -> __wasi_errno_t;
- #[link_name = "fd_filestat_get"]
- pub fn __wasi_fd_filestat_get(
- fd: __wasi_fd_t,
- buf: *mut __wasi_filestat_t,
- ) -> __wasi_errno_t;
- #[link_name = "fd_filestat_set_times"]
- pub fn __wasi_fd_filestat_set_times(
- fd: __wasi_fd_t,
- st_atim: __wasi_timestamp_t,
- st_mtim: __wasi_timestamp_t,
- fstflags: __wasi_fstflags_t,
- ) -> __wasi_errno_t;
- #[link_name = "fd_filestat_set_size"]
- pub fn __wasi_fd_filestat_set_size(
- fd: __wasi_fd_t,
- st_size: __wasi_filesize_t,
- ) -> __wasi_errno_t;
- #[link_name = "path_filestat_get"]
- pub fn __wasi_path_filestat_get(
- fd: __wasi_fd_t,
- flags: __wasi_lookupflags_t,
- path: *const ::c_char,
- path_len: size_t,
- buf: *mut __wasi_filestat_t,
- ) -> __wasi_errno_t;
- #[link_name = "path_filestat_set_times"]
- pub fn __wasi_path_filestat_set_times(
- fd: __wasi_fd_t,
- flags: __wasi_lookupflags_t,
- path: *const ::c_char,
- path_len: size_t,
- st_atim: __wasi_timestamp_t,
- st_mtim: __wasi_timestamp_t,
- fstflags: __wasi_fstflags_t,
- ) -> __wasi_errno_t;
- #[link_name = "path_symlink"]
- pub fn __wasi_path_symlink(
- old_path: *const ::c_char,
- old_path_len: size_t,
- fd: __wasi_fd_t,
- new_path: *const ::c_char,
- new_path_len: size_t,
- ) -> __wasi_errno_t;
- #[link_name = "path_unlink_file"]
- pub fn __wasi_path_unlink_file(
- fd: __wasi_fd_t,
- path: *const ::c_char,
- path_len: size_t,
- ) -> __wasi_errno_t;
- #[link_name = "path_remove_directory"]
- pub fn __wasi_path_remove_directory(
- fd: __wasi_fd_t,
- path: *const ::c_char,
- path_len: size_t,
- ) -> __wasi_errno_t;
- #[link_name = "poll_oneoff"]
- pub fn __wasi_poll_oneoff(
- in_: *const __wasi_subscription_t,
- out: *mut __wasi_event_t,
- nsubscriptions: size_t,
- nevents: *mut size_t,
- ) -> __wasi_errno_t;
- #[link_name = "proc_exit"]
- pub fn __wasi_proc_exit(rval: __wasi_exitcode_t);
- #[link_name = "proc_raise"]
- pub fn __wasi_proc_raise(sig: __wasi_signal_t) -> __wasi_errno_t;
- #[link_name = "random_get"]
- pub fn __wasi_random_get(
- buf: *mut ::c_void,
- buf_len: size_t,
- ) -> __wasi_errno_t;
- #[link_name = "sock_recv"]
- pub fn __wasi_sock_recv(
- sock: __wasi_fd_t,
- ri_data: *const __wasi_iovec_t,
- ri_data_len: size_t,
- ri_flags: __wasi_riflags_t,
- ro_datalen: *mut size_t,
- ro_flags: *mut __wasi_roflags_t,
- ) -> __wasi_errno_t;
- #[link_name = "sock_send"]
- pub fn __wasi_sock_send(
- sock: __wasi_fd_t,
- si_data: *const __wasi_ciovec_t,
- si_data_len: size_t,
- si_flags: __wasi_siflags_t,
- so_datalen: *mut size_t,
- ) -> __wasi_errno_t;
- #[link_name = "sock_shutdown"]
- pub fn __wasi_sock_shutdown(
- sock: __wasi_fd_t,
- how: __wasi_sdflags_t,
- ) -> __wasi_errno_t;
- #[link_name = "sched_yield"]
- pub fn __wasi_sched_yield() -> __wasi_errno_t;
- #[link_name = "args_get"]
- pub fn __wasi_args_get(
- argv: *mut *mut c_char,
- argv_buf: *mut c_char,
- ) -> __wasi_errno_t;
- #[link_name = "args_sizes_get"]
- pub fn __wasi_args_sizes_get(
- argc: *mut size_t,
- argv_buf_size: *mut size_t,
- ) -> __wasi_errno_t;
- #[link_name = "environ_get"]
- pub fn __wasi_environ_get(
- environ: *mut *mut c_char,
- environ_buf: *mut c_char,
- ) -> __wasi_errno_t;
- #[link_name = "environ_sizes_get"]
- pub fn __wasi_environ_sizes_get(
- environ_count: *mut size_t,
- environ_buf_size: *mut size_t,
- ) -> __wasi_errno_t;
- #[link_name = "fd_prestat_get"]
- pub fn __wasi_fd_prestat_get(
- fd: __wasi_fd_t,
- buf: *mut __wasi_prestat_t,
- ) -> __wasi_errno_t;
- #[link_name = "fd_prestat_dir_name"]
- pub fn __wasi_fd_prestat_dir_name(
- fd: __wasi_fd_t,
- path: *mut c_char,
- path_len: size_t,
- ) -> __wasi_errno_t;
-}
diff --git a/libc/src/windows/gnu.rs b/libc/src/windows/gnu.rs
deleted file mode 100644
index 45e7dda..0000000
--- a/libc/src/windows/gnu.rs
+++ /dev/null
@@ -1,13 +0,0 @@
-pub const L_tmpnam: ::c_uint = 14;
-pub const TMP_MAX: ::c_uint = 0x7fff;
-
-// stdio file descriptor numbers
-pub const STDIN_FILENO: ::c_int = 0;
-pub const STDOUT_FILENO: ::c_int = 1;
-pub const STDERR_FILENO: ::c_int = 2;
-
-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/mod.rs b/libc/src/windows/mod.rs
deleted file mode 100644
index be28b70..0000000
--- a/libc/src/windows/mod.rs
+++ /dev/null
@@ -1,457 +0,0 @@
-//! Windows CRT definitions
-
-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 sighandler_t = usize;
-
-pub type c_char = i8;
-pub type c_long = i32;
-pub type c_ulong = u32;
-pub type wchar_t = u16;
-
-pub type clock_t = i32;
-
-cfg_if! {
- if #[cfg(all(target_arch = "x86", target_env = "gnu"))] {
- pub type time_t = i32;
- } else {
- pub type time_t = i64;
- }
-}
-
-pub type off_t = i32;
-pub type dev_t = u32;
-pub type ino_t = u16;
-#[cfg_attr(feature = "extra_traits", derive(Debug))]
-pub enum timezone {}
-impl ::Copy for timezone {}
-impl ::Clone for timezone {
- fn clone(&self) -> timezone { *self }
-}
-pub type time64_t = i64;
-
-pub type SOCKET = ::uintptr_t;
-
-s! {
- // note this is the struct called stat64 in Windows. Not stat, nor stati64.
- pub struct stat {
- pub st_dev: dev_t,
- pub st_ino: ino_t,
- pub st_mode: u16,
- pub st_nlink: ::c_short,
- pub st_uid: ::c_short,
- pub st_gid: ::c_short,
- pub st_rdev: dev_t,
- pub st_size: i64,
- pub st_atime: time64_t,
- pub st_mtime: time64_t,
- pub st_ctime: time64_t,
- }
-
- // note that this is called utimbuf64 in Windows
- pub struct utimbuf {
- pub actime: time64_t,
- pub modtime: time64_t,
- }
-
- 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 timeval {
- pub tv_sec: c_long,
- pub tv_usec: c_long,
- }
-
- pub struct timespec {
- pub tv_sec: time_t,
- pub tv_nsec: c_long,
- }
-
- pub struct sockaddr {
- pub sa_family: c_ushort,
- pub sa_data: [c_char; 14],
- }
-}
-
-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;
-pub const EOF: ::c_int = -1;
-pub const SEEK_SET: ::c_int = 0;
-pub const SEEK_CUR: ::c_int = 1;
-pub const SEEK_END: ::c_int = 2;
-pub const _IOFBF: ::c_int = 0;
-pub const _IONBF: ::c_int = 4;
-pub const _IOLBF: ::c_int = 64;
-pub const BUFSIZ: ::c_uint = 512;
-pub const FOPEN_MAX: ::c_uint = 20;
-pub const FILENAME_MAX: ::c_uint = 260;
-
-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 = 8;
-pub const O_CREAT: ::c_int = 256;
-pub const O_EXCL: ::c_int = 1024;
-pub const O_TEXT: ::c_int = 16384;
-pub const O_BINARY: ::c_int = 32768;
-pub const O_NOINHERIT: ::c_int = 128;
-pub const O_TRUNC: ::c_int = 512;
-pub const S_IFCHR: ::c_int = 8192;
-pub const S_IFDIR: ::c_int = 16384;
-pub const S_IFREG: ::c_int = 32768;
-pub const S_IFMT: ::c_int = 61440;
-pub const S_IEXEC: ::c_int = 64;
-pub const S_IWRITE: ::c_int = 128;
-pub const S_IREAD: ::c_int = 256;
-
-pub const LC_ALL: ::c_int = 0;
-pub const LC_COLLATE: ::c_int = 1;
-pub const LC_CTYPE: ::c_int = 2;
-pub const LC_MONETARY: ::c_int = 3;
-pub const LC_NUMERIC: ::c_int = 4;
-pub const LC_TIME: ::c_int = 5;
-
-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 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 = 36;
-pub const EDEADLOCK: ::c_int = 36;
-pub const ENAMETOOLONG: ::c_int = 38;
-pub const ENOLCK: ::c_int = 39;
-pub const ENOSYS: ::c_int = 40;
-pub const ENOTEMPTY: ::c_int = 41;
-pub const EILSEQ: ::c_int = 42;
-pub const STRUNCATE: ::c_int = 80;
-
-// signal codes
-pub const SIGINT: ::c_int = 2;
-pub const SIGILL: ::c_int = 4;
-pub const SIGFPE: ::c_int = 8;
-pub const SIGSEGV: ::c_int = 11;
-pub const SIGTERM: ::c_int = 15;
-pub const SIGABRT: ::c_int = 22;
-pub const NSIG: ::c_int = 23;
-pub const SIG_ERR: ::c_int = -1;
-
-// inline comment below appeases style checker
-#[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 {}
-
-#[cfg_attr(feature = "extra_traits", derive(Debug))]
-pub enum FILE {}
-impl ::Copy for FILE {}
-impl ::Clone for FILE {
- fn clone(&self) -> FILE { *self }
-}
-#[cfg_attr(feature = "extra_traits", derive(Debug))]
-pub enum fpos_t {} // TODO: fill this out with a struct
-impl ::Copy for fpos_t {}
-impl ::Clone for fpos_t {
- fn clone(&self) -> fpos_t { *self }
-}
-
-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 signal(signum: c_int, handler: sighandler_t) -> sighandler_t;
- pub fn raise(signum: c_int) -> c_int;
-
- #[link_name = "_chmod"]
- pub fn chmod(path: *const c_char, mode: ::c_int) -> ::c_int;
- #[link_name = "_wchmod"]
- pub fn wchmod(path: *const wchar_t, mode: ::c_int) -> ::c_int;
- #[link_name = "_mkdir"]
- pub fn mkdir(path: *const c_char) -> ::c_int;
- #[link_name = "_wrmdir"]
- pub fn wrmdir(path: *const wchar_t) -> ::c_int;
- #[link_name = "_fstat64"]
- pub fn fstat(fildes: ::c_int, buf: *mut stat) -> ::c_int;
- #[link_name = "_stat64"]
- pub fn stat(path: *const c_char, buf: *mut stat) -> ::c_int;
- #[link_name = "_wstat64"]
- pub fn wstat(path: *const wchar_t, buf: *mut stat) -> ::c_int;
- #[link_name = "_wutime64"]
- pub fn wutime(file: *const wchar_t, buf: *mut utimbuf) -> ::c_int;
- #[link_name = "_popen"]
- pub fn popen(command: *const c_char, mode: *const c_char) -> *mut ::FILE;
- #[link_name = "_pclose"]
- pub fn pclose(stream: *mut ::FILE) -> ::c_int;
- #[link_name = "_fdopen"]
- pub fn fdopen(fd: ::c_int, mode: *const c_char) -> *mut ::FILE;
- #[link_name = "_fileno"]
- pub fn fileno(stream: *mut ::FILE) -> ::c_int;
- #[link_name = "_open"]
- pub fn open(path: *const c_char, oflag: ::c_int, ...) -> ::c_int;
- #[link_name = "_wopen"]
- pub fn wopen(path: *const wchar_t, oflag: ::c_int, ...) -> ::c_int;
- #[link_name = "_creat"]
- pub fn creat(path: *const c_char, mode: ::c_int) -> ::c_int;
- #[link_name = "_access"]
- pub fn access(path: *const c_char, amode: ::c_int) -> ::c_int;
- #[link_name = "_chdir"]
- pub fn chdir(dir: *const c_char) -> ::c_int;
- #[link_name = "_close"]
- pub fn close(fd: ::c_int) -> ::c_int;
- #[link_name = "_dup"]
- pub fn dup(fd: ::c_int) -> ::c_int;
- #[link_name = "_dup2"]
- pub fn dup2(src: ::c_int, dst: ::c_int) -> ::c_int;
- #[link_name = "_execv"]
- pub fn execv(prog: *const c_char, argv: *const *const c_char) -> ::intptr_t;
- #[link_name = "_execve"]
- pub fn execve(prog: *const c_char, argv: *const *const c_char,
- envp: *const *const c_char) -> ::c_int;
- #[link_name = "_execvp"]
- pub fn execvp(c: *const c_char, argv: *const *const c_char) -> ::c_int;
- #[link_name = "_execvpe"]
- pub fn execvpe(c: *const c_char, argv: *const *const c_char,
- envp: *const *const c_char) -> ::c_int;
- #[link_name = "_getcwd"]
- pub fn getcwd(buf: *mut c_char, size: ::c_int) -> *mut c_char;
- #[link_name = "_getpid"]
- pub fn getpid() -> ::c_int;
- #[link_name = "_isatty"]
- pub fn isatty(fd: ::c_int) -> ::c_int;
- #[link_name = "_lseek"]
- pub fn lseek(fd: ::c_int, offset: c_long, origin: ::c_int) -> c_long;
- #[link_name = "_pipe"]
- pub fn pipe(fds: *mut ::c_int,
- psize: ::c_uint,
- textmode: ::c_int) -> ::c_int;
- #[link_name = "_read"]
- pub fn read(fd: ::c_int, buf: *mut ::c_void, count: ::c_uint) -> ::c_int;
- #[link_name = "_rmdir"]
- pub fn rmdir(path: *const c_char) -> ::c_int;
- #[link_name = "_unlink"]
- pub fn unlink(c: *const c_char) -> ::c_int;
- #[link_name = "_write"]
- pub fn write(fd: ::c_int, buf: *const ::c_void, count: ::c_uint) -> ::c_int;
- #[link_name = "_commit"]
- pub fn commit(fd: ::c_int) -> ::c_int;
- #[link_name = "_get_osfhandle"]
- pub fn get_osfhandle(fd: ::c_int) -> ::intptr_t;
- #[link_name = "_open_osfhandle"]
- pub fn open_osfhandle(osfhandle: ::intptr_t, flags: ::c_int) -> ::c_int;
- pub fn setlocale(category: ::c_int, locale: *const c_char) -> *mut c_char;
- #[link_name = "_wsetlocale"]
- pub fn wsetlocale(category: ::c_int,
- locale: *const wchar_t) -> *mut wchar_t;
-}
-
-extern "system" {
- pub fn listen(s: SOCKET, backlog: ::c_int) -> ::c_int;
- pub fn accept(s: SOCKET, addr: *mut ::sockaddr,
- addrlen: *mut ::c_int) -> SOCKET;
- pub fn bind(s: SOCKET, name: *const ::sockaddr,
- namelen: ::c_int) -> ::c_int;
- pub fn connect(s: SOCKET, name: *const ::sockaddr,
- namelen: ::c_int) -> ::c_int;
- pub fn getpeername(s: SOCKET, name: *mut ::sockaddr,
- nameln: *mut ::c_int) -> ::c_int;
- pub fn getsockname(s: SOCKET, name: *mut ::sockaddr,
- nameln: *mut ::c_int) -> ::c_int;
- pub fn getsockopt(s: SOCKET, level: ::c_int, optname: ::c_int,
- optval: *mut ::c_char,
- optlen: *mut ::c_int) -> ::c_int;
- pub fn recvfrom(s: SOCKET, buf: *mut ::c_char, len: ::c_int,
- flags: ::c_int, from: *mut ::sockaddr,
- fromlen: *mut ::c_int) -> ::c_int;
- pub fn sendto(s: SOCKET, buf: *const ::c_char, len: ::c_int,
- flags: ::c_int, to: *const ::sockaddr,
- tolen: ::c_int) -> ::c_int;
- pub fn setsockopt(s: SOCKET, level: ::c_int, optname: ::c_int,
- optval: *const ::c_char,
- optlen: ::c_int) -> ::c_int;
- pub fn socket(af: ::c_int, socket_type: ::c_int,
- protocol: ::c_int) -> SOCKET;
-}
-
-cfg_if! {
- if #[cfg(libc_core_cvoid)] {
- pub use ::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)]
- #[allow(missing_copy_implementations)]
- #[allow(missing_debug_implementations)]
- 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
- }
-}
diff --git a/libc/src/windows/msvc.rs b/libc/src/windows/msvc.rs
deleted file mode 100644
index 1ebfcad..0000000
--- a/libc/src/windows/msvc.rs
+++ /dev/null
@@ -1,10 +0,0 @@
-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;
-}
diff --git a/nitrocli/Cargo.lock b/nitrocli/Cargo.lock
deleted file mode 100644
index 0cec5e1..0000000
--- a/nitrocli/Cargo.lock
+++ /dev/null
@@ -1,246 +0,0 @@
-# This file is automatically @generated by Cargo.
-# It is not intended for manual editing.
-[[package]]
-name = "aho-corasick"
-version = "0.6.9"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-dependencies = [
- "memchr 2.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
-]
-
-[[package]]
-name = "argparse"
-version = "0.2.2"
-
-[[package]]
-name = "base32"
-version = "0.4.0"
-
-[[package]]
-name = "bitflags"
-version = "1.0.4"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-
-[[package]]
-name = "cc"
-version = "1.0.37"
-
-[[package]]
-name = "cfg-if"
-version = "0.1.6"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-
-[[package]]
-name = "cloudabi"
-version = "0.0.3"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-dependencies = [
- "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
-]
-
-[[package]]
-name = "fuchsia-zircon"
-version = "0.3.3"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-dependencies = [
- "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.3"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-
-[[package]]
-name = "lazy_static"
-version = "1.2.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-
-[[package]]
-name = "libc"
-version = "0.2.57"
-
-[[package]]
-name = "memchr"
-version = "2.1.3"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-dependencies = [
- "cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
- "libc 0.2.57",
-]
-
-[[package]]
-name = "nitrocli"
-version = "0.2.3"
-dependencies = [
- "argparse 0.2.2",
- "base32 0.4.0",
- "libc 0.2.57",
- "nitrokey 0.3.4",
- "nitrokey-test 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
- "regex 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
-]
-
-[[package]]
-name = "nitrokey"
-version = "0.3.4"
-dependencies = [
- "libc 0.2.57",
- "nitrokey-sys 3.4.3",
- "rand_core 0.3.0",
- "rand_os 0.1.1",
-]
-
-[[package]]
-name = "nitrokey-sys"
-version = "3.4.3"
-dependencies = [
- "cc 1.0.37",
-]
-
-[[package]]
-name = "nitrokey-test"
-version = "0.1.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-dependencies = [
- "proc-macro2 0.4.26 (registry+https://github.com/rust-lang/crates.io-index)",
- "quote 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)",
- "syn 0.15.26 (registry+https://github.com/rust-lang/crates.io-index)",
-]
-
-[[package]]
-name = "proc-macro2"
-version = "0.4.26"
-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.6.11"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-dependencies = [
- "proc-macro2 0.4.26 (registry+https://github.com/rust-lang/crates.io-index)",
-]
-
-[[package]]
-name = "rand_core"
-version = "0.3.0"
-
-[[package]]
-name = "rand_os"
-version = "0.1.1"
-dependencies = [
- "cloudabi 0.0.3 (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.57",
- "rand_core 0.3.0",
- "rdrand 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
-]
-
-[[package]]
-name = "rdrand"
-version = "0.4.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-dependencies = [
- "rand_core 0.3.0",
-]
-
-[[package]]
-name = "regex"
-version = "1.1.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-dependencies = [
- "aho-corasick 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)",
- "memchr 2.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
- "regex-syntax 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)",
- "thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
- "utf8-ranges 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
-]
-
-[[package]]
-name = "regex-syntax"
-version = "0.6.5"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-dependencies = [
- "ucd-util 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
-]
-
-[[package]]
-name = "syn"
-version = "0.15.26"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-dependencies = [
- "proc-macro2 0.4.26 (registry+https://github.com/rust-lang/crates.io-index)",
- "quote 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)",
- "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
-]
-
-[[package]]
-name = "thread_local"
-version = "0.3.6"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-dependencies = [
- "lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
-]
-
-[[package]]
-name = "ucd-util"
-version = "0.1.3"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-
-[[package]]
-name = "unicode-xid"
-version = "0.1.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-
-[[package]]
-name = "utf8-ranges"
-version = "1.0.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-
-[[package]]
-name = "winapi"
-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-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 aho-corasick 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)" = "1e9a933f4e58658d7b12defcf96dc5c720f20832deebe3e0a19efd3b6aaeeb9e"
-"checksum bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "228047a76f468627ca71776ecdebd732a3423081fcf5125585bcd7c49886ce12"
-"checksum cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "082bb9b28e00d3c9d39cc03e64ce4cea0f1bb9b3fde493f0cbc008472d22bdf4"
-"checksum cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f"
-"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 lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a374c89b9db55895453a74c1e38861d9deec0b01b405a82516e9d5de4820dea1"
-"checksum memchr 2.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "e1dd4eaac298c32ce07eb6ed9242eda7d82955b9170b7d6db59b2e02cc63fcb8"
-"checksum nitrokey-test 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "6226eaa31d1bbb031314d9288eb0e1bf6a70e7053da7960fea13ee84cab330ea"
-"checksum proc-macro2 0.4.26 (registry+https://github.com/rust-lang/crates.io-index)" = "38fddd23d98b2144d197c0eca5705632d4fe2667d14a6be5df8934f8d74f1978"
-"checksum quote 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)" = "cdd8e04bd9c52e0342b406469d494fcb033be4bdbe5c606016defbb1681411e1"
-"checksum rdrand 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "678054eb77286b51581ba43620cc911abf02758c91f93f479767aed0f90458b2"
-"checksum regex 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "37e7cbbd370869ce2e8dff25c7018702d10b21a20ef7135316f8daecd6c25b7f"
-"checksum regex-syntax 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)" = "8c2f35eedad5295fdf00a63d7d4b238135723f92b434ec06774dad15c7ab0861"
-"checksum syn 0.15.26 (registry+https://github.com/rust-lang/crates.io-index)" = "f92e629aa1d9c827b2bb8297046c1ccffc57c99b947a680d3ccff1f136a3bee9"
-"checksum thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c6b53e329000edc2b34dbe8545fd20e55a333362d0a321909685a19bd28c3f1b"
-"checksum ucd-util 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "535c204ee4d8434478593480b8f86ab45ec9aae0e83c568ca81abf0fd0e88f86"
-"checksum unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc"
-"checksum utf8-ranges 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "796f7e48bef87609f7ade7e06495a87d5cd06c7866e6a5cbfceffc558a243737"
-"checksum winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "92c1eb33641e276cfa214a0522acad57be5c56b10cb348b3c5117db75f3ac4b0"
-"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/nitrocli/doc/nitrocli.1.pdf b/nitrocli/doc/nitrocli.1.pdf
deleted file mode 100644
index fa4e4bc..0000000
--- a/nitrocli/doc/nitrocli.1.pdf
+++ /dev/null
Binary files differ
diff --git a/nitrocli/src/args.rs b/nitrocli/src/args.rs
deleted file mode 100644
index 10a097e..0000000
--- a/nitrocli/src/args.rs
+++ /dev/null
@@ -1,938 +0,0 @@
-// args.rs
-
-// *************************************************************************
-// * Copyright (C) 2018-2019 Daniel Mueller (deso@posteo.net) *
-// * *
-// * This program is free software: you can redistribute it and/or modify *
-// * it under the terms of the GNU General Public License as published by *
-// * the Free Software Foundation, either version 3 of the License, or *
-// * (at your option) any later version. *
-// * *
-// * This program is distributed in the hope that it will be useful, *
-// * but WITHOUT ANY WARRANTY; without even the implied warranty of *
-// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
-// * GNU General Public License for more details. *
-// * *
-// * You should have received a copy of the GNU General Public License *
-// * along with this program. If not, see <http://www.gnu.org/licenses/>. *
-// *************************************************************************
-
-use std::ffi;
-use std::io;
-use std::result;
-use std::str;
-
-use crate::commands;
-use crate::error::Error;
-use crate::pinentry;
-use crate::RunCtx;
-
-type Result<T> = result::Result<T, Error>;
-
-/// Wraps a writer and buffers its output.
-///
-/// This implementation is similar to `io::BufWriter`, but:
-/// - The inner writer is only written to if `flush` is called.
-/// - The buffer may grow infinitely large.
-struct BufWriter<'w, W: io::Write + ?Sized> {
- buf: Vec<u8>,
- inner: &'w mut W,
-}
-
-impl<'w, W: io::Write + ?Sized> BufWriter<'w, W> {
- pub fn new(inner: &'w mut W) -> Self {
- BufWriter {
- buf: Vec::with_capacity(128),
- inner,
- }
- }
-}
-
-impl<'w, W: io::Write + ?Sized> io::Write for BufWriter<'w, W> {
- fn write(&mut self, buf: &[u8]) -> io::Result<usize> {
- self.buf.extend_from_slice(buf);
- Ok(buf.len())
- }
-
- fn flush(&mut self) -> io::Result<()> {
- self.inner.write_all(&self.buf)?;
- self.buf.clear();
- self.inner.flush()
- }
-}
-
-trait Stdio {
- fn stdio(&mut self) -> (&mut dyn io::Write, &mut dyn io::Write);
-}
-
-impl<'io> Stdio for RunCtx<'io> {
- fn stdio(&mut self) -> (&mut dyn io::Write, &mut dyn io::Write) {
- (self.stdout, self.stderr)
- }
-}
-
-impl<W> Stdio for (&mut W, &mut W)
-where
- W: io::Write,
-{
- fn stdio(&mut self) -> (&mut dyn io::Write, &mut dyn io::Write) {
- (self.0, self.1)
- }
-}
-
-/// A command execution context that captures additional data pertaining
-/// the command execution.
-pub struct ExecCtx<'io> {
- pub model: Option<DeviceModel>,
- pub stdout: &'io mut dyn io::Write,
- pub stderr: &'io mut dyn io::Write,
- pub admin_pin: Option<ffi::OsString>,
- pub user_pin: Option<ffi::OsString>,
- pub new_admin_pin: Option<ffi::OsString>,
- pub new_user_pin: Option<ffi::OsString>,
- pub password: Option<ffi::OsString>,
- pub no_cache: bool,
- pub verbosity: u64,
-}
-
-impl<'io> Stdio for ExecCtx<'io> {
- fn stdio(&mut self) -> (&mut dyn io::Write, &mut dyn io::Write) {
- (self.stdout, self.stderr)
- }
-}
-
-/// The available Nitrokey models.
-#[allow(unused_doc_comments)]
-Enum! {DeviceModel, [
- Pro => "pro",
- Storage => "storage",
-]}
-
-impl From<DeviceModel> for nitrokey::Model {
- fn from(model: DeviceModel) -> nitrokey::Model {
- match model {
- DeviceModel::Pro => nitrokey::Model::Pro,
- DeviceModel::Storage => nitrokey::Model::Storage,
- }
- }
-}
-
-/// A top-level command for nitrocli.
-#[allow(unused_doc_comments)]
-Enum! {Command, [
- Config => ("config", config),
- Lock => ("lock", lock),
- Otp => ("otp", otp),
- Pin => ("pin", pin),
- Pws => ("pws", pws),
- Reset => ("reset", reset),
- Status => ("status", status),
- Storage => ("storage", storage),
-]}
-
-Enum! {ConfigCommand, [
- Get => ("get", config_get),
- Set => ("set", config_set),
-]}
-
-#[derive(Clone, Copy, Debug)]
-pub enum ConfigOption<T> {
- Enable(T),
- Disable,
- Ignore,
-}
-
-impl<T> ConfigOption<T> {
- fn try_from(disable: bool, value: Option<T>, name: &'static str) -> Result<Self> {
- if disable {
- if value.is_some() {
- Err(Error::Error(format!(
- "--{name} and --no-{name} are mutually exclusive",
- name = name
- )))
- } else {
- Ok(ConfigOption::Disable)
- }
- } else {
- match value {
- Some(value) => Ok(ConfigOption::Enable(value)),
- None => Ok(ConfigOption::Ignore),
- }
- }
- }
-
- pub fn or(self, default: Option<T>) -> Option<T> {
- match self {
- ConfigOption::Enable(value) => Some(value),
- ConfigOption::Disable => None,
- ConfigOption::Ignore => default,
- }
- }
-}
-
-Enum! {OtpCommand, [
- Clear => ("clear", otp_clear),
- Get => ("get", otp_get),
- Set => ("set", otp_set),
- Status => ("status", otp_status),
-]}
-
-Enum! {OtpAlgorithm, [
- Hotp => "hotp",
- Totp => "totp",
-]}
-
-Enum! {OtpMode, [
- SixDigits => "6",
- EightDigits => "8",
-]}
-
-impl From<OtpMode> for nitrokey::OtpMode {
- fn from(mode: OtpMode) -> Self {
- match mode {
- OtpMode::SixDigits => nitrokey::OtpMode::SixDigits,
- OtpMode::EightDigits => nitrokey::OtpMode::EightDigits,
- }
- }
-}
-
-Enum! {OtpSecretFormat, [
- Ascii => "ascii",
- Base32 => "base32",
- Hex => "hex",
-]}
-
-Enum! {PinCommand, [
- Clear => ("clear", pin_clear),
- Set => ("set", pin_set),
- Unblock => ("unblock", pin_unblock),
-]}
-
-Enum! {PwsCommand, [
- Clear => ("clear", pws_clear),
- Get => ("get", pws_get),
- Set => ("set", pws_set),
- Status => ("status", pws_status),
-]}
-
-fn parse(
- ctx: &mut impl Stdio,
- parser: argparse::ArgumentParser<'_>,
- args: Vec<String>,
-) -> Result<()> {
- let (stdout, stderr) = ctx.stdio();
- let result = parser
- .parse(args, stdout, stderr)
- .map_err(Error::ArgparseError);
- drop(parser);
- result
-}
-
-/// Inquire the status of the nitrokey.
-fn status(ctx: &mut ExecCtx<'_>, args: Vec<String>) -> Result<()> {
- let mut parser = argparse::ArgumentParser::new();
- parser.set_description("Prints the status of the connected Nitrokey device");
- parse(ctx, parser, args)?;
-
- commands::status(ctx)
-}
-
-/// Perform a factory reset.
-fn reset(ctx: &mut ExecCtx<'_>, args: Vec<String>) -> Result<()> {
- let mut parser = argparse::ArgumentParser::new();
- parser.set_description("Performs a factory reset");
- parse(ctx, parser, args)?;
-
- commands::reset(ctx)
-}
-
-Enum! {StorageCommand, [
- Close => ("close", storage_close),
- Hidden => ("hidden", storage_hidden),
- Open => ("open", storage_open),
- Status => ("status", storage_status),
-]}
-
-/// Execute a storage subcommand.
-fn storage(ctx: &mut ExecCtx<'_>, args: Vec<String>) -> Result<()> {
- let mut subcommand = StorageCommand::Open;
- let help = cmd_help!(subcommand);
- let mut subargs = vec![];
- let mut parser = argparse::ArgumentParser::new();
- parser.set_description("Interacts with the device's storage");
- let _ =
- parser
- .refer(&mut subcommand)
- .required()
- .add_argument("subcommand", argparse::Store, &help);
- let _ = parser.refer(&mut subargs).add_argument(
- "arguments",
- argparse::List,
- "The arguments for the subcommand",
- );
- parser.stop_on_first_argument(true);
- parse(ctx, parser, args)?;
-
- subargs.insert(0, format!("nitrocli {} {}", Command::Storage, subcommand));
- subcommand.execute(ctx, subargs)
-}
-
-/// Open the encrypted volume on the nitrokey.
-fn storage_open(ctx: &mut ExecCtx<'_>, args: Vec<String>) -> Result<()> {
- let mut parser = argparse::ArgumentParser::new();
- parser.set_description("Opens the encrypted volume on a Nitrokey Storage");
- parse(ctx, parser, args)?;
-
- commands::storage_open(ctx)
-}
-
-/// Close the previously opened encrypted volume.
-fn storage_close(ctx: &mut ExecCtx<'_>, args: Vec<String>) -> Result<()> {
- let mut parser = argparse::ArgumentParser::new();
- parser.set_description("Closes the encrypted volume on a Nitrokey Storage");
- parse(ctx, parser, args)?;
-
- commands::storage_close(ctx)
-}
-
-/// Print the status of the nitrokey's storage.
-fn storage_status(ctx: &mut ExecCtx<'_>, args: Vec<String>) -> Result<()> {
- let mut parser = argparse::ArgumentParser::new();
- parser.set_description("Prints the status of the Nitrokey's storage");
- parse(ctx, parser, args)?;
-
- commands::storage_status(ctx)
-}
-
-Enum! {HiddenCommand, [
- Close => ("close", storage_hidden_close),
- Create => ("create", storage_hidden_create),
- Open => ("open", storage_hidden_open),
-]}
-
-/// Execute a storage hidden subcommand.
-fn storage_hidden(ctx: &mut ExecCtx<'_>, args: Vec<String>) -> Result<()> {
- let mut subcommand = HiddenCommand::Open;
- let help = cmd_help!(subcommand);
- let mut subargs = vec![];
- let mut parser = argparse::ArgumentParser::new();
- parser.set_description("Interact with a hidden volume");
- let _ =
- parser
- .refer(&mut subcommand)
- .required()
- .add_argument("subcommand", argparse::Store, &help);
- let _ = parser.refer(&mut subargs).add_argument(
- "arguments",
- argparse::List,
- "The arguments for the subcommand",
- );
- parser.stop_on_first_argument(true);
- parse(ctx, parser, args)?;
-
- subargs.insert(
- 0,
- format!(
- "nitrocli {} {} {}",
- Command::Storage,
- StorageCommand::Hidden,
- subcommand
- ),
- );
- subcommand.execute(ctx, subargs)
-}
-
-fn storage_hidden_create(ctx: &mut ExecCtx<'_>, args: Vec<String>) -> Result<()> {
- let mut slot: u8 = 0;
- let mut start: u8 = 0;
- let mut end: u8 = 0;
- let mut parser = argparse::ArgumentParser::new();
- parser.set_description("Creates a hidden volume on a Nitrokey Storage");
- let _ = parser.refer(&mut slot).required().add_argument(
- "slot",
- argparse::Store,
- "The hidden volume slot to use",
- );
- let _ = parser.refer(&mut start).required().add_argument(
- "start",
- argparse::Store,
- "The start location of the hidden volume as percentage of the \
- encrypted volume's size (0-99)",
- );
- let _ = parser.refer(&mut end).required().add_argument(
- "end",
- argparse::Store,
- "The end location of the hidden volume as percentage of the \
- encrypted volume's size (1-100)",
- );
- parse(ctx, parser, args)?;
-
- commands::storage_hidden_create(ctx, slot, start, end)
-}
-
-fn storage_hidden_open(ctx: &mut ExecCtx<'_>, args: Vec<String>) -> Result<()> {
- let mut parser = argparse::ArgumentParser::new();
- parser.set_description("Opens a hidden volume on a Nitrokey Storage");
- parse(ctx, parser, args)?;
-
- commands::storage_hidden_open(ctx)
-}
-
-fn storage_hidden_close(ctx: &mut ExecCtx<'_>, args: Vec<String>) -> Result<()> {
- let mut parser = argparse::ArgumentParser::new();
- parser.set_description("Closes the hidden volume on a Nitrokey Storage");
- parse(ctx, parser, args)?;
-
- commands::storage_hidden_close(ctx)
-}
-
-/// Execute a config subcommand.
-fn config(ctx: &mut ExecCtx<'_>, args: Vec<String>) -> Result<()> {
- let mut subcommand = ConfigCommand::Get;
- let help = cmd_help!(subcommand);
- let mut subargs = vec![];
- let mut parser = argparse::ArgumentParser::new();
- parser.set_description("Reads or writes the device configuration");
- let _ =
- parser
- .refer(&mut subcommand)
- .required()
- .add_argument("subcommand", argparse::Store, &help);
- let _ = parser.refer(&mut subargs).add_argument(
- "arguments",
- argparse::List,
- "The arguments for the subcommand",
- );
- parser.stop_on_first_argument(true);
- parse(ctx, parser, args)?;
-
- subargs.insert(0, format!("nitrocli {} {}", Command::Config, subcommand));
- subcommand.execute(ctx, subargs)
-}
-
-/// Read the Nitrokey configuration.
-fn config_get(ctx: &mut ExecCtx<'_>, args: Vec<String>) -> Result<()> {
- let mut parser = argparse::ArgumentParser::new();
- parser.set_description("Prints the Nitrokey configuration");
- parse(ctx, parser, args)?;
-
- commands::config_get(ctx)
-}
-
-/// Write the Nitrokey configuration.
-fn config_set(ctx: &mut ExecCtx<'_>, args: Vec<String>) -> Result<()> {
- let mut numlock = None;
- let mut no_numlock = false;
- let mut capslock = None;
- let mut no_capslock = false;
- let mut scrollock = None;
- let mut no_scrollock = false;
- let mut otp_pin = false;
- let mut no_otp_pin = false;
- let mut parser = argparse::ArgumentParser::new();
- parser.set_description("Changes the Nitrokey configuration");
- let _ = parser.refer(&mut numlock).add_option(
- &["-n", "--numlock"],
- argparse::StoreOption,
- "Set the numlock option to the given HOTP slot",
- );
- let _ = parser.refer(&mut no_numlock).add_option(
- &["-N", "--no-numlock"],
- argparse::StoreTrue,
- "Unset the numlock option",
- );
- let _ = parser.refer(&mut capslock).add_option(
- &["-c", "--capslock"],
- argparse::StoreOption,
- "Set the capslock option to the given HOTP slot",
- );
- let _ = parser.refer(&mut no_capslock).add_option(
- &["-C", "--no-capslock"],
- argparse::StoreTrue,
- "Unset the capslock option",
- );
- let _ = parser.refer(&mut scrollock).add_option(
- &["-s", "--scrollock"],
- argparse::StoreOption,
- "Set the scrollock option to the given HOTP slot",
- );
- let _ = parser.refer(&mut no_scrollock).add_option(
- &["-S", "--no-scrollock"],
- argparse::StoreTrue,
- "Unset the scrollock option",
- );
- let _ = parser.refer(&mut otp_pin).add_option(
- &["-o", "--otp-pin"],
- argparse::StoreTrue,
- "Require the user PIN to generate one-time passwords",
- );
- let _ = parser.refer(&mut no_otp_pin).add_option(
- &["-O", "--no-otp-pin"],
- argparse::StoreTrue,
- "Allow one-time password generation without PIN",
- );
- parse(ctx, parser, args)?;
-
- let numlock = ConfigOption::try_from(no_numlock, numlock, "numlock")?;
- let capslock = ConfigOption::try_from(no_capslock, capslock, "capslock")?;
- let scrollock = ConfigOption::try_from(no_scrollock, scrollock, "scrollock")?;
- let otp_pin = if otp_pin {
- Some(true)
- } else if no_otp_pin {
- Some(false)
- } else {
- None
- };
- commands::config_set(ctx, numlock, capslock, scrollock, otp_pin)
-}
-
-/// Lock the Nitrokey.
-fn lock(ctx: &mut ExecCtx<'_>, args: Vec<String>) -> Result<()> {
- let mut parser = argparse::ArgumentParser::new();
- parser.set_description("Locks the connected Nitrokey device");
- parse(ctx, parser, args)?;
-
- commands::lock(ctx)
-}
-
-/// Execute an OTP subcommand.
-fn otp(ctx: &mut ExecCtx<'_>, args: Vec<String>) -> Result<()> {
- let mut subcommand = OtpCommand::Get;
- let help = cmd_help!(subcommand);
- let mut subargs = vec![];
- let mut parser = argparse::ArgumentParser::new();
- parser.set_description("Accesses one-time passwords");
- let _ =
- parser
- .refer(&mut subcommand)
- .required()
- .add_argument("subcommand", argparse::Store, &help);
- let _ = parser.refer(&mut subargs).add_argument(
- "arguments",
- argparse::List,
- "The arguments for the subcommand",
- );
- parser.stop_on_first_argument(true);
- parse(ctx, parser, args)?;
-
- subargs.insert(0, format!("nitrocli {} {}", Command::Otp, subcommand));
- subcommand.execute(ctx, subargs)
-}
-
-/// Generate a one-time password on the Nitrokey device.
-fn otp_get(ctx: &mut ExecCtx<'_>, args: Vec<String>) -> Result<()> {
- let mut slot: u8 = 0;
- let mut algorithm = OtpAlgorithm::Totp;
- let help = format!(
- "The OTP algorithm to use ({}, default: {})",
- fmt_enum!(algorithm),
- algorithm
- );
- let mut time: Option<u64> = None;
- let mut parser = argparse::ArgumentParser::new();
- parser.set_description("Generates a one-time password");
- let _ =
- parser
- .refer(&mut slot)
- .required()
- .add_argument("slot", argparse::Store, "The OTP slot to use");
- let _ = parser
- .refer(&mut algorithm)
- .add_option(&["-a", "--algorithm"], argparse::Store, &help);
- let _ = parser.refer(&mut time).add_option(
- &["-t", "--time"],
- argparse::StoreOption,
- "The time to use for TOTP generation (Unix timestamp, default: system time)",
- );
- parse(ctx, parser, args)?;
-
- commands::otp_get(ctx, slot, algorithm, time)
-}
-
-/// Configure a one-time password slot on the Nitrokey device.
-pub fn otp_set(ctx: &mut ExecCtx<'_>, args: Vec<String>) -> Result<()> {
- let mut slot: u8 = 0;
- let mut algorithm = OtpAlgorithm::Totp;
- let algo_help = format!(
- "The OTP algorithm to use ({}, default: {})",
- fmt_enum!(algorithm),
- algorithm
- );
- let mut name = "".to_owned();
- let mut secret = "".to_owned();
- let mut digits = OtpMode::SixDigits;
- let mut counter: u64 = 0;
- let mut time_window: u16 = 30;
- let mut ascii = false;
- let mut secret_format: Option<OtpSecretFormat> = None;
- let fmt_help = format!(
- "The format of the secret ({})",
- fmt_enum!(OtpSecretFormat::all_variants())
- );
- let mut parser = argparse::ArgumentParser::new();
- parser.set_description("Configures a one-time password slot");
- let _ =
- parser
- .refer(&mut slot)
- .required()
- .add_argument("slot", argparse::Store, "The OTP slot to use");
- let _ =
- parser
- .refer(&mut algorithm)
- .add_option(&["-a", "--algorithm"], argparse::Store, &algo_help);
- let _ = parser.refer(&mut name).required().add_argument(
- "name",
- argparse::Store,
- "The name of the slot",
- );
- let _ = parser.refer(&mut secret).required().add_argument(
- "secret",
- argparse::Store,
- "The secret to store on the slot as a hexadecimal string (unless --ascii is set)",
- );
- let _ = parser.refer(&mut digits).add_option(
- &["-d", "--digits"],
- argparse::Store,
- "The number of digits to use for the one-time password (6 or 8, default: 6)",
- );
- let _ = parser.refer(&mut counter).add_option(
- &["-c", "--counter"],
- argparse::Store,
- "The counter value for HOTP (default: 0)",
- );
- let _ = parser.refer(&mut time_window).add_option(
- &["-t", "--time-window"],
- argparse::Store,
- "The time window for TOTP (default: 30)",
- );
- let _ = parser.refer(&mut ascii).add_option(
- &["--ascii"],
- argparse::StoreTrue,
- "Interpret the given secret as an ASCII string of the secret (deprecated, use --format instead)"
- );
- let _ = parser.refer(&mut secret_format).add_option(
- &["-f", "--format"],
- argparse::StoreOption,
- &fmt_help,
- );
- parse(ctx, parser, args)?;
-
- if ascii {
- if secret_format.is_some() {
- return Err(Error::from(
- "The --format and the --ascii option cannot be used at the same time",
- ));
- }
-
- println!(
- ctx,
- "Warning: The --ascii option is deprecated. Please use --format ascii instead."
- )?;
- secret_format = Some(OtpSecretFormat::Ascii);
- }
- let secret_format = secret_format.unwrap_or(OtpSecretFormat::Hex);
-
- let data = nitrokey::OtpSlotData {
- number: slot,
- name,
- secret,
- mode: nitrokey::OtpMode::from(digits),
- use_enter: false,
- token_id: None,
- };
- commands::otp_set(ctx, data, algorithm, counter, time_window, secret_format)
-}
-
-/// Clear an OTP slot.
-fn otp_clear(ctx: &mut ExecCtx<'_>, args: Vec<String>) -> Result<()> {
- let mut slot: u8 = 0;
- let mut algorithm = OtpAlgorithm::Totp;
- let help = format!(
- "The OTP algorithm to use ({}, default: {})",
- fmt_enum!(algorithm),
- algorithm
- );
- let mut parser = argparse::ArgumentParser::new();
- parser.set_description("Clears a one-time password slot");
- let _ = parser.refer(&mut slot).required().add_argument(
- "slot",
- argparse::Store,
- "The OTP slot to clear",
- );
- let _ = parser
- .refer(&mut algorithm)
- .add_option(&["-a", "--algorithm"], argparse::Store, &help);
- parse(ctx, parser, args)?;
-
- commands::otp_clear(ctx, slot, algorithm)
-}
-
-/// Print the status of the OTP slots.
-fn otp_status(ctx: &mut ExecCtx<'_>, args: Vec<String>) -> Result<()> {
- let mut all = false;
- let mut parser = argparse::ArgumentParser::new();
- parser.set_description("Prints the status of the OTP slots");
- let _ = parser.refer(&mut all).add_option(
- &["-a", "--all"],
- argparse::StoreTrue,
- "Show slots that are not programmed",
- );
- parse(ctx, parser, args)?;
-
- commands::otp_status(ctx, all)
-}
-
-/// Execute a PIN subcommand.
-fn pin(ctx: &mut ExecCtx<'_>, args: Vec<String>) -> Result<()> {
- let mut subcommand = PinCommand::Clear;
- let help = cmd_help!(subcommand);
- let mut subargs = vec![];
- let mut parser = argparse::ArgumentParser::new();
- parser.set_description("Manages the Nitrokey PINs");
- let _ =
- parser
- .refer(&mut subcommand)
- .required()
- .add_argument("subcommand", argparse::Store, &help);
- let _ = parser.refer(&mut subargs).add_argument(
- "arguments",
- argparse::List,
- "The arguments for the subcommand",
- );
- parser.stop_on_first_argument(true);
- parse(ctx, parser, args)?;
-
- subargs.insert(0, format!("nitrocli {} {}", Command::Pin, subcommand));
- subcommand.execute(ctx, subargs)
-}
-
-/// Clear the PIN as cached by various other commands.
-fn pin_clear(ctx: &mut ExecCtx<'_>, args: Vec<String>) -> Result<()> {
- let mut parser = argparse::ArgumentParser::new();
- parser.set_description("Clears the cached PINs");
- parse(ctx, parser, args)?;
-
- commands::pin_clear(ctx)
-}
-
-/// Change a PIN.
-fn pin_set(ctx: &mut ExecCtx<'_>, args: Vec<String>) -> Result<()> {
- let mut pintype = pinentry::PinType::User;
- let help = format!("The PIN type to change ({})", fmt_enum!(pintype));
- let mut parser = argparse::ArgumentParser::new();
- parser.set_description("Changes a PIN");
- let _ = parser
- .refer(&mut pintype)
- .required()
- .add_argument("type", argparse::Store, &help);
- parse(ctx, parser, args)?;
-
- commands::pin_set(ctx, pintype)
-}
-
-/// Unblock and reset the user PIN.
-fn pin_unblock(ctx: &mut ExecCtx<'_>, args: Vec<String>) -> Result<()> {
- let mut parser = argparse::ArgumentParser::new();
- parser.set_description("Unblocks and resets the user PIN");
- parse(ctx, parser, args)?;
-
- commands::pin_unblock(ctx)
-}
-
-/// Execute a PWS subcommand.
-fn pws(ctx: &mut ExecCtx<'_>, args: Vec<String>) -> Result<()> {
- let mut subcommand = PwsCommand::Get;
- let mut subargs = vec![];
- let help = cmd_help!(subcommand);
- let mut parser = argparse::ArgumentParser::new();
- parser.set_description("Accesses the password safe");
- let _ =
- parser
- .refer(&mut subcommand)
- .required()
- .add_argument("subcommand", argparse::Store, &help);
- let _ = parser.refer(&mut subargs).add_argument(
- "arguments",
- argparse::List,
- "The arguments for the subcommand",
- );
- parser.stop_on_first_argument(true);
- parse(ctx, parser, args)?;
-
- subargs.insert(0, format!("nitrocli {} {}", Command::Pws, subcommand));
- subcommand.execute(ctx, subargs)
-}
-
-/// Access a slot of the password safe on the Nitrokey.
-fn pws_get(ctx: &mut ExecCtx<'_>, args: Vec<String>) -> Result<()> {
- let mut slot: u8 = 0;
- let mut name = false;
- let mut login = false;
- let mut password = false;
- let mut quiet = false;
- let mut parser = argparse::ArgumentParser::new();
- parser.set_description("Reads a password safe slot");
- let _ = parser.refer(&mut slot).required().add_argument(
- "slot",
- argparse::Store,
- "The PWS slot to read",
- );
- let _ = parser.refer(&mut name).add_option(
- &["-n", "--name"],
- argparse::StoreTrue,
- "Show the name stored on the slot",
- );
- let _ = parser.refer(&mut login).add_option(
- &["-l", "--login"],
- argparse::StoreTrue,
- "Show the login stored on the slot",
- );
- let _ = parser.refer(&mut password).add_option(
- &["-p", "--password"],
- argparse::StoreTrue,
- "Show the password stored on the slot",
- );
- let _ = parser.refer(&mut quiet).add_option(
- &["-q", "--quiet"],
- argparse::StoreTrue,
- "Print the stored data without description",
- );
- parse(ctx, parser, args)?;
-
- commands::pws_get(ctx, slot, name, login, password, quiet)
-}
-
-/// Set a slot of the password safe on the Nitrokey.
-fn pws_set(ctx: &mut ExecCtx<'_>, args: Vec<String>) -> Result<()> {
- let mut slot: u8 = 0;
- let mut name = String::new();
- let mut login = String::new();
- let mut password = String::new();
- let mut parser = argparse::ArgumentParser::new();
- parser.set_description("Writes a password safe slot");
- let _ = parser.refer(&mut slot).required().add_argument(
- "slot",
- argparse::Store,
- "The PWS slot to write",
- );
- let _ = parser.refer(&mut name).required().add_argument(
- "name",
- argparse::Store,
- "The name to store on the slot",
- );
- let _ = parser.refer(&mut login).required().add_argument(
- "login",
- argparse::Store,
- "The login to store on the slot",
- );
- let _ = parser.refer(&mut password).required().add_argument(
- "password",
- argparse::Store,
- "The password to store on the slot",
- );
- parse(ctx, parser, args)?;
-
- commands::pws_set(ctx, slot, &name, &login, &password)
-}
-
-/// Clear a PWS slot.
-fn pws_clear(ctx: &mut ExecCtx<'_>, args: Vec<String>) -> Result<()> {
- let mut slot: u8 = 0;
- let mut parser = argparse::ArgumentParser::new();
- parser.set_description("Clears a password safe slot");
- let _ = parser.refer(&mut slot).required().add_argument(
- "slot",
- argparse::Store,
- "The PWS slot to clear",
- );
- parse(ctx, parser, args)?;
-
- commands::pws_clear(ctx, slot)
-}
-
-/// Print the status of the PWS slots.
-fn pws_status(ctx: &mut ExecCtx<'_>, args: Vec<String>) -> Result<()> {
- let mut all = false;
- let mut parser = argparse::ArgumentParser::new();
- parser.set_description("Prints the status of the PWS slots");
- let _ = parser.refer(&mut all).add_option(
- &["-a", "--all"],
- argparse::StoreTrue,
- "Show slots that are not programmed",
- );
- parse(ctx, parser, args)?;
-
- commands::pws_status(ctx, all)
-}
-
-/// Parse the command-line arguments and execute the selected command.
-pub(crate) fn handle_arguments(ctx: &mut RunCtx<'_>, args: Vec<String>) -> Result<()> {
- use std::io::Write;
-
- let mut version = false;
- let mut model: Option<DeviceModel> = None;
- let model_help = format!(
- "Select the device model to connect to ({})",
- fmt_enum!(DeviceModel::all_variants())
- );
- let mut verbosity = 0;
- let mut command = Command::Status;
- let cmd_help = cmd_help!(command);
- let mut subargs = vec![];
- let mut parser = argparse::ArgumentParser::new();
- let _ = parser.refer(&mut version).add_option(
- &["-V", "--version"],
- argparse::StoreTrue,
- "Print version information and exit",
- );
- let _ = parser.refer(&mut verbosity).add_option(
- &["-v", "--verbose"],
- argparse::IncrBy::<u64>(1),
- "Increase the log level (can be supplied multiple times)",
- );
- let _ =
- parser
- .refer(&mut model)
- .add_option(&["-m", "--model"], argparse::StoreOption, &model_help);
- parser.set_description("Provides access to a Nitrokey device");
- let _ = parser
- .refer(&mut command)
- .required()
- .add_argument("command", argparse::Store, &cmd_help);
- let _ = parser.refer(&mut subargs).add_argument(
- "arguments",
- argparse::List,
- "The arguments for the command",
- );
- parser.stop_on_first_argument(true);
-
- let mut stdout_buf = BufWriter::new(ctx.stdout);
- let mut stderr_buf = BufWriter::new(ctx.stderr);
- let mut stdio_buf = (&mut stdout_buf, &mut stderr_buf);
- let result = parse(&mut stdio_buf, parser, args);
-
- if version {
- println!(ctx, "nitrocli {}", env!("CARGO_PKG_VERSION"))?;
- Ok(())
- } else {
- stdout_buf.flush()?;
- stderr_buf.flush()?;
-
- result?;
- subargs.insert(0, format!("nitrocli {}", command));
-
- let mut ctx = ExecCtx {
- model,
- stdout: ctx.stdout,
- stderr: ctx.stderr,
- admin_pin: ctx.admin_pin.take(),
- user_pin: ctx.user_pin.take(),
- new_admin_pin: ctx.new_admin_pin.take(),
- new_user_pin: ctx.new_user_pin.take(),
- password: ctx.password.take(),
- no_cache: ctx.no_cache,
- verbosity,
- };
- command.execute(&mut ctx, subargs)
- }
-}
diff --git a/nitrocli/src/commands.rs b/nitrocli/src/commands.rs
deleted file mode 100644
index 7bb314c..0000000
--- a/nitrocli/src/commands.rs
+++ /dev/null
@@ -1,890 +0,0 @@
-// commands.rs
-
-// *************************************************************************
-// * Copyright (C) 2018-2019 Daniel Mueller (deso@posteo.net) *
-// * *
-// * This program is free software: you can redistribute it and/or modify *
-// * it under the terms of the GNU General Public License as published by *
-// * the Free Software Foundation, either version 3 of the License, or *
-// * (at your option) any later version. *
-// * *
-// * This program is distributed in the hope that it will be useful, *
-// * but WITHOUT ANY WARRANTY; without even the implied warranty of *
-// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
-// * GNU General Public License for more details. *
-// * *
-// * You should have received a copy of the GNU General Public License *
-// * along with this program. If not, see <http://www.gnu.org/licenses/>. *
-// *************************************************************************
-
-use std::fmt;
-use std::result;
-use std::thread;
-use std::time;
-use std::u8;
-
-use libc::sync;
-
-use nitrokey::ConfigureOtp;
-use nitrokey::Device;
-use nitrokey::GenerateOtp;
-
-use crate::args;
-use crate::error::Error;
-use crate::pinentry;
-use crate::Result;
-
-const NITROKEY_DEFAULT_ADMIN_PIN: &str = "12345678";
-
-/// Create an `error::Error` with an error message of the format `msg: err`.
-fn get_error(msg: &'static str, err: nitrokey::CommandError) -> Error {
- Error::CommandError(Some(msg), err)
-}
-
-/// Set `libnitrokey`'s log level based on the execution context's verbosity.
-fn set_log_level(ctx: &mut args::ExecCtx<'_>) {
- let log_lvl = match ctx.verbosity {
- // The error log level is what libnitrokey uses by default. As such,
- // there is no harm in us setting that as well when the user did not
- // ask for higher verbosity.
- 0 => nitrokey::LogLevel::Error,
- 1 => nitrokey::LogLevel::Warning,
- 2 => nitrokey::LogLevel::Info,
- 3 => nitrokey::LogLevel::DebugL1,
- 4 => nitrokey::LogLevel::Debug,
- _ => nitrokey::LogLevel::DebugL2,
- };
- nitrokey::set_log_level(log_lvl);
-}
-
-/// Connect to any Nitrokey device and return it.
-fn get_device(ctx: &mut args::ExecCtx<'_>) -> Result<nitrokey::DeviceWrapper> {
- set_log_level(ctx);
-
- match ctx.model {
- Some(model) => nitrokey::connect_model(model.into()),
- None => nitrokey::connect(),
- }
- .map_err(|_| Error::from("Nitrokey device not found"))
-}
-
-/// Connect to a Nitrokey Storage device and return it.
-fn get_storage_device(ctx: &mut args::ExecCtx<'_>) -> Result<nitrokey::Storage> {
- set_log_level(ctx);
-
- if let Some(model) = ctx.model {
- if model != args::DeviceModel::Storage {
- return Err(Error::from(
- "This command is only available on the Nitrokey Storage",
- ));
- }
- }
-
- nitrokey::Storage::connect().or_else(|_| Err(Error::from("Nitrokey Storage device not found")))
-}
-
-/// Open the password safe on the given device.
-fn get_password_safe<'dev, D>(
- ctx: &mut args::ExecCtx<'_>,
- device: &'dev D,
-) -> Result<nitrokey::PasswordSafe<'dev>>
-where
- D: Device,
-{
- let pin_entry = pinentry::PinEntry::from(pinentry::PinType::User, device)?;
-
- try_with_pin_and_data(
- ctx,
- &pin_entry,
- "Could not access the password safe",
- (),
- |_, pin| device.get_password_safe(pin).map_err(|err| ((), err)),
- )
-}
-
-/// Authenticate the given device using the given PIN type and operation.
-///
-/// If an error occurs, the error message `msg` is used.
-fn authenticate<D, A, F>(
- ctx: &mut args::ExecCtx<'_>,
- device: D,
- pin_type: pinentry::PinType,
- msg: &'static str,
- op: F,
-) -> Result<A>
-where
- D: Device,
- F: Fn(D, &str) -> result::Result<A, (D, nitrokey::CommandError)>,
-{
- let pin_entry = pinentry::PinEntry::from(pin_type, &device)?;
-
- try_with_pin_and_data(ctx, &pin_entry, msg, device, op)
-}
-
-/// Authenticate the given device with the user PIN.
-fn authenticate_user<T>(ctx: &mut args::ExecCtx<'_>, device: T) -> Result<nitrokey::User<T>>
-where
- T: Device,
-{
- authenticate(
- ctx,
- device,
- pinentry::PinType::User,
- "Could not authenticate as user",
- |device, pin| device.authenticate_user(pin),
- )
-}
-
-/// Authenticate the given device with the admin PIN.
-fn authenticate_admin<T>(ctx: &mut args::ExecCtx<'_>, device: T) -> Result<nitrokey::Admin<T>>
-where
- T: Device,
-{
- authenticate(
- ctx,
- device,
- pinentry::PinType::Admin,
- "Could not authenticate as admin",
- |device, pin| device.authenticate_admin(pin),
- )
-}
-
-/// Return a string representation of the given volume status.
-fn get_volume_status(status: &nitrokey::VolumeStatus) -> &'static str {
- if status.active {
- if status.read_only {
- "read-only"
- } else {
- "active"
- }
- } else {
- "inactive"
- }
-}
-
-/// Try to execute the given function with a pin queried using pinentry.
-///
-/// This function will query the pin of the given type from the user
-/// using pinentry. It will then execute the given function. If this
-/// function returns a result, the result will be passed on. If it
-/// returns a `CommandError::WrongPassword`, the user will be asked
-/// again to enter the pin. Otherwise, this function returns an error
-/// containing the given error message. The user will have at most
-/// three tries to get the pin right.
-///
-/// The data argument can be used to pass on data between the tries. At
-/// the first try, this function will call `op` with `data`. At the
-/// second or third try, it will call `op` with the data returned by the
-/// previous call to `op`.
-fn try_with_pin_and_data_with_pinentry<D, F, R>(
- ctx: &mut args::ExecCtx<'_>,
- pin_entry: &pinentry::PinEntry,
- msg: &'static str,
- data: D,
- op: F,
-) -> Result<R>
-where
- F: Fn(D, &str) -> result::Result<R, (D, nitrokey::CommandError)>,
-{
- let mut data = data;
- let mut retry = 3;
- let mut error_msg = None;
- loop {
- let pin = pinentry::inquire(ctx, pin_entry, pinentry::Mode::Query, error_msg)?;
- match op(data, &pin) {
- Ok(result) => return Ok(result),
- Err((new_data, err)) => match err {
- nitrokey::CommandError::WrongPassword => {
- pinentry::clear(pin_entry)?;
- retry -= 1;
-
- if retry > 0 {
- error_msg = Some("Wrong password, please reenter");
- data = new_data;
- continue;
- }
- return Err(get_error(msg, err));
- }
- err => return Err(get_error(msg, err)),
- },
- };
- }
-}
-
-/// Try to execute the given function with a PIN.
-fn try_with_pin_and_data<D, F, R>(
- ctx: &mut args::ExecCtx<'_>,
- pin_entry: &pinentry::PinEntry,
- msg: &'static str,
- data: D,
- op: F,
-) -> Result<R>
-where
- F: Fn(D, &str) -> result::Result<R, (D, nitrokey::CommandError)>,
-{
- let pin = match pin_entry.pin_type() {
- pinentry::PinType::Admin => &ctx.admin_pin,
- pinentry::PinType::User => &ctx.user_pin,
- };
-
- if let Some(pin) = pin {
- let pin = pin.to_str().ok_or_else(|| {
- Error::Error(format!(
- "{}: Failed to read PIN due to invalid Unicode data",
- msg
- ))
- })?;
- op(data, &pin).map_err(|(_, err)| get_error(msg, err))
- } else {
- try_with_pin_and_data_with_pinentry(ctx, pin_entry, msg, data, op)
- }
-}
-
-/// Try to execute the given function with a pin queried using pinentry.
-///
-/// This function behaves exactly as `try_with_pin_and_data`, but
-/// it refrains from passing any data to it.
-fn try_with_pin<F>(
- ctx: &mut args::ExecCtx<'_>,
- pin_entry: &pinentry::PinEntry,
- msg: &'static str,
- op: F,
-) -> Result<()>
-where
- F: Fn(&str) -> result::Result<(), nitrokey::CommandError>,
-{
- try_with_pin_and_data(ctx, pin_entry, msg, (), |data, pin| {
- op(pin).map_err(|err| (data, err))
- })
-}
-
-/// Query and pretty print the status that is common to all Nitrokey devices.
-fn print_status(
- ctx: &mut args::ExecCtx<'_>,
- model: &'static str,
- device: &nitrokey::DeviceWrapper,
-) -> Result<()> {
- let serial_number = device
- .get_serial_number()
- .map_err(|err| get_error("Could not query the serial number", err))?;
- println!(
- ctx,
- r#"Status:
- model: {model}
- serial number: 0x{id}
- firmware version: {fwv0}.{fwv1}
- user retry count: {urc}
- admin retry count: {arc}"#,
- model = model,
- id = serial_number,
- fwv0 = device.get_major_firmware_version(),
- fwv1 = device.get_minor_firmware_version(),
- urc = device.get_user_retry_count(),
- arc = device.get_admin_retry_count(),
- )?;
- Ok(())
-}
-
-/// Inquire the status of the nitrokey.
-pub fn status(ctx: &mut args::ExecCtx<'_>) -> Result<()> {
- let device = get_device(ctx)?;
- let model = match device {
- nitrokey::DeviceWrapper::Pro(_) => "Pro",
- nitrokey::DeviceWrapper::Storage(_) => "Storage",
- };
- print_status(ctx, model, &device)
-}
-
-/// Perform a factory reset.
-pub fn reset(ctx: &mut args::ExecCtx<'_>) -> Result<()> {
- let device = get_device(ctx)?;
- let pin_entry = pinentry::PinEntry::from(pinentry::PinType::Admin, &device)?;
-
- // To force the user to enter the admin PIN before performing a
- // factory reset, we clear the pinentry cache for the admin PIN.
- pinentry::clear(&pin_entry)?;
-
- try_with_pin(ctx, &pin_entry, "Factory reset failed", |pin| {
- device.factory_reset(&pin)?;
- // Work around for a timing issue between factory_reset and
- // build_aes_key, see
- // https://github.com/Nitrokey/nitrokey-storage-firmware/issues/80
- thread::sleep(time::Duration::from_secs(3));
- // Another work around for spurious WrongPassword returns of
- // build_aes_key after a factory reset on Pro devices.
- // https://github.com/Nitrokey/nitrokey-pro-firmware/issues/57
- let _ = device.get_user_retry_count();
- device.build_aes_key(NITROKEY_DEFAULT_ADMIN_PIN)
- })
-}
-
-/// Open the encrypted volume on the nitrokey.
-pub fn storage_open(ctx: &mut args::ExecCtx<'_>) -> Result<()> {
- let device = get_storage_device(ctx)?;
- let pin_entry = pinentry::PinEntry::from(pinentry::PinType::User, &device)?;
-
- // We may forcefully close a hidden volume, if active, so be sure to
- // flush caches to disk.
- unsafe { sync() };
-
- try_with_pin(ctx, &pin_entry, "Opening encrypted volume failed", |pin| {
- device.enable_encrypted_volume(&pin)
- })
-}
-
-/// Close the previously opened encrypted volume.
-pub fn storage_close(ctx: &mut args::ExecCtx<'_>) -> Result<()> {
- // Flush all filesystem caches to disk. We are mostly interested in
- // making sure that the encrypted volume on the nitrokey we are
- // about to close is not closed while not all data was written to
- // it.
- unsafe { sync() };
-
- get_storage_device(ctx)?
- .disable_encrypted_volume()
- .map_err(|err| get_error("Closing encrypted volume failed", err))
-}
-
-/// Create a hidden volume.
-pub fn storage_hidden_create(
- ctx: &mut args::ExecCtx<'_>,
- slot: u8,
- start: u8,
- end: u8,
-) -> Result<()> {
- let device = get_storage_device(ctx)?;
- let pwd_entry = pinentry::PwdEntry::from(&device)?;
- let pwd = if let Some(pwd) = &ctx.password {
- pwd
- .to_str()
- .ok_or_else(|| Error::from("Failed to read password: invalid Unicode data found"))
- .map(ToOwned::to_owned)
- } else {
- pinentry::choose(ctx, &pwd_entry)
- }?;
-
- device
- .create_hidden_volume(slot, start, end, &pwd)
- .map_err(|err| get_error("Creating hidden volume failed", err))
-}
-
-/// Open a hidden volume.
-pub fn storage_hidden_open(ctx: &mut args::ExecCtx<'_>) -> Result<()> {
- let device = get_storage_device(ctx)?;
- let pwd_entry = pinentry::PwdEntry::from(&device)?;
- let pwd = if let Some(pwd) = &ctx.password {
- pwd
- .to_str()
- .ok_or_else(|| Error::from("Failed to read password: invalid Unicode data found"))
- .map(ToOwned::to_owned)
- } else {
- pinentry::inquire(ctx, &pwd_entry, pinentry::Mode::Query, None)
- }?;
-
- // We may forcefully close an encrypted volume, if active, so be sure
- // to flush caches to disk.
- unsafe { sync() };
-
- device
- .enable_hidden_volume(&pwd)
- .map_err(|err| get_error("Opening hidden volume failed", err))
-}
-
-/// Close a previously opened hidden volume.
-pub fn storage_hidden_close(ctx: &mut args::ExecCtx<'_>) -> Result<()> {
- unsafe { sync() };
-
- get_storage_device(ctx)?
- .disable_hidden_volume()
- .map_err(|err| get_error("Closing hidden volume failed", err))
-}
-
-/// Pretty print the status of a Nitrokey Storage.
-fn print_storage_status(
- ctx: &mut args::ExecCtx<'_>,
- status: &nitrokey::StorageStatus,
-) -> Result<()> {
- println!(
- ctx,
- r#"Status:
- SD card ID: {id:#x}
- firmware: {fw}
- storage keys: {sk}
- volumes:
- unencrypted: {vu}
- encrypted: {ve}
- hidden: {vh}"#,
- id = status.serial_number_sd_card,
- fw = if status.firmware_locked {
- "locked"
- } else {
- "unlocked"
- },
- sk = if status.stick_initialized {
- "created"
- } else {
- "not created"
- },
- vu = get_volume_status(&status.unencrypted_volume),
- ve = get_volume_status(&status.encrypted_volume),
- vh = get_volume_status(&status.hidden_volume),
- )?;
- Ok(())
-}
-
-/// Connect to and pretty print the status of a Nitrokey Storage.
-pub fn storage_status(ctx: &mut args::ExecCtx<'_>) -> Result<()> {
- let device = get_storage_device(ctx)?;
- let status = device
- .get_status()
- .map_err(|err| get_error("Getting Storage status failed", err))?;
-
- print_storage_status(ctx, &status)
-}
-
-/// Return a String representation of the given Option.
-fn format_option<T: fmt::Display>(option: Option<T>) -> String {
- match option {
- Some(value) => format!("{}", value),
- None => "not set".to_string(),
- }
-}
-
-/// Read the Nitrokey configuration.
-pub fn config_get(ctx: &mut args::ExecCtx<'_>) -> Result<()> {
- let config = get_device(ctx)?
- .get_config()
- .map_err(|err| get_error("Could not get configuration", err))?;
- println!(
- ctx,
- r#"Config:
- numlock binding: {nl}
- capslock binding: {cl}
- scrollock binding: {sl}
- require user PIN for OTP: {otp}"#,
- nl = format_option(config.numlock),
- cl = format_option(config.capslock),
- sl = format_option(config.scrollock),
- otp = config.user_password,
- )?;
- Ok(())
-}
-
-/// Write the Nitrokey configuration.
-pub fn config_set(
- ctx: &mut args::ExecCtx<'_>,
- numlock: args::ConfigOption<u8>,
- capslock: args::ConfigOption<u8>,
- scrollock: args::ConfigOption<u8>,
- user_password: Option<bool>,
-) -> Result<()> {
- let device = get_device(ctx)?;
- let device = authenticate_admin(ctx, device)?;
- let config = device
- .get_config()
- .map_err(|err| get_error("Could not get configuration", err))?;
- let config = nitrokey::Config {
- numlock: numlock.or(config.numlock),
- capslock: capslock.or(config.capslock),
- scrollock: scrollock.or(config.scrollock),
- user_password: user_password.unwrap_or(config.user_password),
- };
- device
- .write_config(config)
- .map_err(|err| get_error("Could not set configuration", err))
-}
-
-/// Lock the Nitrokey device.
-pub fn lock(ctx: &mut args::ExecCtx<'_>) -> Result<()> {
- get_device(ctx)?
- .lock()
- .map_err(|err| get_error("Getting Storage status failed", err))
-}
-
-fn get_otp<T: GenerateOtp>(slot: u8, algorithm: args::OtpAlgorithm, device: &T) -> Result<String> {
- match algorithm {
- args::OtpAlgorithm::Hotp => device.get_hotp_code(slot),
- args::OtpAlgorithm::Totp => device.get_totp_code(slot),
- }
- .map_err(|err| get_error("Could not generate OTP", err))
-}
-
-fn get_unix_timestamp() -> Result<u64> {
- time::SystemTime::now()
- .duration_since(time::UNIX_EPOCH)
- .or_else(|_| Err(Error::from("Current system time is before the Unix epoch")))
- .map(|duration| duration.as_secs())
-}
-
-/// Generate a one-time password on the Nitrokey device.
-pub fn otp_get(
- ctx: &mut args::ExecCtx<'_>,
- slot: u8,
- algorithm: args::OtpAlgorithm,
- time: Option<u64>,
-) -> Result<()> {
- let device = get_device(ctx)?;
- if algorithm == args::OtpAlgorithm::Totp {
- device
- .set_time(
- match time {
- Some(time) => time,
- None => get_unix_timestamp()?,
- },
- true,
- )
- .map_err(|err| get_error("Could not set time", err))?;
- }
- let config = device
- .get_config()
- .map_err(|err| get_error("Could not get device configuration", err))?;
- let otp = if config.user_password {
- let user = authenticate_user(ctx, device)?;
- get_otp(slot, algorithm, &user)
- } else {
- get_otp(slot, algorithm, &device)
- }?;
- println!(ctx, "{}", otp)?;
- Ok(())
-}
-
-/// Format a byte vector as a hex string.
-fn format_bytes(bytes: &[u8]) -> String {
- bytes
- .iter()
- .map(|c| format!("{:x}", c))
- .collect::<Vec<_>>()
- .join("")
-}
-
-/// Prepare an ASCII secret string for libnitrokey.
-///
-/// libnitrokey expects secrets as hexadecimal strings. This function transforms an ASCII string
-/// into a hexadecimal string or returns an error if the given string contains non-ASCII
-/// characters.
-fn prepare_ascii_secret(secret: &str) -> Result<String> {
- if secret.is_ascii() {
- Ok(format_bytes(&secret.as_bytes()))
- } else {
- Err(Error::from(
- "The given secret is not an ASCII string despite --format ascii being set",
- ))
- }
-}
-
-/// Prepare a base32 secret string for libnitrokey.
-fn prepare_base32_secret(secret: &str) -> Result<String> {
- base32::decode(base32::Alphabet::RFC4648 { padding: false }, secret)
- .map(|vec| format_bytes(&vec))
- .ok_or_else(|| Error::from("Could not parse base32 secret"))
-}
-
-/// Configure a one-time password slot on the Nitrokey device.
-pub fn otp_set(
- ctx: &mut args::ExecCtx<'_>,
- data: nitrokey::OtpSlotData,
- algorithm: args::OtpAlgorithm,
- counter: u64,
- time_window: u16,
- secret_format: args::OtpSecretFormat,
-) -> Result<()> {
- let secret = match secret_format {
- args::OtpSecretFormat::Ascii => prepare_ascii_secret(&data.secret)?,
- args::OtpSecretFormat::Base32 => prepare_base32_secret(&data.secret)?,
- args::OtpSecretFormat::Hex => data.secret,
- };
- let data = nitrokey::OtpSlotData { secret, ..data };
- let device = get_device(ctx)?;
- let device = authenticate_admin(ctx, device)?;
- match algorithm {
- args::OtpAlgorithm::Hotp => device.write_hotp_slot(data, counter),
- args::OtpAlgorithm::Totp => device.write_totp_slot(data, time_window),
- }
- .map_err(|err| get_error("Could not write OTP slot", err))?;
- Ok(())
-}
-
-/// Clear an OTP slot.
-pub fn otp_clear(
- ctx: &mut args::ExecCtx<'_>,
- slot: u8,
- algorithm: args::OtpAlgorithm,
-) -> Result<()> {
- let device = get_device(ctx)?;
- let device = authenticate_admin(ctx, device)?;
- match algorithm {
- args::OtpAlgorithm::Hotp => device.erase_hotp_slot(slot),
- args::OtpAlgorithm::Totp => device.erase_totp_slot(slot),
- }
- .map_err(|err| get_error("Could not clear OTP slot", err))?;
- Ok(())
-}
-
-fn print_otp_status(
- ctx: &mut args::ExecCtx<'_>,
- algorithm: args::OtpAlgorithm,
- device: &nitrokey::DeviceWrapper,
- all: bool,
-) -> Result<()> {
- let mut slot: u8 = 0;
- loop {
- let result = match algorithm {
- args::OtpAlgorithm::Hotp => device.get_hotp_slot_name(slot),
- args::OtpAlgorithm::Totp => device.get_totp_slot_name(slot),
- };
- slot = match slot.checked_add(1) {
- Some(slot) => slot,
- None => {
- return Err(Error::from("Integer overflow when iterating OTP slots"));
- }
- };
- let name = match result {
- Ok(name) => name,
- Err(nitrokey::CommandError::InvalidSlot) => return Ok(()),
- Err(nitrokey::CommandError::SlotNotProgrammed) => {
- if all {
- "[not programmed]".to_string()
- } else {
- continue;
- }
- }
- Err(err) => return Err(get_error("Could not check OTP slot", err)),
- };
- println!(ctx, "{}\t{}\t{}", algorithm, slot - 1, name)?;
- }
-}
-
-/// Print the status of the OTP slots.
-pub fn otp_status(ctx: &mut args::ExecCtx<'_>, all: bool) -> Result<()> {
- let device = get_device(ctx)?;
- println!(ctx, "alg\tslot\tname")?;
- print_otp_status(ctx, args::OtpAlgorithm::Hotp, &device, all)?;
- print_otp_status(ctx, args::OtpAlgorithm::Totp, &device, all)?;
- Ok(())
-}
-
-/// Clear the PIN stored by various operations.
-pub fn pin_clear(ctx: &mut args::ExecCtx<'_>) -> Result<()> {
- let device = get_device(ctx)?;
-
- pinentry::clear(&pinentry::PinEntry::from(
- pinentry::PinType::Admin,
- &device,
- )?)?;
- pinentry::clear(&pinentry::PinEntry::from(pinentry::PinType::User, &device)?)?;
- Ok(())
-}
-
-/// Choose a PIN of the given type.
-///
-/// If the user has set the respective environment variable for the
-/// given PIN type, it will be used.
-fn choose_pin(
- ctx: &mut args::ExecCtx<'_>,
- pin_entry: &pinentry::PinEntry,
- new: bool,
-) -> Result<String> {
- let new_pin = match pin_entry.pin_type() {
- pinentry::PinType::Admin => {
- if new {
- &ctx.new_admin_pin
- } else {
- &ctx.admin_pin
- }
- }
- pinentry::PinType::User => {
- if new {
- &ctx.new_user_pin
- } else {
- &ctx.user_pin
- }
- }
- };
-
- if let Some(new_pin) = new_pin {
- new_pin
- .to_str()
- .ok_or_else(|| Error::from("Failed to read PIN: invalid Unicode data found"))
- .map(ToOwned::to_owned)
- } else {
- pinentry::choose(ctx, pin_entry)
- }
-}
-
-/// Change a PIN.
-pub fn pin_set(ctx: &mut args::ExecCtx<'_>, pin_type: pinentry::PinType) -> Result<()> {
- let device = get_device(ctx)?;
- let pin_entry = pinentry::PinEntry::from(pin_type, &device)?;
- let new_pin = choose_pin(ctx, &pin_entry, true)?;
-
- try_with_pin(
- ctx,
- &pin_entry,
- "Could not change the PIN",
- |current_pin| match pin_type {
- pinentry::PinType::Admin => device.change_admin_pin(&current_pin, &new_pin),
- pinentry::PinType::User => device.change_user_pin(&current_pin, &new_pin),
- },
- )?;
-
- // We just changed the PIN but confirmed the action with the old PIN,
- // which may have caused it to be cached. Since it no longer applies,
- // make sure to evict the corresponding entry from the cache.
- pinentry::clear(&pin_entry)
-}
-
-/// Unblock and reset the user PIN.
-pub fn pin_unblock(ctx: &mut args::ExecCtx<'_>) -> Result<()> {
- let device = get_device(ctx)?;
- let pin_entry = pinentry::PinEntry::from(pinentry::PinType::User, &device)?;
- let user_pin = choose_pin(ctx, &pin_entry, false)?;
- let pin_entry = pinentry::PinEntry::from(pinentry::PinType::Admin, &device)?;
-
- try_with_pin(
- ctx,
- &pin_entry,
- "Could not unblock the user PIN",
- |admin_pin| device.unlock_user_pin(&admin_pin, &user_pin),
- )
-}
-
-fn print_pws_data(
- ctx: &mut args::ExecCtx<'_>,
- description: &'static str,
- result: result::Result<String, nitrokey::CommandError>,
- quiet: bool,
-) -> Result<()> {
- let value = result.map_err(|err| get_error("Could not access PWS slot", err))?;
- if quiet {
- println!(ctx, "{}", value)?;
- } else {
- println!(ctx, "{} {}", description, value)?;
- }
- Ok(())
-}
-
-fn check_slot(pws: &nitrokey::PasswordSafe<'_>, slot: u8) -> Result<()> {
- if slot >= nitrokey::SLOT_COUNT {
- return Err(nitrokey::CommandError::InvalidSlot.into());
- }
- let status = pws
- .get_slot_status()
- .map_err(|err| get_error("Could not read PWS slot status", err))?;
- if status[slot as usize] {
- Ok(())
- } else {
- Err(get_error(
- "Could not access PWS slot",
- nitrokey::CommandError::SlotNotProgrammed,
- ))
- }
-}
-
-/// Read a PWS slot.
-pub fn pws_get(
- ctx: &mut args::ExecCtx<'_>,
- slot: u8,
- show_name: bool,
- show_login: bool,
- show_password: bool,
- quiet: bool,
-) -> Result<()> {
- let device = get_device(ctx)?;
- let pws = get_password_safe(ctx, &device)?;
- check_slot(&pws, slot)?;
-
- let show_all = !show_name && !show_login && !show_password;
- if show_all || show_name {
- print_pws_data(ctx, "name: ", pws.get_slot_name(slot), quiet)?;
- }
- if show_all || show_login {
- print_pws_data(ctx, "login: ", pws.get_slot_login(slot), quiet)?;
- }
- if show_all || show_password {
- print_pws_data(ctx, "password:", pws.get_slot_password(slot), quiet)?;
- }
- Ok(())
-}
-
-/// Write a PWS slot.
-pub fn pws_set(
- ctx: &mut args::ExecCtx<'_>,
- slot: u8,
- name: &str,
- login: &str,
- password: &str,
-) -> Result<()> {
- let device = get_device(ctx)?;
- let pws = get_password_safe(ctx, &device)?;
- pws
- .write_slot(slot, name, login, password)
- .map_err(|err| get_error("Could not write PWS slot", err))
-}
-
-/// Clear a PWS slot.
-pub fn pws_clear(ctx: &mut args::ExecCtx<'_>, slot: u8) -> Result<()> {
- let device = get_device(ctx)?;
- let pws = get_password_safe(ctx, &device)?;
- pws
- .erase_slot(slot)
- .map_err(|err| get_error("Could not clear PWS slot", err))
-}
-
-fn print_pws_slot(
- ctx: &mut args::ExecCtx<'_>,
- pws: &nitrokey::PasswordSafe<'_>,
- slot: usize,
- programmed: bool,
-) -> Result<()> {
- if slot > u8::MAX as usize {
- return Err(Error::from("Invalid PWS slot number"));
- }
- let slot = slot as u8;
- let name = if programmed {
- pws
- .get_slot_name(slot)
- .map_err(|err| get_error("Could not read PWS slot", err))?
- } else {
- "[not programmed]".to_string()
- };
- println!(ctx, "{}\t{}", slot, name)?;
- Ok(())
-}
-
-/// Print the status of all PWS slots.
-pub fn pws_status(ctx: &mut args::ExecCtx<'_>, all: bool) -> Result<()> {
- let device = get_device(ctx)?;
- let pws = get_password_safe(ctx, &device)?;
- let slots = pws
- .get_slot_status()
- .map_err(|err| get_error("Could not read PWS slot status", err))?;
- println!(ctx, "slot\tname")?;
- for (i, &value) in slots
- .into_iter()
- .enumerate()
- .filter(|(_, &value)| all || value)
- {
- print_pws_slot(ctx, &pws, i, value)?;
- }
- Ok(())
-}
-
-#[cfg(test)]
-mod tests {
- use super::*;
-
- #[test]
- fn prepare_secret_ascii() {
- let result = prepare_ascii_secret("12345678901234567890");
- assert_eq!(
- "3132333435363738393031323334353637383930".to_string(),
- result.unwrap()
- );
- }
-
- #[test]
- fn prepare_secret_non_ascii() {
- let result = prepare_ascii_secret("Österreich");
- assert!(result.is_err());
- }
-}
diff --git a/nitrocli/src/tests/storage.rs b/nitrocli/src/tests/storage.rs
deleted file mode 100644
index be933ca..0000000
--- a/nitrocli/src/tests/storage.rs
+++ /dev/null
@@ -1,117 +0,0 @@
-// storage.rs
-
-// *************************************************************************
-// * Copyright (C) 2019 Daniel Mueller (deso@posteo.net) *
-// * *
-// * This program is free software: you can redistribute it and/or modify *
-// * it under the terms of the GNU General Public License as published by *
-// * the Free Software Foundation, either version 3 of the License, or *
-// * (at your option) any later version. *
-// * *
-// * This program is distributed in the hope that it will be useful, *
-// * but WITHOUT ANY WARRANTY; without even the implied warranty of *
-// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
-// * GNU General Public License for more details. *
-// * *
-// * You should have received a copy of the GNU General Public License *
-// * along with this program. If not, see <http://www.gnu.org/licenses/>. *
-// *************************************************************************
-
-use super::*;
-
-#[test_device]
-fn status_on_pro(device: nitrokey::Pro) {
- let res = Nitrocli::with_dev(device).handle(&["storage", "status"]);
- assert_eq!(
- res.unwrap_str_err(),
- "This command is only available on the Nitrokey Storage",
- );
-}
-
-#[test_device]
-fn status_open_close(device: nitrokey::Storage) -> crate::Result<()> {
- fn make_re(open: Option<bool>) -> regex::Regex {
- let encrypted = match open {
- Some(open) => {
- if open {
- "active"
- } else {
- "(read-only|inactive)"
- }
- }
- None => "(read-only|active|inactive)",
- };
- let re = format!(
- r#"^Status:
- SD card ID: 0x[[:xdigit:]]{{8}}
- firmware: (un)?locked
- storage keys: (not )?created
- volumes:
- unencrypted: (read-only|active|inactive)
- encrypted: {}
- hidden: (read-only|active|inactive)
-$"#,
- encrypted
- );
- regex::Regex::new(&re).unwrap()
- }
-
- let mut ncli = Nitrocli::with_dev(device);
- let out = ncli.handle(&["storage", "status"])?;
- assert!(make_re(None).is_match(&out), out);
-
- let _ = ncli.handle(&["storage", "open"])?;
- let out = ncli.handle(&["storage", "status"])?;
- assert!(make_re(Some(true)).is_match(&out), out);
-
- let _ = ncli.handle(&["storage", "close"])?;
- let out = ncli.handle(&["storage", "status"])?;
- assert!(make_re(Some(false)).is_match(&out), out);
-
- Ok(())
-}
-
-#[test_device]
-fn encrypted_open_close(device: nitrokey::Storage) -> crate::Result<()> {
- let mut ncli = Nitrocli::with_dev(device);
- let out = ncli.handle(&["storage", "open"])?;
- assert!(out.is_empty());
-
- let device = nitrokey::Storage::connect()?;
- assert!(device.get_status()?.encrypted_volume.active);
- assert!(!device.get_status()?.hidden_volume.active);
- drop(device);
-
- let out = ncli.handle(&["storage", "close"])?;
- assert!(out.is_empty());
-
- let device = nitrokey::Storage::connect()?;
- assert!(!device.get_status()?.encrypted_volume.active);
- assert!(!device.get_status()?.hidden_volume.active);
-
- Ok(())
-}
-
-#[test_device]
-fn hidden_create_open_close(device: nitrokey::Storage) -> crate::Result<()> {
- let mut ncli = Nitrocli::with_dev(device);
- let out = ncli.handle(&["storage", "hidden", "create", "0", "50", "100"])?;
- assert!(out.is_empty());
-
- let out = ncli.handle(&["storage", "hidden", "open"])?;
- assert!(out.is_empty());
-
- let device = nitrokey::Storage::connect()?;
- assert!(!device.get_status()?.encrypted_volume.active);
- assert!(device.get_status()?.hidden_volume.active);
- drop(device);
-
- let out = ncli.handle(&["storage", "hidden", "close"])?;
- assert!(out.is_empty());
-
- let device = nitrokey::Storage::connect()?;
- assert!(!device.get_status()?.encrypted_volume.active);
- assert!(!device.get_status()?.hidden_volume.active);
-
- Ok(())
-}
diff --git a/nitrokey-sys/.gitignore b/nitrokey-sys/.gitignore
deleted file mode 100644
index a821aa9..0000000
--- a/nitrokey-sys/.gitignore
+++ /dev/null
@@ -1,4 +0,0 @@
-
-/target
-**/*.rs.bk
-Cargo.lock
diff --git a/nitrokey-sys/CHANGELOG.md b/nitrokey-sys/CHANGELOG.md
deleted file mode 100644
index a11d168..0000000
--- a/nitrokey-sys/CHANGELOG.md
+++ /dev/null
@@ -1,50 +0,0 @@
-# v3.4.3 (2019-10-12)
-- Link directly against `libnitrokey` if the `USE_SYSTEM_LIBNITROKEY`
- environment variable is set.
-
-# v3.4.2 (2019-01-01)
-- Use the -std=c++14 compiler flag.
-- Change the build script to link to `-lhidapi` on non-Linux operating systems
- (while still using `-lhidapi-libusb` on Linux).
-- Decouple the libnitrokey and nitrokey-sys-rs versions.
-
-# v3.4.1 (2018-12-10)
-
-- Update to libnitrokey 3.4.1. There are no changes affecting this crate.
-
-# v3.4.0 (2018-12-10)
-
-- Update to libnitrokey 3.4, causing all following changes.
-- New constant `NK_device_model_NK_DISCONNECTED` in the `NK_device_model`
- enumeration.
-- New structures:
- - `NK_storage_ProductionTest`
- - `NK_storage_status`
-- New functions:
- - `NK_get_device_model`
- - `NK_get_library_version`
- - `NK_get_major_library_version`
- - `NK_get_minor_libray_version`
- - `NK_get_status_storage`
- - `NK_get_storage_production_info`
- - `NK_totp_set_time_soft`
- - `NK_wink`
-- The function `NK_totp_get_time` is now deprecated. If applicable,
- `NK_totp_set_time_soft` should be used instead. See the [upstream pull
- request #114][] for details.
-- Strings are now returned as mutable instead of constant pointers.
-
-# v3.3.0 (2018-05-21)
-
-- Change the crate license to LGPL 3.0.
-- Adapt the crate version number according to the bundled `libnitrokey`
- version.
-- Include a copy of `libnitrokey`.
-- Compile `libnitrokey` from source.
-- Generate the `bindgen` bindings statically and add them to the repository.
-
-# v0.1.0 (2018-05-19)
-
-- Initial release.
-
-[upstream pull request #114]: https://github.com/Nitrokey/libnitrokey/pull/114
diff --git a/nitrokey-sys/Cargo.toml b/nitrokey-sys/Cargo.toml
deleted file mode 100644
index f9d304b..0000000
--- a/nitrokey-sys/Cargo.toml
+++ /dev/null
@@ -1,16 +0,0 @@
-[package]
-name = "nitrokey-sys"
-version = "3.4.3"
-authors = ["Robin Krahl <robin.krahl@ireas.org>"]
-edition = "2018"
-homepage = "https://code.ireas.org/nitrokey-rs/"
-repository = "https://git.ireas.org/nitrokey-sys-rs/"
-description = "Low-level bindings to libnitrokey for communication with Nitrokey devices"
-categories = ["external-ffi-bindings"]
-license = "LGPL-3.0"
-links = "nitrokey"
-build = "build.rs"
-readme = "README.md"
-
-[build-dependencies]
-cc = "1.0"
diff --git a/nitrokey-sys/LICENSE b/nitrokey-sys/LICENSE
deleted file mode 100644
index 341c30b..0000000
--- a/nitrokey-sys/LICENSE
+++ /dev/null
@@ -1,166 +0,0 @@
- GNU LESSER GENERAL PUBLIC LICENSE
- Version 3, 29 June 2007
-
- Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
-
- This version of the GNU Lesser General Public License incorporates
-the terms and conditions of version 3 of the GNU General Public
-License, supplemented by the additional permissions listed below.
-
- 0. Additional Definitions.
-
- As used herein, "this License" refers to version 3 of the GNU Lesser
-General Public License, and the "GNU GPL" refers to version 3 of the GNU
-General Public License.
-
- "The Library" refers to a covered work governed by this License,
-other than an Application or a Combined Work as defined below.
-
- An "Application" is any work that makes use of an interface provided
-by the Library, but which is not otherwise based on the Library.
-Defining a subclass of a class defined by the Library is deemed a mode
-of using an interface provided by the Library.
-
- A "Combined Work" is a work produced by combining or linking an
-Application with the Library. The particular version of the Library
-with which the Combined Work was made is also called the "Linked
-Version".
-
- The "Minimal Corresponding Source" for a Combined Work means the
-Corresponding Source for the Combined Work, excluding any source code
-for portions of the Combined Work that, considered in isolation, are
-based on the Application, and not on the Linked Version.
-
- The "Corresponding Application Code" for a Combined Work means the
-object code and/or source code for the Application, including any data
-and utility programs needed for reproducing the Combined Work from the
-Application, but excluding the System Libraries of the Combined Work.
-
- 1. Exception to Section 3 of the GNU GPL.
-
- You may convey a covered work under sections 3 and 4 of this License
-without being bound by section 3 of the GNU GPL.
-
- 2. Conveying Modified Versions.
-
- If you modify a copy of the Library, and, in your modifications, a
-facility refers to a function or data to be supplied by an Application
-that uses the facility (other than as an argument passed when the
-facility is invoked), then you may convey a copy of the modified
-version:
-
- a) under this License, provided that you make a good faith effort to
- ensure that, in the event an Application does not supply the
- function or data, the facility still operates, and performs
- whatever part of its purpose remains meaningful, or
-
- b) under the GNU GPL, with none of the additional permissions of
- this License applicable to that copy.
-
- 3. Object Code Incorporating Material from Library Header Files.
-
- The object code form of an Application may incorporate material from
-a header file that is part of the Library. You may convey such object
-code under terms of your choice, provided that, if the incorporated
-material is not limited to numerical parameters, data structure
-layouts and accessors, or small macros, inline functions and templates
-(ten or fewer lines in length), you do both of the following:
-
- a) Give prominent notice with each copy of the object code that the
- Library is used in it and that the Library and its use are
- covered by this License.
-
- b) Accompany the object code with a copy of the GNU GPL and this license
- document.
-
- 4. Combined Works.
-
- You may convey a Combined Work under terms of your choice that,
-taken together, effectively do not restrict modification of the
-portions of the Library contained in the Combined Work and reverse
-engineering for debugging such modifications, if you also do each of
-the following:
-
- a) Give prominent notice with each copy of the Combined Work that
- the Library is used in it and that the Library and its use are
- covered by this License.
-
- b) Accompany the Combined Work with a copy of the GNU GPL and this license
- document.
-
- c) For a Combined Work that displays copyright notices during
- execution, include the copyright notice for the Library among
- these notices, as well as a reference directing the user to the
- copies of the GNU GPL and this license document.
-
- d) Do one of the following:
-
- 0) Convey the Minimal Corresponding Source under the terms of this
- License, and the Corresponding Application Code in a form
- suitable for, and under terms that permit, the user to
- recombine or relink the Application with a modified version of
- the Linked Version to produce a modified Combined Work, in the
- manner specified by section 6 of the GNU GPL for conveying
- Corresponding Source.
-
- 1) Use a suitable shared library mechanism for linking with the
- Library. A suitable mechanism is one that (a) uses at run time
- a copy of the Library already present on the user's computer
- system, and (b) will operate properly with a modified version
- of the Library that is interface-compatible with the Linked
- Version.
-
- e) Provide Installation Information, but only if you would otherwise
- be required to provide such information under section 6 of the
- GNU GPL, and only to the extent that such information is
- necessary to install and execute a modified version of the
- Combined Work produced by recombining or relinking the
- Application with a modified version of the Linked Version. (If
- you use option 4d0, the Installation Information must accompany
- the Minimal Corresponding Source and Corresponding Application
- Code. If you use option 4d1, you must provide the Installation
- Information in the manner specified by section 6 of the GNU GPL
- for conveying Corresponding Source.)
-
- 5. Combined Libraries.
-
- You may place library facilities that are a work based on the
-Library side by side in a single library together with other library
-facilities that are not Applications and are not covered by this
-License, and convey such a combined library under terms of your
-choice, if you do both of the following:
-
- a) Accompany the combined library with a copy of the same work based
- on the Library, uncombined with any other library facilities,
- conveyed under the terms of this License.
-
- b) Give prominent notice with the combined library that part of it
- is a work based on the Library, and explaining where to find the
- accompanying uncombined form of the same work.
-
- 6. Revised Versions of the GNU Lesser General Public License.
-
- The Free Software Foundation may publish revised and/or new versions
-of the GNU Lesser General Public License from time to time. Such new
-versions will be similar in spirit to the present version, but may
-differ in detail to address new problems or concerns.
-
- Each version is given a distinguishing version number. If the
-Library as you received it specifies that a certain numbered version
-of the GNU Lesser General Public License "or any later version"
-applies to it, you have the option of following the terms and
-conditions either of that published version or of any later version
-published by the Free Software Foundation. If the Library as you
-received it does not specify a version number of the GNU Lesser
-General Public License, you may choose any version of the GNU Lesser
-General Public License ever published by the Free Software Foundation.
-
- If the Library as you received it specifies that a proxy can decide
-whether future versions of the GNU Lesser General Public License shall
-apply, that proxy's public statement of acceptance of any version is
-permanent authorization for you to choose that version for the
-Library.
-
diff --git a/nitrokey-sys/README.md b/nitrokey-sys/README.md
deleted file mode 100644
index 343b7b5..0000000
--- a/nitrokey-sys/README.md
+++ /dev/null
@@ -1,35 +0,0 @@
-# nitrokey-sys-rs
-
-Low-level Rust bindings for `libnitrokey`, providing access to Nitrokey
-devices.
-
-This crate contains a copy of the [`libnitrokey`][] library, builds it from
-source and links it statically. The host system must provide its dependencies
-in the library search path:
-
-- `libhidapi-libusb0` (on Linux)
-- `libhidapi` (on non-Linux systems)
-
-If you set the `USE_SYSTEM_LIBNITROKEY` environment variable when building this
-crate, it links directly against `libnitrokey` instead of building it from
-source. In this case, `libnitrokey` must be available in the library search
-path.
-
-## Versioning
-
-The major and minor version of the `nitrokey-sys` crate map to the major and
-minor version of `libnitrokey`. The `nitrokey-sys` patch version may be
-increased independently.
-
-## Contact
-
-For bug reports, patches, feature requests or other messages, please send a
-mail to [nitrokey-rs-dev@ireas.org][].
-
-## License
-
-This project as well as `libnitrokey` are licensed under the [LGPL-3.0][].
-
-[`libnitrokey`]: https://github.com/nitrokey/libnitrokey
-[nitrokey-rs-dev@ireas.org]: mailto:nitrokey-rs-dev@ireas.org
-[LGPL-3.0]: https://opensource.org/licenses/lgpl-3.0.html
diff --git a/nitrokey-sys/build.rs b/nitrokey-sys/build.rs
deleted file mode 100644
index defce72..0000000
--- a/nitrokey-sys/build.rs
+++ /dev/null
@@ -1,94 +0,0 @@
-use std::env;
-use std::fs;
-use std::io;
-use std::io::{Read, Write};
-use std::path;
-use std::string;
-
-use cc;
-
-#[derive(Clone, Copy, Debug, PartialEq)]
-struct Version {
- major: u32,
- minor: u32,
- patch: Option<u32>,
-}
-
-impl string::ToString for Version {
- fn to_string(&self) -> String {
- match self.patch {
- Some(patch) => format!("v{}.{}.{}", self.major, self.minor, patch),
- None => format!("v{}.{}", self.major, self.minor),
- }
- }
-}
-
-const LIBNITROKEY_VERSION: Version = Version {
- major: 3,
- minor: 4,
- patch: Some(1),
-};
-
-fn prepare_version_source(
- version: Version,
- out_path: &path::Path,
- library_path: &path::Path,
-) -> io::Result<path::PathBuf> {
- let out = out_path.join("version.cc");
- let template = library_path.join("version.cc.in");
-
- let mut file = fs::File::open(template)?;
- let mut data = String::new();
- file.read_to_string(&mut data)?;
- drop(file);
-
- let data = data
- .replace("@PROJECT_VERSION_MAJOR@", &version.major.to_string())
- .replace("@PROJECT_VERSION_MINOR@", &version.minor.to_string())
- .replace("@PROJECT_VERSION_GIT@", &version.to_string());
-
- let mut file = fs::File::create(&out)?;
- file.write_all(data.as_bytes())?;
-
- Ok(out)
-}
-
-fn main() {
- if env::var("USE_SYSTEM_LIBNITROKEY").is_ok() {
- println!("cargo:rustc-link-lib=nitrokey");
- return;
- }
-
- let out_dir = env::var("OUT_DIR").expect("Environment variable OUT_DIR is not set");
- let out_path = path::PathBuf::from(out_dir);
-
- let sources = [
- "DeviceCommunicationExceptions.cpp",
- "NK_C_API.cc",
- "NitrokeyManager.cc",
- "command_id.cc",
- "device.cc",
- "log.cc",
- "misc.cc",
- ];
- let library_dir = format!("libnitrokey-{}", LIBNITROKEY_VERSION.to_string());
- let library_path = path::Path::new(&library_dir);
-
- let version_source = prepare_version_source(LIBNITROKEY_VERSION, &out_path, &library_path)
- .expect("Could not prepare the version source file");
-
- cc::Build::new()
- .cpp(true)
- .flag("-std=c++14")
- .include(library_path.join("libnitrokey"))
- .files(sources.iter().map(|s| library_path.join(s)))
- .file(version_source)
- .compile("libnitrokey.a");
-
- let hidapi_library_name = if cfg!(target_os = "linux") {
- "hidapi-libusb"
- } else {
- "hidapi"
- };
- println!("cargo:rustc-link-lib={}", hidapi_library_name);
-}
diff --git a/nitrokey-sys/libnitrokey-v3.4.1/DeviceCommunicationExceptions.cpp b/nitrokey-sys/libnitrokey-v3.4.1/DeviceCommunicationExceptions.cpp
deleted file mode 100644
index 4d62aad..0000000
--- a/nitrokey-sys/libnitrokey-v3.4.1/DeviceCommunicationExceptions.cpp
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * Copyright (c) 2015-2018 Nitrokey UG
- *
- * This file is part of libnitrokey.
- *
- * libnitrokey is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * any later version.
- *
- * libnitrokey is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with libnitrokey. If not, see <http://www.gnu.org/licenses/>.
- *
- * SPDX-License-Identifier: LGPL-3.0
- */
-
-#include "DeviceCommunicationExceptions.h"
-
-std::atomic_int DeviceCommunicationException::occurred {0};
diff --git a/nitrokey-sys/libnitrokey-v3.4.1/LICENSE b/nitrokey-sys/libnitrokey-v3.4.1/LICENSE
deleted file mode 100644
index 341c30b..0000000
--- a/nitrokey-sys/libnitrokey-v3.4.1/LICENSE
+++ /dev/null
@@ -1,166 +0,0 @@
- GNU LESSER GENERAL PUBLIC LICENSE
- Version 3, 29 June 2007
-
- Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
-
- This version of the GNU Lesser General Public License incorporates
-the terms and conditions of version 3 of the GNU General Public
-License, supplemented by the additional permissions listed below.
-
- 0. Additional Definitions.
-
- As used herein, "this License" refers to version 3 of the GNU Lesser
-General Public License, and the "GNU GPL" refers to version 3 of the GNU
-General Public License.
-
- "The Library" refers to a covered work governed by this License,
-other than an Application or a Combined Work as defined below.
-
- An "Application" is any work that makes use of an interface provided
-by the Library, but which is not otherwise based on the Library.
-Defining a subclass of a class defined by the Library is deemed a mode
-of using an interface provided by the Library.
-
- A "Combined Work" is a work produced by combining or linking an
-Application with the Library. The particular version of the Library
-with which the Combined Work was made is also called the "Linked
-Version".
-
- The "Minimal Corresponding Source" for a Combined Work means the
-Corresponding Source for the Combined Work, excluding any source code
-for portions of the Combined Work that, considered in isolation, are
-based on the Application, and not on the Linked Version.
-
- The "Corresponding Application Code" for a Combined Work means the
-object code and/or source code for the Application, including any data
-and utility programs needed for reproducing the Combined Work from the
-Application, but excluding the System Libraries of the Combined Work.
-
- 1. Exception to Section 3 of the GNU GPL.
-
- You may convey a covered work under sections 3 and 4 of this License
-without being bound by section 3 of the GNU GPL.
-
- 2. Conveying Modified Versions.
-
- If you modify a copy of the Library, and, in your modifications, a
-facility refers to a function or data to be supplied by an Application
-that uses the facility (other than as an argument passed when the
-facility is invoked), then you may convey a copy of the modified
-version:
-
- a) under this License, provided that you make a good faith effort to
- ensure that, in the event an Application does not supply the
- function or data, the facility still operates, and performs
- whatever part of its purpose remains meaningful, or
-
- b) under the GNU GPL, with none of the additional permissions of
- this License applicable to that copy.
-
- 3. Object Code Incorporating Material from Library Header Files.
-
- The object code form of an Application may incorporate material from
-a header file that is part of the Library. You may convey such object
-code under terms of your choice, provided that, if the incorporated
-material is not limited to numerical parameters, data structure
-layouts and accessors, or small macros, inline functions and templates
-(ten or fewer lines in length), you do both of the following:
-
- a) Give prominent notice with each copy of the object code that the
- Library is used in it and that the Library and its use are
- covered by this License.
-
- b) Accompany the object code with a copy of the GNU GPL and this license
- document.
-
- 4. Combined Works.
-
- You may convey a Combined Work under terms of your choice that,
-taken together, effectively do not restrict modification of the
-portions of the Library contained in the Combined Work and reverse
-engineering for debugging such modifications, if you also do each of
-the following:
-
- a) Give prominent notice with each copy of the Combined Work that
- the Library is used in it and that the Library and its use are
- covered by this License.
-
- b) Accompany the Combined Work with a copy of the GNU GPL and this license
- document.
-
- c) For a Combined Work that displays copyright notices during
- execution, include the copyright notice for the Library among
- these notices, as well as a reference directing the user to the
- copies of the GNU GPL and this license document.
-
- d) Do one of the following:
-
- 0) Convey the Minimal Corresponding Source under the terms of this
- License, and the Corresponding Application Code in a form
- suitable for, and under terms that permit, the user to
- recombine or relink the Application with a modified version of
- the Linked Version to produce a modified Combined Work, in the
- manner specified by section 6 of the GNU GPL for conveying
- Corresponding Source.
-
- 1) Use a suitable shared library mechanism for linking with the
- Library. A suitable mechanism is one that (a) uses at run time
- a copy of the Library already present on the user's computer
- system, and (b) will operate properly with a modified version
- of the Library that is interface-compatible with the Linked
- Version.
-
- e) Provide Installation Information, but only if you would otherwise
- be required to provide such information under section 6 of the
- GNU GPL, and only to the extent that such information is
- necessary to install and execute a modified version of the
- Combined Work produced by recombining or relinking the
- Application with a modified version of the Linked Version. (If
- you use option 4d0, the Installation Information must accompany
- the Minimal Corresponding Source and Corresponding Application
- Code. If you use option 4d1, you must provide the Installation
- Information in the manner specified by section 6 of the GNU GPL
- for conveying Corresponding Source.)
-
- 5. Combined Libraries.
-
- You may place library facilities that are a work based on the
-Library side by side in a single library together with other library
-facilities that are not Applications and are not covered by this
-License, and convey such a combined library under terms of your
-choice, if you do both of the following:
-
- a) Accompany the combined library with a copy of the same work based
- on the Library, uncombined with any other library facilities,
- conveyed under the terms of this License.
-
- b) Give prominent notice with the combined library that part of it
- is a work based on the Library, and explaining where to find the
- accompanying uncombined form of the same work.
-
- 6. Revised Versions of the GNU Lesser General Public License.
-
- The Free Software Foundation may publish revised and/or new versions
-of the GNU Lesser General Public License from time to time. Such new
-versions will be similar in spirit to the present version, but may
-differ in detail to address new problems or concerns.
-
- Each version is given a distinguishing version number. If the
-Library as you received it specifies that a certain numbered version
-of the GNU Lesser General Public License "or any later version"
-applies to it, you have the option of following the terms and
-conditions either of that published version or of any later version
-published by the Free Software Foundation. If the Library as you
-received it does not specify a version number of the GNU Lesser
-General Public License, you may choose any version of the GNU Lesser
-General Public License ever published by the Free Software Foundation.
-
- If the Library as you received it specifies that a proxy can decide
-whether future versions of the GNU Lesser General Public License shall
-apply, that proxy's public statement of acceptance of any version is
-permanent authorization for you to choose that version for the
-Library.
-
diff --git a/nitrokey-sys/libnitrokey-v3.4.1/NK_C_API.cc b/nitrokey-sys/libnitrokey-v3.4.1/NK_C_API.cc
deleted file mode 100644
index 7d0a10e..0000000
--- a/nitrokey-sys/libnitrokey-v3.4.1/NK_C_API.cc
+++ /dev/null
@@ -1,755 +0,0 @@
-/*
- * Copyright (c) 2015-2018 Nitrokey UG
- *
- * This file is part of libnitrokey.
- *
- * libnitrokey is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * any later version.
- *
- * libnitrokey is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with libnitrokey. If not, see <http://www.gnu.org/licenses/>.
- *
- * SPDX-License-Identifier: LGPL-3.0
- */
-
-#include "NK_C_API.h"
-#include <iostream>
-#include <tuple>
-#include "libnitrokey/NitrokeyManager.h"
-#include <cstring>
-#include "libnitrokey/LibraryException.h"
-#include "libnitrokey/cxx_semantics.h"
-#include "libnitrokey/stick20_commands.h"
-#include "version.h"
-
-#ifdef _MSC_VER
-#ifdef _WIN32
-#pragma message "Using own strndup"
-char * strndup(const char* str, size_t maxlen) {
- size_t len = strnlen(str, maxlen);
- char* dup = (char *)malloc(len + 1);
- memcpy(dup, str, len);
- dup[len] = 0;
- return dup;
-}
-#endif
-#endif
-
-using namespace nitrokey;
-
-static uint8_t NK_last_command_status = 0;
-static const int max_string_field_length = 100;
-
-template <typename T>
-T* duplicate_vector_and_clear(std::vector<T> &v){
- auto d = new T[v.size()];
- std::copy(v.begin(), v.end(), d);
- std::fill(v.begin(), v.end(), 0);
- return d;
-}
-
-template <typename R, typename T>
-std::tuple<int, R> get_with_status(T func, R fallback) {
- NK_last_command_status = 0;
- try {
- return std::make_tuple(0, func());
- }
- catch (CommandFailedException & commandFailedException){
- NK_last_command_status = commandFailedException.last_command_status;
- }
- catch (LibraryException & libraryException){
- NK_last_command_status = libraryException.exception_id();
- }
- catch (const DeviceCommunicationException &deviceException){
- NK_last_command_status = 256-deviceException.getType();
- }
- return std::make_tuple(NK_last_command_status, fallback);
-}
-
-template <typename T>
-uint8_t * get_with_array_result(T func){
- return std::get<1>(get_with_status<uint8_t*>(func, nullptr));
-}
-
-template <typename T>
-char* get_with_string_result(T func){
- auto result = std::get<1>(get_with_status<char*>(func, nullptr));
- if (result == nullptr) {
- return strndup("", MAXIMUM_STR_REPLY_LENGTH);
- }
- return result;
-}
-
-template <typename T>
-auto get_with_result(T func){
- return std::get<1>(get_with_status(func, static_cast<decltype(func())>(0)));
-}
-
-template <typename T>
-uint8_t get_without_result(T func){
- NK_last_command_status = 0;
- try {
- func();
- return 0;
- }
- catch (CommandFailedException & commandFailedException){
- NK_last_command_status = commandFailedException.last_command_status;
- }
- catch (LibraryException & libraryException){
- NK_last_command_status = libraryException.exception_id();
- }
- catch (const InvalidCRCReceived &invalidCRCException){
- ;
- }
- catch (const DeviceCommunicationException &deviceException){
- NK_last_command_status = 256-deviceException.getType();
- }
- return NK_last_command_status;
-}
-
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
- NK_C_API uint8_t NK_get_last_command_status() {
- auto _copy = NK_last_command_status;
- NK_last_command_status = 0;
- return _copy;
- }
-
- NK_C_API int NK_login(const char *device_model) {
- auto m = NitrokeyManager::instance();
- try {
- NK_last_command_status = 0;
- return m->connect(device_model);
- }
- catch (CommandFailedException & commandFailedException) {
- NK_last_command_status = commandFailedException.last_command_status;
- return commandFailedException.last_command_status;
- }
- catch (const DeviceCommunicationException &deviceException){
- NK_last_command_status = 256-deviceException.getType();
- cerr << deviceException.what() << endl;
- return 0;
- }
- catch (std::runtime_error &e) {
- cerr << e.what() << endl;
- return 0;
- }
- return 0;
- }
-
- NK_C_API int NK_login_enum(NK_device_model device_model) {
- const char *model_string;
- switch (device_model) {
- case NK_PRO:
- model_string = "P";
- break;
- case NK_STORAGE:
- model_string = "S";
- break;
- case NK_DISCONNECTED:
- default:
- /* no such enum value -- return error code */
- return 0;
- }
- return NK_login(model_string);
- }
-
- NK_C_API int NK_logout() {
- auto m = NitrokeyManager::instance();
- return get_without_result([&]() {
- m->disconnect();
- });
- }
-
- NK_C_API int NK_first_authenticate(const char* admin_password, const char* admin_temporary_password) {
- auto m = NitrokeyManager::instance();
- return get_without_result([&]() {
- return m->first_authenticate(admin_password, admin_temporary_password);
- });
- }
-
-
- NK_C_API int NK_user_authenticate(const char* user_password, const char* user_temporary_password) {
- auto m = NitrokeyManager::instance();
- return get_without_result([&]() {
- m->user_authenticate(user_password, user_temporary_password);
- });
- }
-
- NK_C_API int NK_factory_reset(const char* admin_password) {
- auto m = NitrokeyManager::instance();
- return get_without_result([&]() {
- m->factory_reset(admin_password);
- });
- }
- NK_C_API int NK_build_aes_key(const char* admin_password) {
- auto m = NitrokeyManager::instance();
- return get_without_result([&]() {
- m->build_aes_key(admin_password);
- });
- }
-
- NK_C_API int NK_unlock_user_password(const char *admin_password, const char *new_user_password) {
- auto m = NitrokeyManager::instance();
- return get_without_result([&]() {
- m->unlock_user_password(admin_password, new_user_password);
- });
- }
-
- NK_C_API int NK_write_config(uint8_t numlock, uint8_t capslock, uint8_t scrolllock, bool enable_user_password,
- bool delete_user_password,
- const char *admin_temporary_password) {
- auto m = NitrokeyManager::instance();
- return get_without_result([&]() {
- return m->write_config(numlock, capslock, scrolllock, enable_user_password, delete_user_password, admin_temporary_password);
- });
- }
-
-
- NK_C_API uint8_t* NK_read_config() {
- auto m = NitrokeyManager::instance();
- return get_with_array_result([&]() {
- auto v = m->read_config();
- return duplicate_vector_and_clear(v);
- });
- }
-
-
- NK_C_API enum NK_device_model NK_get_device_model() {
- auto m = NitrokeyManager::instance();
- try {
- auto model = m->get_connected_device_model();
- switch (model) {
- case DeviceModel::PRO:
- return NK_PRO;
- case DeviceModel::STORAGE:
- return NK_STORAGE;
- default:
- /* unknown or not connected device */
- return NK_device_model::NK_DISCONNECTED;
- }
- } catch (const DeviceNotConnected& e) {
- return NK_device_model::NK_DISCONNECTED;
- }
-}
-
-
- void clear_string(std::string &s) {
- std::fill(s.begin(), s.end(), ' ');
- }
-
-
- NK_C_API char * NK_status() {
- auto m = NitrokeyManager::instance();
- return get_with_string_result([&]() {
- string && s = m->get_status_as_string();
- char * rs = strndup(s.c_str(), MAXIMUM_STR_REPLY_LENGTH);
- clear_string(s);
- return rs;
- });
- }
-
- NK_C_API char * NK_device_serial_number() {
- auto m = NitrokeyManager::instance();
- return get_with_string_result([&]() {
- string && s = m->get_serial_number();
- char * rs = strndup(s.c_str(), max_string_field_length);
- clear_string(s);
- return rs;
- });
- }
-
- NK_C_API char * NK_get_hotp_code(uint8_t slot_number) {
- return NK_get_hotp_code_PIN(slot_number, "");
- }
-
- NK_C_API char * NK_get_hotp_code_PIN(uint8_t slot_number, const char *user_temporary_password) {
- auto m = NitrokeyManager::instance();
- return get_with_string_result([&]() {
- string && s = m->get_HOTP_code(slot_number, user_temporary_password);
- char * rs = strndup(s.c_str(), max_string_field_length);
- clear_string(s);
- return rs;
- });
- }
-
- NK_C_API char * NK_get_totp_code(uint8_t slot_number, uint64_t challenge, uint64_t last_totp_time,
- uint8_t last_interval) {
- return NK_get_totp_code_PIN(slot_number, challenge, last_totp_time, last_interval, "");
- }
-
- NK_C_API char * NK_get_totp_code_PIN(uint8_t slot_number, uint64_t challenge, uint64_t last_totp_time,
- uint8_t last_interval, const char *user_temporary_password) {
- auto m = NitrokeyManager::instance();
- return get_with_string_result([&]() {
- string && s = m->get_TOTP_code(slot_number, challenge, last_totp_time, last_interval, user_temporary_password);
- char * rs = strndup(s.c_str(), max_string_field_length);
- clear_string(s);
- return rs;
- });
- }
-
- NK_C_API int NK_erase_hotp_slot(uint8_t slot_number, const char *temporary_password) {
- auto m = NitrokeyManager::instance();
- return get_without_result([&] {
- m->erase_hotp_slot(slot_number, temporary_password);
- });
- }
-
- NK_C_API int NK_erase_totp_slot(uint8_t slot_number, const char *temporary_password) {
- auto m = NitrokeyManager::instance();
- return get_without_result([&] {
- m->erase_totp_slot(slot_number, temporary_password);
- });
- }
-
- NK_C_API int NK_write_hotp_slot(uint8_t slot_number, const char *slot_name, const char *secret, uint64_t hotp_counter,
- bool use_8_digits, bool use_enter, bool use_tokenID, const char *token_ID,
- const char *temporary_password) {
- auto m = NitrokeyManager::instance();
- return get_without_result([&] {
- m->write_HOTP_slot(slot_number, slot_name, secret, hotp_counter, use_8_digits, use_enter, use_tokenID, token_ID,
- temporary_password);
- });
- }
-
- NK_C_API int NK_write_totp_slot(uint8_t slot_number, const char *slot_name, const char *secret, uint16_t time_window,
- bool use_8_digits, bool use_enter, bool use_tokenID, const char *token_ID,
- const char *temporary_password) {
- auto m = NitrokeyManager::instance();
- return get_without_result([&] {
- m->write_TOTP_slot(slot_number, slot_name, secret, time_window, use_8_digits, use_enter, use_tokenID, token_ID,
- temporary_password);
- });
- }
-
- NK_C_API char* NK_get_totp_slot_name(uint8_t slot_number) {
- auto m = NitrokeyManager::instance();
- return get_with_string_result([&]() {
- const auto slot_name = m->get_totp_slot_name(slot_number);
- return slot_name;
- });
- }
- NK_C_API char* NK_get_hotp_slot_name(uint8_t slot_number) {
- auto m = NitrokeyManager::instance();
- return get_with_string_result([&]() {
- const auto slot_name = m->get_hotp_slot_name(slot_number);
- return slot_name;
- });
- }
-
- NK_C_API void NK_set_debug(bool state) {
- auto m = NitrokeyManager::instance();
- m->set_debug(state);
- }
-
-
- NK_C_API void NK_set_debug_level(const int level) {
- auto m = NitrokeyManager::instance();
- m->set_loglevel(level);
- }
-
- NK_C_API unsigned int NK_get_major_library_version() {
- return get_major_library_version();
- }
-
- NK_C_API unsigned int NK_get_minor_library_version() {
- return get_minor_library_version();
- }
-
- NK_C_API const char* NK_get_library_version() {
- return get_library_version();
- }
-
- NK_C_API int NK_totp_set_time(uint64_t time) {
- auto m = NitrokeyManager::instance();
- return get_without_result([&]() {
- m->set_time(time);
- });
- }
-
- NK_C_API int NK_totp_set_time_soft(uint64_t time) {
- auto m = NitrokeyManager::instance();
- return get_without_result([&]() {
- m->set_time_soft(time);
- });
- }
-
- NK_C_API int NK_totp_get_time() {
- return 0;
- }
-
- NK_C_API int NK_change_admin_PIN(const char *current_PIN, const char *new_PIN) {
- auto m = NitrokeyManager::instance();
- return get_without_result([&]() {
- m->change_admin_PIN(current_PIN, new_PIN);
- });
- }
-
- NK_C_API int NK_change_user_PIN(const char *current_PIN, const char *new_PIN) {
- auto m = NitrokeyManager::instance();
- return get_without_result([&]() {
- m->change_user_PIN(current_PIN, new_PIN);
- });
- }
-
- NK_C_API int NK_enable_password_safe(const char *user_pin) {
- auto m = NitrokeyManager::instance();
- return get_without_result([&]() {
- m->enable_password_safe(user_pin);
- });
- }
- NK_C_API uint8_t * NK_get_password_safe_slot_status() {
- auto m = NitrokeyManager::instance();
- return get_with_array_result([&]() {
- auto slot_status = m->get_password_safe_slot_status();
- return duplicate_vector_and_clear(slot_status);
- });
-
- }
-
- NK_C_API uint8_t NK_get_user_retry_count() {
- auto m = NitrokeyManager::instance();
- return get_with_result([&]() {
- return m->get_user_retry_count();
- });
- }
-
- NK_C_API uint8_t NK_get_admin_retry_count() {
- auto m = NitrokeyManager::instance();
- return get_with_result([&]() {
- return m->get_admin_retry_count();
- });
- }
-
- NK_C_API int NK_lock_device() {
- auto m = NitrokeyManager::instance();
- return get_without_result([&]() {
- m->lock_device();
- });
- }
-
- NK_C_API char *NK_get_password_safe_slot_name(uint8_t slot_number) {
- auto m = NitrokeyManager::instance();
- return get_with_string_result([&]() {
- return m->get_password_safe_slot_name(slot_number);
- });
- }
-
- NK_C_API char *NK_get_password_safe_slot_login(uint8_t slot_number) {
- auto m = NitrokeyManager::instance();
- return get_with_string_result([&]() {
- return m->get_password_safe_slot_login(slot_number);
- });
- }
- NK_C_API char *NK_get_password_safe_slot_password(uint8_t slot_number) {
- auto m = NitrokeyManager::instance();
- return get_with_string_result([&]() {
- return m->get_password_safe_slot_password(slot_number);
- });
- }
- NK_C_API int NK_write_password_safe_slot(uint8_t slot_number, const char *slot_name, const char *slot_login,
- const char *slot_password) {
- auto m = NitrokeyManager::instance();
- return get_without_result([&]() {
- m->write_password_safe_slot(slot_number, slot_name, slot_login, slot_password);
- });
- }
-
- NK_C_API int NK_erase_password_safe_slot(uint8_t slot_number) {
- auto m = NitrokeyManager::instance();
- return get_without_result([&]() {
- m->erase_password_safe_slot(slot_number);
- });
- }
-
- NK_C_API int NK_is_AES_supported(const char *user_password) {
- auto m = NitrokeyManager::instance();
- return get_with_result([&]() {
- return (uint8_t)m->is_AES_supported(user_password);
- });
- }
-
- NK_C_API int NK_login_auto() {
- auto m = NitrokeyManager::instance();
- return get_with_result([&]() {
- return (uint8_t)m->connect();
- });
- }
-
- // storage commands
-
- NK_C_API int NK_send_startup(uint64_t seconds_from_epoch) {
- auto m = NitrokeyManager::instance();
- return get_without_result([&]() {
- m->send_startup(seconds_from_epoch);
- });
- }
-
- NK_C_API int NK_unlock_encrypted_volume(const char* user_pin) {
- auto m = NitrokeyManager::instance();
- return get_without_result([&]() {
- m->unlock_encrypted_volume(user_pin);
- });
- }
-
- NK_C_API int NK_lock_encrypted_volume() {
- auto m = NitrokeyManager::instance();
- return get_without_result([&]() {
- m->lock_encrypted_volume();
- });
- }
-
- NK_C_API int NK_unlock_hidden_volume(const char* hidden_volume_password) {
- auto m = NitrokeyManager::instance();
- return get_without_result([&]() {
- m->unlock_hidden_volume(hidden_volume_password);
- });
- }
-
- NK_C_API int NK_lock_hidden_volume() {
- auto m = NitrokeyManager::instance();
- return get_without_result([&]() {
- m->lock_hidden_volume();
- });
- }
-
- NK_C_API int NK_create_hidden_volume(uint8_t slot_nr, uint8_t start_percent, uint8_t end_percent,
- const char *hidden_volume_password) {
- auto m = NitrokeyManager::instance();
- return get_without_result([&]() {
- m->create_hidden_volume(slot_nr, start_percent, end_percent,
- hidden_volume_password);
- });
- }
-
- NK_C_API int NK_set_unencrypted_read_only(const char *user_pin) {
- auto m = NitrokeyManager::instance();
- return get_without_result([&]() {
- m->set_unencrypted_read_only(user_pin);
- });
- }
-
- NK_C_API int NK_set_unencrypted_read_write(const char *user_pin) {
- auto m = NitrokeyManager::instance();
- return get_without_result([&]() {
- m->set_unencrypted_read_write(user_pin);
- });
- }
-
- NK_C_API int NK_set_unencrypted_read_only_admin(const char *admin_pin) {
- auto m = NitrokeyManager::instance();
- return get_without_result([&]() {
- m->set_unencrypted_read_only_admin(admin_pin);
- });
- }
-
- NK_C_API int NK_set_unencrypted_read_write_admin(const char *admin_pin) {
- auto m = NitrokeyManager::instance();
- return get_without_result([&]() {
- m->set_unencrypted_read_write_admin(admin_pin);
- });
- }
-
- NK_C_API int NK_set_encrypted_read_only(const char* admin_pin) {
- auto m = NitrokeyManager::instance();
- return get_without_result([&]() {
- m->set_encrypted_volume_read_only(admin_pin);
- });
- }
-
- NK_C_API int NK_set_encrypted_read_write(const char* admin_pin) {
- auto m = NitrokeyManager::instance();
- return get_without_result([&]() {
- m->set_encrypted_volume_read_write(admin_pin);
- });
- }
-
- NK_C_API int NK_export_firmware(const char* admin_pin) {
- auto m = NitrokeyManager::instance();
- return get_without_result([&]() {
- m->export_firmware(admin_pin);
- });
- }
-
- NK_C_API int NK_clear_new_sd_card_warning(const char* admin_pin) {
- auto m = NitrokeyManager::instance();
- return get_without_result([&]() {
- m->clear_new_sd_card_warning(admin_pin);
- });
- }
-
- NK_C_API int NK_fill_SD_card_with_random_data(const char* admin_pin) {
- auto m = NitrokeyManager::instance();
- return get_without_result([&]() {
- m->fill_SD_card_with_random_data(admin_pin);
- });
- }
-
- NK_C_API int NK_change_update_password(const char* current_update_password,
- const char* new_update_password) {
- auto m = NitrokeyManager::instance();
- return get_without_result([&]() {
- m->change_update_password(current_update_password, new_update_password);
- });
- }
-
- NK_C_API int NK_enable_firmware_update(const char* update_password){
- auto m = NitrokeyManager::instance();
- return get_without_result([&]() {
- m->enable_firmware_update(update_password);
- });
- }
-
- NK_C_API char* NK_get_status_storage_as_string() {
- auto m = NitrokeyManager::instance();
- return get_with_string_result([&]() {
- return m->get_status_storage_as_string();
- });
- }
-
- NK_C_API int NK_get_status_storage(NK_storage_status* out) {
- if (out == nullptr) {
- return -1;
- }
- auto m = NitrokeyManager::instance();
- auto result = get_with_status([&]() {
- return m->get_status_storage();
- }, proto::stick20::DeviceConfigurationResponsePacket::ResponsePayload());
- auto error_code = std::get<0>(result);
- if (error_code != 0) {
- return error_code;
- }
-
- auto status = std::get<1>(result);
- out->unencrypted_volume_read_only = status.ReadWriteFlagUncryptedVolume_u8 != 0;
- out->unencrypted_volume_active = status.VolumeActiceFlag_st.unencrypted;
- out->encrypted_volume_read_only = status.ReadWriteFlagCryptedVolume_u8 != 0;
- out->encrypted_volume_active = status.VolumeActiceFlag_st.encrypted;
- out->hidden_volume_read_only = status.ReadWriteFlagHiddenVolume_u8 != 0;
- out->hidden_volume_active = status.VolumeActiceFlag_st.hidden;
- out->firmware_version_major = status.versionInfo.major;
- out->firmware_version_minor = status.versionInfo.minor;
- out->firmware_locked = status.FirmwareLocked_u8 != 0;
- out->serial_number_sd_card = status.ActiveSD_CardID_u32;
- out->serial_number_smart_card = status.ActiveSmartCardID_u32;
- out->user_retry_count = status.UserPwRetryCount;
- out->admin_retry_count = status.AdminPwRetryCount;
- out->new_sd_card_found = status.NewSDCardFound_st.NewCard;
- out->filled_with_random = (status.SDFillWithRandomChars_u8 & 0x01) != 0;
- out->stick_initialized = status.StickKeysNotInitiated == 0;
- return 0;
- }
-
- NK_C_API int NK_get_storage_production_info(NK_storage_ProductionTest * out){
- if (out == nullptr) {
- return -1;
- }
- auto m = NitrokeyManager::instance();
- auto result = get_with_status([&]() {
- return m->production_info();
- }, proto::stick20::ProductionTest::ResponsePayload());
-
- auto error_code = std::get<0>(result);
- if (error_code != 0) {
- return error_code;
- }
-
- stick20::ProductionTest::ResponsePayload status = std::get<1>(result);
- // Cannot use memcpy without declaring C API struct packed
- // (which is not parsed by Python's CFFI apparently), hence the manual way.
-#define a(x) out->x = status.x;
- a(FirmwareVersion_au8[0]);
- a(FirmwareVersion_au8[1]);
- a(FirmwareVersionInternal_u8);
- a(SD_Card_Size_u8);
- a(CPU_CardID_u32);
- a(SmartCardID_u32);
- a(SD_CardID_u32);
- a(SC_UserPwRetryCount);
- a(SC_AdminPwRetryCount);
- a(SD_Card_ManufacturingYear_u8);
- a(SD_Card_ManufacturingMonth_u8);
- a(SD_Card_OEM_u16);
- a(SD_WriteSpeed_u16);
- a(SD_Card_Manufacturer_u8);
-#undef a
- return 0;
- }
-
-
-NK_C_API char* NK_get_SD_usage_data_as_string() {
- auto m = NitrokeyManager::instance();
- return get_with_string_result([&]() {
- return m->get_SD_usage_data_as_string();
- });
- }
-
- NK_C_API int NK_get_progress_bar_value() {
- auto m = NitrokeyManager::instance();
- return get_with_result([&]() {
- return m->get_progress_bar_value();
- });
- }
-
- NK_C_API int NK_get_major_firmware_version() {
- auto m = NitrokeyManager::instance();
- return get_with_result([&]() {
- return m->get_major_firmware_version();
- });
- }
-
- NK_C_API int NK_get_minor_firmware_version() {
- auto m = NitrokeyManager::instance();
- return get_with_result([&]() {
- return m->get_minor_firmware_version();
- });
- }
-
- NK_C_API int NK_set_unencrypted_volume_rorw_pin_type_user() {
- auto m = NitrokeyManager::instance();
- return get_with_result([&]() {
- return m->set_unencrypted_volume_rorw_pin_type_user() ? 1 : 0;
- });
- }
-
- NK_C_API char* NK_list_devices_by_cpuID() {
- auto nm = NitrokeyManager::instance();
- return get_with_string_result([&]() {
- auto v = nm->list_devices_by_cpuID();
- std::string res;
- for (const auto a : v){
- res += a+";";
- }
- if (res.size()>0) res.pop_back(); // remove last delimiter char
- return strndup(res.c_str(), MAXIMUM_STR_REPLY_LENGTH);
- });
- }
-
- NK_C_API int NK_connect_with_ID(const char* id) {
- auto m = NitrokeyManager::instance();
- return get_with_result([&]() {
- return m->connect_with_ID(id) ? 1 : 0;
- });
- }
-
- NK_C_API int NK_wink() {
- auto m = NitrokeyManager::instance();
- return get_without_result([&]() {
- return m->wink();
- });
- }
-
-#ifdef __cplusplus
-}
-#endif
diff --git a/nitrokey-sys/libnitrokey-v3.4.1/NK_C_API.h b/nitrokey-sys/libnitrokey-v3.4.1/NK_C_API.h
deleted file mode 100644
index b1bdf1e..0000000
--- a/nitrokey-sys/libnitrokey-v3.4.1/NK_C_API.h
+++ /dev/null
@@ -1,792 +0,0 @@
-/*
- * Copyright (c) 2015-2018 Nitrokey UG
- *
- * This file is part of libnitrokey.
- *
- * libnitrokey is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * any later version.
- *
- * libnitrokey is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with libnitrokey. If not, see <http://www.gnu.org/licenses/>.
- *
- * SPDX-License-Identifier: LGPL-3.0
- */
-
-#ifndef LIBNITROKEY_NK_C_API_H
-#define LIBNITROKEY_NK_C_API_H
-
-#include <stdbool.h>
-#include <stdint.h>
-
-#include "deprecated.h"
-
-#ifdef _MSC_VER
-#define NK_C_API __declspec(dllexport)
-#else
-#define NK_C_API
-#endif
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
- static const int MAXIMUM_STR_REPLY_LENGTH = 8192;
-
- /**
- * The Nitrokey device models supported by the API.
- */
- enum NK_device_model {
- /**
- * Use, if no supported device is connected
- */
- NK_DISCONNECTED = 0,
- /**
- * Nitrokey Pro.
- */
- NK_PRO = 1,
- /**
- * Nitrokey Storage.
- */
- NK_STORAGE = 2
- };
-
- /**
- * Stores the status of a Storage device.
- */
- struct NK_storage_status {
- /**
- * Indicates whether the unencrypted volume is read-only.
- */
- bool unencrypted_volume_read_only;
- /**
- * Indicates whether the unencrypted volume is active.
- */
- bool unencrypted_volume_active;
- /**
- * Indicates whether the encrypted volume is read-only.
- */
- bool encrypted_volume_read_only;
- /**
- * Indicates whether the encrypted volume is active.
- */
- bool encrypted_volume_active;
- /**
- * Indicates whether the hidden volume is read-only.
- */
- bool hidden_volume_read_only;
- /**
- * Indicates whether the hidden volume is active.
- */
- bool hidden_volume_active;
- /**
- * The major firmware version, e. g. 0 in v0.40.
- */
- uint8_t firmware_version_major;
- /**
- * The minor firmware version, e. g. 40 in v0.40.
- */
- uint8_t firmware_version_minor;
- /**
- * Indicates whether the firmware is locked.
- */
- bool firmware_locked;
- /**
- * The serial number of the SD card in the Storage stick.
- */
- uint32_t serial_number_sd_card;
- /**
- * The serial number of the smart card in the Storage stick.
- */
- uint32_t serial_number_smart_card;
- /**
- * The number of remaining login attempts for the user PIN.
- */
- uint8_t user_retry_count;
- /**
- * The number of remaining login attempts for the admin PIN.
- */
- uint8_t admin_retry_count;
- /**
- * Indicates whether a new SD card was found.
- */
- bool new_sd_card_found;
- /**
- * Indicates whether the SD card is filled with random characters.
- */
- bool filled_with_random;
- /**
- * Indicates whether the stick has been initialized by generating
- * the AES keys.
- */
- bool stick_initialized;
- };
-
- struct NK_storage_ProductionTest{
- uint8_t FirmwareVersion_au8[2];
- uint8_t FirmwareVersionInternal_u8;
- uint8_t SD_Card_Size_u8;
- uint32_t CPU_CardID_u32;
- uint32_t SmartCardID_u32;
- uint32_t SD_CardID_u32;
- uint8_t SC_UserPwRetryCount;
- uint8_t SC_AdminPwRetryCount;
- uint8_t SD_Card_ManufacturingYear_u8;
- uint8_t SD_Card_ManufacturingMonth_u8;
- uint16_t SD_Card_OEM_u16;
- uint16_t SD_WriteSpeed_u16;
- uint8_t SD_Card_Manufacturer_u8;
- };
-
- NK_C_API int NK_get_storage_production_info(struct NK_storage_ProductionTest * out);
-
-
-/**
- * Set debug level of messages written on stderr
- * @param state state=True - most messages, state=False - only errors level
- */
- NK_C_API void NK_set_debug(bool state);
-
- /**
- * Set debug level of messages written on stderr
- * @param level (int) 0-lowest verbosity, 5-highest verbosity
- */
- NK_C_API void NK_set_debug_level(const int level);
-
- /**
- * Get the major library version, e. g. the 3 in v3.2.
- * @return the major library version
- */
- NK_C_API unsigned int NK_get_major_library_version();
-
- /**
- * Get the minor library version, e. g. the 2 in v3.2.
- * @return the minor library version
- */
- NK_C_API unsigned int NK_get_minor_library_version();
-
- /**
- * Get the library version as a string. This is the output of
- * `git describe --always` at compile time, for example "v3.3" or
- * "v3.3-19-gaee920b".
- * The return value is a string literal and must not be freed.
- * @return the library version as a string
- */
- NK_C_API const char* NK_get_library_version();
-
- /**
- * Connect to device of given model. Currently library can be connected only to one device at once.
- * @param device_model char 'S': Nitrokey Storage, 'P': Nitrokey Pro
- * @return 1 if connected, 0 if wrong model or cannot connect
- */
- NK_C_API int NK_login(const char *device_model);
-
- /**
- * Connect to device of given model. Currently library can be connected only to one device at once.
- * @param device_model NK_device_model: NK_PRO: Nitrokey Pro, NK_STORAGE: Nitrokey Storage
- * @return 1 if connected, 0 if wrong model or cannot connect
- */
- NK_C_API int NK_login_enum(enum NK_device_model device_model);
-
- /**
- * Connect to first available device, starting checking from Pro 1st to Storage 2nd.
- * @return 1 if connected, 0 if wrong model or cannot connect
- */
- NK_C_API int NK_login_auto();
-
- /**
- * Disconnect from the device.
- * @return command processing error code
- */
- NK_C_API int NK_logout();
-
- /**
- * Query the model of the connected device.
- * Returns the model of the connected device or NK_DISCONNECTED.
- *
- * @return true if a device is connected and the out argument has been set
- */
- NK_C_API enum NK_device_model NK_get_device_model();
-
- /**
- * Return the debug status string. Debug purposes.
- * @return command processing error code
- */
- NK_C_API char * NK_status();
-
- /**
- * Return the device's serial number string in hex.
- * @return string device's serial number in hex
- */
- NK_C_API char * NK_device_serial_number();
-
- /**
- * Get last command processing status. Useful for commands which returns the results of their own and could not return
- * an error code.
- * @return previous command processing error code
- */
- NK_C_API uint8_t NK_get_last_command_status();
-
- /**
- * Lock device - cancel any user device unlocking.
- * @return command processing error code
- */
- NK_C_API int NK_lock_device();
-
- /**
- * Authenticates the user on USER privilages with user_password and sets user's temporary password on device to user_temporary_password.
- * @param user_password char[25] current user password
- * @param user_temporary_password char[25] user temporary password to be set on device for further communication (authentication command)
- * @return command processing error code
- */
- NK_C_API int NK_user_authenticate(const char* user_password, const char* user_temporary_password);
-
- /**
- * Authenticates the user on ADMIN privilages with admin_password and sets user's temporary password on device to admin_temporary_password.
- * @param admin_password char[25] current administrator PIN
- * @param admin_temporary_password char[25] admin temporary password to be set on device for further communication (authentication command)
- * @return command processing error code
- */
- NK_C_API int NK_first_authenticate(const char* admin_password, const char* admin_temporary_password);
-
- /**
- * Execute a factory reset.
- * @param admin_password char[20] current administrator PIN
- * @return command processing error code
- */
- NK_C_API int NK_factory_reset(const char* admin_password);
-
- /**
- * Generates AES key on the device
- * @param admin_password char[20] current administrator PIN
- * @return command processing error code
- */
- NK_C_API int NK_build_aes_key(const char* admin_password);
-
- /**
- * Unlock user PIN locked after 3 incorrect codes tries.
- * @param admin_password char[20] current administrator PIN
- * @return command processing error code
- */
- NK_C_API int NK_unlock_user_password(const char *admin_password, const char *new_user_password);
-
- /**
- * Write general config to the device
- * @param numlock set value in range [0-1] to send HOTP code from slot 'numlock' after double pressing numlock
- * or outside the range to disable this function
- * @param capslock similar to numlock but with capslock
- * @param scrolllock similar to numlock but with scrolllock
- * @param enable_user_password set True to enable OTP PIN protection (require PIN each OTP code request)
- * @param delete_user_password (unused)
- * @param admin_temporary_password current admin temporary password
- * @return command processing error code
- */
- NK_C_API int NK_write_config(uint8_t numlock, uint8_t capslock, uint8_t scrolllock,
- bool enable_user_password, bool delete_user_password, const char *admin_temporary_password);
-
- /**
- * Get currently set config - status of function Numlock/Capslock/Scrollock OTP sending and is enabled PIN protected OTP
- * @see NK_write_config
- * @return uint8_t general_config[5]:
- * uint8_t numlock;
- uint8_t capslock;
- uint8_t scrolllock;
- uint8_t enable_user_password;
- uint8_t delete_user_password;
-
- */
- NK_C_API uint8_t* NK_read_config();
-
- //OTP
-
- /**
- * Get name of given TOTP slot
- * @param slot_number TOTP slot number, slot_number<15
- * @return char[20] the name of the slot
- */
- NK_C_API char * NK_get_totp_slot_name(uint8_t slot_number);
-
- /**
- *
- * @param slot_number HOTP slot number, slot_number<3
- * @return char[20] the name of the slot
- */
- NK_C_API char * NK_get_hotp_slot_name(uint8_t slot_number);
-
- /**
- * Erase HOTP slot data from the device
- * @param slot_number HOTP slot number, slot_number<3
- * @param temporary_password admin temporary password
- * @return command processing error code
- */
- NK_C_API int NK_erase_hotp_slot(uint8_t slot_number, const char *temporary_password);
-
- /**
- * Erase TOTP slot data from the device
- * @param slot_number TOTP slot number, slot_number<15
- * @param temporary_password admin temporary password
- * @return command processing error code
- */
- NK_C_API int NK_erase_totp_slot(uint8_t slot_number, const char *temporary_password);
-
- /**
- * Write HOTP slot data to the device
- * @param slot_number HOTP slot number, slot_number<3, 0-numbered
- * @param slot_name char[15] desired slot name. C string (requires ending '\0'; 16 bytes).
- * @param secret char[40] 160-bit or 320-bit (currently Pro v0.8 only) secret as a hex string. C string (requires ending '\0'; 41 bytes).
- * See NitrokeyManager::is_320_OTP_secret_supported.
- * @param hotp_counter uint32_t starting value of HOTP counter
- * @param use_8_digits should returned codes be 6 (false) or 8 digits (true)
- * @param use_enter press ENTER key after sending OTP code using double-pressed scroll/num/capslock
- * @param use_tokenID @see token_ID
- * @param token_ID @see https://openauthentication.org/token-specs/, 'Class A' section
- * @param temporary_password char[25] admin temporary password
- * @return command processing error code
- */
- NK_C_API int NK_write_hotp_slot(uint8_t slot_number, const char *slot_name, const char *secret, uint64_t hotp_counter,
- bool use_8_digits, bool use_enter, bool use_tokenID, const char *token_ID,
- const char *temporary_password);
-
- /**
- * Write TOTP slot data to the device
- * @param slot_number TOTP slot number, slot_number<15, 0-numbered
- * @param slot_name char[15] desired slot name. C string (requires ending '\0'; 16 bytes).
- * @param secret char[40] 160-bit or 320-bit (currently Pro v0.8 only) secret as a hex string. C string (requires ending '\0'; 41 bytes).
- * See NitrokeyManager::is_320_OTP_secret_supported.
- * @param time_window uint16_t time window for this TOTP
- * @param use_8_digits should returned codes be 6 (false) or 8 digits (true)
- * @param use_enter press ENTER key after sending OTP code using double-pressed scroll/num/capslock
- * @param use_tokenID @see token_ID
- * @param token_ID @see https://openauthentication.org/token-specs/, 'Class A' section
- * @param temporary_password char[20] admin temporary password
- * @return command processing error code
- */
- NK_C_API int NK_write_totp_slot(uint8_t slot_number, const char *slot_name, const char *secret, uint16_t time_window,
- bool use_8_digits, bool use_enter, bool use_tokenID, const char *token_ID,
- const char *temporary_password);
-
- /**
- * Get HOTP code from the device
- * @param slot_number HOTP slot number, slot_number<3
- * @return HOTP code
- */
- NK_C_API char * NK_get_hotp_code(uint8_t slot_number);
-
- /**
- * Get HOTP code from the device (PIN protected)
- * @param slot_number HOTP slot number, slot_number<3
- * @param user_temporary_password char[25] user temporary password if PIN protected OTP codes are enabled,
- * otherwise should be set to empty string - ''
- * @return HOTP code
- */
- NK_C_API char * NK_get_hotp_code_PIN(uint8_t slot_number, const char *user_temporary_password);
-
- /**
- * Get TOTP code from the device
- * @param slot_number TOTP slot number, slot_number<15
- * @param challenge TOTP challenge -- unused
- * @param last_totp_time last time -- unused
- * @param last_interval last interval --unused
- * @return TOTP code
- */
- NK_C_API char * NK_get_totp_code(uint8_t slot_number, uint64_t challenge, uint64_t last_totp_time,
- uint8_t last_interval);
-
- /**
- * Get TOTP code from the device (PIN protected)
- * @param slot_number TOTP slot number, slot_number<15
- * @param challenge TOTP challenge -- unused
- * @param last_totp_time last time -- unused
- * @param last_interval last interval -- unused
- * @param user_temporary_password char[25] user temporary password if PIN protected OTP codes are enabled,
- * otherwise should be set to empty string - ''
- * @return TOTP code
- */
- NK_C_API char * NK_get_totp_code_PIN(uint8_t slot_number, uint64_t challenge,
- uint64_t last_totp_time, uint8_t last_interval,
- const char *user_temporary_password);
-
- /**
- * Set time on the device (for TOTP requests)
- * @param time seconds in unix epoch (from 01.01.1970)
- * @return command processing error code
- */
- NK_C_API int NK_totp_set_time(uint64_t time);
-
- /**
- * Set the device time used for TOTP to the given time. Contrary to
- * {@code set_time(uint64_t)}, this command fails if {@code old_time}
- * &gt; {@code time} or if {@code old_time} is zero (where {@code
- * old_time} is the current time on the device).
- *
- * @param time new device time as Unix timestamp (seconds since
- * 1970-01-01)
- * @return command processing error code
- */
- NK_C_API int NK_totp_set_time_soft(uint64_t time);
-
- // NK_totp_get_time is deprecated -- use NK_totp_set_time_soft instead
- DEPRECATED
- NK_C_API int NK_totp_get_time();
-
- //passwords
- /**
- * Change administrator PIN
- * @param current_PIN char[25] current PIN
- * @param new_PIN char[25] new PIN
- * @return command processing error code
- */
- NK_C_API int NK_change_admin_PIN(const char *current_PIN, const char *new_PIN);
-
- /**
- * Change user PIN
- * @param current_PIN char[25] current PIN
- * @param new_PIN char[25] new PIN
- * @return command processing error code
- */
- NK_C_API int NK_change_user_PIN(const char *current_PIN, const char *new_PIN);
-
-
- /**
- * Get retry count of user PIN
- * @return user PIN retry count
- */
- NK_C_API uint8_t NK_get_user_retry_count();
-
- /**
- * Get retry count of admin PIN
- * @return admin PIN retry count
- */
- NK_C_API uint8_t NK_get_admin_retry_count();
- //password safe
-
- /**
- * Enable password safe access
- * @param user_pin char[30] current user PIN
- * @return command processing error code
- */
- NK_C_API int NK_enable_password_safe(const char *user_pin);
-
- /**
- * Get password safe slots' status
- * @return uint8_t[16] slot statuses - each byte represents one slot with 0 (not programmed) and 1 (programmed)
- */
- NK_C_API uint8_t * NK_get_password_safe_slot_status();
-
- /**
- * Get password safe slot name
- * @param slot_number password safe slot number, slot_number<16
- * @return slot name
- */
- NK_C_API char *NK_get_password_safe_slot_name(uint8_t slot_number);
-
- /**
- * Get password safe slot login
- * @param slot_number password safe slot number, slot_number<16
- * @return login from the PWS slot
- */
- NK_C_API char *NK_get_password_safe_slot_login(uint8_t slot_number);
-
- /**
- * Get the password safe slot password
- * @param slot_number password safe slot number, slot_number<16
- * @return password from the PWS slot
- */
- NK_C_API char *NK_get_password_safe_slot_password(uint8_t slot_number);
-
- /**
- * Write password safe data to the slot
- * @param slot_number password safe slot number, slot_number<16
- * @param slot_name char[11] name of the slot
- * @param slot_login char[32] login string
- * @param slot_password char[20] password string
- * @return command processing error code
- */
- NK_C_API int NK_write_password_safe_slot(uint8_t slot_number, const char *slot_name,
- const char *slot_login, const char *slot_password);
-
- /**
- * Erase the password safe slot from the device
- * @param slot_number password safe slot number, slot_number<16
- * @return command processing error code
- */
- NK_C_API int NK_erase_password_safe_slot(uint8_t slot_number);
-
- /**
- * Check whether AES is supported by the device
- * @return 0 for no and 1 for yes
- */
- NK_C_API int NK_is_AES_supported(const char *user_password);
-
- /**
- * Get device's major firmware version
- * @return major part of the version number (e.g. 0 from 0.48, 0 from 0.7 etc.)
- */
- NK_C_API int NK_get_major_firmware_version();
-
- /**
- * Get device's minor firmware version
- * @return minor part of the version number (e.g. 7 from 0.7, 48 from 0.48 etc.)
- */
- NK_C_API int NK_get_minor_firmware_version();
-
- /**
- * Function to determine unencrypted volume PIN type
- * @param minor_firmware_version
- * @return Returns 1, if set unencrypted volume ro/rw pin type is User, 0 otherwise.
- */
- NK_C_API int NK_set_unencrypted_volume_rorw_pin_type_user();
-
-
- /**
- * This command is typically run to initiate
- * communication with the device (altough not required).
- * It sets time on device and returns its current status
- * - a combination of set_time and get_status_storage commands
- * Storage only
- * @param seconds_from_epoch date and time expressed in seconds
- */
- NK_C_API int NK_send_startup(uint64_t seconds_from_epoch);
-
- /**
- * Unlock encrypted volume.
- * Storage only
- * @param user_pin user pin 20 characters
- * @return command processing error code
- */
- NK_C_API int NK_unlock_encrypted_volume(const char* user_pin);
-
- /**
- * Locks encrypted volume
- * @return command processing error code
- */
- NK_C_API int NK_lock_encrypted_volume();
-
- /**
- * Unlock hidden volume and lock encrypted volume.
- * Requires encrypted volume to be unlocked.
- * Storage only
- * @param hidden_volume_password 20 characters
- * @return command processing error code
- */
- NK_C_API int NK_unlock_hidden_volume(const char* hidden_volume_password);
-
- /**
- * Locks hidden volume
- * @return command processing error code
- */
- NK_C_API int NK_lock_hidden_volume();
-
- /**
- * Create hidden volume.
- * Requires encrypted volume to be unlocked.
- * Storage only
- * @param slot_nr slot number in range 0-3
- * @param start_percent volume begin expressed in percent of total available storage, int in range 0-99
- * @param end_percent volume end expressed in percent of total available storage, int in range 1-100
- * @param hidden_volume_password 20 characters
- * @return command processing error code
- */
- NK_C_API int NK_create_hidden_volume(uint8_t slot_nr, uint8_t start_percent, uint8_t end_percent,
- const char *hidden_volume_password);
-
- /**
- * Make unencrypted volume read-only.
- * Device hides unencrypted volume for a second therefore make sure
- * buffers are flushed before running.
- * Does nothing if firmware version is not matched
- * Firmware range: Storage v0.50, v0.48 and below
- * Storage only
- * @param user_pin 20 characters User PIN
- * @return command processing error code
- */
- NK_C_API int NK_set_unencrypted_read_only(const char *user_pin);
-
- /**
- * Make unencrypted volume read-write.
- * Device hides unencrypted volume for a second therefore make sure
- * buffers are flushed before running.
- * Does nothing if firmware version is not matched
- * Firmware range: Storage v0.50, v0.48 and below
- * Storage only
- * @param user_pin 20 characters User PIN
- * @return command processing error code
- */
- NK_C_API int NK_set_unencrypted_read_write(const char *user_pin);
-
- /**
- * Make unencrypted volume read-only.
- * Device hides unencrypted volume for a second therefore make sure
- * buffers are flushed before running.
- * Does nothing if firmware version is not matched
- * Firmware range: Storage v0.49, v0.51+
- * Storage only
- * @param admin_pin 20 characters Admin PIN
- * @return command processing error code
- */
- NK_C_API int NK_set_unencrypted_read_only_admin(const char* admin_pin);
-
- /**
- * Make unencrypted volume read-write.
- * Device hides unencrypted volume for a second therefore make sure
- * buffers are flushed before running.
- * Does nothing if firmware version is not matched
- * Firmware range: Storage v0.49, v0.51+
- * Storage only
- * @param admin_pin 20 characters Admin PIN
- * @return command processing error code
- */
- NK_C_API int NK_set_unencrypted_read_write_admin(const char* admin_pin);
-
- /**
- * Make encrypted volume read-only.
- * Device hides encrypted volume for a second therefore make sure
- * buffers are flushed before running.
- * Firmware range: v0.49 only, future (see firmware release notes)
- * Storage only
- * @param admin_pin 20 characters
- * @return command processing error code
- */
- NK_C_API int NK_set_encrypted_read_only(const char* admin_pin);
-
- /**
- * Make encrypted volume read-write.
- * Device hides encrypted volume for a second therefore make sure
- * buffers are flushed before running.
- * Firmware range: v0.49 only, future (see firmware release notes)
- * Storage only
- * @param admin_pin 20 characters
- * @return command processing error code
- */
- NK_C_API int NK_set_encrypted_read_write(const char* admin_pin);
-
- /**
- * Exports device's firmware to unencrypted volume.
- * Storage only
- * @param admin_pin 20 characters
- * @return command processing error code
- */
- NK_C_API int NK_export_firmware(const char* admin_pin);
-
- /**
- * Clear new SD card notification. It is set after factory reset.
- * Storage only
- * @param admin_pin 20 characters
- * @return command processing error code
- */
- NK_C_API int NK_clear_new_sd_card_warning(const char* admin_pin);
-
- /**
- * Fill SD card with random data.
- * Should be done on first stick initialization after creating keys.
- * Storage only
- * @param admin_pin 20 characters
- * @return command processing error code
- */
- NK_C_API int NK_fill_SD_card_with_random_data(const char* admin_pin);
-
- /**
- * Change update password.
- * Update password is used for entering update mode, where firmware
- * could be uploaded using dfu-programmer or other means.
- * Storage only
- * @param current_update_password 20 characters
- * @param new_update_password 20 characters
- * @return command processing error code
- */
- NK_C_API int NK_change_update_password(const char* current_update_password,
- const char* new_update_password);
-
- /**
- * Enter update mode. Needs update password.
- * When device is in update mode it no longer accepts any HID commands until
- * firmware is launched (regardless of being updated or not).
- * Smartcard (through CCID interface) and its all volumes are not visible as well.
- * Its VID and PID are changed to factory-default (03eb:2ff1 Atmel Corp.)
- * to be detected by flashing software. Result of this command can be reversed
- * by using 'launch' command.
- * For dfu-programmer it would be: 'dfu-programmer at32uc3a3256s launch'.
- * Storage only
- * @param update_password 20 characters
- * @return command processing error code
- */
- NK_C_API int NK_enable_firmware_update(const char* update_password);
-
- /**
- * Get Storage stick status as string.
- * Storage only
- * @return string with devices attributes
- */
- NK_C_API char* NK_get_status_storage_as_string();
-
- /**
- * Get the Storage stick status and return the command processing
- * error code. If the code is zero, i. e. the command was successful,
- * the storage status is written to the output pointer's target.
- * The output pointer must not be null.
- *
- * @param out the output pointer for the storage status
- * @return command processing error code
- */
- NK_C_API int NK_get_status_storage(struct NK_storage_status* out);
-
- /**
- * Get SD card usage attributes as string.
- * Usable during hidden volumes creation.
- * Storage only
- * @return string with SD card usage attributes
- */
- NK_C_API char* NK_get_SD_usage_data_as_string();
-
- /**
- * Get progress value of current long operation.
- * Storage only
- * @return int in range 0-100 or -1 if device is not busy
- */
- NK_C_API int NK_get_progress_bar_value();
-
-/**
- * Returns a list of connected devices' id's, delimited by ';' character. Empty string is returned on no device found.
- * Each ID could consist of:
- * 1. SC_id:SD_id_p_path (about 40 bytes)
- * 2. path (about 10 bytes)
- * where 'path' is USB path (bus:num), 'SC_id' is smartcard ID, 'SD_id' is storage card ID and
- * '_p_' and ':' are field delimiters.
- * Case 2 (USB path only) is used, when the device cannot be asked about its status data (e.g. during a long operation,
- * like clearing SD card.
- * Internally connects to all available devices and creates a map between ids and connection objects.
- * Side effects: changes active device to last detected Storage device.
- * Storage only
- * @example Example of returned data: '00005d19:dacc2cb4_p_0001:0010:02;000037c7:4cf12445_p_0001:000f:02;0001:000c:02'
- * @return string delimited id's of connected devices
- */
- NK_C_API char* NK_list_devices_by_cpuID();
-
-
-/**
- * Connects to the device with given ID. ID's list could be created with NK_list_devices_by_cpuID.
- * Requires calling to NK_list_devices_by_cpuID first. Connecting to arbitrary ID/USB path is not handled.
- * On connection requests status from device and disconnects it / removes from map on connection failure.
- * Storage only
- * @param id Target device ID (example: '00005d19:dacc2cb4_p_0001:0010:02')
- * @return 1 on successful connection, 0 otherwise
- */
- NK_C_API int NK_connect_with_ID(const char* id);
-
- /**
- * Blink red and green LED alternatively and infinitely (until device is reconnected).
- * @return command processing error code
- */
- NK_C_API int NK_wink();
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif //LIBNITROKEY_NK_C_API_H
diff --git a/nitrokey-sys/libnitrokey-v3.4.1/NitrokeyManager.cc b/nitrokey-sys/libnitrokey-v3.4.1/NitrokeyManager.cc
deleted file mode 100644
index a950e4b..0000000
--- a/nitrokey-sys/libnitrokey-v3.4.1/NitrokeyManager.cc
+++ /dev/null
@@ -1,1149 +0,0 @@
-/*
- * Copyright (c) 2015-2018 Nitrokey UG
- *
- * This file is part of libnitrokey.
- *
- * libnitrokey is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * any later version.
- *
- * libnitrokey is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with libnitrokey. If not, see <http://www.gnu.org/licenses/>.
- *
- * SPDX-License-Identifier: LGPL-3.0
- */
-
-#include <cstring>
-#include <iostream>
-#include "libnitrokey/NitrokeyManager.h"
-#include "libnitrokey/LibraryException.h"
-#include <algorithm>
-#include <unordered_map>
-#include <stick20_commands.h>
-#include "libnitrokey/misc.h"
-#include <mutex>
-#include "libnitrokey/cxx_semantics.h"
-#include <functional>
-#include <stick10_commands.h>
-
-std::mutex nitrokey::proto::send_receive_mtx;
-
-namespace nitrokey{
-
- std::mutex mex_dev_com_manager;
-
-#ifndef strndup
-#ifdef _WIN32
-#pragma message "Using own strndup"
-char * strndup(const char* str, size_t maxlen){
- size_t len = strnlen(str, maxlen);
- char* dup = (char *) malloc(len + 1);
- memcpy(dup, str, len);
- dup[len] = 0;
- return dup;
-}
-#endif
-#endif
-
-using nitrokey::misc::strcpyT;
-
- template <typename T>
- typename T::CommandPayload get_payload(){
- //Create, initialize and return by value command payload
- typename T::CommandPayload st;
- bzero(&st, sizeof(st));
- return st;
- }
-
-
- // package type to auth, auth type [Authorize,UserAuthorize]
- template <typename S, typename A, typename T>
- void NitrokeyManager::authorize_packet(T &package, const char *admin_temporary_password, shared_ptr<Device> device){
- if (!is_authorization_command_supported()){
- LOG("Authorization command not supported, skipping", Loglevel::WARNING);
- }
- auto auth = get_payload<A>();
- strcpyT(auth.temporary_password, admin_temporary_password);
- auth.crc_to_authorize = S::CommandTransaction::getCRC(package);
- A::CommandTransaction::run(device, auth);
- }
-
- shared_ptr <NitrokeyManager> NitrokeyManager::_instance = nullptr;
-
- NitrokeyManager::NitrokeyManager() : device(nullptr)
- {
- set_debug(false);
- }
- NitrokeyManager::~NitrokeyManager() {
- std::lock_guard<std::mutex> lock(mex_dev_com_manager);
-
- for (auto d : connected_devices){
- if (d.second == nullptr) continue;
- d.second->disconnect();
- connected_devices[d.first] = nullptr;
- }
- }
-
- bool NitrokeyManager::set_current_device_speed(int retry_delay, int send_receive_delay){
- if (retry_delay < 20 || send_receive_delay < 20){
- LOG("Delay set too low: " + to_string(retry_delay) +" "+ to_string(send_receive_delay), Loglevel::WARNING);
- return false;
- }
-
- std::lock_guard<std::mutex> lock(mex_dev_com_manager);
- if(device == nullptr) {
- return false;
- }
- device->set_receiving_delay(std::chrono::duration<int, std::milli>(send_receive_delay));
- device->set_retry_delay(std::chrono::duration<int, std::milli>(retry_delay));
- return true;
- }
-
- std::vector<std::string> NitrokeyManager::list_devices(){
- std::lock_guard<std::mutex> lock(mex_dev_com_manager);
-
- auto p = make_shared<Stick20>();
- return p->enumerate(); // make static
- }
-
- std::vector<std::string> NitrokeyManager::list_devices_by_cpuID(){
- using misc::toHex;
- //disconnect default device
- disconnect();
-
- std::lock_guard<std::mutex> lock(mex_dev_com_manager);
- LOGD1("Disconnecting registered devices");
- for (auto & kv : connected_devices_byID){
- if (kv.second != nullptr)
- kv.second->disconnect();
- }
- connected_devices_byID.clear();
-
- LOGD1("Enumerating devices");
- std::vector<std::string> res;
- auto d = make_shared<Stick20>();
- const auto v = d->enumerate();
- LOGD1("Discovering IDs");
- for (auto & p: v){
- d = make_shared<Stick20>();
- LOGD1( std::string("Found: ") + p );
- d->set_path(p);
- try{
- if (d->connect()){
- device = d;
- std::string id;
- try {
- const auto status = get_status_storage();
- const auto sc_id = toHex(status.ActiveSmartCardID_u32);
- const auto sd_id = toHex(status.ActiveSD_CardID_u32);
- id += sc_id + ":" + sd_id;
- id += "_p_" + p;
- }
- catch (const LongOperationInProgressException &e) {
- LOGD1(std::string("Long operation in progress, setting ID to: ") + p);
- id = p;
- }
-
- connected_devices_byID[id] = d;
- res.push_back(id);
- LOGD1( std::string("Found: ") + p + " => " + id);
- } else{
- LOGD1( std::string("Could not connect to: ") + p);
- }
- }
- catch (const DeviceCommunicationException &e){
- LOGD1( std::string("Exception encountered: ") + p);
- }
- }
- return res;
- }
-
- bool NitrokeyManager::connect_with_ID(const std::string id) {
- std::lock_guard<std::mutex> lock(mex_dev_com_manager);
-
- auto position = connected_devices_byID.find(id);
- if (position == connected_devices_byID.end()) {
- LOGD1(std::string("Could not find device ")+id + ". Refresh devices list with list_devices_by_cpuID().");
- return false;
- }
-
- auto d = connected_devices_byID[id];
- device = d;
- current_device_id = id;
-
- //validate connection
- try{
- get_status();
- }
- catch (const LongOperationInProgressException &){
- //ignore
- }
- catch (const DeviceCommunicationException &){
- d->disconnect();
- current_device_id = "";
- connected_devices_byID[id] = nullptr;
- connected_devices_byID.erase(position);
- return false;
- }
- nitrokey::log::Log::setPrefix(id);
- LOGD1("Device successfully changed");
- return true;
- }
-
- /**
- * Connects device to path.
- * Assumes devices are not being disconnected and caches connections (param cache_connections).
- * @param path os-dependent device path
- * @return false, when could not connect, true otherwise
- */
- bool NitrokeyManager::connect_with_path(std::string path) {
- const bool cache_connections = false;
-
- std::lock_guard<std::mutex> lock(mex_dev_com_manager);
-
- if (cache_connections){
- if(connected_devices.find(path) != connected_devices.end()
- && connected_devices[path] != nullptr) {
- device = connected_devices[path];
- return true;
- }
- }
-
- auto p = make_shared<Stick20>();
- p->set_path(path);
-
- if(!p->connect()) return false;
-
- if(cache_connections){
- connected_devices [path] = p;
- }
-
- device = p; //previous device will be disconnected automatically
- current_device_id = path;
- nitrokey::log::Log::setPrefix(path);
- LOGD1("Device successfully changed");
- return true;
- }
-
- bool NitrokeyManager::connect() {
- std::lock_guard<std::mutex> lock(mex_dev_com_manager);
- vector< shared_ptr<Device> > devices = { make_shared<Stick10>(), make_shared<Stick20>() };
- bool connected = false;
- for( auto & d : devices ){
- if (d->connect()){
- device = std::shared_ptr<Device>(d);
- connected = true;
- }
- }
- return connected;
- }
-
-
- void NitrokeyManager::set_log_function(std::function<void(std::string)> log_function){
- static nitrokey::log::FunctionalLogHandler handler(log_function);
- nitrokey::log::Log::instance().set_handler(&handler);
- }
-
- bool NitrokeyManager::set_default_commands_delay(int delay){
- if (delay < 20){
- LOG("Delay set too low: " + to_string(delay), Loglevel::WARNING);
- return false;
- }
- Device::set_default_device_speed(delay);
- return true;
- }
-
- bool NitrokeyManager::connect(const char *device_model) {
- std::lock_guard<std::mutex> lock(mex_dev_com_manager);
- LOG(__FUNCTION__, nitrokey::log::Loglevel::DEBUG_L2);
- switch (device_model[0]){
- case 'P':
- device = make_shared<Stick10>();
- break;
- case 'S':
- device = make_shared<Stick20>();
- break;
- default:
- throw std::runtime_error("Unknown model");
- }
- return device->connect();
- }
-
- bool NitrokeyManager::connect(device::DeviceModel device_model) {
- const char *model_string;
- switch (device_model) {
- case device::DeviceModel::PRO:
- model_string = "P";
- break;
- case device::DeviceModel::STORAGE:
- model_string = "S";
- break;
- default:
- throw std::runtime_error("Unknown model");
- }
- return connect(model_string);
- }
-
- shared_ptr<NitrokeyManager> NitrokeyManager::instance() {
- static std::mutex mutex;
- std::lock_guard<std::mutex> lock(mutex);
- if (_instance == nullptr){
- _instance = make_shared<NitrokeyManager>();
- }
- return _instance;
- }
-
-
-
- bool NitrokeyManager::disconnect() {
- std::lock_guard<std::mutex> lock(mex_dev_com_manager);
- return _disconnect_no_lock();
- }
-
- bool NitrokeyManager::_disconnect_no_lock() {
- //do not use directly without locked mutex,
- //used by could_be_enumerated, disconnect
- if (device == nullptr){
- return false;
- }
- const auto res = device->disconnect();
- device = nullptr;
- return res;
- }
-
- bool NitrokeyManager::is_connected() throw(){
- std::lock_guard<std::mutex> lock(mex_dev_com_manager);
- if(device != nullptr){
- auto connected = device->could_be_enumerated();
- if(connected){
- return true;
- } else {
- _disconnect_no_lock();
- return false;
- }
- }
- return false;
- }
-
- bool NitrokeyManager::could_current_device_be_enumerated() {
- std::lock_guard<std::mutex> lock(mex_dev_com_manager);
- if (device != nullptr) {
- return device->could_be_enumerated();
- }
- return false;
- }
-
- void NitrokeyManager::set_loglevel(int loglevel) {
- loglevel = max(loglevel, static_cast<int>(Loglevel::ERROR));
- loglevel = min(loglevel, static_cast<int>(Loglevel::DEBUG_L2));
- Log::instance().set_loglevel(static_cast<Loglevel>(loglevel));
- }
-
- void NitrokeyManager::set_loglevel(Loglevel loglevel) {
- Log::instance().set_loglevel(loglevel);
- }
-
- void NitrokeyManager::set_debug(bool state) {
- if (state){
- Log::instance().set_loglevel(Loglevel::DEBUG);
- } else {
- Log::instance().set_loglevel(Loglevel::ERROR);
- }
- }
-
-
- string NitrokeyManager::get_serial_number() {
- if (device == nullptr) { return ""; };
- switch (device->get_device_model()) {
- case DeviceModel::PRO: {
- auto response = GetStatus::CommandTransaction::run(device);
- return nitrokey::misc::toHex(response.data().card_serial_u32);
- }
- break;
-
- case DeviceModel::STORAGE:
- {
- auto response = stick20::GetDeviceStatus::CommandTransaction::run(device);
- return nitrokey::misc::toHex(response.data().ActiveSmartCardID_u32);
- }
- break;
- }
- return "NA";
- }
-
- stick10::GetStatus::ResponsePayload NitrokeyManager::get_status(){
- try{
- auto response = GetStatus::CommandTransaction::run(device);
- return response.data();
- }
- catch (DeviceSendingFailure &e){
-// disconnect();
- throw;
- }
- }
-
- string NitrokeyManager::get_status_as_string() {
- auto response = GetStatus::CommandTransaction::run(device);
- return response.data().dissect();
- }
-
- string getFilledOTPCode(uint32_t code, bool use_8_digits){
- stringstream s;
- s << std::right << std::setw(use_8_digits ? 8 : 6) << std::setfill('0') << code;
- return s.str();
- }
-
- string NitrokeyManager::get_HOTP_code(uint8_t slot_number, const char *user_temporary_password) {
- if (!is_valid_hotp_slot_number(slot_number)) throw InvalidSlotException(slot_number);
-
- if (is_authorization_command_supported()){
- auto gh = get_payload<GetHOTP>();
- gh.slot_number = get_internal_slot_number_for_hotp(slot_number);
- if(user_temporary_password != nullptr && strlen(user_temporary_password)!=0){ //FIXME use string instead of strlen
- authorize_packet<GetHOTP, UserAuthorize>(gh, user_temporary_password, device);
- }
- auto resp = GetHOTP::CommandTransaction::run(device, gh);
- return getFilledOTPCode(resp.data().code, resp.data().use_8_digits);
- } else {
- auto gh = get_payload<stick10_08::GetHOTP>();
- gh.slot_number = get_internal_slot_number_for_hotp(slot_number);
- if(user_temporary_password != nullptr && strlen(user_temporary_password)!=0) {
- strcpyT(gh.temporary_user_password, user_temporary_password);
- }
- auto resp = stick10_08::GetHOTP::CommandTransaction::run(device, gh);
- return getFilledOTPCode(resp.data().code, resp.data().use_8_digits);
- }
- return "";
- }
-
- bool NitrokeyManager::is_valid_hotp_slot_number(uint8_t slot_number) const { return slot_number < 3; }
- bool NitrokeyManager::is_valid_totp_slot_number(uint8_t slot_number) const { return slot_number < 0x10-1; } //15
- uint8_t NitrokeyManager::get_internal_slot_number_for_totp(uint8_t slot_number) const { return (uint8_t) (0x20 + slot_number); }
- uint8_t NitrokeyManager::get_internal_slot_number_for_hotp(uint8_t slot_number) const { return (uint8_t) (0x10 + slot_number); }
-
-
-
- string NitrokeyManager::get_TOTP_code(uint8_t slot_number, uint64_t challenge, uint64_t last_totp_time,
- uint8_t last_interval,
- const char *user_temporary_password) {
- if(!is_valid_totp_slot_number(slot_number)) throw InvalidSlotException(slot_number);
- slot_number = get_internal_slot_number_for_totp(slot_number);
-
- if (is_authorization_command_supported()){
- auto gt = get_payload<GetTOTP>();
- gt.slot_number = slot_number;
- gt.challenge = challenge;
- gt.last_interval = last_interval;
- gt.last_totp_time = last_totp_time;
-
- if(user_temporary_password != nullptr && strlen(user_temporary_password)!=0){ //FIXME use string instead of strlen
- authorize_packet<GetTOTP, UserAuthorize>(gt, user_temporary_password, device);
- }
- auto resp = GetTOTP::CommandTransaction::run(device, gt);
- return getFilledOTPCode(resp.data().code, resp.data().use_8_digits);
- } else {
- auto gt = get_payload<stick10_08::GetTOTP>();
- strcpyT(gt.temporary_user_password, user_temporary_password);
- gt.slot_number = slot_number;
- auto resp = stick10_08::GetTOTP::CommandTransaction::run(device, gt);
- return getFilledOTPCode(resp.data().code, resp.data().use_8_digits);
- }
- return "";
- }
-
- bool NitrokeyManager::erase_slot(uint8_t slot_number, const char *temporary_password) {
- if (is_authorization_command_supported()){
- auto p = get_payload<EraseSlot>();
- p.slot_number = slot_number;
- authorize_packet<EraseSlot, Authorize>(p, temporary_password, device);
- auto resp = EraseSlot::CommandTransaction::run(device,p);
- } else {
- auto p = get_payload<stick10_08::EraseSlot>();
- p.slot_number = slot_number;
- strcpyT(p.temporary_admin_password, temporary_password);
- auto resp = stick10_08::EraseSlot::CommandTransaction::run(device,p);
- }
- return true;
- }
-
- bool NitrokeyManager::erase_hotp_slot(uint8_t slot_number, const char *temporary_password) {
- if (!is_valid_hotp_slot_number(slot_number)) throw InvalidSlotException(slot_number);
- slot_number = get_internal_slot_number_for_hotp(slot_number);
- return erase_slot(slot_number, temporary_password);
- }
-
- bool NitrokeyManager::erase_totp_slot(uint8_t slot_number, const char *temporary_password) {
- if (!is_valid_totp_slot_number(slot_number)) throw InvalidSlotException(slot_number);
- slot_number = get_internal_slot_number_for_totp(slot_number);
- return erase_slot(slot_number, temporary_password);
- }
-
- template <typename T, typename U>
- void vector_copy_ranged(T& dest, std::vector<U> &vec, size_t begin, size_t elements_to_copy){
- const size_t d_size = sizeof(dest);
- if(d_size < elements_to_copy){
- throw TargetBufferSmallerThanSource(elements_to_copy, d_size);
- }
- std::fill(dest, dest+d_size, 0);
- std::copy(vec.begin() + begin, vec.begin() +begin + elements_to_copy, dest);
- }
-
- template <typename T, typename U>
- void vector_copy(T& dest, std::vector<U> &vec){
- const size_t d_size = sizeof(dest);
- if(d_size < vec.size()){
- throw TargetBufferSmallerThanSource(vec.size(), d_size);
- }
- std::fill(dest, dest+d_size, 0);
- std::copy(vec.begin(), vec.end(), dest);
- }
-
- bool NitrokeyManager::write_HOTP_slot(uint8_t slot_number, const char *slot_name, const char *secret, uint64_t hotp_counter,
- bool use_8_digits, bool use_enter, bool use_tokenID, const char *token_ID,
- const char *temporary_password) {
- if (!is_valid_hotp_slot_number(slot_number)) throw InvalidSlotException(slot_number);
-
- int internal_slot_number = get_internal_slot_number_for_hotp(slot_number);
- if (is_authorization_command_supported()){
- write_HOTP_slot_authorize(internal_slot_number, slot_name, secret, hotp_counter, use_8_digits, use_enter, use_tokenID,
- token_ID, temporary_password);
- } else {
- write_OTP_slot_no_authorize(internal_slot_number, slot_name, secret, hotp_counter, use_8_digits, use_enter, use_tokenID,
- token_ID, temporary_password);
- }
- return true;
- }
-
- void NitrokeyManager::write_HOTP_slot_authorize(uint8_t slot_number, const char *slot_name, const char *secret,
- uint64_t hotp_counter, bool use_8_digits, bool use_enter,
- bool use_tokenID, const char *token_ID, const char *temporary_password) {
- auto payload = get_payload<WriteToHOTPSlot>();
- payload.slot_number = slot_number;
- auto secret_bin = misc::hex_string_to_byte(secret);
- vector_copy(payload.slot_secret, secret_bin);
- strcpyT(payload.slot_name, slot_name);
- strcpyT(payload.slot_token_id, token_ID);
- switch (device->get_device_model() ){
- case DeviceModel::PRO: {
- payload.slot_counter = hotp_counter;
- break;
- }
- case DeviceModel::STORAGE: {
- string counter = to_string(hotp_counter);
- strcpyT(payload.slot_counter_s, counter.c_str());
- break;
- }
- default:
- LOG(string(__FILE__) + to_string(__LINE__) +
- string(__FUNCTION__) + string(" Unhandled device model for HOTP")
- , Loglevel::DEBUG);
- break;
- }
- payload.use_8_digits = use_8_digits;
- payload.use_enter = use_enter;
- payload.use_tokenID = use_tokenID;
-
- authorize_packet<WriteToHOTPSlot, Authorize>(payload, temporary_password, device);
-
- auto resp = WriteToHOTPSlot::CommandTransaction::run(device, payload);
- }
-
- bool NitrokeyManager::write_TOTP_slot(uint8_t slot_number, const char *slot_name, const char *secret, uint16_t time_window,
- bool use_8_digits, bool use_enter, bool use_tokenID, const char *token_ID,
- const char *temporary_password) {
- if (!is_valid_totp_slot_number(slot_number)) throw InvalidSlotException(slot_number);
- int internal_slot_number = get_internal_slot_number_for_totp(slot_number);
-
- if (is_authorization_command_supported()){
- write_TOTP_slot_authorize(internal_slot_number, slot_name, secret, time_window, use_8_digits, use_enter, use_tokenID,
- token_ID, temporary_password);
- } else {
- write_OTP_slot_no_authorize(internal_slot_number, slot_name, secret, time_window, use_8_digits, use_enter, use_tokenID,
- token_ID, temporary_password);
- }
-
- return true;
- }
-
- void NitrokeyManager::write_OTP_slot_no_authorize(uint8_t internal_slot_number, const char *slot_name,
- const char *secret,
- uint64_t counter_or_interval, bool use_8_digits, bool use_enter,
- bool use_tokenID, const char *token_ID,
- const char *temporary_password) const {
-
- auto payload2 = get_payload<stick10_08::SendOTPData>();
- strcpyT(payload2.temporary_admin_password, temporary_password);
- strcpyT(payload2.data, slot_name);
- payload2.setTypeName();
- stick10_08::SendOTPData::CommandTransaction::run(device, payload2);
-
- payload2.setTypeSecret();
- payload2.id = 0;
- auto secret_bin = misc::hex_string_to_byte(secret);
- auto remaining_secret_length = secret_bin.size();
- const auto maximum_OTP_secret_size = 40;
- if(remaining_secret_length > maximum_OTP_secret_size){
- throw TargetBufferSmallerThanSource(remaining_secret_length, maximum_OTP_secret_size);
- }
-
- while (remaining_secret_length>0){
- const auto bytesToCopy = std::min(sizeof(payload2.data), remaining_secret_length);
- const auto start = secret_bin.size() - remaining_secret_length;
- memset(payload2.data, 0, sizeof(payload2.data));
- vector_copy_ranged(payload2.data, secret_bin, start, bytesToCopy);
- stick10_08::SendOTPData::CommandTransaction::run(device, payload2);
- remaining_secret_length -= bytesToCopy;
- payload2.id++;
- }
-
- auto payload = get_payload<stick10_08::WriteToOTPSlot>();
- strcpyT(payload.temporary_admin_password, temporary_password);
- strcpyT(payload.slot_token_id, token_ID);
- payload.use_8_digits = use_8_digits;
- payload.use_enter = use_enter;
- payload.use_tokenID = use_tokenID;
- payload.slot_counter_or_interval = counter_or_interval;
- payload.slot_number = internal_slot_number;
- stick10_08::WriteToOTPSlot::CommandTransaction::run(device, payload);
- }
-
- void NitrokeyManager::write_TOTP_slot_authorize(uint8_t slot_number, const char *slot_name, const char *secret,
- uint16_t time_window, bool use_8_digits, bool use_enter,
- bool use_tokenID, const char *token_ID, const char *temporary_password) {
- auto payload = get_payload<WriteToTOTPSlot>();
- payload.slot_number = slot_number;
- auto secret_bin = misc::hex_string_to_byte(secret);
- vector_copy(payload.slot_secret, secret_bin);
- strcpyT(payload.slot_name, slot_name);
- strcpyT(payload.slot_token_id, token_ID);
- payload.slot_interval = time_window; //FIXME naming
- payload.use_8_digits = use_8_digits;
- payload.use_enter = use_enter;
- payload.use_tokenID = use_tokenID;
-
- authorize_packet<WriteToTOTPSlot, Authorize>(payload, temporary_password, device);
-
- auto resp = WriteToTOTPSlot::CommandTransaction::run(device, payload);
- }
-
- char * NitrokeyManager::get_totp_slot_name(uint8_t slot_number) {
- if (!is_valid_totp_slot_number(slot_number)) throw InvalidSlotException(slot_number);
- slot_number = get_internal_slot_number_for_totp(slot_number);
- return get_slot_name(slot_number);
- }
- char * NitrokeyManager::get_hotp_slot_name(uint8_t slot_number) {
- if (!is_valid_hotp_slot_number(slot_number)) throw InvalidSlotException(slot_number);
- slot_number = get_internal_slot_number_for_hotp(slot_number);
- return get_slot_name(slot_number);
- }
-
- static const int max_string_field_length = 2*1024; //storage's status string is ~1k
-
- char * NitrokeyManager::get_slot_name(uint8_t slot_number) {
- auto payload = get_payload<GetSlotName>();
- payload.slot_number = slot_number;
- auto resp = GetSlotName::CommandTransaction::run(device, payload);
- return strndup((const char *) resp.data().slot_name, max_string_field_length);
- }
-
- bool NitrokeyManager::first_authenticate(const char *pin, const char *temporary_password) {
- auto authreq = get_payload<FirstAuthenticate>();
- strcpyT(authreq.card_password, pin);
- strcpyT(authreq.temporary_password, temporary_password);
- FirstAuthenticate::CommandTransaction::run(device, authreq);
- return true;
- }
-
- bool NitrokeyManager::set_time(uint64_t time) {
- auto p = get_payload<SetTime>();
- p.reset = 1;
- p.time = time;
- SetTime::CommandTransaction::run(device, p);
- return false;
- }
-
- void NitrokeyManager::set_time_soft(uint64_t time) {
- auto p = get_payload<SetTime>();
- p.reset = 0;
- p.time = time;
- SetTime::CommandTransaction::run(device, p);
- }
-
- bool NitrokeyManager::get_time(uint64_t time) {
- set_time_soft(time);
- return true;
- }
-
- void NitrokeyManager::change_user_PIN(const char *current_PIN, const char *new_PIN) {
- change_PIN_general<ChangeUserPin, PasswordKind::User>(current_PIN, new_PIN);
- }
-
- void NitrokeyManager::change_admin_PIN(const char *current_PIN, const char *new_PIN) {
- change_PIN_general<ChangeAdminPin, PasswordKind::Admin>(current_PIN, new_PIN);
- }
-
- template <typename ProCommand, PasswordKind StoKind>
- void NitrokeyManager::change_PIN_general(const char *current_PIN, const char *new_PIN) {
- switch (device->get_device_model()){
- case DeviceModel::PRO:
- {
- auto p = get_payload<ProCommand>();
- strcpyT(p.old_pin, current_PIN);
- strcpyT(p.new_pin, new_PIN);
- ProCommand::CommandTransaction::run(device, p);
- }
- break;
- //in Storage change admin/user pin is divided to two commands with 20 chars field len
- case DeviceModel::STORAGE:
- {
- auto p = get_payload<ChangeAdminUserPin20Current>();
- strcpyT(p.password, current_PIN);
- p.set_kind(StoKind);
- auto p2 = get_payload<ChangeAdminUserPin20New>();
- strcpyT(p2.password, new_PIN);
- p2.set_kind(StoKind);
- ChangeAdminUserPin20Current::CommandTransaction::run(device, p);
- ChangeAdminUserPin20New::CommandTransaction::run(device, p2);
- }
- break;
- }
-
- }
-
- void NitrokeyManager::enable_password_safe(const char *user_pin) {
- //The following command will cancel enabling PWS if it is not supported
- auto a = get_payload<IsAESSupported>();
- strcpyT(a.user_password, user_pin);
- IsAESSupported::CommandTransaction::run(device, a);
-
- auto p = get_payload<EnablePasswordSafe>();
- strcpyT(p.user_password, user_pin);
- EnablePasswordSafe::CommandTransaction::run(device, p);
- }
-
- vector <uint8_t> NitrokeyManager::get_password_safe_slot_status() {
- auto responsePayload = GetPasswordSafeSlotStatus::CommandTransaction::run(device);
- vector<uint8_t> v = vector<uint8_t>(responsePayload.data().password_safe_status,
- responsePayload.data().password_safe_status
- + sizeof(responsePayload.data().password_safe_status));
- return v;
- }
-
- uint8_t NitrokeyManager::get_user_retry_count() {
- if(device->get_device_model() == DeviceModel::STORAGE){
- stick20::GetDeviceStatus::CommandTransaction::run(device);
- }
- auto response = GetUserPasswordRetryCount::CommandTransaction::run(device);
- return response.data().password_retry_count;
- }
-
- uint8_t NitrokeyManager::get_admin_retry_count() {
- if(device->get_device_model() == DeviceModel::STORAGE){
- stick20::GetDeviceStatus::CommandTransaction::run(device);
- }
- auto response = GetPasswordRetryCount::CommandTransaction::run(device);
- return response.data().password_retry_count;
- }
-
- void NitrokeyManager::lock_device() {
- LockDevice::CommandTransaction::run(device);
- }
-
- char * NitrokeyManager::get_password_safe_slot_name(uint8_t slot_number) {
- if (!is_valid_password_safe_slot_number(slot_number)) throw InvalidSlotException(slot_number);
- auto p = get_payload<GetPasswordSafeSlotName>();
- p.slot_number = slot_number;
- auto response = GetPasswordSafeSlotName::CommandTransaction::run(device, p);
- return strndup((const char *) response.data().slot_name, max_string_field_length);
- }
-
- bool NitrokeyManager::is_valid_password_safe_slot_number(uint8_t slot_number) const { return slot_number < 16; }
-
- char * NitrokeyManager::get_password_safe_slot_login(uint8_t slot_number) {
- if (!is_valid_password_safe_slot_number(slot_number)) throw InvalidSlotException(slot_number);
- auto p = get_payload<GetPasswordSafeSlotLogin>();
- p.slot_number = slot_number;
- auto response = GetPasswordSafeSlotLogin::CommandTransaction::run(device, p);
- return strndup((const char *) response.data().slot_login, max_string_field_length);
- }
-
- char * NitrokeyManager::get_password_safe_slot_password(uint8_t slot_number) {
- if (!is_valid_password_safe_slot_number(slot_number)) throw InvalidSlotException(slot_number);
- auto p = get_payload<GetPasswordSafeSlotPassword>();
- p.slot_number = slot_number;
- auto response = GetPasswordSafeSlotPassword::CommandTransaction::run(device, p);
- return strndup((const char *) response.data().slot_password, max_string_field_length); //FIXME use secure way
- }
-
- void NitrokeyManager::write_password_safe_slot(uint8_t slot_number, const char *slot_name, const char *slot_login,
- const char *slot_password) {
- if (!is_valid_password_safe_slot_number(slot_number)) throw InvalidSlotException(slot_number);
- auto p = get_payload<SetPasswordSafeSlotData>();
- p.slot_number = slot_number;
- strcpyT(p.slot_name, slot_name);
- strcpyT(p.slot_password, slot_password);
- SetPasswordSafeSlotData::CommandTransaction::run(device, p);
-
- auto p2 = get_payload<SetPasswordSafeSlotData2>();
- p2.slot_number = slot_number;
- strcpyT(p2.slot_login_name, slot_login);
- SetPasswordSafeSlotData2::CommandTransaction::run(device, p2);
- }
-
- void NitrokeyManager::erase_password_safe_slot(uint8_t slot_number) {
- if (!is_valid_password_safe_slot_number(slot_number)) throw InvalidSlotException(slot_number);
- auto p = get_payload<ErasePasswordSafeSlot>();
- p.slot_number = slot_number;
- ErasePasswordSafeSlot::CommandTransaction::run(device, p);
- }
-
- void NitrokeyManager::user_authenticate(const char *user_password, const char *temporary_password) {
- auto p = get_payload<UserAuthenticate>();
- strcpyT(p.card_password, user_password);
- strcpyT(p.temporary_password, temporary_password);
- UserAuthenticate::CommandTransaction::run(device, p);
- }
-
- void NitrokeyManager::build_aes_key(const char *admin_password) {
- switch (device->get_device_model()) {
- case DeviceModel::PRO: {
- auto p = get_payload<BuildAESKey>();
- strcpyT(p.admin_password, admin_password);
- BuildAESKey::CommandTransaction::run(device, p);
- break;
- }
- case DeviceModel::STORAGE : {
- auto p = get_payload<stick20::CreateNewKeys>();
- strcpyT(p.password, admin_password);
- p.set_defaults();
- stick20::CreateNewKeys::CommandTransaction::run(device, p);
- break;
- }
- }
- }
-
- void NitrokeyManager::factory_reset(const char *admin_password) {
- auto p = get_payload<FactoryReset>();
- strcpyT(p.admin_password, admin_password);
- FactoryReset::CommandTransaction::run(device, p);
- }
-
- void NitrokeyManager::unlock_user_password(const char *admin_password, const char *new_user_password) {
- switch (device->get_device_model()){
- case DeviceModel::PRO: {
- auto p = get_payload<stick10::UnlockUserPassword>();
- strcpyT(p.admin_password, admin_password);
- strcpyT(p.user_new_password, new_user_password);
- stick10::UnlockUserPassword::CommandTransaction::run(device, p);
- break;
- }
- case DeviceModel::STORAGE : {
- auto p2 = get_payload<ChangeAdminUserPin20Current>();
- p2.set_defaults();
- strcpyT(p2.password, admin_password);
- ChangeAdminUserPin20Current::CommandTransaction::run(device, p2);
- auto p3 = get_payload<stick20::UnlockUserPin>();
- p3.set_defaults();
- strcpyT(p3.password, new_user_password);
- stick20::UnlockUserPin::CommandTransaction::run(device, p3);
- break;
- }
- }
- }
-
-
- void NitrokeyManager::write_config(uint8_t numlock, uint8_t capslock, uint8_t scrolllock, bool enable_user_password,
- bool delete_user_password, const char *admin_temporary_password) {
- auto p = get_payload<stick10_08::WriteGeneralConfig>();
- p.numlock = numlock;
- p.capslock = capslock;
- p.scrolllock = scrolllock;
- p.enable_user_password = static_cast<uint8_t>(enable_user_password ? 1 : 0);
- p.delete_user_password = static_cast<uint8_t>(delete_user_password ? 1 : 0);
- if (is_authorization_command_supported()){
- authorize_packet<stick10_08::WriteGeneralConfig, Authorize>(p, admin_temporary_password, device);
- } else {
- strcpyT(p.temporary_admin_password, admin_temporary_password);
- }
- stick10_08::WriteGeneralConfig::CommandTransaction::run(device, p);
- }
-
- vector<uint8_t> NitrokeyManager::read_config() {
- auto responsePayload = GetStatus::CommandTransaction::run(device);
- vector<uint8_t> v = vector<uint8_t>(responsePayload.data().general_config,
- responsePayload.data().general_config+sizeof(responsePayload.data().general_config));
- return v;
- }
-
- bool NitrokeyManager::is_authorization_command_supported(){
- //authorization command is supported for versions equal or below:
- auto m = std::unordered_map<DeviceModel , int, EnumClassHash>({
- {DeviceModel::PRO, 7},
- {DeviceModel::STORAGE, 999},
- });
- return get_minor_firmware_version() <= m[device->get_device_model()];
- }
-
- bool NitrokeyManager::is_320_OTP_secret_supported(){
- //authorization command is supported for versions equal or below:
- auto m = std::unordered_map<DeviceModel , int, EnumClassHash>({
- {DeviceModel::PRO, 8},
- {DeviceModel::STORAGE, 999},
- });
- return get_minor_firmware_version() >= m[device->get_device_model()];
- }
-
- DeviceModel NitrokeyManager::get_connected_device_model() const{
- if (device == nullptr){
- throw DeviceNotConnected("device not connected");
- }
- return device->get_device_model();
- }
-
- bool NitrokeyManager::is_smartcard_in_use(){
- try{
- stick20::CheckSmartcardUsage::CommandTransaction::run(device);
- }
- catch(const CommandFailedException & e){
- return e.reason_smartcard_busy();
- }
- return false;
- }
-
- int NitrokeyManager::get_minor_firmware_version(){
- switch(device->get_device_model()){
- case DeviceModel::PRO:{
- auto status_p = GetStatus::CommandTransaction::run(device);
- return status_p.data().firmware_version_st.minor; //7 or 8
- }
- case DeviceModel::STORAGE:{
- auto status = stick20::GetDeviceStatus::CommandTransaction::run(device);
- auto test_firmware = status.data().versionInfo.build_iteration != 0;
- if (test_firmware)
- LOG("Development firmware detected. Increasing minor version number.", nitrokey::log::Loglevel::WARNING);
- return status.data().versionInfo.minor + (test_firmware? 1 : 0);
- }
- }
- return 0;
- }
- int NitrokeyManager::get_major_firmware_version(){
- switch(device->get_device_model()){
- case DeviceModel::PRO:{
- auto status_p = GetStatus::CommandTransaction::run(device);
- return status_p.data().firmware_version_st.major; //0
- }
- case DeviceModel::STORAGE:{
- auto status = stick20::GetDeviceStatus::CommandTransaction::run(device);
- return status.data().versionInfo.major;
- }
- }
- return 0;
- }
-
- bool NitrokeyManager::is_AES_supported(const char *user_password) {
- auto a = get_payload<IsAESSupported>();
- strcpyT(a.user_password, user_password);
- IsAESSupported::CommandTransaction::run(device, a);
- return true;
- }
-
- //storage commands
-
- void NitrokeyManager::send_startup(uint64_t seconds_from_epoch){
- auto p = get_payload<stick20::SendStartup>();
-// p.set_defaults(); //set current time
- p.localtime = seconds_from_epoch;
- stick20::SendStartup::CommandTransaction::run(device, p);
- }
-
- void NitrokeyManager::unlock_encrypted_volume(const char* user_pin){
- misc::execute_password_command<stick20::EnableEncryptedPartition>(device, user_pin);
- }
-
- void NitrokeyManager::unlock_hidden_volume(const char* hidden_volume_password) {
- misc::execute_password_command<stick20::EnableHiddenEncryptedPartition>(device, hidden_volume_password);
- }
-
- void NitrokeyManager::set_encrypted_volume_read_only(const char* admin_pin) {
- misc::execute_password_command<stick20::SetEncryptedVolumeReadOnly>(device, admin_pin);
- }
-
- void NitrokeyManager::set_encrypted_volume_read_write(const char* admin_pin) {
- misc::execute_password_command<stick20::SetEncryptedVolumeReadWrite>(device, admin_pin);
- }
-
- //TODO check is encrypted volume unlocked before execution
- //if not return library exception
- void NitrokeyManager::create_hidden_volume(uint8_t slot_nr, uint8_t start_percent, uint8_t end_percent,
- const char *hidden_volume_password) {
- auto p = get_payload<stick20::SetupHiddenVolume>();
- p.SlotNr_u8 = slot_nr;
- p.StartBlockPercent_u8 = start_percent;
- p.EndBlockPercent_u8 = end_percent;
- strcpyT(p.HiddenVolumePassword_au8, hidden_volume_password);
- stick20::SetupHiddenVolume::CommandTransaction::run(device, p);
- }
-
- void NitrokeyManager::set_unencrypted_read_only_admin(const char* admin_pin) {
- //from v0.49, v0.52+ it needs Admin PIN
- if (set_unencrypted_volume_rorw_pin_type_user()){
- LOG("set_unencrypted_read_only_admin is not supported for this version of Storage device. "
- "Please update firmware to v0.52+. Doing nothing.", nitrokey::log::Loglevel::WARNING);
- return;
- }
- misc::execute_password_command<stick20::SetUnencryptedVolumeReadOnlyAdmin>(device, admin_pin);
- }
-
- void NitrokeyManager::set_unencrypted_read_only(const char *user_pin) {
- //until v0.48 (incl. v0.50 and v0.51) User PIN was sufficient
- LOG("set_unencrypted_read_only is deprecated. Use set_unencrypted_read_only_admin instead.",
- nitrokey::log::Loglevel::WARNING);
- if (!set_unencrypted_volume_rorw_pin_type_user()){
- LOG("set_unencrypted_read_only is not supported for this version of Storage device. Doing nothing.",
- nitrokey::log::Loglevel::WARNING);
- return;
- }
- misc::execute_password_command<stick20::SendSetReadonlyToUncryptedVolume>(device, user_pin);
- }
-
- void NitrokeyManager::set_unencrypted_read_write_admin(const char* admin_pin) {
- //from v0.49, v0.52+ it needs Admin PIN
- if (set_unencrypted_volume_rorw_pin_type_user()){
- LOG("set_unencrypted_read_write_admin is not supported for this version of Storage device. "
- "Please update firmware to v0.52+. Doing nothing.", nitrokey::log::Loglevel::WARNING);
- return;
- }
- misc::execute_password_command<stick20::SetUnencryptedVolumeReadWriteAdmin>(device, admin_pin);
- }
-
- void NitrokeyManager::set_unencrypted_read_write(const char *user_pin) {
- //until v0.48 (incl. v0.50 and v0.51) User PIN was sufficient
- LOG("set_unencrypted_read_write is deprecated. Use set_unencrypted_read_write_admin instead.",
- nitrokey::log::Loglevel::WARNING);
- if (!set_unencrypted_volume_rorw_pin_type_user()){
- LOG("set_unencrypted_read_write is not supported for this version of Storage device. Doing nothing.",
- nitrokey::log::Loglevel::WARNING);
- return;
- }
- misc::execute_password_command<stick20::SendSetReadwriteToUncryptedVolume>(device, user_pin);
- }
-
- bool NitrokeyManager::set_unencrypted_volume_rorw_pin_type_user(){
- auto minor_firmware_version = get_minor_firmware_version();
- return minor_firmware_version <= 48 || minor_firmware_version == 50 || minor_firmware_version == 51;
- }
-
- void NitrokeyManager::export_firmware(const char* admin_pin) {
- misc::execute_password_command<stick20::ExportFirmware>(device, admin_pin);
- }
-
- void NitrokeyManager::enable_firmware_update(const char* firmware_pin) {
- misc::execute_password_command<stick20::EnableFirmwareUpdate>(device, firmware_pin);
- }
-
- void NitrokeyManager::clear_new_sd_card_warning(const char* admin_pin) {
- misc::execute_password_command<stick20::SendClearNewSdCardFound>(device, admin_pin);
- }
-
- void NitrokeyManager::fill_SD_card_with_random_data(const char* admin_pin) {
- auto p = get_payload<stick20::FillSDCardWithRandomChars>();
- p.set_defaults();
- strcpyT(p.admin_pin, admin_pin);
- stick20::FillSDCardWithRandomChars::CommandTransaction::run(device, p);
- }
-
- void NitrokeyManager::change_update_password(const char* current_update_password, const char* new_update_password) {
- auto p = get_payload<stick20::ChangeUpdatePassword>();
- strcpyT(p.current_update_password, current_update_password);
- strcpyT(p.new_update_password, new_update_password);
- stick20::ChangeUpdatePassword::CommandTransaction::run(device, p);
- }
-
- char * NitrokeyManager::get_status_storage_as_string(){
- auto p = stick20::GetDeviceStatus::CommandTransaction::run(device);
- return strndup(p.data().dissect().c_str(), max_string_field_length);
- }
-
- stick20::DeviceConfigurationResponsePacket::ResponsePayload NitrokeyManager::get_status_storage(){
- auto p = stick20::GetDeviceStatus::CommandTransaction::run(device);
- return p.data();
- }
-
- char * NitrokeyManager::get_SD_usage_data_as_string(){
- auto p = stick20::GetSDCardOccupancy::CommandTransaction::run(device);
- return strndup(p.data().dissect().c_str(), max_string_field_length);
- }
-
- std::pair<uint8_t,uint8_t> NitrokeyManager::get_SD_usage_data(){
- auto p = stick20::GetSDCardOccupancy::CommandTransaction::run(device);
- return std::make_pair(p.data().WriteLevelMin, p.data().WriteLevelMax);
- }
-
- int NitrokeyManager::get_progress_bar_value(){
- try{
- stick20::GetDeviceStatus::CommandTransaction::run(device);
- return -1;
- }
- catch (LongOperationInProgressException &e){
- return e.progress_bar_value;
- }
- }
-
- string NitrokeyManager::get_TOTP_code(uint8_t slot_number, const char *user_temporary_password) {
- return get_TOTP_code(slot_number, 0, 0, 0, user_temporary_password);
- }
-
- stick10::ReadSlot::ResponsePayload NitrokeyManager::get_OTP_slot_data(const uint8_t slot_number) {
- auto p = get_payload<stick10::ReadSlot>();
- p.slot_number = slot_number;
- auto data = stick10::ReadSlot::CommandTransaction::run(device, p);
- return data.data();
- }
-
- stick10::ReadSlot::ResponsePayload NitrokeyManager::get_TOTP_slot_data(const uint8_t slot_number) {
- return get_OTP_slot_data(get_internal_slot_number_for_totp(slot_number));
- }
-
- stick10::ReadSlot::ResponsePayload NitrokeyManager::get_HOTP_slot_data(const uint8_t slot_number) {
- auto slot_data = get_OTP_slot_data(get_internal_slot_number_for_hotp(slot_number));
- if (device->get_device_model() == DeviceModel::STORAGE){
- //convert counter from string to ull
- auto counter_s = std::string(slot_data.slot_counter_s, slot_data.slot_counter_s+sizeof(slot_data.slot_counter_s));
- slot_data.slot_counter = std::stoull(counter_s);
- }
- return slot_data;
- }
-
- void NitrokeyManager::lock_encrypted_volume() {
- misc::execute_password_command<stick20::DisableEncryptedPartition>(device, "");
- }
-
- void NitrokeyManager::lock_hidden_volume() {
- misc::execute_password_command<stick20::DisableHiddenEncryptedPartition>(device, "");
- }
-
- uint8_t NitrokeyManager::get_SD_card_size() {
- auto data = stick20::ProductionTest::CommandTransaction::run(device);
- return data.data().SD_Card_Size_u8;
- }
-
- const string NitrokeyManager::get_current_device_id() const {
- return current_device_id;
- }
-
- void NitrokeyManager::wink(){
- stick20::Wink::CommandTransaction::run(device);
- };
-
- stick20::ProductionTest::ResponsePayload NitrokeyManager::production_info(){
- auto data = stick20::ProductionTest::CommandTransaction::run(device);
- return data.data();
- };
-
-}
diff --git a/nitrokey-sys/libnitrokey-v3.4.1/README.md b/nitrokey-sys/libnitrokey-v3.4.1/README.md
deleted file mode 100644
index 81b367a..0000000
--- a/nitrokey-sys/libnitrokey-v3.4.1/README.md
+++ /dev/null
@@ -1,210 +0,0 @@
-[![Build Status](https://travis-ci.org/Nitrokey/libnitrokey.svg?branch=master)](https://travis-ci.org/Nitrokey/libnitrokey)
-[![Waffle.io - Columns and their card count](https://badge.waffle.io/Nitrokey/libnitrokey.svg?columns=ready,in%20progress,test,waiting%20for%20feedback)](https://waffle.io/Nitrokey/libnitrokey)
-
-# libnitrokey
-libnitrokey is a project to communicate with Nitrokey Pro and Storage devices in a clean and easy manner. Written in C++14, testable with `py.test` and `Catch` frameworks, with C API, Python access (through CFFI and C API, in future with Pybind11).
-
-The development of this project is aimed to make it itself a living documentation of communication protocol between host and the Nitrokey stick devices. The command packets' format is described here: [Pro v0.7](include/stick10_commands.h), [Pro v0.8](include/stick10_commands_0.8.h), [Storage](include/stick20_commands.h). Handling and additional operations are described here: [NitrokeyManager.cc](NitrokeyManager.cc).
-
-A C++14 complying compiler is required due to heavy use of variable templates. For feature support tables please check [table 1](https://gcc.gnu.org/projects/cxx-status.html#cxx14) or [table 2](http://en.cppreference.com/w/cpp/compiler_support).
-
-libnitrokey is developed and tested with the latest compilers: g++ 6.2, clang 3.8. We use Travis CI to test builds also on g++ 5.4 and under OSX compilers starting up from xcode 8.2 environment.
-
-## Getting sources
-This repository uses `git submodules`.
-To clone please use git's `--recursive` option like in:
-```bash
-git clone --recursive https://github.com/Nitrokey/libnitrokey.git
-```
-or for already cloned repository:
-```bash
-git clone https://github.com/Nitrokey/libnitrokey.git
-cd libnitrokey
-git submodule update --init --recursive
-```
-
-## Dependencies
-Following libraries are needed to use libnitrokey on Linux (names of the packages on Ubuntu):
-- libhidapi-dev [(HID API)](http://www.signal11.us/oss/hidapi/)
-- libusb-1.0-0-dev
-
-
-## Compilation
-libnitrokey uses CMake as its main build system. As a secondary option it offers building through Qt's qMake.
-### Qt
-A Qt's .pro project file is provided for direct compilation and for inclusion to other projects.
-Using it directly is not recommended due to lack of dependencies check and not implemented library versioning.
-Compilation is tested with Qt 5.6 and greater.
-
-Quick start example:
-```bash
-mkdir -p build
-cd build
-qmake ..
-make -j2
-```
-
-### Windows MS Visual Studio 2017
-Lately Visual Studio has started handling CMake files directly. After opening the project's directory it should recognize it and initialize build system. Afterwards please run:
-1. `CMake -> Cache -> View Cache CMakeLists.txt -> CMakeLists.txt` to edit settings
-2. `CMake -> Build All` to build
-
-It is possible too to use CMake GUI directly with its settings editor.
-
-### CMake
-To compile please run following sequence of commands:
-```bash
-# assuming current dir is ./libnitrokey/
-mkdir -p build
-cd build
-cmake .. <OPTIONS>
-make -j2
-```
-
-By default (with empty `<OPTIONS>` string) this will create in `build/` directory a shared library (.so, .dll or .dynlib). If you wish to build static version you can use as `<OPTIONS>` string `-DBUILD_SHARED_LIBS=OFF`.
-
-All options could be listed with `cmake .. -L` or instead `cmake` a `ccmake ..` tool could be used for configuration (where `..` is the path to directory with `CMakeLists.txt` file). `ccmake` shows also description of the build parameters.
-
-If you have trouble compiling or running the library you can check [.travis.yml](.travis.yml) file for configuration details. This file is used by Travis CI service to make test builds on OSX and Ubuntu 14.04.
-
-Other build options (all take either `ON` or `OFF`):
-* ADD_ASAN - add tests for memory leaks and out-of-bounds access
-* ADD_TSAN - add tests for threads race, needs USE_CLANG
-* COMPILE_TESTS - compile C++ tests
-* COMPILE_OFFLINE_TESTS - compile C++ tests, that do not require any device to be connected
-* LOG_VOLATILE_DATA (default: OFF) - include secrets in log (PWS passwords, PINs etc)
-* NO_LOG (default: OFF) - do not compile LOG statements - will make library smaller, but without any diagnostic messages
-
-
-
-# Using libnitrokey with Python
-To use libnitrokey with Python a [CFFI](http://cffi.readthedocs.io/en/latest/overview.html) library is required (either 2.7+ or 3.0+). It can be installed with:
-```bash
-pip install --user cffi # for python 2.x
-pip3 install cffi # for python 3.x
-```
-Just import it, read the C API header and it is done! You have access to the library. Here is an example (in Python 2) printing HOTP code for Pro or Storage device, assuming it is run in root directory [(full example)](python_bindings_example.py):
-```python
-#!/usr/bin/env python2
-import cffi
-
-ffi = cffi.FFI()
-get_string = ffi.string
-
-def get_library():
- fp = 'NK_C_API.h' # path to C API header
-
- declarations = []
- with open(fp, 'r') as f:
- declarations = f.readlines()
-
- cnt = 0
- a = iter(declarations)
- for declaration in a:
- if declaration.strip().startswith('NK_C_API'):
- declaration = declaration.replace('NK_C_API', '').strip()
- while ';' not in declaration:
- declaration += (next(a)).strip()
- # print(declaration)
- ffi.cdef(declaration, override=True)
- cnt +=1
- print('Imported {} declarations'.format(cnt))
-
-
- C = None
- import os, sys
- path_build = os.path.join(".", "build")
- paths = [
- os.environ.get('LIBNK_PATH', None),
- os.path.join(path_build,"libnitrokey.so"),
- os.path.join(path_build,"libnitrokey.dylib"),
- os.path.join(path_build,"libnitrokey.dll"),
- os.path.join(path_build,"nitrokey.dll"),
- ]
- for p in paths:
- if not p: continue
- print("Trying " +p)
- p = os.path.abspath(p)
- if os.path.exists(p):
- print("Found: "+p)
- C = ffi.dlopen(p)
- break
- else:
- print("File does not exist: " + p)
- if not C:
- print("No library file found")
- sys.exit(1)
-
- return C
-
-
-def get_hotp_code(lib, i):
- return lib.NK_get_hotp_code(i)
-
-
-libnitrokey = get_library()
-libnitrokey.NK_set_debug(False) # do not show debug messages (log library only)
-
-hotp_slot_code = get_hotp_code(libnitrokey, 1)
-print('Getting HOTP code from Nitrokey device: ')
-print(hotp_slot_code)
-libnitrokey.NK_logout() # disconnect device
-```
-
-In case no devices are connected, a friendly message will be printed.
-All available functions for C and Python are listed in [NK_C_API.h](NK_C_API.h). Please check `Documentation` section below.
-
-## Documentation
-The documentation of C API is included in the sources (could be generated with doxygen if requested).
-Please check [NK_C_API.h](NK_C_API.h) (C API) for high level commands and [include/NitrokeyManager.h](include/NitrokeyManager.h) (C++ API). All devices' commands are listed along with packet format in [include/stick10_commands.h](include/stick10_commands.h) and [include/stick20_commands.h](include/stick20_commands.h) respectively for Nitrokey Pro and Nitrokey Storage products.
-
-# Tests
-Warning! Before you run unittests please either change both your Admin and User PINs on your Nitrostick to defaults (`12345678` and `123456` respectively) or change the values in tests source code. If you do not change them the tests might lock your device and lose your data. If it's too late, you can reset your Nitrokey using instructions from [homepage](https://www.nitrokey.com/de/documentation/how-reset-nitrokey).
-
-## Python tests
-libnitrokey has a great suite of tests written in Python 3 under the path: `unittest/test_*.py`:
-* `test_pro.py` - contains tests of OTP, Password Safe and PIN control functionality. Could be run on both Pro and Storage devices.
-* `test_storage.py` - contains tests of Encrypted Volumes functionality. Could be run only on Storage.
-The tests themselves show how to handle common requests to device.
-Before running please install all required libraries with:
-```bash
-cd unittest
-pip install --user -r requirements.txt
-```
-To run them please execute:
-```bash
-# substitute <dev> with either pro or storage
-py.test -v test_<dev>.py
-# more specific use - run tests containing in name <test_name> 5 times:
-py.test -v test_<dev>.py -k <test_name> --count 5
-
-```
-For additional documentation please check the following for [py.test installation](http://doc.pytest.org/en/latest/getting-started.html). For better coverage [randomly plugin](https://pypi.python.org/pypi/pytest-randomly) is installed - it randomizes the test order allowing to detect unseen dependencies between the tests.
-
-## C++ tests
-There are also some unit tests implemented in C++, placed in unittest directory. They are not written as extensively as Python tests and are rather more a C++ low level interface check, often not using C++ API from `NitrokeyManager.cc`. Some of them are: [test_HOTP.cc](https://github.com/Nitrokey/libnitrokey/blob/master/unittest/test_HOTP.cc),
-[test.cc](https://github.com/Nitrokey/libnitrokey/blob/master/unittest/test.cc).
-Unit tests were written and tested on Ubuntu 16.04/16.10/17.04. To run them just execute binaries built in ./libnitrokey/build dir after enabling them by passing `-DCOMPILE_TESTS=ON` option like in `cmake .. -DCOMPILE_TESTS=ON && make`.
-
-
-The documentation of how it works could be found in nitrokey-app project's README on Github:
-[Nitrokey-app - internals](https://github.com/Nitrokey/nitrokey-app/blob/master/README.md#internals).
-
-To peek/debug communication with device running nitrokey-app (0.x branch) in debug mode (`-d` switch) and checking the logs
-(right click on tray icon and then 'Debug') might be helpful. Latest Nitrokey App (1.x branch) uses libnitrokey to communicate with device. Once run with `--dl 3` (3 or higher; range 0-5) it will print all communication to the console. Additionally crosschecking with
-firmware code should show how things works:
-[report_protocol.c](https://github.com/Nitrokey/nitrokey-pro-firmware/blob/master/src/keyboard/report_protocol.c)
-(for Nitrokey Pro, for Storage similarly).
-
-# Known issues / tasks
-* Currently only one device can be connected at a time (experimental work could be found in `wip-multiple_devices` branch),
-* C++ API needs some reorganization to C++ objects (instead of pointers to arrays). This will be also preparing for integration with Pybind11,
-* Fix compilation warnings.
-
-Other tasks might be listed either in [TODO](TODO) file or on project's issues page.
-
-# License
-This project is licensed under LGPL version 3. License text could be found under [LICENSE](LICENSE) file.
-
-# Roadmap
-To check what issues will be fixed and when please check [milestones](https://github.com/Nitrokey/libnitrokey/milestones) page.
diff --git a/nitrokey-sys/libnitrokey-v3.4.1/command_id.cc b/nitrokey-sys/libnitrokey-v3.4.1/command_id.cc
deleted file mode 100644
index a6c2a28..0000000
--- a/nitrokey-sys/libnitrokey-v3.4.1/command_id.cc
+++ /dev/null
@@ -1,184 +0,0 @@
-/*
- * Copyright (c) 2015-2018 Nitrokey UG
- *
- * This file is part of libnitrokey.
- *
- * libnitrokey is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * any later version.
- *
- * libnitrokey is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with libnitrokey. If not, see <http://www.gnu.org/licenses/>.
- *
- * SPDX-License-Identifier: LGPL-3.0
- */
-
-#include <assert.h>
-#include "command_id.h"
-
-namespace nitrokey {
-namespace proto {
-
-const char *commandid_to_string(CommandID id) {
- switch (id) {
- case CommandID::GET_STATUS:
- return "GET_STATUS";
- case CommandID::WRITE_TO_SLOT:
- return "WRITE_TO_SLOT";
- case CommandID::READ_SLOT_NAME:
- return "READ_SLOT_NAME";
- case CommandID::READ_SLOT:
- return "READ_SLOT";
- case CommandID::GET_CODE:
- return "GET_CODE";
- case CommandID::WRITE_CONFIG:
- return "WRITE_CONFIG";
- case CommandID::ERASE_SLOT:
- return "ERASE_SLOT";
- case CommandID::FIRST_AUTHENTICATE:
- return "FIRST_AUTHENTICATE";
- case CommandID::AUTHORIZE:
- return "AUTHORIZE";
- case CommandID::GET_PASSWORD_RETRY_COUNT:
- return "GET_PASSWORD_RETRY_COUNT";
- case CommandID::CLEAR_WARNING:
- return "CLEAR_WARNING";
- case CommandID::SET_TIME:
- return "SET_TIME";
- case CommandID::TEST_COUNTER:
- return "TEST_COUNTER";
- case CommandID::TEST_TIME:
- return "TEST_TIME";
- case CommandID::USER_AUTHENTICATE:
- return "USER_AUTHENTICATE";
- case CommandID::GET_USER_PASSWORD_RETRY_COUNT:
- return "GET_USER_PASSWORD_RETRY_COUNT";
- case CommandID::USER_AUTHORIZE:
- return "USER_AUTHORIZE";
- case CommandID::UNLOCK_USER_PASSWORD:
- return "UNLOCK_USER_PASSWORD";
- case CommandID::LOCK_DEVICE:
- return "LOCK_DEVICE";
- case CommandID::FACTORY_RESET:
- return "FACTORY_RESET";
- case CommandID::CHANGE_USER_PIN:
- return "CHANGE_USER_PIN";
- case CommandID::CHANGE_ADMIN_PIN:
- return "CHANGE_ADMIN_PIN";
-
- case CommandID::ENABLE_CRYPTED_PARI:
- return "ENABLE_CRYPTED_PARI";
- case CommandID::DISABLE_CRYPTED_PARI:
- return "DISABLE_CRYPTED_PARI";
- case CommandID::ENABLE_HIDDEN_CRYPTED_PARI:
- return "ENABLE_HIDDEN_CRYPTED_PARI";
- case CommandID::DISABLE_HIDDEN_CRYPTED_PARI:
- return "DISABLE_HIDDEN_CRYPTED_PARI";
- case CommandID::ENABLE_FIRMWARE_UPDATE:
- return "ENABLE_FIRMWARE_UPDATE";
- case CommandID::EXPORT_FIRMWARE_TO_FILE:
- return "EXPORT_FIRMWARE_TO_FILE";
- case CommandID::GENERATE_NEW_KEYS:
- return "GENERATE_NEW_KEYS";
- case CommandID::FILL_SD_CARD_WITH_RANDOM_CHARS:
- return "FILL_SD_CARD_WITH_RANDOM_CHARS";
-
- case CommandID::WRITE_STATUS_DATA:
- return "WRITE_STATUS_DATA";
- case CommandID::ENABLE_READONLY_UNCRYPTED_LUN:
- return "ENABLE_READONLY_UNCRYPTED_LUN";
- case CommandID::ENABLE_READWRITE_UNCRYPTED_LUN:
- return "ENABLE_READWRITE_UNCRYPTED_LUN";
-
- case CommandID::SEND_PASSWORD_MATRIX:
- return "SEND_PASSWORD_MATRIX";
- case CommandID::SEND_PASSWORD_MATRIX_PINDATA:
- return "SEND_PASSWORD_MATRIX_PINDATA";
- case CommandID::SEND_PASSWORD_MATRIX_SETUP:
- return "SEND_PASSWORD_MATRIX_SETUP";
-
- case CommandID::GET_DEVICE_STATUS:
- return "GET_DEVICE_STATUS";
- case CommandID::SEND_DEVICE_STATUS:
- return "SEND_DEVICE_STATUS";
-
- case CommandID::SEND_HIDDEN_VOLUME_PASSWORD:
- return "SEND_HIDDEN_VOLUME_PASSWORD";
- case CommandID::SEND_HIDDEN_VOLUME_SETUP:
- return "SEND_HIDDEN_VOLUME_SETUP";
- case CommandID::SEND_PASSWORD:
- return "SEND_PASSWORD";
- case CommandID::SEND_NEW_PASSWORD:
- return "SEND_NEW_PASSWORD";
- case CommandID::CLEAR_NEW_SD_CARD_FOUND:
- return "CLEAR_NEW_SD_CARD_FOUND";
-
- case CommandID::SEND_STARTUP:
- return "SEND_STARTUP";
- case CommandID::SEND_CLEAR_STICK_KEYS_NOT_INITIATED:
- return "SEND_CLEAR_STICK_KEYS_NOT_INITIATED";
- case CommandID::SEND_LOCK_STICK_HARDWARE:
- return "SEND_LOCK_STICK_HARDWARE";
-
- case CommandID::PRODUCTION_TEST:
- return "PRODUCTION_TEST";
- case CommandID::SEND_DEBUG_DATA:
- return "SEND_DEBUG_DATA";
-
- case CommandID::CHANGE_UPDATE_PIN:
- return "CHANGE_UPDATE_PIN";
-
- case CommandID::ENABLE_ADMIN_READONLY_UNCRYPTED_LUN:
- return "ENABLE_ADMIN_READONLY_UNCRYPTED_LUN";
- case CommandID::ENABLE_ADMIN_READWRITE_UNCRYPTED_LUN:
- return "ENABLE_ADMIN_READWRITE_UNCRYPTED_LUN";
- case CommandID::ENABLE_ADMIN_READONLY_ENCRYPTED_LUN:
- return "ENABLE_ADMIN_READONLY_ENCRYPTED_LUN";
- case CommandID::ENABLE_ADMIN_READWRITE_ENCRYPTED_LUN:
- return "ENABLE_ADMIN_READWRITE_ENCRYPTED_LUN";
- case CommandID::CHECK_SMARTCARD_USAGE:
- return "CHECK_SMARTCARD_USAGE";
-
- case CommandID::GET_PW_SAFE_SLOT_STATUS:
- return "GET_PW_SAFE_SLOT_STATUS";
- case CommandID::GET_PW_SAFE_SLOT_NAME:
- return "GET_PW_SAFE_SLOT_NAME";
- case CommandID::GET_PW_SAFE_SLOT_PASSWORD:
- return "GET_PW_SAFE_SLOT_PASSWORD";
- case CommandID::GET_PW_SAFE_SLOT_LOGINNAME:
- return "GET_PW_SAFE_SLOT_LOGINNAME";
- case CommandID::SET_PW_SAFE_SLOT_DATA_1:
- return "SET_PW_SAFE_SLOT_DATA_1";
- case CommandID::SET_PW_SAFE_SLOT_DATA_2:
- return "SET_PW_SAFE_SLOT_DATA_2";
- case CommandID::PW_SAFE_ERASE_SLOT:
- return "PW_SAFE_ERASE_SLOT";
- case CommandID::PW_SAFE_ENABLE:
- return "PW_SAFE_ENABLE";
- case CommandID::PW_SAFE_INIT_KEY:
- return "PW_SAFE_INIT_KEY";
- case CommandID::PW_SAFE_SEND_DATA:
- return "PW_SAFE_SEND_DATA";
- case CommandID::SD_CARD_HIGH_WATERMARK:
- return "SD_CARD_HIGH_WATERMARK";
- case CommandID::DETECT_SC_AES:
- return "DETECT_SC_AES";
- case CommandID::NEW_AES_KEY:
- return "NEW_AES_KEY";
- case CommandID::WRITE_TO_SLOT_2:
- return "WRITE_TO_SLOT_2";
- case CommandID::SEND_OTP_DATA:
- return "SEND_OTP_DATA";
- case CommandID::WINK:
- return "WINK";
- }
- return "UNKNOWN";
-}
-}
-}
diff --git a/nitrokey-sys/libnitrokey-v3.4.1/device.cc b/nitrokey-sys/libnitrokey-v3.4.1/device.cc
deleted file mode 100644
index 80e4b38..0000000
--- a/nitrokey-sys/libnitrokey-v3.4.1/device.cc
+++ /dev/null
@@ -1,295 +0,0 @@
-/*
- * Copyright (c) 2015-2018 Nitrokey UG
- *
- * This file is part of libnitrokey.
- *
- * libnitrokey is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * any later version.
- *
- * libnitrokey is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with libnitrokey. If not, see <http://www.gnu.org/licenses/>.
- *
- * SPDX-License-Identifier: LGPL-3.0
- */
-
-#include <chrono>
-#include <iostream>
-#include <thread>
-#include <cstddef>
-#include <stdexcept>
-#include "hidapi/hidapi.h"
-#include "libnitrokey/misc.h"
-#include "libnitrokey/device.h"
-#include "libnitrokey/log.h"
-#include <mutex>
-#include "DeviceCommunicationExceptions.h"
-#include "device.h"
-
-std::mutex mex_dev_com;
-
-using namespace nitrokey::device;
-using namespace nitrokey::log;
-using namespace std::chrono;
-
-std::atomic_int Device::instances_count{0};
-std::chrono::milliseconds Device::default_delay {0} ;
-
-Device::Device(const uint16_t vid, const uint16_t pid, const DeviceModel model,
- const milliseconds send_receive_delay, const int retry_receiving_count,
- const milliseconds retry_timeout)
- :
- last_command_status(0),
- m_vid(vid),
- m_pid(pid),
- m_model(model),
- m_retry_sending_count(1),
- m_retry_receiving_count(retry_receiving_count),
- m_retry_timeout(retry_timeout),
- m_send_receive_delay(send_receive_delay),
- mp_devhandle(nullptr)
-{
- instances_count++;
-}
-
-bool Device::disconnect() {
- //called in object's destructor
- LOG(__FUNCTION__, Loglevel::DEBUG_L2);
- std::lock_guard<std::mutex> lock(mex_dev_com);
- return _disconnect();
-}
-
-bool Device::_disconnect() {
- LOG(std::string(__FUNCTION__) + std::string(m_model == DeviceModel::PRO ? "PRO" : "STORAGE"), Loglevel::DEBUG_L2);
- LOG(std::string(__FUNCTION__) + std::string(" *IN* "), Loglevel::DEBUG_L2);
-
- if(mp_devhandle == nullptr) {
- LOG(std::string("Disconnection: handle already freed: ") + std::to_string(mp_devhandle == nullptr) + " ("+m_path+")", Loglevel::DEBUG_L1);
- return false;
- }
-
- hid_close(mp_devhandle);
- mp_devhandle = nullptr;
-#ifndef __APPLE__
- if (instances_count == 1){
- LOG(std::string("Calling hid_exit"), Loglevel::DEBUG_L2);
- hid_exit();
- }
-#endif
- return true;
-}
-
-bool Device::connect() {
- LOG(__FUNCTION__, Loglevel::DEBUG_L2);
- std::lock_guard<std::mutex> lock(mex_dev_com);
- return _connect();
-}
-
-bool Device::_connect() {
- LOG(std::string(__FUNCTION__) + std::string(" *IN* "), Loglevel::DEBUG_L2);
-
-// hid_init(); // done automatically on hid_open
- if (m_path.empty()){
- mp_devhandle = hid_open(m_vid, m_pid, nullptr);
- } else {
- mp_devhandle = hid_open_path(m_path.c_str());
- }
- const bool success = mp_devhandle != nullptr;
- LOG(std::string("Connection success: ") + std::to_string(success) + " ("+m_path+")", Loglevel::DEBUG_L1);
- return success;
-}
-
-void Device::set_path(const std::string path){
- m_path = path;
-}
-
-int Device::send(const void *packet) {
- LOG(__FUNCTION__, Loglevel::DEBUG_L2);
- std::lock_guard<std::mutex> lock(mex_dev_com);
- LOG(std::string(__FUNCTION__) + std::string(" *IN* "), Loglevel::DEBUG_L2);
-
- int send_feature_report = -1;
-
- for (int i = 0; i < 3 && send_feature_report < 0; ++i) {
- if (mp_devhandle == nullptr) {
- LOG(std::string("Connection fail") , Loglevel::DEBUG_L2);
- throw DeviceNotConnected("Attempted HID send on an invalid descriptor.");
- }
- send_feature_report = hid_send_feature_report(
- mp_devhandle, (const unsigned char *)(packet), HID_REPORT_SIZE);
- if (send_feature_report < 0) _reconnect();
- //add thread sleep?
- LOG(std::string("Sending attempt: ")+std::to_string(i+1) + " / 3" , Loglevel::DEBUG_L2);
- }
- return send_feature_report;
-}
-
-int Device::recv(void *packet) {
- LOG(__FUNCTION__, Loglevel::DEBUG_L2);
- std::lock_guard<std::mutex> lock(mex_dev_com);
- LOG(std::string(__FUNCTION__) + std::string(" *IN* "), Loglevel::DEBUG_L2);
- int status;
- int retry_count = 0;
-
- for (;;) {
- if (mp_devhandle == nullptr){
- LOG(std::string("Connection fail") , Loglevel::DEBUG_L2);
- throw DeviceNotConnected("Attempted HID receive on an invalid descriptor.");
- }
-
- status = (hid_get_feature_report(mp_devhandle, (unsigned char *)(packet),
- HID_REPORT_SIZE));
-
- auto pwherr = hid_error(mp_devhandle);
- std::wstring wherr = (pwherr != nullptr) ? pwherr : L"No error message";
- std::string herr(wherr.begin(), wherr.end());
- LOG(std::string("libhid error message: ") + herr,
- Loglevel::DEBUG_L2);
-
- if (status > 0) break; // success
- if (retry_count++ >= m_retry_receiving_count) {
- LOG(
- "Maximum retry count reached: " + std::to_string(retry_count),
- Loglevel::WARNING);
- LOG(
- std::string("Counter stats: ") + m_counters.get_as_string(),
- Loglevel::DEBUG);
- break;
- }
- _reconnect();
- LOG("Retrying... " + std::to_string(retry_count),
- Loglevel::DEBUG);
- std::this_thread::sleep_for(m_retry_timeout);
- }
-
- return status;
-}
-
-std::vector<std::string> Device::enumerate(){
- //TODO make static
- auto pInfo = hid_enumerate(m_vid, m_pid);
- auto pInfo_ = pInfo;
- std::vector<std::string> res;
- while (pInfo != nullptr){
- std::string a (pInfo->path);
- res.push_back(a);
- pInfo = pInfo->next;
- }
-
- if (pInfo_ != nullptr){
- hid_free_enumeration(pInfo_);
- }
-
- return res;
-}
-
-bool Device::could_be_enumerated() {
- LOG(__FUNCTION__, Loglevel::DEBUG_L2);
- std::lock_guard<std::mutex> lock(mex_dev_com);
- if (mp_devhandle==nullptr){
- return false;
- }
-#ifndef __APPLE__
- auto pInfo = hid_enumerate(m_vid, m_pid);
- if (pInfo != nullptr){
- hid_free_enumeration(pInfo);
- return true;
- }
- return false;
-#else
-// alternative for OSX
- unsigned char buf[1];
- return hid_read_timeout(mp_devhandle, buf, sizeof(buf), 20) != -1;
-#endif
-}
-
-void Device::show_stats() {
- auto s = m_counters.get_as_string();
- LOG(s, Loglevel::DEBUG_L2);
-}
-
-void Device::_reconnect() {
- LOG(__FUNCTION__, Loglevel::DEBUG_L2);
- ++m_counters.low_level_reconnect;
- _disconnect();
- _connect();
-}
-
-Device::~Device() {
- show_stats();
- disconnect();
- instances_count--;
-}
-
-void Device::set_default_device_speed(int delay) {
- default_delay = std::chrono::duration<int, std::milli>(delay);
-}
-
-
-void Device::set_receiving_delay(const std::chrono::milliseconds delay){
- std::lock_guard<std::mutex> lock(mex_dev_com);
- m_send_receive_delay = delay;
-}
-
-void Device::set_retry_delay(const std::chrono::milliseconds delay){
- std::lock_guard<std::mutex> lock(mex_dev_com);
- m_retry_timeout = delay;
-}
-
-Stick10::Stick10():
- Device(0x20a0, 0x4108, DeviceModel::PRO, 100ms, 5, 100ms)
- {
- setDefaultDelay();
- }
-
-
-Stick20::Stick20():
- Device(0x20a0, 0x4109, DeviceModel::STORAGE, 40ms, 55, 40ms)
- {
- setDefaultDelay();
- }
-
-#include <sstream>
-#define p(x) ss << #x << " " << x << ", ";
-std::string Device::ErrorCounters::get_as_string() {
- std::stringstream ss;
- p(total_comm_runs);
- p(communication_successful);
- ss << "(";
- p(command_successful_recv);
- p(command_result_not_equal_0_recv);
- ss << "), ";
- p(sends_executed);
- p(recv_executed);
- p(successful_storage_commands);
- p(total_retries);
- ss << "(";
- p(busy);
- p(busy_progressbar);
- p(CRC_other_than_awaited);
- p(wrong_CRC);
- ss << "), ";
- p(low_level_reconnect);
- p(sending_error);
- p(receiving_error);
- return ss.str();
-}
-
-void Device::setDefaultDelay() {
- LOG(__FUNCTION__, Loglevel::DEBUG_L2);
-
- auto count = default_delay.count();
- if (count != 0){
- LOG("Setting default delay to " + std::to_string(count), Loglevel::DEBUG_L2);
- m_retry_timeout = default_delay;
- m_send_receive_delay = default_delay;
- }
-}
-
-#undef p
diff --git a/nitrokey-sys/libnitrokey-v3.4.1/libnitrokey/CommandFailedException.h b/nitrokey-sys/libnitrokey-v3.4.1/libnitrokey/CommandFailedException.h
deleted file mode 100644
index 32bd6b7..0000000
--- a/nitrokey-sys/libnitrokey-v3.4.1/libnitrokey/CommandFailedException.h
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * Copyright (c) 2015-2018 Nitrokey UG
- *
- * This file is part of libnitrokey.
- *
- * libnitrokey is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * any later version.
- *
- * libnitrokey is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with libnitrokey. If not, see <http://www.gnu.org/licenses/>.
- *
- * SPDX-License-Identifier: LGPL-3.0
- */
-
-#ifndef LIBNITROKEY_COMMANDFAILEDEXCEPTION_H
-#define LIBNITROKEY_COMMANDFAILEDEXCEPTION_H
-
-#include <exception>
-#include <cstdint>
-#include "log.h"
-#include "command_id.h"
-
-using cs = nitrokey::proto::stick10::command_status;
-using cs2 = nitrokey::proto::stick20::device_status;
-
-class CommandFailedException : public std::exception {
-public:
- const uint8_t last_command_id;
- const uint8_t last_command_status;
-
- CommandFailedException(uint8_t last_command_id, uint8_t last_command_status) :
- last_command_id(last_command_id),
- last_command_status(last_command_status){
- LOG(std::string("CommandFailedException, status: ")+ std::to_string(last_command_status), nitrokey::log::Loglevel::DEBUG);
- }
-
- virtual const char *what() const throw() {
- return "Command execution has failed on device";
- }
-
-
- bool reason_timestamp_warning() const throw(){
- return last_command_status == static_cast<uint8_t>(cs::timestamp_warning);
- }
-
- bool reason_AES_not_initialized() const throw(){
- return last_command_status == static_cast<uint8_t>(cs::AES_dec_failed);
- }
-
- bool reason_not_authorized() const throw(){
- return last_command_status == static_cast<uint8_t>(cs::not_authorized);
- }
-
- bool reason_slot_not_programmed() const throw(){
- return last_command_status == static_cast<uint8_t>(cs::slot_not_programmed);
- }
-
- bool reason_wrong_password() const throw(){
- return last_command_status == static_cast<uint8_t>(cs::wrong_password);
- }
-
- bool reason_smartcard_busy() const throw(){
- return last_command_status == static_cast<uint8_t>(cs2::smartcard_error);
- }
-
-};
-
-
-#endif //LIBNITROKEY_COMMANDFAILEDEXCEPTION_H
diff --git a/nitrokey-sys/libnitrokey-v3.4.1/libnitrokey/DeviceCommunicationExceptions.h b/nitrokey-sys/libnitrokey-v3.4.1/libnitrokey/DeviceCommunicationExceptions.h
deleted file mode 100644
index f710d0b..0000000
--- a/nitrokey-sys/libnitrokey-v3.4.1/libnitrokey/DeviceCommunicationExceptions.h
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * Copyright (c) 2015-2018 Nitrokey UG
- *
- * This file is part of libnitrokey.
- *
- * libnitrokey is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * any later version.
- *
- * libnitrokey is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with libnitrokey. If not, see <http://www.gnu.org/licenses/>.
- *
- * SPDX-License-Identifier: LGPL-3.0
- */
-
-
-#ifndef LIBNITROKEY_DEVICECOMMUNICATIONEXCEPTIONS_H
-#define LIBNITROKEY_DEVICECOMMUNICATIONEXCEPTIONS_H
-
-#include <atomic>
-#include <exception>
-#include <stdexcept>
-#include <string>
-
-
-class DeviceCommunicationException: public std::runtime_error
-{
- std::string message;
- static std::atomic_int occurred;
-public:
- DeviceCommunicationException(std::string _msg): std::runtime_error(_msg), message(_msg){
- ++occurred;
- }
- uint8_t getType() const {return 1;};
-// virtual const char* what() const throw() override {
-// return message.c_str();
-// }
- static bool has_occurred(){ return occurred > 0; };
- static void reset_occurred_flag(){ occurred = 0; };
-};
-
-class DeviceNotConnected: public DeviceCommunicationException {
-public:
- DeviceNotConnected(std::string msg) : DeviceCommunicationException(msg){}
- uint8_t getType() const {return 2;};
-};
-
-class DeviceSendingFailure: public DeviceCommunicationException {
-public:
- DeviceSendingFailure(std::string msg) : DeviceCommunicationException(msg){}
- uint8_t getType() const {return 3;};
-};
-
-class DeviceReceivingFailure: public DeviceCommunicationException {
-public:
- DeviceReceivingFailure(std::string msg) : DeviceCommunicationException(msg){}
- uint8_t getType() const {return 4;};
-};
-
-class InvalidCRCReceived: public DeviceReceivingFailure {
-public:
- InvalidCRCReceived(std::string msg) : DeviceReceivingFailure(msg){}
- uint8_t getType() const {return 5;};
-};
-
-
-#endif //LIBNITROKEY_DEVICECOMMUNICATIONEXCEPTIONS_H
diff --git a/nitrokey-sys/libnitrokey-v3.4.1/libnitrokey/LibraryException.h b/nitrokey-sys/libnitrokey-v3.4.1/libnitrokey/LibraryException.h
deleted file mode 100644
index 3b9d177..0000000
--- a/nitrokey-sys/libnitrokey-v3.4.1/libnitrokey/LibraryException.h
+++ /dev/null
@@ -1,118 +0,0 @@
-/*
- * Copyright (c) 2015-2018 Nitrokey UG
- *
- * This file is part of libnitrokey.
- *
- * libnitrokey is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * any later version.
- *
- * libnitrokey is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with libnitrokey. If not, see <http://www.gnu.org/licenses/>.
- *
- * SPDX-License-Identifier: LGPL-3.0
- */
-
-#ifndef LIBNITROKEY_LIBRARYEXCEPTION_H
-#define LIBNITROKEY_LIBRARYEXCEPTION_H
-
-#include <exception>
-#include <cstdint>
-#include <string>
-#include "log.h"
-
-class LibraryException: std::exception {
-public:
- virtual uint8_t exception_id()= 0;
-};
-
-class TargetBufferSmallerThanSource: public LibraryException {
-public:
- virtual uint8_t exception_id() override {
- return 203;
- }
-
-public:
- size_t source_size;
- size_t target_size;
-
- TargetBufferSmallerThanSource(
- size_t source_size, size_t target_size
- ) : source_size(source_size), target_size(target_size) {}
-
- virtual const char *what() const throw() override {
- std::string s = " ";
- auto ts = [](size_t x){ return std::to_string(x); };
- std::string msg = std::string("Target buffer size is smaller than source: [source size, buffer size]")
- +s+ ts(source_size) +s+ ts(target_size);
- return msg.c_str();
- }
-
-};
-
-class InvalidHexString : public LibraryException {
-public:
- virtual uint8_t exception_id() override {
- return 202;
- }
-
-public:
- uint8_t invalid_char;
-
- InvalidHexString (uint8_t invalid_char) : invalid_char( invalid_char) {}
-
- virtual const char *what() const throw() override {
- return "Invalid character in hex string";
- }
-
-};
-
-class InvalidSlotException : public LibraryException {
-public:
- virtual uint8_t exception_id() override {
- return 201;
- }
-
-public:
- uint8_t slot_selected;
-
- InvalidSlotException(uint8_t slot_selected) : slot_selected(slot_selected) {}
-
- virtual const char *what() const throw() override {
- return "Wrong slot selected";
- }
-
-};
-
-
-
-class TooLongStringException : public LibraryException {
-public:
- virtual uint8_t exception_id() override {
- return 200;
- }
-
- std::size_t size_source;
- std::size_t size_destination;
- std::string message;
-
- TooLongStringException(size_t size_source, size_t size_destination, const std::string &message = "") : size_source(
- size_source), size_destination(size_destination), message(message) {
- LOG(std::string("TooLongStringException, size diff: ")+ std::to_string(size_source-size_destination), nitrokey::log::Loglevel::DEBUG);
-
- }
-
- virtual const char *what() const throw() override {
- //TODO add sizes and message data to final message
- return "Too long string has been supplied as an argument";
- }
-
-};
-
-#endif //LIBNITROKEY_LIBRARYEXCEPTION_H
diff --git a/nitrokey-sys/libnitrokey-v3.4.1/libnitrokey/LongOperationInProgressException.h b/nitrokey-sys/libnitrokey-v3.4.1/libnitrokey/LongOperationInProgressException.h
deleted file mode 100644
index 865d6b5..0000000
--- a/nitrokey-sys/libnitrokey-v3.4.1/libnitrokey/LongOperationInProgressException.h
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Copyright (c) 2015-2018 Nitrokey UG
- *
- * This file is part of libnitrokey.
- *
- * libnitrokey is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * any later version.
- *
- * libnitrokey is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with libnitrokey. If not, see <http://www.gnu.org/licenses/>.
- *
- * SPDX-License-Identifier: LGPL-3.0
- */
-
-#ifndef LIBNITROKEY_LONGOPERATIONINPROGRESSEXCEPTION_H
-#define LIBNITROKEY_LONGOPERATIONINPROGRESSEXCEPTION_H
-
-#include "CommandFailedException.h"
-
-class LongOperationInProgressException : public CommandFailedException {
-
-public:
- unsigned char progress_bar_value;
-
- LongOperationInProgressException(
- unsigned char _command_id, uint8_t last_command_status, unsigned char _progress_bar_value)
- : CommandFailedException(_command_id, last_command_status), progress_bar_value(_progress_bar_value){
- LOG(
- std::string("LongOperationInProgressException, progress bar status: ")+
- std::to_string(progress_bar_value), nitrokey::log::Loglevel::DEBUG);
- }
- virtual const char *what() const throw() {
- return "Device returned busy status with long operation in progress";
- }
-};
-
-
-#endif //LIBNITROKEY_LONGOPERATIONINPROGRESSEXCEPTION_H
diff --git a/nitrokey-sys/libnitrokey-v3.4.1/libnitrokey/NitrokeyManager.h b/nitrokey-sys/libnitrokey-v3.4.1/libnitrokey/NitrokeyManager.h
deleted file mode 100644
index d6e5df4..0000000
--- a/nitrokey-sys/libnitrokey-v3.4.1/libnitrokey/NitrokeyManager.h
+++ /dev/null
@@ -1,303 +0,0 @@
-/*
- * Copyright (c) 2015-2018 Nitrokey UG
- *
- * This file is part of libnitrokey.
- *
- * libnitrokey is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * any later version.
- *
- * libnitrokey is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with libnitrokey. If not, see <http://www.gnu.org/licenses/>.
- *
- * SPDX-License-Identifier: LGPL-3.0
- */
-
-#ifndef LIBNITROKEY_NITROKEYMANAGER_H
-#define LIBNITROKEY_NITROKEYMANAGER_H
-
-#include "device.h"
-#include "log.h"
-#include "device_proto.h"
-#include "stick10_commands.h"
-#include "stick10_commands_0.8.h"
-#include "stick20_commands.h"
-#include <vector>
-#include <memory>
-#include <unordered_map>
-
-namespace nitrokey {
- using namespace nitrokey::device;
- using namespace std;
- using namespace nitrokey::proto::stick10;
- using namespace nitrokey::proto::stick20;
- using namespace nitrokey::proto;
- using namespace nitrokey::log;
-
-
-#ifdef __WIN32
-char * strndup(const char* str, size_t maxlen);
-#endif
-
- class NitrokeyManager {
- public:
- static shared_ptr <NitrokeyManager> instance();
-
- bool first_authenticate(const char *pin, const char *temporary_password);
- bool write_HOTP_slot(uint8_t slot_number, const char *slot_name, const char *secret, uint64_t hotp_counter,
- bool use_8_digits, bool use_enter, bool use_tokenID, const char *token_ID,
- const char *temporary_password);
- bool write_TOTP_slot(uint8_t slot_number, const char *slot_name, const char *secret, uint16_t time_window,
- bool use_8_digits, bool use_enter, bool use_tokenID, const char *token_ID,
- const char *temporary_password);
- string get_HOTP_code(uint8_t slot_number, const char *user_temporary_password);
- string get_TOTP_code(uint8_t slot_number, uint64_t challenge, uint64_t last_totp_time,
- uint8_t last_interval,
- const char *user_temporary_password);
- string get_TOTP_code(uint8_t slot_number, const char *user_temporary_password);
- stick10::ReadSlot::ResponsePayload get_TOTP_slot_data(const uint8_t slot_number);
- stick10::ReadSlot::ResponsePayload get_HOTP_slot_data(const uint8_t slot_number);
-
- bool set_time(uint64_t time);
- /**
- * Set the device time used for TOTP to the given time. Contrary to
- * {@code set_time(uint64_t)}, this command fails if {@code old_time}
- * &gt; {@code time} or if {@code old_time} is zero (where {@code
- * old_time} is the current time on the device).
- *
- * @param time new device time as Unix timestamp (seconds since
- * 1970-01-01)
- */
- void set_time_soft(uint64_t time);
-
- [[deprecated("get_time is deprecated -- use set_time_soft instead")]]
- bool get_time(uint64_t time = 0);
- bool erase_totp_slot(uint8_t slot_number, const char *temporary_password);
- bool erase_hotp_slot(uint8_t slot_number, const char *temporary_password);
- std::vector<std::string> list_devices();
- std::vector<std::string> list_devices_by_cpuID();
-
- /**
- * Connect to the device using unique smartcard:datacard id.
- * Needs list_device_by_cpuID() run first
- * @param id Current ID of the target device
- * @return true on success, false on failure
- */
- bool connect_with_ID(const std::string id);
- bool connect_with_path (std::string path);
- bool connect(const char *device_model);
- bool connect(device::DeviceModel device_model);
- bool connect();
- bool disconnect();
- bool is_connected() throw() ;
- bool could_current_device_be_enumerated();
- bool set_default_commands_delay(int delay);
-
- DeviceModel get_connected_device_model() const;
- void set_debug(bool state);
- stick10::GetStatus::ResponsePayload get_status();
- string get_status_as_string();
- string get_serial_number();
-
- char * get_totp_slot_name(uint8_t slot_number);
- char * get_hotp_slot_name(uint8_t slot_number);
-
- void change_user_PIN(const char *current_PIN, const char *new_PIN);
- void change_admin_PIN(const char *current_PIN, const char *new_PIN);
-
- void enable_password_safe(const char *user_pin);
-
- vector <uint8_t> get_password_safe_slot_status();
-
- uint8_t get_admin_retry_count();
- uint8_t get_user_retry_count();
-
- void lock_device();
-
- char * get_password_safe_slot_name(uint8_t slot_number);
- char * get_password_safe_slot_password(uint8_t slot_number);
- char * get_password_safe_slot_login(uint8_t slot_number);
-
- void
- write_password_safe_slot(uint8_t slot_number, const char *slot_name, const char *slot_login,
- const char *slot_password);
-
- void erase_password_safe_slot(uint8_t slot_number);
-
- void user_authenticate(const char *user_password, const char *temporary_password);
-
- void factory_reset(const char *admin_password);
-
- void build_aes_key(const char *admin_password);
-
- void unlock_user_password(const char *admin_password, const char *new_user_password);
-
- void write_config(uint8_t numlock, uint8_t capslock, uint8_t scrolllock, bool enable_user_password,
- bool delete_user_password, const char *admin_temporary_password);
-
- vector<uint8_t> read_config();
-
- bool is_AES_supported(const char *user_password);
-
- void unlock_encrypted_volume(const char *user_password);
- void lock_encrypted_volume();
-
- void unlock_hidden_volume(const char *hidden_volume_password);
- void lock_hidden_volume();
-
- /**
- * Sets unencrypted volume read-only.
- * Works until v0.48 (incl. v0.50), where User PIN was sufficient
- * Does nothing otherwise.
- * @param user_pin User PIN
- */
- void set_unencrypted_read_only(const char *user_pin);
-
- /**
- * Sets unencrypted volume read-only.
- * Works from v0.49 (except v0.50) accepts Admin PIN
- * Does nothing otherwise.
- * @param admin_pin Admin PIN
- */
- void set_unencrypted_read_only_admin(const char *admin_pin);
-
- /**
- * Sets unencrypted volume read-write.
- * Works until v0.48 (incl. v0.50), where User PIN was sufficient
- * Does nothing otherwise.
- * @param user_pin User PIN
- */
- void set_unencrypted_read_write(const char *user_pin);
-
- /**
- * Sets unencrypted volume read-write.
- * Works from v0.49 (except v0.50) accepts Admin PIN
- * Does nothing otherwise.
- * @param admin_pin Admin PIN
- */
- void set_unencrypted_read_write_admin(const char *admin_pin);
-
- void export_firmware(const char *admin_pin);
- void enable_firmware_update(const char *firmware_pin);
-
- void clear_new_sd_card_warning(const char *admin_pin);
-
- void fill_SD_card_with_random_data(const char *admin_pin);
-
- uint8_t get_SD_card_size();
-
- void change_update_password(const char *current_update_password, const char *new_update_password);
-
- void create_hidden_volume(uint8_t slot_nr, uint8_t start_percent, uint8_t end_percent,
- const char *hidden_volume_password);
-
- void send_startup(uint64_t seconds_from_epoch);
-
- char * get_status_storage_as_string();
- stick20::DeviceConfigurationResponsePacket::ResponsePayload get_status_storage();
-
- char * get_SD_usage_data_as_string();
- std::pair<uint8_t,uint8_t> get_SD_usage_data();
-
-
- int get_progress_bar_value();
-
- ~NitrokeyManager();
- bool is_authorization_command_supported();
- bool is_320_OTP_secret_supported();
-
-
- template <typename S, typename A, typename T>
- void authorize_packet(T &package, const char *admin_temporary_password, shared_ptr<Device> device);
- int get_minor_firmware_version();
-
- explicit NitrokeyManager();
- void set_log_function(std::function<void(std::string)> log_function);
- private:
-
- static shared_ptr <NitrokeyManager> _instance;
- std::shared_ptr<Device> device;
- std::string current_device_id;
- public:
- const string get_current_device_id() const;
-
- private:
- std::unordered_map<std::string, shared_ptr<Device> > connected_devices;
- std::unordered_map<std::string, shared_ptr<Device> > connected_devices_byID;
-
-
- stick10::ReadSlot::ResponsePayload get_OTP_slot_data(const uint8_t slot_number);
- bool is_valid_hotp_slot_number(uint8_t slot_number) const;
- bool is_valid_totp_slot_number(uint8_t slot_number) const;
- bool is_valid_password_safe_slot_number(uint8_t slot_number) const;
- uint8_t get_internal_slot_number_for_hotp(uint8_t slot_number) const;
- uint8_t get_internal_slot_number_for_totp(uint8_t slot_number) const;
- bool erase_slot(uint8_t slot_number, const char *temporary_password);
- char * get_slot_name(uint8_t slot_number);
-
- template <typename ProCommand, PasswordKind StoKind>
- void change_PIN_general(const char *current_PIN, const char *new_PIN);
-
- void write_HOTP_slot_authorize(uint8_t slot_number, const char *slot_name, const char *secret, uint64_t hotp_counter,
- bool use_8_digits, bool use_enter, bool use_tokenID, const char *token_ID,
- const char *temporary_password);
-
- void write_TOTP_slot_authorize(uint8_t slot_number, const char *slot_name, const char *secret, uint16_t time_window,
- bool use_8_digits, bool use_enter, bool use_tokenID, const char *token_ID,
- const char *temporary_password);
-
- void write_OTP_slot_no_authorize(uint8_t internal_slot_number, const char *slot_name, const char *secret,
- uint64_t counter_or_interval,
- bool use_8_digits, bool use_enter, bool use_tokenID, const char *token_ID,
- const char *temporary_password) const;
- bool _disconnect_no_lock();
-
- public:
- bool set_current_device_speed(int retry_delay, int send_receive_delay);
- void set_loglevel(Loglevel loglevel);
-
- void set_loglevel(int loglevel);
-
- /**
- * Sets encrypted volume read-only.
- * Supported from future versions of Storage.
- * @param admin_pin Admin PIN
- */
- void set_encrypted_volume_read_only(const char *admin_pin);
-
- /**
- * Sets encrypted volume read-write.
- * Supported from future versions of Storage.
- * @param admin_pin Admin PIN
- */
- void set_encrypted_volume_read_write(const char *admin_pin);
-
- int get_major_firmware_version();
-
- bool is_smartcard_in_use();
-
- /**
- * Function to determine unencrypted volume PIN type
- * @param minor_firmware_version
- * @return Returns true, if set unencrypted volume ro/rw pin type is User, false otherwise.
- */
- bool set_unencrypted_volume_rorw_pin_type_user();
-
- /**
- * Blink red and green LED alternatively and infinitely (until device is reconnected).
- */
- void wink();
-
- stick20::ProductionTest::ResponsePayload production_info();
- };
-}
-
-
-
-#endif //LIBNITROKEY_NITROKEYMANAGER_H
diff --git a/nitrokey-sys/libnitrokey-v3.4.1/libnitrokey/command.h b/nitrokey-sys/libnitrokey-v3.4.1/libnitrokey/command.h
deleted file mode 100644
index 6852bf0..0000000
--- a/nitrokey-sys/libnitrokey-v3.4.1/libnitrokey/command.h
+++ /dev/null
@@ -1,112 +0,0 @@
-/*
- * Copyright (c) 2015-2018 Nitrokey UG
- *
- * This file is part of libnitrokey.
- *
- * libnitrokey is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * any later version.
- *
- * libnitrokey is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with libnitrokey. If not, see <http://www.gnu.org/licenses/>.
- *
- * SPDX-License-Identifier: LGPL-3.0
- */
-
-#ifndef COMMAND_H
-#define COMMAND_H
-#include <string>
-#include "command_id.h"
-#include "cxx_semantics.h"
-
-#define print_to_ss(x) ( ss << " " << (#x) <<":\t" << (x) << std::endl );
-#ifdef LOG_VOLATILE_DATA
-#define print_to_ss_volatile(x) print_to_ss(x);
-#else
-#define print_to_ss_volatile(x) ( ss << " " << (#x) <<":\t" << "***********" << std::endl );
-#endif
-#define hexdump_to_ss(x) (ss << #x":\n"\
- << ::nitrokey::misc::hexdump((const uint8_t *) (&x), sizeof x, false));
-
-namespace nitrokey {
- namespace proto {
-
- template<CommandID cmd_id>
- class Command : semantics::non_constructible {
- public:
- constexpr static CommandID command_id() { return cmd_id; }
-
- template<typename T>
- std::string dissect(const T &) {
- return std::string("Payload dissection is unavailable");
- }
- };
-
-namespace stick20{
- enum class PasswordKind : uint8_t {
- User = 'P',
- Admin = 'A',
- AdminPrefixed
- };
-
- template<CommandID cmd_id, PasswordKind Tpassword_kind = PasswordKind::User, int password_length = 20>
- class PasswordCommand : public Command<cmd_id> {
- constexpr static CommandID _command_id() { return cmd_id; }
- public:
- struct CommandPayload {
- uint8_t kind;
- uint8_t password[password_length];
-
- std::string dissect() const {
- std::stringstream ss;
- print_to_ss( kind );
- print_to_ss_volatile(password);
- return ss.str();
- }
- void set_kind_admin() {
- kind = (uint8_t) 'A';
- }
- void set_kind_admin_prefixed() {
- kind = (uint8_t) 'P';
- }
- void set_kind_user() {
- kind = (uint8_t) 'P';
- }
-
- void set_defaults(){
- set_kind(Tpassword_kind);
- }
-
- void set_kind(PasswordKind password_kind){
- switch (password_kind){
- case PasswordKind::Admin:
- set_kind_admin();
- break;
- case PasswordKind::User:
- set_kind_user();
- break;
- case PasswordKind::AdminPrefixed:
- set_kind_admin_prefixed();
- break;
- }
- };
-
- } __packed;
-
- //typedef Transaction<Command<cmd_id>::command_id(), struct CommandPayload, struct EmptyPayload>
- // CommandTransaction;
- using CommandTransaction = Transaction<cmd_id, CommandPayload, EmptyPayload>;
- //using CommandTransaction = Transaction<_command_id(), CommandPayload, EmptyPayload>;
-
- };
- }
- }
-}
-
-#endif
diff --git a/nitrokey-sys/libnitrokey-v3.4.1/libnitrokey/command_id.h b/nitrokey-sys/libnitrokey-v3.4.1/libnitrokey/command_id.h
deleted file mode 100644
index eb0d450..0000000
--- a/nitrokey-sys/libnitrokey-v3.4.1/libnitrokey/command_id.h
+++ /dev/null
@@ -1,154 +0,0 @@
-/*
- * Copyright (c) 2015-2018 Nitrokey UG
- *
- * This file is part of libnitrokey.
- *
- * libnitrokey is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * any later version.
- *
- * libnitrokey is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with libnitrokey. If not, see <http://www.gnu.org/licenses/>.
- *
- * SPDX-License-Identifier: LGPL-3.0
- */
-
-#ifndef COMMAND_ID_H
-#define COMMAND_ID_H
-#include <stdint.h>
-
-namespace nitrokey {
-namespace proto {
- namespace stick20 {
- enum class device_status : uint8_t {
- idle = 0,
- ok,
- busy,
- wrong_password,
- busy_progressbar,
- password_matrix_ready,
- no_user_password_unlock, // FIXME: translate on receive to command status error (fix in firmware?)
- smartcard_error,
- security_bit_active
- };
- const int CMD_START_VALUE = 0x20;
- const int CMD_END_VALUE = 0x60;
- }
- namespace stick10 {
- enum class command_status : uint8_t {
- ok = 0,
- wrong_CRC,
- wrong_slot,
- slot_not_programmed,
- wrong_password = 4,
- not_authorized,
- timestamp_warning,
- no_name_error,
- not_supported,
- unknown_command,
- AES_dec_failed
- };
- enum class device_status : uint8_t {
- ok = 0,
- busy = 1,
- error,
- received_report,
- };
- }
-
-
-enum class CommandID : uint8_t {
- GET_STATUS = 0x00,
- WRITE_TO_SLOT = 0x01,
- READ_SLOT_NAME = 0x02,
- READ_SLOT = 0x03,
- GET_CODE = 0x04,
- WRITE_CONFIG = 0x05,
- ERASE_SLOT = 0x06,
- FIRST_AUTHENTICATE = 0x07,
- AUTHORIZE = 0x08,
- GET_PASSWORD_RETRY_COUNT = 0x09,
- CLEAR_WARNING = 0x0A,
- SET_TIME = 0x0B,
- TEST_COUNTER = 0x0C,
- TEST_TIME = 0x0D,
- USER_AUTHENTICATE = 0x0E,
- GET_USER_PASSWORD_RETRY_COUNT = 0x0F,
- USER_AUTHORIZE = 0x10,
- UNLOCK_USER_PASSWORD = 0x11,
- LOCK_DEVICE = 0x12,
- FACTORY_RESET = 0x13,
- CHANGE_USER_PIN = 0x14,
- CHANGE_ADMIN_PIN = 0x15,
- WRITE_TO_SLOT_2 = 0x16,
- SEND_OTP_DATA = 0x17,
-
- ENABLE_CRYPTED_PARI = 0x20,
- DISABLE_CRYPTED_PARI = 0x20 + 1,
- ENABLE_HIDDEN_CRYPTED_PARI = 0x20 + 2,
- DISABLE_HIDDEN_CRYPTED_PARI = 0x20 + 3,
- ENABLE_FIRMWARE_UPDATE = 0x20 + 4, //enables update mode
- EXPORT_FIRMWARE_TO_FILE = 0x20 + 5,
- GENERATE_NEW_KEYS = 0x20 + 6,
- FILL_SD_CARD_WITH_RANDOM_CHARS = 0x20 + 7,
-
- WRITE_STATUS_DATA = 0x20 + 8, //@unused
- ENABLE_READONLY_UNCRYPTED_LUN = 0x20 + 9,
- ENABLE_READWRITE_UNCRYPTED_LUN = 0x20 + 10,
-
- SEND_PASSWORD_MATRIX = 0x20 + 11, //@unused
- SEND_PASSWORD_MATRIX_PINDATA = 0x20 + 12, //@unused
- SEND_PASSWORD_MATRIX_SETUP = 0x20 + 13, //@unused
-
- GET_DEVICE_STATUS = 0x20 + 14,
- SEND_DEVICE_STATUS = 0x20 + 15,
-
- SEND_HIDDEN_VOLUME_PASSWORD = 0x20 + 16, //@unused
- SEND_HIDDEN_VOLUME_SETUP = 0x20 + 17,
- SEND_PASSWORD = 0x20 + 18,
- SEND_NEW_PASSWORD = 0x20 + 19,
- CLEAR_NEW_SD_CARD_FOUND = 0x20 + 20,
-
- SEND_STARTUP = 0x20 + 21,
- SEND_CLEAR_STICK_KEYS_NOT_INITIATED = 0x20 + 22,
- SEND_LOCK_STICK_HARDWARE = 0x20 + 23, //locks firmware upgrade
-
- PRODUCTION_TEST = 0x20 + 24,
- SEND_DEBUG_DATA = 0x20 + 25, //@unused
-
- CHANGE_UPDATE_PIN = 0x20 + 26,
-
- //added in v0.48.5
- ENABLE_ADMIN_READONLY_UNCRYPTED_LUN = 0x20 + 28,
- ENABLE_ADMIN_READWRITE_UNCRYPTED_LUN = 0x20 + 29,
- ENABLE_ADMIN_READONLY_ENCRYPTED_LUN = 0x20 + 30,
- ENABLE_ADMIN_READWRITE_ENCRYPTED_LUN = 0x20 + 31,
- CHECK_SMARTCARD_USAGE = 0x20 + 32,
- //v0.52+
- WINK = 0x20 + 33,
-
- GET_PW_SAFE_SLOT_STATUS = 0x60,
- GET_PW_SAFE_SLOT_NAME = 0x61,
- GET_PW_SAFE_SLOT_PASSWORD = 0x62,
- GET_PW_SAFE_SLOT_LOGINNAME = 0x63,
- SET_PW_SAFE_SLOT_DATA_1 = 0x64,
- SET_PW_SAFE_SLOT_DATA_2 = 0x65,
- PW_SAFE_ERASE_SLOT = 0x66,
- PW_SAFE_ENABLE = 0x67,
- PW_SAFE_INIT_KEY = 0x68, //@unused
- PW_SAFE_SEND_DATA = 0x69, //@unused
- SD_CARD_HIGH_WATERMARK = 0x70,
- DETECT_SC_AES = 0x6a,
- NEW_AES_KEY = 0x6b
-};
-
-const char *commandid_to_string(CommandID id);
-}
-}
-#endif
diff --git a/nitrokey-sys/libnitrokey-v3.4.1/libnitrokey/cxx_semantics.h b/nitrokey-sys/libnitrokey-v3.4.1/libnitrokey/cxx_semantics.h
deleted file mode 100644
index 36ed142..0000000
--- a/nitrokey-sys/libnitrokey-v3.4.1/libnitrokey/cxx_semantics.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright (c) 2015-2018 Nitrokey UG
- *
- * This file is part of libnitrokey.
- *
- * libnitrokey is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * any later version.
- *
- * libnitrokey is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with libnitrokey. If not, see <http://www.gnu.org/licenses/>.
- *
- * SPDX-License-Identifier: LGPL-3.0
- */
-
-#ifndef CXX_SEMANTICS_H
-#define CXX_SEMANTICS_H
-
-#ifndef _MSC_VER
-#define __packed __attribute__((__packed__))
-#else
-#define __packed
-#endif
-
-#ifdef _MSC_VER
-#define strdup _strdup
-#endif
-
-/*
- * There's no need to include Boost for a simple subset this project needs.
- */
-namespace semantics {
-class non_constructible {
- non_constructible() {}
-};
-}
-
-#endif
diff --git a/nitrokey-sys/libnitrokey-v3.4.1/libnitrokey/deprecated.h b/nitrokey-sys/libnitrokey-v3.4.1/libnitrokey/deprecated.h
deleted file mode 100644
index 5a83288..0000000
--- a/nitrokey-sys/libnitrokey-v3.4.1/libnitrokey/deprecated.h
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Copyright (c) 2018 Nitrokey UG
- *
- * This file is part of libnitrokey.
- *
- * libnitrokey is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * any later version.
- *
- * libnitrokey is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with libnitrokey. If not, see <http://www.gnu.org/licenses/>.
- *
- * SPDX-License-Identifier: LGPL-3.0
- */
-
-
-#ifndef LIBNITROKEY_DEPRECATED_H
-#define LIBNITROKEY_DEPRECATED_H
-
-#if defined(__GNUC__) || defined(__clang__)
-#define DEPRECATED __attribute__((deprecated))
-#elif defined(_MSC_VER)
-#define DEPRECATED __declspec(deprecated)
-#else
-#pragma message("WARNING: DEPRECATED macro is not defined for this compiler")
-#define DEPRECATED
-#endif
-
-#endif //LIBNITROKEY_DEPRECATED_H
diff --git a/nitrokey-sys/libnitrokey-v3.4.1/libnitrokey/device.h b/nitrokey-sys/libnitrokey-v3.4.1/libnitrokey/device.h
deleted file mode 100644
index f6d2380..0000000
--- a/nitrokey-sys/libnitrokey-v3.4.1/libnitrokey/device.h
+++ /dev/null
@@ -1,169 +0,0 @@
-/*
- * Copyright (c) 2015-2018 Nitrokey UG
- *
- * This file is part of libnitrokey.
- *
- * libnitrokey is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * any later version.
- *
- * libnitrokey is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with libnitrokey. If not, see <http://www.gnu.org/licenses/>.
- *
- * SPDX-License-Identifier: LGPL-3.0
- */
-
-#ifndef DEVICE_H
-#define DEVICE_H
-#include <chrono>
-#include "hidapi/hidapi.h"
-#include <cstdint>
-#include <string>
-#include <vector>
-
-#define HID_REPORT_SIZE 65
-
-#include <atomic>
-
-namespace nitrokey {
-namespace device {
- using namespace std::chrono_literals;
- using std::chrono::milliseconds;
-
- struct EnumClassHash
- {
- template <typename T>
- std::size_t operator()(T t) const
- {
- return static_cast<std::size_t>(t);
- }
- };
-
-enum class DeviceModel{
- PRO,
- STORAGE
-};
-
-#include <atomic>
-
-class Device {
-
-public:
-
- struct ErrorCounters{
- using cnt = std::atomic_int;
- cnt wrong_CRC;
- cnt CRC_other_than_awaited;
- cnt busy;
- cnt total_retries;
- cnt sending_error;
- cnt receiving_error;
- cnt total_comm_runs;
- cnt successful_storage_commands;
- cnt command_successful_recv;
- cnt recv_executed;
- cnt sends_executed;
- cnt busy_progressbar;
- cnt command_result_not_equal_0_recv;
- cnt communication_successful;
- cnt low_level_reconnect;
- std::string get_as_string();
-
- } m_counters = {};
-
-
- Device(const uint16_t vid, const uint16_t pid, const DeviceModel model,
- const milliseconds send_receive_delay, const int retry_receiving_count,
- const milliseconds retry_timeout);
-
- virtual ~Device();
-
- // lack of device is not actually an error,
- // so it doesn't throw
- virtual bool connect();
- virtual bool disconnect();
-
- /*
- * Sends packet of HID_REPORT_SIZE.
- */
- virtual int send(const void *packet);
-
- /*
- * Gets packet of HID_REPORT_SIZE.
- * Can sleep. See below.
- */
- virtual int recv(void *packet);
-
- /***
- * Returns true if some device is visible by OS with given VID and PID
- * whether the device is connected through HID API or not.
- * @return true if visible by OS
- */
- bool could_be_enumerated();
- std::vector<std::string> enumerate();
-
-
- void show_stats();
-// ErrorCounters get_stats(){ return m_counters; }
- int get_retry_receiving_count() const { return m_retry_receiving_count; };
- int get_retry_sending_count() const { return m_retry_sending_count; };
- std::chrono::milliseconds get_retry_timeout() const { return m_retry_timeout; };
- std::chrono::milliseconds get_send_receive_delay() const {return m_send_receive_delay;}
-
- int get_last_command_status() {int a = std::atomic_exchange(&last_command_status, static_cast<uint8_t>(0)); return a;};
- void set_last_command_status(uint8_t _err) { last_command_status = _err;} ;
- bool last_command_sucessfull() const {return last_command_status == 0;};
- DeviceModel get_device_model() const {return m_model;}
- void set_receiving_delay(std::chrono::milliseconds delay);
- void set_retry_delay(std::chrono::milliseconds delay);
- static void set_default_device_speed(int delay);
- void setDefaultDelay();
- void set_path(const std::string path);
-
-
- private:
- std::atomic<uint8_t> last_command_status;
- void _reconnect();
- bool _connect();
- bool _disconnect();
-
-protected:
- const uint16_t m_vid;
- const uint16_t m_pid;
- const DeviceModel m_model;
-
- /*
- * While the project uses Signal11 portable HIDAPI
- * library, there's no way of doing it asynchronously,
- * hence polling.
- */
- const int m_retry_sending_count;
- const int m_retry_receiving_count;
- std::chrono::milliseconds m_retry_timeout;
- std::chrono::milliseconds m_send_receive_delay;
- std::atomic<hid_device *>mp_devhandle;
- std::string m_path;
-
- static std::atomic_int instances_count;
- static std::chrono::milliseconds default_delay ;
-};
-
-class Stick10 : public Device {
- public:
- Stick10();
-
-};
-
-class Stick20 : public Device {
- public:
- Stick20();
-};
-}
-}
-#endif
diff --git a/nitrokey-sys/libnitrokey-v3.4.1/libnitrokey/device_proto.h b/nitrokey-sys/libnitrokey-v3.4.1/libnitrokey/device_proto.h
deleted file mode 100644
index 45a6c16..0000000
--- a/nitrokey-sys/libnitrokey-v3.4.1/libnitrokey/device_proto.h
+++ /dev/null
@@ -1,491 +0,0 @@
-/*
- * Copyright (c) 2015-2018 Nitrokey UG
- *
- * This file is part of libnitrokey.
- *
- * libnitrokey is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * any later version.
- *
- * libnitrokey is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with libnitrokey. If not, see <http://www.gnu.org/licenses/>.
- *
- * SPDX-License-Identifier: LGPL-3.0
- */
-
-#ifndef DEVICE_PROTO_H
-#define DEVICE_PROTO_H
-
-#include <utility>
-#include <thread>
-#include <type_traits>
-#include <stdexcept>
-#include <string>
-// a local version for compatibility with Windows
-#include <stdint.h>
-#include "cxx_semantics.h"
-#include "device.h"
-#include "misc.h"
-#include "log.h"
-#include "command_id.h"
-#include "dissect.h"
-#include "CommandFailedException.h"
-#include "LongOperationInProgressException.h"
-
-#define STICK20_UPDATE_MODE_VID 0x03EB
-#define STICK20_UPDATE_MODE_PID 0x2FF1
-
-#define PAYLOAD_SIZE 53
-#define PWS_SLOT_COUNT 16
-#define PWS_SLOTNAME_LENGTH 11
-#define PWS_PASSWORD_LENGTH 20
-#define PWS_LOGINNAME_LENGTH 32
-
-#define PWS_SEND_PASSWORD 0
-#define PWS_SEND_LOGINNAME 1
-#define PWS_SEND_TAB 2
-#define PWS_SEND_CR 3
-
-#include <mutex>
-#include "DeviceCommunicationExceptions.h"
-#define bzero(b,len) (memset((b), '\0', (len)), (void) 0)
-
-namespace nitrokey {
- namespace proto {
- extern std::mutex send_receive_mtx;
-
-
-/*
- * POD types for HID proto commands
- * Instances are meant to be __packed.
- *
- * TODO (future) support for Big Endian
- */
-#pragma pack (push,1)
-/*
- * Every packet is a USB HID report (check USB spec)
- */
- template<CommandID cmd_id, typename Payload>
- struct HIDReport {
- uint8_t _zero;
- CommandID command_id; // uint8_t
- union {
- uint8_t _padding[HID_REPORT_SIZE - 6];
- Payload payload;
- } __packed;
- uint32_t crc;
-
- // POD types can't have non-default constructors
- // used in Transaction<>::run()
- void initialize() {
- bzero(this, sizeof *this);
- command_id = cmd_id;
- }
-
- uint32_t calculate_CRC() const {
- // w/o leading zero, a part of each HID packet
- // w/o 4-byte crc
- return misc::stm_crc32((const uint8_t *) (this) + 1,
- (size_t) (HID_REPORT_SIZE - 5));
- }
-
- void update_CRC() { crc = calculate_CRC(); }
-
- bool isCRCcorrect() const { return crc == calculate_CRC(); }
-
- bool isValid() const {
- return true;
- // return !_zero && payload.isValid() && isCRCcorrect();
- }
-
- operator std::string() const {
- // Packet type is known upfront in normal operation.
- // Can't be used to dissect random packets.
- return QueryDissector<cmd_id, decltype(*this)>::dissect(*this);
- }
- } __packed;
-
-/*
- * Response payload (the parametrized type inside struct HIDReport)
- *
- * command_id member in incoming HIDReport structure carries the command
- * type last used.
- */
- namespace DeviceResponseConstants{
- //magic numbers from firmware
- static constexpr auto storage_status_absolute_address = 21;
- static constexpr auto storage_data_absolute_address = storage_status_absolute_address + 5;
- static constexpr auto header_size = 8; //from _zero to last_command_status inclusive
- static constexpr auto footer_size = 4; //crc
- static constexpr auto wrapping_size = header_size + footer_size;
- }
-
- template<CommandID cmd_id, typename ResponsePayload>
- struct DeviceResponse {
- static constexpr auto storage_status_padding_size =
- DeviceResponseConstants::storage_status_absolute_address - DeviceResponseConstants::header_size;
-
- uint8_t _zero;
- uint8_t device_status;
- uint8_t command_id; // originally last_command_type
- uint32_t last_command_crc;
- uint8_t last_command_status;
-
- union {
- uint8_t _padding[HID_REPORT_SIZE - DeviceResponseConstants::wrapping_size];
- ResponsePayload payload;
- struct {
- uint8_t _storage_status_padding[storage_status_padding_size];
- uint8_t command_counter;
- uint8_t command_id;
- uint8_t device_status; //@see stick20::device_status
- uint8_t progress_bar_value;
- } __packed storage_status;
- } __packed;
-
- uint32_t crc;
-
- void initialize() { bzero(this, sizeof *this); }
-
- uint32_t calculate_CRC() const {
- // w/o leading zero, a part of each HID packet
- // w/o 4-byte crc
- return misc::stm_crc32((const uint8_t *) (this) + 1,
- (size_t) (HID_REPORT_SIZE - 5));
- }
-
- void update_CRC() { crc = calculate_CRC(); }
- bool isCRCcorrect() const { return crc == calculate_CRC(); }
- bool isValid() const {
- // return !_zero && payload.isValid() && isCRCcorrect() &&
- // command_id == (uint8_t)(cmd_id);
- return crc != 0;
- }
-
- operator std::string() const {
- return ResponseDissector<cmd_id, decltype(*this)>::dissect(*this);
- }
- } __packed;
-
- struct EmptyPayload {
- bool isValid() const { return true; }
-
- std::string dissect() const { return std::string("Empty Payload."); }
- } __packed;
-
- template<typename command_packet, typename response_payload>
- class ClearingProxy {
- public:
- ClearingProxy(command_packet &p) {
- packet = p;
- bzero(&p, sizeof(p));
- }
-
- ~ClearingProxy() {
- bzero(&packet, sizeof(packet));
- }
-
- response_payload &data() {
- return packet.payload;
- }
-
- command_packet packet;
- };
-
- template<CommandID cmd_id, typename command_payload, typename response_payload>
- class Transaction : semantics::non_constructible {
- public:
- // Types declared in command class scope can't be reached from there.
- typedef command_payload CommandPayload;
- typedef response_payload ResponsePayload;
-
-
- typedef struct HIDReport<cmd_id, CommandPayload> OutgoingPacket;
- typedef struct DeviceResponse<cmd_id, ResponsePayload> ResponsePacket;
-#pragma pack (pop)
-
- static_assert(std::is_pod<OutgoingPacket>::value,
- "outgoingpacket must be a pod type");
- static_assert(std::is_pod<ResponsePacket>::value,
- "ResponsePacket must be a POD type");
- static_assert(sizeof(OutgoingPacket) == HID_REPORT_SIZE,
- "OutgoingPacket type is not the right size");
- static_assert(sizeof(ResponsePacket) == HID_REPORT_SIZE,
- "ResponsePacket type is not the right size");
-
- static uint32_t getCRC(
- const command_payload &payload) {
- OutgoingPacket outp;
- outp.initialize();
- outp.payload = payload;
- outp.update_CRC();
- return outp.crc;
- }
-
- template<typename T>
- static void clear_packet(T &st) {
- bzero(&st, sizeof(st));
- }
-
- static ClearingProxy<ResponsePacket, response_payload> run(std::shared_ptr<device::Device> dev,
- const command_payload &payload) {
- using namespace ::nitrokey::device;
- using namespace ::nitrokey::log;
- using namespace std::chrono_literals;
-
- std::lock_guard<std::mutex> guard(send_receive_mtx);
-
- LOG(__FUNCTION__, Loglevel::DEBUG_L2);
-
- if (dev == nullptr){
- LOG(std::string("Throw: Device not initialized"), Loglevel::DEBUG_L1);
- throw DeviceNotConnected("Device not initialized");
- }
- dev->m_counters.total_comm_runs++;
-
- int status;
- OutgoingPacket outp;
- ResponsePacket resp;
-
- // POD types can't have non-default constructors
- outp.initialize();
- resp.initialize();
-
- outp.payload = payload;
- outp.update_CRC();
-
- LOG("-------------------", Loglevel::DEBUG);
- LOG("Outgoing HID packet:", Loglevel::DEBUG);
- LOG(static_cast<std::string>(outp), Loglevel::DEBUG);
- LOG(std::string("=> ") + std::string(commandid_to_string(static_cast<CommandID>(outp.command_id))), Loglevel::DEBUG_L1);
-
-
- if (!outp.isValid()) {
- LOG(std::string("Throw: Invalid outgoing packet"), Loglevel::DEBUG_L1);
- throw DeviceSendingFailure("Invalid outgoing packet");
- }
-
- bool successful_communication = false;
- int receiving_retry_counter = 0;
- int sending_retry_counter = dev->get_retry_sending_count();
- while (sending_retry_counter-- > 0) {
- dev->m_counters.sends_executed++;
- status = dev->send(&outp);
- if (status <= 0){
- //FIXME early disconnection not yet working properly
-// LOG("Encountered communication error, disconnecting device", Loglevel::DEBUG_L2);
-// dev->disconnect();
- dev->m_counters.sending_error++;
- LOG(std::string("Throw: Device error while sending command "), Loglevel::DEBUG_L1);
- throw DeviceSendingFailure(
- std::string("Device error while sending command ") +
- std::to_string(status));
- }
-
- std::this_thread::sleep_for(dev->get_send_receive_delay());
-
- // FIXME make checks done in device:recv here
- receiving_retry_counter = dev->get_retry_receiving_count();
- int busy_counter = 0;
- auto retry_timeout = dev->get_retry_timeout();
- while (receiving_retry_counter-- > 0) {
- dev->m_counters.recv_executed++;
- status = dev->recv(&resp);
-
- if (dev->get_device_model() == DeviceModel::STORAGE &&
- resp.command_id >= stick20::CMD_START_VALUE &&
- resp.command_id < stick20::CMD_END_VALUE ) {
- LOG(std::string("Detected storage device cmd, status: ") +
- std::to_string(resp.storage_status.device_status), Loglevel::DEBUG_L2);
-
- resp.last_command_status = static_cast<uint8_t>(stick10::command_status::ok);
- switch (static_cast<stick20::device_status>(resp.storage_status.device_status)) {
- case stick20::device_status::idle :
- case stick20::device_status::ok:
- resp.device_status = static_cast<uint8_t>(stick10::device_status::ok);
- break;
- case stick20::device_status::busy:
- case stick20::device_status::busy_progressbar: //TODO this will be modified later for getting progressbar status
- resp.device_status = static_cast<uint8_t>(stick10::device_status::busy);
- break;
- case stick20::device_status::wrong_password:
- resp.last_command_status = static_cast<uint8_t>(stick10::command_status::wrong_password);
- resp.device_status = static_cast<uint8_t>(stick10::device_status::ok);
- break;
- case stick20::device_status::no_user_password_unlock:
- resp.last_command_status = static_cast<uint8_t>(stick10::command_status::AES_dec_failed);
- resp.device_status = static_cast<uint8_t>(stick10::device_status::ok);
- break;
- default:
- LOG(std::string("Unknown storage device status, cannot translate: ") +
- std::to_string(resp.storage_status.device_status), Loglevel::DEBUG);
- resp.device_status = resp.storage_status.device_status;
- break;
- };
- }
-
- //Some of the commands return wrong CRC, for now skip checking it (TODO list and report)
- //if (resp.device_status == 0 && resp.last_command_crc == outp.crc && resp.isCRCcorrect()) break;
- auto CRC_equal_awaited = true; // resp.last_command_crc == outp.crc;
- if (resp.device_status == static_cast<uint8_t>(stick10::device_status::ok) &&
- CRC_equal_awaited && resp.isValid()){
- successful_communication = true;
- break;
- }
- if (resp.device_status == static_cast<uint8_t>(stick10::device_status::busy)) {
- dev->m_counters.busy++;
-
- if (busy_counter++<10) {
- receiving_retry_counter++;
- LOG("Status busy, not decreasing receiving_retry_counter counter: " +
- std::to_string(receiving_retry_counter), Loglevel::DEBUG_L2);
- } else {
- retry_timeout *= 2;
- retry_timeout = std::min(retry_timeout, 300ms);
- busy_counter = 0;
- LOG("Status busy, decreasing receiving_retry_counter counter: " +
- std::to_string(receiving_retry_counter) + ", current delay:"
- + std::to_string(retry_timeout.count()), Loglevel::DEBUG);
- LOG(std::string("Busy retry: status ")
- + std::to_string(resp.storage_status.device_status)
- + ", "
- + std::to_string(retry_timeout.count())
- + "ms, counter "
- + std::to_string(receiving_retry_counter)
- + ", progress: "
- + std::to_string(resp.storage_status.progress_bar_value)
- , Loglevel::DEBUG_L1);
- }
- }
- if (resp.device_status == static_cast<uint8_t>(stick10::device_status::busy) &&
- static_cast<stick20::device_status>(resp.storage_status.device_status)
- == stick20::device_status::busy_progressbar){
- successful_communication = true;
- break;
- }
- LOG(std::string("Retry status - dev status, awaited cmd crc, correct packet CRC: ")
- + std::to_string(resp.device_status) +
- " " + std::to_string(CRC_equal_awaited) +
- " " + std::to_string(resp.isCRCcorrect()), Loglevel::DEBUG_L2);
-
- if (!resp.isCRCcorrect()) dev->m_counters.wrong_CRC++;
- if (!CRC_equal_awaited) dev->m_counters.CRC_other_than_awaited++;
-
-
- LOG(
- "Device is not ready or received packet's last CRC is not equal to sent CRC packet, retrying...",
- Loglevel::DEBUG_L2);
- LOG("Invalid incoming HID packet:", Loglevel::DEBUG_L2);
- LOG(static_cast<std::string>(resp), Loglevel::DEBUG_L2);
- dev->m_counters.total_retries++;
- LOG(".", Loglevel::DEBUG_L1);
- std::this_thread::sleep_for(retry_timeout);
- continue;
- }
- if (successful_communication) break;
- LOG(std::string("Resending (outer loop) "), Loglevel::DEBUG_L2);
- LOG(std::string("sending_retry_counter count: ") + std::to_string(sending_retry_counter),
- Loglevel::DEBUG);
- }
-
- if(resp.last_command_crc != outp.crc){
- LOG(std::string("Accepting response with CRC other than expected ")
- + "Command ID: " + std::to_string(resp.command_id) + " " +
- commandid_to_string(static_cast<CommandID>(resp.command_id)) + " "
- + "Reported by response and expected: " + std::to_string(resp.last_command_crc) + "!=" + std::to_string(outp.crc),
- Loglevel::WARNING
- );
- }
-
- dev->set_last_command_status(resp.last_command_status); // FIXME should be handled on device.recv
-
- clear_packet(outp);
-
-
- if (status <= 0) {
- dev->m_counters.receiving_error++;
- LOG(std::string("Throw: Device error while executing command "), Loglevel::DEBUG_L1);
- throw DeviceReceivingFailure( //FIXME replace with CriticalErrorException
- std::string("Device error while executing command ") +
- std::to_string(status));
- }
-
- LOG(std::string("<= ") +
- std::string(
- commandid_to_string(static_cast<CommandID>(resp.command_id))
- + std::string(" ")
- + std::to_string(resp.device_status)
- + std::string(" ")
- + std::to_string(resp.storage_status.device_status)
-// + std::to_string( status_translate_command(resp.storage_status.device_status))
- ), Loglevel::DEBUG_L1);
-
- LOG("Incoming HID packet:", Loglevel::DEBUG);
- LOG(static_cast<std::string>(resp), Loglevel::DEBUG);
- if (dev->get_retry_receiving_count() - receiving_retry_counter > 2) {
- LOG(std::string("Packet received with receiving_retry_counter count: ") +
- std::to_string(receiving_retry_counter),
- Loglevel::DEBUG_L1);
- }
-
- if (resp.device_status == static_cast<uint8_t>(stick10::device_status::busy) &&
- static_cast<stick20::device_status>(resp.storage_status.device_status)
- == stick20::device_status::busy_progressbar){
- dev->m_counters.busy_progressbar++;
- LOG(std::string("Throw: Long operation in progress exception"), Loglevel::DEBUG_L1);
- throw LongOperationInProgressException(
- resp.command_id, resp.device_status, resp.storage_status.progress_bar_value);
- }
-
- if (!resp.isValid()) {
- LOG(std::string("Throw: Invalid incoming packet"), Loglevel::DEBUG_L1);
- throw InvalidCRCReceived("Invalid incoming packet");
- }
- if (receiving_retry_counter <= 0){
- LOG(std::string("Throw: \"Maximum receiving_retry_counter count reached for receiving response from the device!\""
- + std::to_string(receiving_retry_counter)), Loglevel::DEBUG_L1);
- throw DeviceReceivingFailure(
- "Maximum receiving_retry_counter count reached for receiving response from the device!");
- }
- dev->m_counters.communication_successful++;
-
- if (resp.last_command_status != static_cast<uint8_t>(stick10::command_status::ok)){
- dev->m_counters.command_result_not_equal_0_recv++;
- LOG(std::string("Throw: CommandFailedException ") + std::to_string(resp.last_command_status), Loglevel::DEBUG_L1);
- throw CommandFailedException(resp.command_id, resp.last_command_status);
- }
-
- dev->m_counters.command_successful_recv++;
-
- if (dev->get_device_model() == DeviceModel::STORAGE &&
- resp.command_id >= stick20::CMD_START_VALUE &&
- resp.command_id < stick20::CMD_END_VALUE ) {
- dev->m_counters.successful_storage_commands++;
- }
-
- if (!resp.isCRCcorrect())
- LOG(std::string("Accepting response from device with invalid CRC. ")
- + "Command ID: " + std::to_string(resp.command_id) + " " +
- commandid_to_string(static_cast<CommandID>(resp.command_id)) + " "
- + "Reported and calculated: " + std::to_string(resp.crc) + "!=" + std::to_string(resp.calculate_CRC()),
- Loglevel::WARNING
- );
-
- // See: DeviceResponse
- return resp;
- }
-
- static ClearingProxy<ResponsePacket, response_payload> run(std::shared_ptr<device::Device> dev) {
- command_payload empty_payload;
- return run(dev, empty_payload);
- }
- };
- }
-}
-#endif
diff --git a/nitrokey-sys/libnitrokey-v3.4.1/libnitrokey/dissect.h b/nitrokey-sys/libnitrokey-v3.4.1/libnitrokey/dissect.h
deleted file mode 100644
index 690b5b7..0000000
--- a/nitrokey-sys/libnitrokey-v3.4.1/libnitrokey/dissect.h
+++ /dev/null
@@ -1,145 +0,0 @@
-/*
- * Copyright (c) 2015-2018 Nitrokey UG
- *
- * This file is part of libnitrokey.
- *
- * libnitrokey is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * any later version.
- *
- * libnitrokey is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with libnitrokey. If not, see <http://www.gnu.org/licenses/>.
- *
- * SPDX-License-Identifier: LGPL-3.0
- */
-
-/*
- * Protocol packet dissection
- */
-#ifndef DISSECT_H
-#define DISSECT_H
-#include <string>
-#include <sstream>
-#include <iomanip>
-#include "misc.h"
-#include "cxx_semantics.h"
-#include "command_id.h"
-#include "device_proto.h"
-
-namespace nitrokey {
-namespace proto {
-
-template <CommandID id, class HIDPacket>
-class QueryDissector : semantics::non_constructible {
- public:
- static std::string dissect(const HIDPacket &pod) {
- std::stringstream out;
-
-#ifdef LOG_VOLATILE_DATA
- out << "Raw HID packet:" << std::endl;
- out << ::nitrokey::misc::hexdump((const uint8_t *)(&pod), sizeof pod);
-#endif
-
- out << "Contents:" << std::endl;
- out << "Command ID:\t" << commandid_to_string((CommandID)(pod.command_id))
- << std::endl;
- out << "CRC:\t"
- << std::hex << std::setw(2) << std::setfill('0')
- << pod.crc << std::endl;
-
- out << "Payload:" << std::endl;
- out << pod.payload.dissect();
- return out.str();
- }
-};
-
-
-
-
-template <CommandID id, class HIDPacket>
-class ResponseDissector : semantics::non_constructible {
- public:
- static std::string status_translate_device(int status){
- auto enum_status = static_cast<proto::stick10::device_status>(status);
- switch (enum_status){
- case stick10::device_status::ok: return "OK";
- case stick10::device_status::busy: return "BUSY";
- case stick10::device_status::error: return "ERROR";
- case stick10::device_status::received_report: return "RECEIVED_REPORT";
- }
- return std::string("UNKNOWN: ") + std::to_string(status);
- }
-
- static std::string to_upper(std::string str){
- for (auto & c: str) c = toupper(c);
- return str;
- }
- static std::string status_translate_command(int status){
- auto enum_status = static_cast<proto::stick10::command_status >(status);
- switch (enum_status) {
-#define p(X) case X: return to_upper(std::string(#X));
- p(stick10::command_status::ok)
- p(stick10::command_status::wrong_CRC)
- p(stick10::command_status::wrong_slot)
- p(stick10::command_status::slot_not_programmed)
- p(stick10::command_status::wrong_password)
- p(stick10::command_status::not_authorized)
- p(stick10::command_status::timestamp_warning)
- p(stick10::command_status::no_name_error)
- p(stick10::command_status::not_supported)
- p(stick10::command_status::unknown_command)
- p(stick10::command_status::AES_dec_failed)
-#undef p
- }
- return std::string("UNKNOWN: ") + std::to_string(status);
- }
-
- static std::string dissect(const HIDPacket &pod) {
- std::stringstream out;
-
- // FIXME use values from firmware (possibly generate separate
- // header automatically)
-
-#ifdef LOG_VOLATILE_DATA
- out << "Raw HID packet:" << std::endl;
- out << ::nitrokey::misc::hexdump((const uint8_t *)(&pod), sizeof pod);
-#endif
-
- out << "Device status:\t" << pod.device_status + 0 << " "
- << status_translate_device(pod.device_status) << std::endl;
- out << "Command ID:\t" << commandid_to_string((CommandID)(pod.command_id)) << " hex: " << std::hex << (int)pod.command_id
- << std::endl;
- out << "Last command CRC:\t"
- << std::hex << std::setw(2) << std::setfill('0')
- << pod.last_command_crc << std::endl;
- out << "Last command status:\t" << pod.last_command_status + 0 << " "
- << status_translate_command(pod.last_command_status) << std::endl;
- out << "CRC:\t"
- << std::hex << std::setw(2) << std::setfill('0')
- << pod.crc << std::endl;
- if((int)pod.command_id == pod.storage_status.command_id){
- out << "Storage stick status (where applicable):" << std::endl;
-#define d(x) out << " "#x": \t"<< std::hex << std::setw(2) \
- << std::setfill('0')<< static_cast<int>(x) << std::endl;
- d(pod.storage_status.command_counter);
- d(pod.storage_status.command_id);
- d(pod.storage_status.device_status);
- d(pod.storage_status.progress_bar_value);
-#undef d
- }
-
- out << "Payload:" << std::endl;
- out << pod.payload.dissect();
- return out.str();
- }
-};
-}
-}
-
-#endif
diff --git a/nitrokey-sys/libnitrokey-v3.4.1/libnitrokey/hidapi/hidapi.h b/nitrokey-sys/libnitrokey-v3.4.1/libnitrokey/hidapi/hidapi.h
deleted file mode 100644
index e5bc2dc..0000000
--- a/nitrokey-sys/libnitrokey-v3.4.1/libnitrokey/hidapi/hidapi.h
+++ /dev/null
@@ -1,391 +0,0 @@
-/*******************************************************
- HIDAPI - Multi-Platform library for
- communication with HID devices.
-
- Alan Ott
- Signal 11 Software
-
- 8/22/2009
-
- Copyright 2009, All Rights Reserved.
-
- At the discretion of the user of this library,
- this software may be licensed under the terms of the
- GNU General Public License v3, a BSD-Style license, or the
- original HIDAPI license as outlined in the LICENSE.txt,
- LICENSE-gpl3.txt, LICENSE-bsd.txt, and LICENSE-orig.txt
- files located at the root of the source distribution.
- These files may also be found in the public source
- code repository located at:
- http://github.com/signal11/hidapi .
-********************************************************/
-
-/** @file
- * @defgroup API hidapi API
- */
-
-#ifndef HIDAPI_H__
-#define HIDAPI_H__
-
-#include <wchar.h>
-
-#ifdef _WIN32
- #define HID_API_EXPORT __declspec(dllexport)
- #define HID_API_CALL
-#else
- #define HID_API_EXPORT /**< API export macro */
- #define HID_API_CALL /**< API call macro */
-#endif
-
-#define HID_API_EXPORT_CALL HID_API_EXPORT HID_API_CALL /**< API export and call macro*/
-
-#ifdef __cplusplus
-extern "C" {
-#endif
- struct hid_device_;
- typedef struct hid_device_ hid_device; /**< opaque hidapi structure */
-
- /** hidapi info structure */
- struct hid_device_info {
- /** Platform-specific device path */
- char *path;
- /** Device Vendor ID */
- unsigned short vendor_id;
- /** Device Product ID */
- unsigned short product_id;
- /** Serial Number */
- wchar_t *serial_number;
- /** Device Release Number in binary-coded decimal,
- also known as Device Version Number */
- unsigned short release_number;
- /** Manufacturer String */
- wchar_t *manufacturer_string;
- /** Product string */
- wchar_t *product_string;
- /** Usage Page for this Device/Interface
- (Windows/Mac only). */
- unsigned short usage_page;
- /** Usage for this Device/Interface
- (Windows/Mac only).*/
- unsigned short usage;
- /** The USB interface which this logical device
- represents. Valid on both Linux implementations
- in all cases, and valid on the Windows implementation
- only if the device contains more than one interface. */
- int interface_number;
-
- /** Pointer to the next device */
- struct hid_device_info *next;
- };
-
-
- /** @brief Initialize the HIDAPI library.
-
- This function initializes the HIDAPI library. Calling it is not
- strictly necessary, as it will be called automatically by
- hid_enumerate() and any of the hid_open_*() functions if it is
- needed. This function should be called at the beginning of
- execution however, if there is a chance of HIDAPI handles
- being opened by different threads simultaneously.
-
- @ingroup API
-
- @returns
- This function returns 0 on success and -1 on error.
- */
- int HID_API_EXPORT HID_API_CALL hid_init(void);
-
- /** @brief Finalize the HIDAPI library.
-
- This function frees all of the static data associated with
- HIDAPI. It should be called at the end of execution to avoid
- memory leaks.
-
- @ingroup API
-
- @returns
- This function returns 0 on success and -1 on error.
- */
- int HID_API_EXPORT HID_API_CALL hid_exit(void);
-
- /** @brief Enumerate the HID Devices.
-
- This function returns a linked list of all the HID devices
- attached to the system which match vendor_id and product_id.
- If @p vendor_id is set to 0 then any vendor matches.
- If @p product_id is set to 0 then any product matches.
- If @p vendor_id and @p product_id are both set to 0, then
- all HID devices will be returned.
-
- @ingroup API
- @param vendor_id The Vendor ID (VID) of the types of device
- to open.
- @param product_id The Product ID (PID) of the types of
- device to open.
-
- @returns
- This function returns a pointer to a linked list of type
- struct #hid_device, containing information about the HID devices
- attached to the system, or NULL in the case of failure. Free
- this linked list by calling hid_free_enumeration().
- */
- struct hid_device_info HID_API_EXPORT * HID_API_CALL hid_enumerate(unsigned short vendor_id, unsigned short product_id);
-
- /** @brief Free an enumeration Linked List
-
- This function frees a linked list created by hid_enumerate().
-
- @ingroup API
- @param devs Pointer to a list of struct_device returned from
- hid_enumerate().
- */
- void HID_API_EXPORT HID_API_CALL hid_free_enumeration(struct hid_device_info *devs);
-
- /** @brief Open a HID device using a Vendor ID (VID), Product ID
- (PID) and optionally a serial number.
-
- If @p serial_number is NULL, the first device with the
- specified VID and PID is opened.
-
- @ingroup API
- @param vendor_id The Vendor ID (VID) of the device to open.
- @param product_id The Product ID (PID) of the device to open.
- @param serial_number The Serial Number of the device to open
- (Optionally NULL).
-
- @returns
- This function returns a pointer to a #hid_device object on
- success or NULL on failure.
- */
- HID_API_EXPORT hid_device * HID_API_CALL hid_open(unsigned short vendor_id, unsigned short product_id, const wchar_t *serial_number);
-
- /** @brief Open a HID device by its path name.
-
- The path name be determined by calling hid_enumerate(), or a
- platform-specific path name can be used (eg: /dev/hidraw0 on
- Linux).
-
- @ingroup API
- @param path The path name of the device to open
-
- @returns
- This function returns a pointer to a #hid_device object on
- success or NULL on failure.
- */
- HID_API_EXPORT hid_device * HID_API_CALL hid_open_path(const char *path);
-
- /** @brief Write an Output report to a HID device.
-
- The first byte of @p data[] must contain the Report ID. For
- devices which only support a single report, this must be set
- to 0x0. The remaining bytes contain the report data. Since
- the Report ID is mandatory, calls to hid_write() will always
- contain one more byte than the report contains. For example,
- if a hid report is 16 bytes long, 17 bytes must be passed to
- hid_write(), the Report ID (or 0x0, for devices with a
- single report), followed by the report data (16 bytes). In
- this example, the length passed in would be 17.
-
- hid_write() will send the data on the first OUT endpoint, if
- one exists. If it does not, it will send the data through
- the Control Endpoint (Endpoint 0).
-
- @ingroup API
- @param device A device handle returned from hid_open().
- @param data The data to send, including the report number as
- the first byte.
- @param length The length in bytes of the data to send.
-
- @returns
- This function returns the actual number of bytes written and
- -1 on error.
- */
- int HID_API_EXPORT HID_API_CALL hid_write(hid_device *device, const unsigned char *data, size_t length);
-
- /** @brief Read an Input report from a HID device with timeout.
-
- Input reports are returned
- to the host through the INTERRUPT IN endpoint. The first byte will
- contain the Report number if the device uses numbered reports.
-
- @ingroup API
- @param device A device handle returned from hid_open().
- @param data A buffer to put the read data into.
- @param length The number of bytes to read. For devices with
- multiple reports, make sure to read an extra byte for
- the report number.
- @param milliseconds timeout in milliseconds or -1 for blocking wait.
-
- @returns
- This function returns the actual number of bytes read and
- -1 on error. If no packet was available to be read within
- the timeout period, this function returns 0.
- */
- int HID_API_EXPORT HID_API_CALL hid_read_timeout(hid_device *dev, unsigned char *data, size_t length, int milliseconds);
-
- /** @brief Read an Input report from a HID device.
-
- Input reports are returned
- to the host through the INTERRUPT IN endpoint. The first byte will
- contain the Report number if the device uses numbered reports.
-
- @ingroup API
- @param device A device handle returned from hid_open().
- @param data A buffer to put the read data into.
- @param length The number of bytes to read. For devices with
- multiple reports, make sure to read an extra byte for
- the report number.
-
- @returns
- This function returns the actual number of bytes read and
- -1 on error. If no packet was available to be read and
- the handle is in non-blocking mode, this function returns 0.
- */
- int HID_API_EXPORT HID_API_CALL hid_read(hid_device *device, unsigned char *data, size_t length);
-
- /** @brief Set the device handle to be non-blocking.
-
- In non-blocking mode calls to hid_read() will return
- immediately with a value of 0 if there is no data to be
- read. In blocking mode, hid_read() will wait (block) until
- there is data to read before returning.
-
- Nonblocking can be turned on and off at any time.
-
- @ingroup API
- @param device A device handle returned from hid_open().
- @param nonblock enable or not the nonblocking reads
- - 1 to enable nonblocking
- - 0 to disable nonblocking.
-
- @returns
- This function returns 0 on success and -1 on error.
- */
- int HID_API_EXPORT HID_API_CALL hid_set_nonblocking(hid_device *device, int nonblock);
-
- /** @brief Send a Feature report to the device.
-
- Feature reports are sent over the Control endpoint as a
- Set_Report transfer. The first byte of @p data[] must
- contain the Report ID. For devices which only support a
- single report, this must be set to 0x0. The remaining bytes
- contain the report data. Since the Report ID is mandatory,
- calls to hid_send_feature_report() will always contain one
- more byte than the report contains. For example, if a hid
- report is 16 bytes long, 17 bytes must be passed to
- hid_send_feature_report(): the Report ID (or 0x0, for
- devices which do not use numbered reports), followed by the
- report data (16 bytes). In this example, the length passed
- in would be 17.
-
- @ingroup API
- @param device A device handle returned from hid_open().
- @param data The data to send, including the report number as
- the first byte.
- @param length The length in bytes of the data to send, including
- the report number.
-
- @returns
- This function returns the actual number of bytes written and
- -1 on error.
- */
- int HID_API_EXPORT HID_API_CALL hid_send_feature_report(hid_device *device, const unsigned char *data, size_t length);
-
- /** @brief Get a feature report from a HID device.
-
- Set the first byte of @p data[] to the Report ID of the
- report to be read. Make sure to allow space for this
- extra byte in @p data[]. Upon return, the first byte will
- still contain the Report ID, and the report data will
- start in data[1].
-
- @ingroup API
- @param device A device handle returned from hid_open().
- @param data A buffer to put the read data into, including
- the Report ID. Set the first byte of @p data[] to the
- Report ID of the report to be read, or set it to zero
- if your device does not use numbered reports.
- @param length The number of bytes to read, including an
- extra byte for the report ID. The buffer can be longer
- than the actual report.
-
- @returns
- This function returns the number of bytes read plus
- one for the report ID (which is still in the first
- byte), or -1 on error.
- */
- int HID_API_EXPORT HID_API_CALL hid_get_feature_report(hid_device *device, unsigned char *data, size_t length);
-
- /** @brief Close a HID device.
-
- @ingroup API
- @param device A device handle returned from hid_open().
- */
- void HID_API_EXPORT HID_API_CALL hid_close(hid_device *device);
-
- /** @brief Get The Manufacturer String from a HID device.
-
- @ingroup API
- @param device A device handle returned from hid_open().
- @param string A wide string buffer to put the data into.
- @param maxlen The length of the buffer in multiples of wchar_t.
-
- @returns
- This function returns 0 on success and -1 on error.
- */
- int HID_API_EXPORT_CALL hid_get_manufacturer_string(hid_device *device, wchar_t *string, size_t maxlen);
-
- /** @brief Get The Product String from a HID device.
-
- @ingroup API
- @param device A device handle returned from hid_open().
- @param string A wide string buffer to put the data into.
- @param maxlen The length of the buffer in multiples of wchar_t.
-
- @returns
- This function returns 0 on success and -1 on error.
- */
- int HID_API_EXPORT_CALL hid_get_product_string(hid_device *device, wchar_t *string, size_t maxlen);
-
- /** @brief Get The Serial Number String from a HID device.
-
- @ingroup API
- @param device A device handle returned from hid_open().
- @param string A wide string buffer to put the data into.
- @param maxlen The length of the buffer in multiples of wchar_t.
-
- @returns
- This function returns 0 on success and -1 on error.
- */
- int HID_API_EXPORT_CALL hid_get_serial_number_string(hid_device *device, wchar_t *string, size_t maxlen);
-
- /** @brief Get a string from a HID device, based on its string index.
-
- @ingroup API
- @param device A device handle returned from hid_open().
- @param string_index The index of the string to get.
- @param string A wide string buffer to put the data into.
- @param maxlen The length of the buffer in multiples of wchar_t.
-
- @returns
- This function returns 0 on success and -1 on error.
- */
- int HID_API_EXPORT_CALL hid_get_indexed_string(hid_device *device, int string_index, wchar_t *string, size_t maxlen);
-
- /** @brief Get a string describing the last error which occurred.
-
- @ingroup API
- @param device A device handle returned from hid_open().
-
- @returns
- This function returns a string containing the last error
- which occurred or NULL if none has occurred.
- */
- HID_API_EXPORT const wchar_t* HID_API_CALL hid_error(hid_device *device);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
-
diff --git a/nitrokey-sys/libnitrokey-v3.4.1/libnitrokey/log.h b/nitrokey-sys/libnitrokey-v3.4.1/libnitrokey/log.h
deleted file mode 100644
index 2a64bef..0000000
--- a/nitrokey-sys/libnitrokey-v3.4.1/libnitrokey/log.h
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- * Copyright (c) 2015-2018 Nitrokey UG
- *
- * This file is part of libnitrokey.
- *
- * libnitrokey is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * any later version.
- *
- * libnitrokey is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with libnitrokey. If not, see <http://www.gnu.org/licenses/>.
- *
- * SPDX-License-Identifier: LGPL-3.0
- */
-
-#ifndef LOG_H
-#define LOG_H
-
-#include <string>
-#include <functional>
-
-namespace nitrokey {
- namespace log {
-
-//for MSVC
-#ifdef ERROR
-#undef ERROR
-#endif
-
-
- enum class Loglevel : int {
- ERROR,
- WARNING,
- INFO,
- DEBUG_L1,
- DEBUG,
- DEBUG_L2
- };
-
- class LogHandler {
- public:
- virtual void print(const std::string &, Loglevel lvl) = 0;
- protected:
- std::string loglevel_to_str(Loglevel);
- std::string format_message_to_string(const std::string &str, const Loglevel &lvl);
-
- };
-
- class StdlogHandler : public LogHandler {
- public:
- virtual void print(const std::string &, Loglevel lvl);
- };
-
- class FunctionalLogHandler : public LogHandler {
- using log_function_type = std::function<void(std::string)>;
- log_function_type log_function;
- public:
- FunctionalLogHandler(log_function_type _log_function);
- virtual void print(const std::string &, Loglevel lvl);
-
- };
-
- extern StdlogHandler stdlog_handler;
-
- class Log {
- public:
- Log() : mp_loghandler(&stdlog_handler), m_loglevel(Loglevel::WARNING) {}
-
- static Log &instance() {
- if (mp_instance == nullptr) mp_instance = new Log;
- return *mp_instance;
- }
-
- void operator()(const std::string &, Loglevel);
- void set_loglevel(Loglevel lvl) { m_loglevel = lvl; }
- void set_handler(LogHandler *handler) { mp_loghandler = handler; }
-
- private:
- LogHandler *mp_loghandler;
- Loglevel m_loglevel;
- static std::string prefix;
- public:
- static void setPrefix(std::string prefix = std::string());
-
- private:
-
- static Log *mp_instance;
- };
- }
-}
-
-
-#ifdef NO_LOG
-#define LOG(string, level) while(false){}
-#define LOGD(string) while(false){}
-#else
-#define LOG(string, level) nitrokey::log::Log::instance()((string), (level))
-#define LOGD1(string) nitrokey::log::Log::instance()((string), (nitrokey::log::Loglevel::DEBUG_L1))
-#define LOGD(string) nitrokey::log::Log::instance()((string), (nitrokey::log::Loglevel::DEBUG_L2))
-#endif
-
-#endif
diff --git a/nitrokey-sys/libnitrokey-v3.4.1/libnitrokey/misc.h b/nitrokey-sys/libnitrokey-v3.4.1/libnitrokey/misc.h
deleted file mode 100644
index 88254dd..0000000
--- a/nitrokey-sys/libnitrokey-v3.4.1/libnitrokey/misc.h
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * Copyright (c) 2015-2018 Nitrokey UG
- *
- * This file is part of libnitrokey.
- *
- * libnitrokey is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * any later version.
- *
- * libnitrokey is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with libnitrokey. If not, see <http://www.gnu.org/licenses/>.
- *
- * SPDX-License-Identifier: LGPL-3.0
- */
-
-
-#ifndef MISC_H
-#define MISC_H
-#include <stdio.h>
-#include <string>
-#include <vector>
-#include <string.h>
-#include "log.h"
-#include "LibraryException.h"
-#include <sstream>
-#include <iomanip>
-
-
-namespace nitrokey {
-namespace misc {
-
- template<typename T>
- std::string toHex(T value){
- using namespace std;
- std::ostringstream oss;
- oss << std::hex << std::setw(sizeof(value)*2) << std::setfill('0') << value;
- return oss.str();
- }
-
- /**
- * Copies string from pointer to fixed size C-style array. Src needs to be a valid C-string - eg. ended with '\0'.
- * Throws when source is bigger than destination.
- * @tparam T type of destination array
- * @param dest fixed size destination array
- * @param src pointer to source c-style valid string
- */
- template <typename T>
- void strcpyT(T& dest, const char* src){
-
- if (src == nullptr)
-// throw EmptySourceStringException(slot_number);
- return;
- const size_t s_dest = sizeof dest;
- LOG(std::string("strcpyT sizes dest src ")
- +std::to_string(s_dest)+ " "
- +std::to_string(strlen(src))+ " "
- ,nitrokey::log::Loglevel::DEBUG_L2);
- if (strlen(src) > s_dest){
- throw TooLongStringException(strlen(src), s_dest, src);
- }
- strncpy((char*) &dest, src, s_dest);
- }
-
-#define bzero(b,len) (memset((b), '\0', (len)), (void) 0)
- template <typename T>
-typename T::CommandPayload get_payload(){
- //Create, initialize and return by value command payload
- typename T::CommandPayload st;
- bzero(&st, sizeof(st));
- return st;
-}
-
- template<typename CMDTYPE, typename Tdev>
- void execute_password_command(Tdev &stick, const char *password) {
- auto p = get_payload<CMDTYPE>();
- p.set_defaults();
- strcpyT(p.password, password);
- CMDTYPE::CommandTransaction::run(stick, p);
- }
-
- std::string hexdump(const uint8_t *p, size_t size, bool print_header=true, bool print_ascii=true,
- bool print_empty=true);
- uint32_t stm_crc32(const uint8_t *data, size_t size);
- std::vector<uint8_t> hex_string_to_byte(const char* hexString);
-}
-}
-
-#endif
diff --git a/nitrokey-sys/libnitrokey-v3.4.1/libnitrokey/stick10_commands.h b/nitrokey-sys/libnitrokey-v3.4.1/libnitrokey/stick10_commands.h
deleted file mode 100644
index f2ffba2..0000000
--- a/nitrokey-sys/libnitrokey-v3.4.1/libnitrokey/stick10_commands.h
+++ /dev/null
@@ -1,889 +0,0 @@
-/*
- * Copyright (c) 2015-2018 Nitrokey UG
- *
- * This file is part of libnitrokey.
- *
- * libnitrokey is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * any later version.
- *
- * libnitrokey is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with libnitrokey. If not, see <http://www.gnu.org/licenses/>.
- *
- * SPDX-License-Identifier: LGPL-3.0
- */
-
-#ifndef STICK10_COMMANDS_H
-#define STICK10_COMMANDS_H
-
-#include <bitset>
-#include <iomanip>
-#include <string>
-#include <sstream>
-#include <stdint.h>
-#include "device_proto.h"
-#include "command.h"
-
-#pragma pack (push,1)
-
-namespace nitrokey {
-namespace proto {
-
-
-
-/*
- * Stick10 protocol definition
- */
-namespace stick10 {
-class GetSlotName : public Command<CommandID::READ_SLOT_NAME> {
- public:
- // reachable as a typedef in Transaction
- struct CommandPayload {
- uint8_t slot_number;
-
- bool isValid() const { return slot_number<0x10+3; }
- std::string dissect() const {
- std::stringstream ss;
- ss << "slot_number:\t" << (int)(slot_number) << std::endl;
- return ss.str();
- }
- } __packed;
-
- struct ResponsePayload {
- uint8_t slot_name[15];
-
- bool isValid() const { return true; }
- std::string dissect() const {
- std::stringstream ss;
- print_to_ss_volatile(slot_name);
- return ss.str();
- }
- } __packed;
-
- typedef Transaction<command_id(), struct CommandPayload,
- struct ResponsePayload> CommandTransaction;
-};
-
-class EraseSlot : Command<CommandID::ERASE_SLOT> {
- public:
- struct CommandPayload {
- uint8_t slot_number;
-
- bool isValid() const { return !(slot_number & 0xF0); }
- std::string dissect() const {
- std::stringstream ss;
- ss << "slot_number:\t" << (int)(slot_number) << std::endl;
- return ss.str();
- }
- } __packed;
-
- typedef Transaction<command_id(), struct CommandPayload, struct EmptyPayload>
- CommandTransaction;
-};
-
-class SetTime : Command<CommandID::SET_TIME> {
- public:
- struct CommandPayload {
- uint8_t reset; // 0 - get time, 1 - set time
- uint64_t time; // posix time
-
- bool isValid() const { return reset && reset != 1; }
- std::string dissect() const {
- std::stringstream ss;
- ss << "reset:\t" << (int)(reset) << std::endl;
- ss << "time:\t" << (time) << std::endl;
- return ss.str();
- }
- } __packed;
-
- typedef Transaction<command_id(), struct CommandPayload, struct EmptyPayload>
- CommandTransaction;
-};
-
-
-class WriteToHOTPSlot : Command<CommandID::WRITE_TO_SLOT> {
- public:
- struct CommandPayload {
- uint8_t slot_number;
- uint8_t slot_name[15];
- uint8_t slot_secret[20];
- union{
- uint8_t _slot_config;
- struct{
- bool use_8_digits : 1;
- bool use_enter : 1;
- bool use_tokenID : 1;
- };
- };
- union{
- uint8_t slot_token_id[13]; /** OATH Token Identifier */
- struct{ /** @see https://openauthentication.org/token-specs/ */
- uint8_t omp[2];
- uint8_t tt[2];
- uint8_t mui[8];
- uint8_t keyboard_layout; //disabled feature in nitroapp as of 20160805
- } slot_token_fields;
- };
- union{
- uint64_t slot_counter;
- uint8_t slot_counter_s[8];
- } __packed;
-
- bool isValid() const { return !(slot_number & 0xF0); }
- std::string dissect() const {
- std::stringstream ss;
- ss << "slot_number:\t" << (int)(slot_number) << std::endl;
- print_to_ss_volatile(slot_name);
- print_to_ss_volatile(slot_secret);
- ss << "slot_config:\t" << std::bitset<8>((int)_slot_config) << std::endl;
- ss << "\tuse_8_digits(0):\t" << use_8_digits << std::endl;
- ss << "\tuse_enter(1):\t" << use_enter << std::endl;
- ss << "\tuse_tokenID(2):\t" << use_tokenID << std::endl;
-
- ss << "slot_token_id:\t";
- for (auto i : slot_token_id)
- ss << std::hex << std::setw(2) << std::setfill('0')<< (int) i << " " ;
- ss << std::endl;
- ss << "slot_counter:\t[" << (int)slot_counter << "]\t"
- << ::nitrokey::misc::hexdump((const uint8_t *)(&slot_counter), sizeof slot_counter, false);
-
- return ss.str();
- }
- } __packed;
-
- typedef Transaction<command_id(), struct CommandPayload, struct EmptyPayload>
- CommandTransaction;
-};
-
-class WriteToTOTPSlot : Command<CommandID::WRITE_TO_SLOT> {
- public:
- struct CommandPayload {
- uint8_t slot_number;
- uint8_t slot_name[15];
- uint8_t slot_secret[20];
- union{
- uint8_t _slot_config;
- struct{
- bool use_8_digits : 1;
- bool use_enter : 1;
- bool use_tokenID : 1;
- };
- };
- union{
- uint8_t slot_token_id[13]; /** OATH Token Identifier */
- struct{ /** @see https://openauthentication.org/token-specs/ */
- uint8_t omp[2];
- uint8_t tt[2];
- uint8_t mui[8];
- uint8_t keyboard_layout; //disabled feature in nitroapp as of 20160805
- } slot_token_fields;
- };
- uint16_t slot_interval;
-
- bool isValid() const { return !(slot_number & 0xF0); } //TODO check
- std::string dissect() const {
- std::stringstream ss;
- ss << "slot_number:\t" << (int)(slot_number) << std::endl;
- print_to_ss_volatile(slot_name);
- print_to_ss_volatile(slot_secret);
- ss << "slot_config:\t" << std::bitset<8>((int)_slot_config) << std::endl;
- ss << "slot_token_id:\t";
- for (auto i : slot_token_id)
- ss << std::hex << std::setw(2) << std::setfill('0')<< (int) i << " " ;
- ss << std::endl;
- ss << "slot_interval:\t" << (int)slot_interval << std::endl;
- return ss.str();
- }
- } __packed;
-
- typedef Transaction<command_id(), struct CommandPayload, struct EmptyPayload>
- CommandTransaction;
-};
-
-class GetTOTP : Command<CommandID::GET_CODE> {
- public:
- struct CommandPayload {
- uint8_t slot_number;
- uint64_t challenge;
- uint64_t last_totp_time;
- uint8_t last_interval;
-
- bool isValid() const { return !(slot_number & 0xF0); }
- std::string dissect() const {
- std::stringstream ss;
- ss << "slot_number:\t" << (int)(slot_number) << std::endl;
- ss << "challenge:\t" << (challenge) << std::endl;
- ss << "last_totp_time:\t" << (last_totp_time) << std::endl;
- ss << "last_interval:\t" << (int)(last_interval) << std::endl;
- return ss.str();
- }
- } __packed;
-
- struct ResponsePayload {
- union {
- uint8_t whole_response[18]; //14 bytes reserved for config, but used only 1
- struct {
- uint32_t code;
- union{
- uint8_t _slot_config;
- struct{
- bool use_8_digits : 1;
- bool use_enter : 1;
- bool use_tokenID : 1;
- };
- };
- } __packed ;
- } __packed ;
-
- bool isValid() const { return true; }
- std::string dissect() const {
- std::stringstream ss;
- ss << "code:\t" << (code) << std::endl;
- ss << "slot_config:\t" << std::bitset<8>((int)_slot_config) << std::endl;
- ss << "\tuse_8_digits(0):\t" << use_8_digits << std::endl;
- ss << "\tuse_enter(1):\t" << use_enter << std::endl;
- ss << "\tuse_tokenID(2):\t" << use_tokenID << std::endl;
- return ss.str();
- }
- } __packed;
-
- typedef Transaction<command_id(), struct CommandPayload, struct ResponsePayload>
- CommandTransaction;
-};
-
-class GetHOTP : Command<CommandID::GET_CODE> {
- public:
- struct CommandPayload {
- uint8_t slot_number;
-
- bool isValid() const { return (slot_number & 0xF0); }
- std::string dissect() const {
- std::stringstream ss;
- ss << "slot_number:\t" << (int)(slot_number) << std::endl;
- return ss.str();
- }
- } __packed;
-
- struct ResponsePayload {
- union {
- uint8_t whole_response[18]; //14 bytes reserved for config, but used only 1
- struct {
- uint32_t code;
- union{
- uint8_t _slot_config;
- struct{
- bool use_8_digits : 1;
- bool use_enter : 1;
- bool use_tokenID : 1;
- };
- };
- } __packed;
- } __packed;
-
- bool isValid() const { return true; }
- std::string dissect() const {
- std::stringstream ss;
- ss << "code:\t" << (code) << std::endl;
- ss << "slot_config:\t" << std::bitset<8>((int)_slot_config) << std::endl;
- ss << "\tuse_8_digits(0):\t" << use_8_digits << std::endl;
- ss << "\tuse_enter(1):\t" << use_enter << std::endl;
- ss << "\tuse_tokenID(2):\t" << use_tokenID << std::endl;
- return ss.str();
- }
- } __packed;
-
- typedef Transaction<command_id(), struct CommandPayload, struct ResponsePayload>
- CommandTransaction;
-};
-
-class ReadSlot : Command<CommandID::READ_SLOT> {
- public:
- struct CommandPayload {
- uint8_t slot_number;
-
- bool isValid() const { return !(slot_number & 0xF0); }
-
- std::string dissect() const {
- std::stringstream ss;
- ss << "slot_number:\t" << (int)(slot_number) << std::endl;
- return ss.str();
- }
- } __packed;
-
- struct ResponsePayload {
- uint8_t slot_name[15];
- union{
- uint8_t _slot_config;
- struct{
- bool use_8_digits : 1;
- bool use_enter : 1;
- bool use_tokenID : 1;
- };
- };
- union{
- uint8_t slot_token_id[13]; /** OATH Token Identifier */
- struct{ /** @see https://openauthentication.org/token-specs/ */
- uint8_t omp[2];
- uint8_t tt[2];
- uint8_t mui[8];
- uint8_t keyboard_layout; //disabled feature in nitroapp as of 20160805
- } slot_token_fields;
- };
- union{
- uint64_t slot_counter;
- uint8_t slot_counter_s[8];
- } __packed;
-
- bool isValid() const { return true; }
-
- std::string dissect() const {
- std::stringstream ss;
- print_to_ss_volatile(slot_name);
- ss << "slot_config:\t" << std::bitset<8>((int)_slot_config) << std::endl;
- ss << "\tuse_8_digits(0):\t" << use_8_digits << std::endl;
- ss << "\tuse_enter(1):\t" << use_enter << std::endl;
- ss << "\tuse_tokenID(2):\t" << use_tokenID << std::endl;
-
- ss << "slot_token_id:\t";
- for (auto i : slot_token_id)
- ss << std::hex << std::setw(2) << std::setfill('0')<< (int) i << " " ;
- ss << std::endl;
- ss << "slot_counter:\t[" << (int)slot_counter << "]\t"
- << ::nitrokey::misc::hexdump((const uint8_t *)(&slot_counter), sizeof slot_counter, false);
- return ss.str();
- }
- } __packed;
-
- typedef Transaction<command_id(), struct CommandPayload,
- struct ResponsePayload> CommandTransaction;
-};
-
-class GetStatus : Command<CommandID::GET_STATUS> {
- public:
- struct ResponsePayload {
- union {
- uint16_t firmware_version;
- struct {
- uint8_t minor;
- uint8_t major;
- } firmware_version_st;
- };
- union{
- uint8_t card_serial[4];
- uint32_t card_serial_u32;
- } __packed;
- union {
- uint8_t general_config[5];
- struct{
- uint8_t numlock; /** 0-1: HOTP slot number from which the code will be get on double press, other value - function disabled */
- uint8_t capslock; /** same as numlock */
- uint8_t scrolllock; /** same as numlock */
- uint8_t enable_user_password;
- uint8_t delete_user_password; /* unused */
- } __packed;
- } __packed;
-
- static constexpr uint8_t special_HOTP_slots = 2;
- bool isValid() const { return numlock < special_HOTP_slots && capslock < special_HOTP_slots
- && scrolllock < special_HOTP_slots && enable_user_password < 2; }
-
- std::string get_card_serial_hex() const {
- return nitrokey::misc::toHex(card_serial_u32);
- }
-
- std::string dissect() const {
- std::stringstream ss;
- ss << "firmware_version:\t"
- << "[" << firmware_version << "]" << "\t"
- << ::nitrokey::misc::hexdump(
- (const uint8_t *)(&firmware_version), sizeof firmware_version, false);
- ss << "card_serial_u32:\t" << std::hex << card_serial_u32 << std::endl;
- ss << "card_serial:\t"
- << ::nitrokey::misc::hexdump((const uint8_t *)(card_serial),
- sizeof card_serial, false);
- ss << "general_config:\t"
- << ::nitrokey::misc::hexdump((const uint8_t *)(general_config),
- sizeof general_config, false);
- ss << "numlock:\t" << (int)numlock << std::endl;
- ss << "capslock:\t" << (int)capslock << std::endl;
- ss << "scrolllock:\t" << (int)scrolllock << std::endl;
- ss << "enable_user_password:\t" << (bool) enable_user_password << std::endl;
- ss << "delete_user_password:\t" << (bool) delete_user_password << std::endl;
-
- return ss.str();
- }
- } __packed;
-
- typedef Transaction<command_id(), struct EmptyPayload, struct ResponsePayload>
- CommandTransaction;
-};
-
-class GetPasswordRetryCount : Command<CommandID::GET_PASSWORD_RETRY_COUNT> {
- public:
- struct ResponsePayload {
- uint8_t password_retry_count;
-
- bool isValid() const { return true; }
- std::string dissect() const {
- std::stringstream ss;
- ss << " password_retry_count\t" << (int)password_retry_count << std::endl;
- return ss.str();
- }
- } __packed;
-
- typedef Transaction<command_id(), struct EmptyPayload, struct ResponsePayload>
- CommandTransaction;
-};
-
-class GetUserPasswordRetryCount
- : Command<CommandID::GET_USER_PASSWORD_RETRY_COUNT> {
- public:
- struct ResponsePayload {
- uint8_t password_retry_count;
-
- bool isValid() const { return true; }
- std::string dissect() const {
- std::stringstream ss;
- ss << " password_retry_count\t" << (int)password_retry_count << std::endl;
- return ss.str();
- }
- } __packed;
-
- typedef Transaction<command_id(), struct EmptyPayload, struct ResponsePayload>
- CommandTransaction;
-};
-
- template <typename T, typename Q, int N>
- void write_array(T &ss, Q (&arr)[N]){
- for (int i=0; i<N; i++){
- ss << std::hex << std::setfill('0') << std::setw(2) << (int)arr[i] << " ";
- }
- ss << std::endl;
- };
-
-
-class GetPasswordSafeSlotStatus : Command<CommandID::GET_PW_SAFE_SLOT_STATUS> {
- public:
- struct ResponsePayload {
- uint8_t password_safe_status[PWS_SLOT_COUNT];
-
- bool isValid() const { return true; }
- std::string dissect() const {
- std::stringstream ss;
- ss << "password_safe_status\t";
- write_array(ss, password_safe_status);
- return ss.str();
- }
- } __packed;
-
- typedef Transaction<command_id(), struct EmptyPayload, struct ResponsePayload>
- CommandTransaction;
-};
-
-class GetPasswordSafeSlotName : Command<CommandID::GET_PW_SAFE_SLOT_NAME> {
- public:
- struct CommandPayload {
- uint8_t slot_number;
-
- bool isValid() const { return !(slot_number & 0xF0); }
- std::string dissect() const {
- std::stringstream ss;
- ss << "slot_number\t" << (int)slot_number << std::endl;
- return ss.str();
- }
- } __packed;
-
- struct ResponsePayload {
- uint8_t slot_name[PWS_SLOTNAME_LENGTH];
-
- bool isValid() const { return true; }
- std::string dissect() const {
- std::stringstream ss;
- print_to_ss_volatile(slot_name);
- return ss.str();
- }
- } __packed;
-
- typedef Transaction<command_id(), struct CommandPayload,
- struct ResponsePayload> CommandTransaction;
-};
-
-class GetPasswordSafeSlotPassword
- : Command<CommandID::GET_PW_SAFE_SLOT_PASSWORD> {
- public:
- struct CommandPayload {
- uint8_t slot_number;
-
- bool isValid() const { return !(slot_number & 0xF0); }
- std::string dissect() const {
- std::stringstream ss;
- ss << " slot_number\t" << (int)slot_number << std::endl;
- return ss.str();
- }
- } __packed;
-
- struct ResponsePayload {
- uint8_t slot_password[PWS_PASSWORD_LENGTH];
-
- bool isValid() const { return true; }
- std::string dissect() const {
- std::stringstream ss;
- print_to_ss_volatile(slot_password);
- return ss.str();
- }
- } __packed;
-
- typedef Transaction<command_id(), struct CommandPayload,
- struct ResponsePayload> CommandTransaction;
-};
-
-class GetPasswordSafeSlotLogin
- : Command<CommandID::GET_PW_SAFE_SLOT_LOGINNAME> {
- public:
- struct CommandPayload {
- uint8_t slot_number;
-
- bool isValid() const { return !(slot_number & 0xF0); }
- std::string dissect() const {
- std::stringstream ss;
- ss << " slot_number\t" << (int)slot_number << std::endl;
- return ss.str();
- }
- } __packed;
-
- struct ResponsePayload {
- uint8_t slot_login[PWS_LOGINNAME_LENGTH];
-
- bool isValid() const { return true; }
- std::string dissect() const {
- std::stringstream ss;
- print_to_ss_volatile(slot_login);
- return ss.str();
- }
- } __packed;
-
- typedef Transaction<command_id(), struct CommandPayload,
- struct ResponsePayload> CommandTransaction;
-};
-
-class SetPasswordSafeSlotData : Command<CommandID::SET_PW_SAFE_SLOT_DATA_1> {
- public:
- struct CommandPayload {
- uint8_t slot_number;
- uint8_t slot_name[PWS_SLOTNAME_LENGTH];
- uint8_t slot_password[PWS_PASSWORD_LENGTH];
-
- bool isValid() const { return !(slot_number & 0xF0); }
- std::string dissect() const {
- std::stringstream ss;
- ss << " slot_number\t" << (int)slot_number << std::endl;
- print_to_ss_volatile(slot_name);
- print_to_ss_volatile(slot_password);
- return ss.str();
- }
- } __packed;
-
- typedef Transaction<command_id(), struct CommandPayload, struct EmptyPayload>
- CommandTransaction;
-};
-
-class SetPasswordSafeSlotData2 : Command<CommandID::SET_PW_SAFE_SLOT_DATA_2> {
- public:
- struct CommandPayload {
- uint8_t slot_number;
- uint8_t slot_login_name[PWS_LOGINNAME_LENGTH];
-
- bool isValid() const { return !(slot_number & 0xF0); }
- std::string dissect() const {
- std::stringstream ss;
- ss << " slot_number\t" << (int)slot_number << std::endl;
- print_to_ss_volatile(slot_login_name);
- return ss.str();
- }
- } __packed;
-
- typedef Transaction<command_id(), struct CommandPayload, struct EmptyPayload>
- CommandTransaction;
-};
-
-class ErasePasswordSafeSlot : Command<CommandID::PW_SAFE_ERASE_SLOT> {
- public:
- struct CommandPayload {
- uint8_t slot_number;
-
- bool isValid() const { return !(slot_number & 0xF0); }
- std::string dissect() const {
- std::stringstream ss;
- ss << " slot_number\t" << (int)slot_number << std::endl;
- return ss.str();
- }
-
- } __packed;
-
- typedef Transaction<command_id(), struct CommandPayload, struct EmptyPayload>
- CommandTransaction;
-};
-
-class EnablePasswordSafe : Command<CommandID::PW_SAFE_ENABLE> {
- public:
- struct CommandPayload {
- uint8_t user_password[30];
-
- bool isValid() const { return true; }
- std::string dissect() const {
- std::stringstream ss;
- print_to_ss_volatile(user_password);
- return ss.str();
- }
- } __packed;
-
- typedef Transaction<command_id(), struct CommandPayload, struct EmptyPayload>
- CommandTransaction;
-};
-
-class PasswordSafeInitKey : Command<CommandID::PW_SAFE_INIT_KEY> {
- /**
- * never used in Nitrokey App
- */
- public:
- typedef Transaction<command_id(), struct EmptyPayload, struct EmptyPayload>
- CommandTransaction;
-};
-
-class PasswordSafeSendSlotViaHID : Command<CommandID::PW_SAFE_SEND_DATA> {
- /**
- * never used in Nitrokey App
- */
- public:
- struct CommandPayload {
- uint8_t slot_number;
- uint8_t slot_kind;
-
- bool isValid() const { return !(slot_number & 0xF0); }
- } __packed;
-
- typedef Transaction<command_id(), struct CommandPayload, struct EmptyPayload>
- CommandTransaction;
-};
-
-// TODO "Device::passwordSafeSendSlotDataViaHID"
-
-class WriteGeneralConfig : Command<CommandID::WRITE_CONFIG> {
- public:
- struct CommandPayload {
- union{
- uint8_t config[5];
- struct{
- uint8_t numlock; /** 0-1: HOTP slot number from which the code will be get on double press, other value - function disabled */
- uint8_t capslock; /** same as numlock */
- uint8_t scrolllock; /** same as numlock */
- uint8_t enable_user_password;
- uint8_t delete_user_password;
- };
- };
- bool isValid() const { return numlock < 2 && capslock < 2 && scrolllock < 2 && enable_user_password < 2; }
-
- std::string dissect() const {
- std::stringstream ss;
- ss << "numlock:\t" << (int)numlock << std::endl;
- ss << "capslock:\t" << (int)capslock << std::endl;
- ss << "scrolllock:\t" << (int)scrolllock << std::endl;
- ss << "enable_user_password:\t" << (bool) enable_user_password << std::endl;
- ss << "delete_user_password:\t" << (bool) delete_user_password << std::endl;
- return ss.str();
- }
- } __packed;
-
- typedef Transaction<command_id(), struct CommandPayload, struct EmptyPayload>
- CommandTransaction;
-};
-
-class FirstAuthenticate : Command<CommandID::FIRST_AUTHENTICATE> {
- public:
- struct CommandPayload {
- uint8_t card_password[25];
- uint8_t temporary_password[25];
-
- bool isValid() const { return true; }
-
- std::string dissect() const {
- std::stringstream ss;
- print_to_ss_volatile(card_password);
- hexdump_to_ss(temporary_password);
- return ss.str();
- }
- } __packed;
-
- typedef Transaction<command_id(), struct CommandPayload, struct EmptyPayload>
- CommandTransaction;
-};
-
-class UserAuthenticate : Command<CommandID::USER_AUTHENTICATE> {
- public:
- struct CommandPayload {
- uint8_t card_password[25];
- uint8_t temporary_password[25];
-
- bool isValid() const { return true; }
- std::string dissect() const {
- std::stringstream ss;
- print_to_ss_volatile(card_password);
- hexdump_to_ss(temporary_password);
- return ss.str();
- }
- } __packed;
-
- typedef Transaction<command_id(), struct CommandPayload, struct EmptyPayload>
- CommandTransaction;
-};
-
-class Authorize : Command<CommandID::AUTHORIZE> {
- public:
- struct CommandPayload {
- uint32_t crc_to_authorize;
- uint8_t temporary_password[25];
-
- std::string dissect() const {
- std::stringstream ss;
- ss << " crc_to_authorize:\t" << std::hex << std::setw(2) << std::setfill('0') << crc_to_authorize<< std::endl;
- hexdump_to_ss(temporary_password);
- return ss.str();
- }
- } __packed;
-
- typedef Transaction<command_id(), struct CommandPayload, struct EmptyPayload>
- CommandTransaction;
-};
-
-class UserAuthorize : Command<CommandID::USER_AUTHORIZE> {
- public:
- struct CommandPayload {
- uint32_t crc_to_authorize;
- uint8_t temporary_password[25];
- std::string dissect() const {
- std::stringstream ss;
- ss << " crc_to_authorize:\t" << crc_to_authorize<< std::endl;
- hexdump_to_ss(temporary_password);
- return ss.str();
- }
- } __packed;
-
- typedef Transaction<command_id(), struct CommandPayload, struct EmptyPayload>
- CommandTransaction;
-};
-
-class UnlockUserPassword : Command<CommandID::UNLOCK_USER_PASSWORD> {
- public:
- struct CommandPayload {
- uint8_t admin_password[25];
- uint8_t user_new_password[25];
- std::string dissect() const {
- std::stringstream ss;
- print_to_ss_volatile(admin_password);
- print_to_ss_volatile(user_new_password);
- return ss.str();
- }
- } __packed;
-
- typedef Transaction<command_id(), struct CommandPayload, struct EmptyPayload>
- CommandTransaction;
-};
-
-class ChangeUserPin : Command<CommandID::CHANGE_USER_PIN> {
- public:
- struct CommandPayload {
- uint8_t old_pin[25];
- uint8_t new_pin[25];
- std::string dissect() const {
- std::stringstream ss;
- print_to_ss_volatile(old_pin);
- print_to_ss_volatile(new_pin);
- return ss.str();
- }
- } __packed;
-
- typedef Transaction<command_id(), struct CommandPayload, struct EmptyPayload>
- CommandTransaction;
-};
-
-class IsAESSupported : Command<CommandID::DETECT_SC_AES> {
- public:
- struct CommandPayload {
- uint8_t user_password[20];
- std::string dissect() const {
- std::stringstream ss;
- print_to_ss_volatile(user_password);
- return ss.str();
- }
- } __packed;
-
- typedef Transaction<command_id(), struct CommandPayload, struct EmptyPayload>
- CommandTransaction;
-};
-
-
-class ChangeAdminPin : Command<CommandID::CHANGE_ADMIN_PIN> {
- public:
- struct CommandPayload {
- uint8_t old_pin[25];
- uint8_t new_pin[25];
- std::string dissect() const {
- std::stringstream ss;
- print_to_ss_volatile(old_pin);
- print_to_ss_volatile(new_pin);
- return ss.str();
- }
- } __packed;
-
- typedef Transaction<command_id(), struct CommandPayload, struct EmptyPayload>
- CommandTransaction;
-};
-
-class LockDevice : Command<CommandID::LOCK_DEVICE> {
- public:
- typedef Transaction<command_id(), struct EmptyPayload, struct EmptyPayload>
- CommandTransaction;
-};
-
-class FactoryReset : Command<CommandID::FACTORY_RESET> {
- public:
- struct CommandPayload {
- uint8_t admin_password[20];
- std::string dissect() const {
- std::stringstream ss;
- print_to_ss_volatile(admin_password);
- return ss.str();
- }
- } __packed;
-
- typedef Transaction<command_id(), struct CommandPayload, struct EmptyPayload>
- CommandTransaction;
-};
-
-class BuildAESKey : Command<CommandID::NEW_AES_KEY> {
- public:
- struct CommandPayload {
- uint8_t admin_password[20];
- std::string dissect() const {
- std::stringstream ss;
- print_to_ss_volatile(admin_password);
- return ss.str();
- }
- } __packed;
-
- typedef Transaction<command_id(), struct CommandPayload, struct EmptyPayload>
- CommandTransaction;
-
-};
-
-}
-}
-}
-#pragma pack (pop)
-#endif
diff --git a/nitrokey-sys/libnitrokey-v3.4.1/libnitrokey/stick10_commands_0.8.h b/nitrokey-sys/libnitrokey-v3.4.1/libnitrokey/stick10_commands_0.8.h
deleted file mode 100644
index 9477890..0000000
--- a/nitrokey-sys/libnitrokey-v3.4.1/libnitrokey/stick10_commands_0.8.h
+++ /dev/null
@@ -1,348 +0,0 @@
-/*
- * Copyright (c) 2015-2018 Nitrokey UG
- *
- * This file is part of libnitrokey.
- *
- * libnitrokey is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * any later version.
- *
- * libnitrokey is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with libnitrokey. If not, see <http://www.gnu.org/licenses/>.
- *
- * SPDX-License-Identifier: LGPL-3.0
- */
-
-
-#ifndef LIBNITROKEY_STICK10_COMMANDS_0_8_H
-#define LIBNITROKEY_STICK10_COMMANDS_0_8_H
-
-#include <bitset>
-#include <iomanip>
-#include <string>
-#include <sstream>
-#include <cstdint>
-#include "command.h"
-#include "device_proto.h"
-#include "stick10_commands.h"
-
-#pragma pack (push,1)
-
-
-namespace nitrokey {
- namespace proto {
-
-/*
- * Stick10 protocol definition
- */
- namespace stick10_08 {
- using stick10::FirstAuthenticate;
- using stick10::UserAuthenticate;
- using stick10::SetTime;
- using stick10::GetStatus;
- using stick10::BuildAESKey;
- using stick10::ChangeAdminPin;
- using stick10::ChangeUserPin;
- using stick10::EnablePasswordSafe;
- using stick10::ErasePasswordSafeSlot;
- using stick10::FactoryReset;
- using stick10::GetPasswordRetryCount;
- using stick10::GetUserPasswordRetryCount;
- using stick10::GetPasswordSafeSlotLogin;
- using stick10::GetPasswordSafeSlotName;
- using stick10::GetPasswordSafeSlotPassword;
- using stick10::GetPasswordSafeSlotStatus;
- using stick10::GetSlotName;
- using stick10::IsAESSupported;
- using stick10::LockDevice;
- using stick10::PasswordSafeInitKey;
- using stick10::PasswordSafeSendSlotViaHID;
- using stick10::SetPasswordSafeSlotData;
- using stick10::SetPasswordSafeSlotData2;
- using stick10::UnlockUserPassword;
- using stick10::ReadSlot;
-
- class EraseSlot : Command<CommandID::ERASE_SLOT> {
- public:
- struct CommandPayload {
- uint8_t slot_number;
- uint8_t temporary_admin_password[25];
-
- bool isValid() const { return !(slot_number & 0xF0); }
- std::string dissect() const {
- std::stringstream ss;
- ss << "slot_number:\t" << (int)(slot_number) << std::endl;
- hexdump_to_ss(temporary_admin_password);
- return ss.str();
- }
- } __packed;
-
- typedef Transaction<command_id(), struct CommandPayload, struct EmptyPayload>
- CommandTransaction;
- };
-
- class SendOTPData : Command<CommandID::SEND_OTP_DATA> {
- //admin auth
- public:
- struct CommandPayload {
- uint8_t temporary_admin_password[25];
- uint8_t type; //S-secret, N-name
- uint8_t id; //multiple reports for values longer than 30 bytes
- uint8_t data[30]; //data, does not need null termination
-
- bool isValid() const { return true; }
-
- void setTypeName(){
- type = 'N';
- }
- void setTypeSecret(){
- type = 'S';
- }
-
- std::string dissect() const {
- std::stringstream ss;
- hexdump_to_ss(temporary_admin_password);
- ss << "type:\t" << type << std::endl;
- ss << "id:\t" << (int)id << std::endl;
-#ifdef LOG_VOLATILE_DATA
- ss << "data:" << std::endl
- << ::nitrokey::misc::hexdump((const uint8_t *) (&data), sizeof data);
-#else
- ss << " Volatile data not logged" << std::endl;
-#endif
- return ss.str();
- }
- } __packed;
-
-
- struct ResponsePayload {
- union {
- uint8_t data[40];
- } __packed;
-
- bool isValid() const { return true; }
- std::string dissect() const {
- std::stringstream ss;
-#ifdef LOG_VOLATILE_DATA
- ss << "data:" << std::endl
- << ::nitrokey::misc::hexdump((const uint8_t *) (&data), sizeof data);
-#else
- ss << " Volatile data not logged" << std::endl;
-#endif
- return ss.str();
- }
- } __packed;
-
-
- typedef Transaction<command_id(), struct CommandPayload, struct ResponsePayload>
- CommandTransaction;
- };
-
- class WriteToOTPSlot : Command<CommandID::WRITE_TO_SLOT> {
- //admin auth
- public:
- struct CommandPayload {
- uint8_t temporary_admin_password[25];
- uint8_t slot_number;
- union {
- uint64_t slot_counter_or_interval;
- uint8_t slot_counter_s[8];
- } __packed;
- union {
- uint8_t _slot_config;
- struct {
- bool use_8_digits : 1;
- bool use_enter : 1;
- bool use_tokenID : 1;
- };
- };
- union {
- uint8_t slot_token_id[13]; /** OATH Token Identifier */
- struct { /** @see https://openauthentication.org/token-specs/ */
- uint8_t omp[2];
- uint8_t tt[2];
- uint8_t mui[8];
- uint8_t keyboard_layout; //disabled feature in nitroapp as of 20160805
- } slot_token_fields;
- };
-
- bool isValid() const { return true; }
-
- std::string dissect() const {
- std::stringstream ss;
- hexdump_to_ss(temporary_admin_password);
- ss << "slot_config:\t" << std::bitset<8>((int) _slot_config) << std::endl;
- ss << "\tuse_8_digits(0):\t" << use_8_digits << std::endl;
- ss << "\tuse_enter(1):\t" << use_enter << std::endl;
- ss << "\tuse_tokenID(2):\t" << use_tokenID << std::endl;
- ss << "slot_number:\t" << (int) (slot_number) << std::endl;
- ss << "slot_counter_or_interval:\t[" << (int) slot_counter_or_interval << "]\t"
- << ::nitrokey::misc::hexdump((const uint8_t *) (&slot_counter_or_interval), sizeof slot_counter_or_interval, false);
-
- ss << "slot_token_id:\t";
- for (auto i : slot_token_id)
- ss << std::hex << std::setw(2) << std::setfill('0') << (int) i << " ";
- ss << std::endl;
-
- return ss.str();
- }
- } __packed;
-
- typedef Transaction<command_id(), struct CommandPayload, struct EmptyPayload>
- CommandTransaction;
- };
-
- class GetHOTP : Command<CommandID::GET_CODE> {
- public:
- struct CommandPayload {
- uint8_t slot_number;
- struct {
- uint64_t challenge; //@unused
- uint64_t last_totp_time; //@unused
- uint8_t last_interval; //@unused
- } __packed _unused;
- uint8_t temporary_user_password[25];
-
- bool isValid() const { return (slot_number & 0xF0); }
- std::string dissect() const {
- std::stringstream ss;
- hexdump_to_ss(temporary_user_password);
- ss << "slot_number:\t" << (int)(slot_number) << std::endl;
- return ss.str();
- }
- } __packed;
-
- struct ResponsePayload {
- union {
- uint8_t whole_response[18]; //14 bytes reserved for config, but used only 1
- struct {
- uint32_t code;
- union{
- uint8_t _slot_config;
- struct{
- bool use_8_digits : 1;
- bool use_enter : 1;
- bool use_tokenID : 1;
- };
- };
- } __packed;
- } __packed;
-
- bool isValid() const { return true; }
- std::string dissect() const {
- std::stringstream ss;
- ss << "code:\t" << (code) << std::endl;
- ss << "slot_config:\t" << std::bitset<8>((int)_slot_config) << std::endl;
- ss << "\tuse_8_digits(0):\t" << use_8_digits << std::endl;
- ss << "\tuse_enter(1):\t" << use_enter << std::endl;
- ss << "\tuse_tokenID(2):\t" << use_tokenID << std::endl;
- return ss.str();
- }
- } __packed;
-
- typedef Transaction<command_id(), struct CommandPayload, struct ResponsePayload>
- CommandTransaction;
- };
-
-
- class GetTOTP : Command<CommandID::GET_CODE> {
- //user auth
- public:
- struct CommandPayload {
- uint8_t slot_number;
- uint64_t challenge; //@unused
- uint64_t last_totp_time; //@unused
- uint8_t last_interval; //@unused
- uint8_t temporary_user_password[25];
-
- bool isValid() const { return !(slot_number & 0xF0); }
- std::string dissect() const {
- std::stringstream ss;
- hexdump_to_ss(temporary_user_password);
- ss << "slot_number:\t" << (int)(slot_number) << std::endl;
- ss << "challenge:\t" << (challenge) << std::endl;
- ss << "last_totp_time:\t" << (last_totp_time) << std::endl;
- ss << "last_interval:\t" << (int)(last_interval) << std::endl;
- return ss.str();
- }
- } __packed;
-
- struct ResponsePayload {
- union {
- uint8_t whole_response[18]; //14 bytes reserved for config, but used only 1
- struct {
- uint32_t code;
- union{
- uint8_t _slot_config;
- struct{
- bool use_8_digits : 1;
- bool use_enter : 1;
- bool use_tokenID : 1;
- };
- };
- } __packed ;
- } __packed ;
-
- bool isValid() const { return true; }
- std::string dissect() const {
- std::stringstream ss;
- ss << "code:\t" << (code) << std::endl;
- ss << "slot_config:\t" << std::bitset<8>((int)_slot_config) << std::endl;
- ss << "\tuse_8_digits(0):\t" << use_8_digits << std::endl;
- ss << "\tuse_enter(1):\t" << use_enter << std::endl;
- ss << "\tuse_tokenID(2):\t" << use_tokenID << std::endl;
- return ss.str();
- }
- } __packed;
-
- typedef Transaction<command_id(), struct CommandPayload, struct ResponsePayload>
- CommandTransaction;
- };
-
-
- class WriteGeneralConfig : Command<CommandID::WRITE_CONFIG> {
- //admin auth
- public:
- struct CommandPayload {
- union{
- uint8_t config[5];
- struct{
- uint8_t numlock; /** 0-1: HOTP slot number from which the code will be get on double press, other value - function disabled */
- uint8_t capslock; /** same as numlock */
- uint8_t scrolllock; /** same as numlock */
- uint8_t enable_user_password;
- uint8_t delete_user_password;
- };
- };
- uint8_t temporary_admin_password[25];
-
- static constexpr uint8_t special_HOTP_slots = 3;
- bool isValid() const { return numlock < special_HOTP_slots && capslock < special_HOTP_slots
- && scrolllock < special_HOTP_slots && enable_user_password < 2; }
-
- std::string dissect() const {
- std::stringstream ss;
- ss << "numlock:\t" << (int)numlock << std::endl;
- ss << "capslock:\t" << (int)capslock << std::endl;
- ss << "scrolllock:\t" << (int)scrolllock << std::endl;
- ss << "enable_user_password:\t" << (bool) enable_user_password << std::endl;
- ss << "delete_user_password:\t" << (bool) delete_user_password << std::endl;
- return ss.str();
- }
- } __packed;
-
- typedef Transaction<command_id(), struct CommandPayload, struct EmptyPayload>
- CommandTransaction;
- };
- }
- }
-}
-#pragma pack (pop)
-
-#endif //LIBNITROKEY_STICK10_COMMANDS_0_8_H
diff --git a/nitrokey-sys/libnitrokey-v3.4.1/libnitrokey/stick20_commands.h b/nitrokey-sys/libnitrokey-v3.4.1/libnitrokey/stick20_commands.h
deleted file mode 100644
index 7efa1b6..0000000
--- a/nitrokey-sys/libnitrokey-v3.4.1/libnitrokey/stick20_commands.h
+++ /dev/null
@@ -1,394 +0,0 @@
-/*
- * Copyright (c) 2015-2018 Nitrokey UG
- *
- * This file is part of libnitrokey.
- *
- * libnitrokey is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * any later version.
- *
- * libnitrokey is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with libnitrokey. If not, see <http://www.gnu.org/licenses/>.
- *
- * SPDX-License-Identifier: LGPL-3.0
- */
-
-#ifndef STICK20_COMMANDS_H
-#define STICK20_COMMANDS_H
-
-
-
-#include <cstdint>
-#include "command.h"
-#include <string>
-#include <sstream>
-#include "device_proto.h"
-
-#pragma pack (push,1)
-
-namespace nitrokey {
- namespace proto {
-
-/*
-* STICK20 protocol command ids
-* a superset (almost) of STICK10
-*/
-
- namespace stick20 {
-
- class ChangeAdminUserPin20Current :
- public PasswordCommand<CommandID::SEND_PASSWORD, PasswordKind::Admin> {};
- class ChangeAdminUserPin20New :
- public PasswordCommand<CommandID::SEND_NEW_PASSWORD, PasswordKind::Admin> {};
- class UnlockUserPin :
- public PasswordCommand<CommandID::UNLOCK_USER_PASSWORD, PasswordKind::Admin> {};
-
- class EnableEncryptedPartition : public PasswordCommand<CommandID::ENABLE_CRYPTED_PARI> {};
- class EnableHiddenEncryptedPartition : public PasswordCommand<CommandID::ENABLE_HIDDEN_CRYPTED_PARI> {};
-
- class SetUnencryptedVolumeReadOnlyAdmin :
- public PasswordCommand<CommandID::ENABLE_ADMIN_READONLY_UNCRYPTED_LUN, PasswordKind::Admin> {};
- class SetUnencryptedVolumeReadWriteAdmin :
- public PasswordCommand<CommandID::ENABLE_ADMIN_READWRITE_UNCRYPTED_LUN, PasswordKind::Admin> {};
- class SetEncryptedVolumeReadOnly :
- public PasswordCommand<CommandID::ENABLE_ADMIN_READONLY_ENCRYPTED_LUN, PasswordKind::Admin> {};
- class SetEncryptedVolumeReadWrite :
- public PasswordCommand<CommandID::ENABLE_ADMIN_READWRITE_ENCRYPTED_LUN, PasswordKind::Admin> {};
-
- //FIXME the volume disabling commands do not need password
- class DisableEncryptedPartition : public PasswordCommand<CommandID::DISABLE_CRYPTED_PARI> {};
- class DisableHiddenEncryptedPartition : public PasswordCommand<CommandID::DISABLE_HIDDEN_CRYPTED_PARI> {};
-
- class EnableFirmwareUpdate : public PasswordCommand<CommandID::ENABLE_FIRMWARE_UPDATE> {};
-
- class ChangeUpdatePassword : Command<CommandID::CHANGE_UPDATE_PIN> {
- public:
- struct CommandPayload {
- uint8_t __gap;
- uint8_t current_update_password[20];
- uint8_t __gap2;
- uint8_t new_update_password[20];
- std::string dissect() const {
- std::stringstream ss;
- print_to_ss_volatile( current_update_password );
- print_to_ss_volatile( new_update_password );
- return ss.str();
- }
- };
-
- typedef Transaction<command_id(), struct CommandPayload, struct EmptyPayload>
- CommandTransaction;
- };
-
- class ExportFirmware : public PasswordCommand<CommandID::EXPORT_FIRMWARE_TO_FILE> {};
-
- class CreateNewKeys :
- public PasswordCommand<CommandID::GENERATE_NEW_KEYS, PasswordKind::AdminPrefixed, 30> {};
-
-
- class FillSDCardWithRandomChars : Command<CommandID::FILL_SD_CARD_WITH_RANDOM_CHARS> {
- public:
- enum class ChosenVolumes : uint8_t {
- all_volumes = 0,
- encrypted_volume = 1
- };
-
- struct CommandPayload {
- uint8_t volume_flag;
- uint8_t kind;
- uint8_t admin_pin[20];
-
- std::string dissect() const {
- std::stringstream ss;
- print_to_ss( (int) volume_flag );
- print_to_ss( kind );
- print_to_ss_volatile(admin_pin);
- return ss.str();
- }
- void set_kind_user() {
- kind = (uint8_t) 'P';
- }
- void set_defaults(){
- set_kind_user();
- volume_flag = static_cast<uint8_t>(ChosenVolumes::encrypted_volume);
- }
-
- } __packed;
-
- typedef Transaction<Command<CommandID::FILL_SD_CARD_WITH_RANDOM_CHARS>::command_id(),
- struct CommandPayload, struct EmptyPayload>
- CommandTransaction;
- };
-
- namespace StorageCommandResponsePayload{
- using namespace DeviceResponseConstants;
- static constexpr auto padding_size =
- storage_data_absolute_address - header_size;
- struct TransmissionData{
- uint8_t _padding[padding_size];
-
- uint8_t SendCounter_u8;
- uint8_t SendDataType_u8;
- uint8_t FollowBytesFlag_u8;
- uint8_t SendSize_u8;
-
- std::string dissect() const {
- std::stringstream ss;
- ss << "_padding:" << std::endl
- << ::nitrokey::misc::hexdump((const uint8_t *) (_padding),
- sizeof _padding);
- print_to_ss((int) SendCounter_u8);
- print_to_ss((int) SendDataType_u8);
- print_to_ss((int) FollowBytesFlag_u8);
- print_to_ss((int) SendSize_u8);
- return ss.str();
- }
-
- } __packed;
- }
-
- namespace DeviceConfigurationResponsePacket{
-
- struct ResponsePayload {
- StorageCommandResponsePayload::TransmissionData transmission_data;
-
- uint16_t MagicNumber_StickConfig_u16;
- /**
- * READ_WRITE_ACTIVE = ReadWriteFlagUncryptedVolume_u8 == 0;
- */
- uint8_t ReadWriteFlagUncryptedVolume_u8;
- uint8_t ReadWriteFlagCryptedVolume_u8;
-
- union{
- uint8_t VersionInfo_au8[4];
- struct {
- uint8_t major;
- uint8_t minor;
- uint8_t _reserved2;
- uint8_t build_iteration;
- } __packed versionInfo;
- } __packed;
-
- uint8_t ReadWriteFlagHiddenVolume_u8;
- uint8_t FirmwareLocked_u8;
-
- union{
- uint8_t NewSDCardFound_u8;
- struct {
- bool NewCard :1;
- uint8_t Counter :7;
- } __packed NewSDCardFound_st;
- } __packed;
-
- /**
- * SD card FILLED with random chars
- */
- uint8_t SDFillWithRandomChars_u8;
- uint32_t ActiveSD_CardID_u32;
- union{
- uint8_t VolumeActiceFlag_u8;
- struct {
- bool unencrypted :1;
- bool encrypted :1;
- bool hidden :1;
- } __packed VolumeActiceFlag_st;
- } __packed;
- uint8_t NewSmartCardFound_u8;
- uint8_t UserPwRetryCount;
- uint8_t AdminPwRetryCount;
- uint32_t ActiveSmartCardID_u32;
- uint8_t StickKeysNotInitiated;
-
- bool isValid() const { return true; }
-
- std::string dissect() const {
- std::stringstream ss;
-
- print_to_ss(transmission_data.dissect());
- print_to_ss( MagicNumber_StickConfig_u16 );
- print_to_ss((int) ReadWriteFlagUncryptedVolume_u8 );
- print_to_ss((int) ReadWriteFlagCryptedVolume_u8 );
- print_to_ss((int) ReadWriteFlagHiddenVolume_u8 );
- print_to_ss((int) versionInfo.major );
- print_to_ss((int) versionInfo.minor );
- print_to_ss((int) versionInfo.build_iteration );
- print_to_ss((int) FirmwareLocked_u8 );
- print_to_ss((int) NewSDCardFound_u8 );
- print_to_ss((int) NewSDCardFound_st.NewCard );
- print_to_ss((int) NewSDCardFound_st.Counter );
- print_to_ss((int) SDFillWithRandomChars_u8 );
- print_to_ss( ActiveSD_CardID_u32 );
- print_to_ss((int) VolumeActiceFlag_u8 );
- print_to_ss((int) VolumeActiceFlag_st.unencrypted );
- print_to_ss((int) VolumeActiceFlag_st.encrypted );
- print_to_ss((int) VolumeActiceFlag_st.hidden);
- print_to_ss((int) NewSmartCardFound_u8 );
- print_to_ss((int) UserPwRetryCount );
- print_to_ss((int) AdminPwRetryCount );
- print_to_ss( ActiveSmartCardID_u32 );
- print_to_ss((int) StickKeysNotInitiated );
-
- return ss.str();
- }
- } __packed;
- }
-
- class SendStartup : Command<CommandID::SEND_STARTUP> {
- public:
- struct CommandPayload {
- uint64_t localtime; // POSIX seconds from epoch start, supports until year 2106
- std::string dissect() const {
- std::stringstream ss;
- print_to_ss( localtime );
- return ss.str();
- }
- void set_defaults(){
- localtime =
- std::chrono::duration_cast<std::chrono::seconds> (
- std::chrono::system_clock::now().time_since_epoch()).count();
- }
- }__packed;
-
- using ResponsePayload = DeviceConfigurationResponsePacket::ResponsePayload;
-
- typedef Transaction<command_id(), struct CommandPayload, ResponsePayload>
- CommandTransaction;
- };
-
-
-// TODO fix original nomenclature
- class SendSetReadonlyToUncryptedVolume : public PasswordCommand<CommandID::ENABLE_READONLY_UNCRYPTED_LUN> {};
- class SendSetReadwriteToUncryptedVolume : public PasswordCommand<CommandID::ENABLE_READWRITE_UNCRYPTED_LUN> {};
- class SendClearNewSdCardFound : public PasswordCommand<CommandID::CLEAR_NEW_SD_CARD_FOUND> {};
-
- class GetDeviceStatus : Command<CommandID::GET_DEVICE_STATUS> {
- public:
- using ResponsePayload = DeviceConfigurationResponsePacket::ResponsePayload;
-
- typedef Transaction<command_id(), struct EmptyPayload, ResponsePayload>
- CommandTransaction;
- };
-
- class Wink : Command<CommandID::WINK> {
- public:
- typedef Transaction<command_id(), struct EmptyPayload, struct EmptyPayload>
- CommandTransaction;
- };
-
- class CheckSmartcardUsage : Command<CommandID::CHECK_SMARTCARD_USAGE> {
- public:
- typedef Transaction<command_id(), struct EmptyPayload, EmptyPayload>
- CommandTransaction;
- };
-
- class GetSDCardOccupancy : Command<CommandID::SD_CARD_HIGH_WATERMARK> {
- public:
- struct ResponsePayload {
- uint8_t WriteLevelMin;
- uint8_t WriteLevelMax;
- uint8_t ReadLevelMin;
- uint8_t ReadLevelMax;
- std::string dissect() const {
- std::stringstream ss;
- print_to_ss((int) WriteLevelMin);
- print_to_ss((int) WriteLevelMax);
- print_to_ss((int) ReadLevelMin);
- print_to_ss((int) ReadLevelMax);
- return ss.str();
- }
- } __packed;
-
- typedef Transaction<command_id(), struct EmptyPayload, struct ResponsePayload>
- CommandTransaction;
- };
-
-
- class SetupHiddenVolume : Command<CommandID::SEND_HIDDEN_VOLUME_SETUP> {
- public:
- constexpr static int MAX_HIDDEN_VOLUME_PASSWORD_SIZE = 20;
- struct CommandPayload {
- uint8_t SlotNr_u8;
- uint8_t StartBlockPercent_u8;
- uint8_t EndBlockPercent_u8;
- uint8_t HiddenVolumePassword_au8[MAX_HIDDEN_VOLUME_PASSWORD_SIZE];
- std::string dissect() const {
- std::stringstream ss;
- print_to_ss((int) SlotNr_u8);
- print_to_ss((int) StartBlockPercent_u8);
- print_to_ss((int) EndBlockPercent_u8);
- print_to_ss_volatile(HiddenVolumePassword_au8);
- return ss.str();
- }
- } __packed;
-
- typedef Transaction<command_id(), struct CommandPayload, struct EmptyPayload>
- CommandTransaction;
- };
-
-
-//disable this command for now
-// class LockFirmware : public PasswordCommand<CommandID::SEND_LOCK_STICK_HARDWARE> {};
-
- class ProductionTest : Command<CommandID::PRODUCTION_TEST> {
- public:
- struct ResponsePayload {
-
- StorageCommandResponsePayload::TransmissionData transmission_data;
-
- uint8_t FirmwareVersion_au8[2]; // 2 byte // 2
- uint8_t FirmwareVersionInternal_u8; // 1 byte // 3
- uint8_t SD_Card_Size_u8; // 1 byte // 4
- uint32_t CPU_CardID_u32; // 4 byte // 8
- uint32_t SmartCardID_u32; // 4 byte // 12
- uint32_t SD_CardID_u32; // 4 byte // 16
- uint8_t SC_UserPwRetryCount; // User PIN retry count 1 byte // 17
- uint8_t SC_AdminPwRetryCount; // Admin PIN retry count 1 byte // 18
- uint8_t SD_Card_ManufacturingYear_u8; // 1 byte // 19
- uint8_t SD_Card_ManufacturingMonth_u8; // 1 byte // 20
- uint16_t SD_Card_OEM_u16; // 2 byte // 22
- uint16_t SD_WriteSpeed_u16; // in kbyte / sec 2 byte // 24
- uint8_t SD_Card_Manufacturer_u8; // 1 byte // 25
-
- bool isValid() const { return true; }
-
- std::string dissect() const {
- std::stringstream ss;
-
- print_to_ss(transmission_data.dissect());
- print_to_ss((int) FirmwareVersion_au8[0]);
- print_to_ss((int) FirmwareVersion_au8[1]);
- print_to_ss((int) FirmwareVersionInternal_u8);
- print_to_ss((int) SD_Card_Size_u8);
- print_to_ss( CPU_CardID_u32);
- print_to_ss( SmartCardID_u32);
- print_to_ss( SD_CardID_u32);
- print_to_ss((int) SC_UserPwRetryCount);
- print_to_ss((int) SC_AdminPwRetryCount);
- print_to_ss((int) SD_Card_ManufacturingYear_u8);
- print_to_ss((int) SD_Card_ManufacturingMonth_u8);
- print_to_ss( SD_Card_OEM_u16);
- print_to_ss( SD_WriteSpeed_u16);
- print_to_ss((int) SD_Card_Manufacturer_u8);
- return ss.str();
- }
-
- } __packed;
-
- typedef Transaction<command_id(), struct EmptyPayload, struct ResponsePayload>
- CommandTransaction;
- };
-
- }
- }
-}
-
-#undef print_to_ss
-#pragma pack (pop)
-
-#endif
diff --git a/nitrokey-sys/libnitrokey-v3.4.1/libnitrokey/version.h b/nitrokey-sys/libnitrokey-v3.4.1/libnitrokey/version.h
deleted file mode 100644
index 6547af0..0000000
--- a/nitrokey-sys/libnitrokey-v3.4.1/libnitrokey/version.h
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Copyright (c) 2018 Nitrokey UG
- *
- * This file is part of libnitrokey.
- *
- * libnitrokey is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * any later version.
- *
- * libnitrokey is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with libnitrokey. If not, see <http://www.gnu.org/licenses/>.
- *
- * SPDX-License-Identifier: LGPL-3.0
- */
-
-#ifndef LIBNITROKEY_VERSION_H
-#define LIBNITROKEY_VERSION_H
-
-namespace nitrokey {
- unsigned int get_major_library_version();
-
- unsigned int get_minor_library_version();
-
- const char* get_library_version();
-}
-
-#endif
diff --git a/nitrokey-sys/libnitrokey-v3.4.1/log.cc b/nitrokey-sys/libnitrokey-v3.4.1/log.cc
deleted file mode 100644
index 06acee7..0000000
--- a/nitrokey-sys/libnitrokey-v3.4.1/log.cc
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- * Copyright (c) 2015-2018 Nitrokey UG
- *
- * This file is part of libnitrokey.
- *
- * libnitrokey is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * any later version.
- *
- * libnitrokey is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with libnitrokey. If not, see <http://www.gnu.org/licenses/>.
- *
- * SPDX-License-Identifier: LGPL-3.0
- */
-
-#include "log.h"
-#include <iostream>
-#include <ctime>
-#include <iomanip>
-
-#include <sstream>
-
-namespace nitrokey {
- namespace log {
-
- Log *Log::mp_instance = nullptr;
- StdlogHandler stdlog_handler;
-
- std::string Log::prefix = "";
-
-
- std::string LogHandler::loglevel_to_str(Loglevel lvl) {
- switch (lvl) {
- case Loglevel::DEBUG_L1:
- return std::string("DEBUG_L1");
- case Loglevel::DEBUG_L2:
- return std::string("DEBUG_L2");
- case Loglevel::DEBUG:
- return std::string("DEBUG");
- case Loglevel::INFO:
- return std::string("INFO");
- case Loglevel::WARNING:
- return std::string("WARNING");
- case Loglevel::ERROR:
- return std::string("ERROR");
- }
- return std::string("");
- }
-
- void Log::operator()(const std::string &logstr, Loglevel lvl) {
- if (mp_loghandler != nullptr){
- if ((int) lvl <= (int) m_loglevel) mp_loghandler->print(prefix+logstr, lvl);
- }
- }
-
- void Log::setPrefix(const std::string prefix) {
- if (!prefix.empty()){
- Log::prefix = "["+prefix+"]";
- } else {
- Log::prefix = "";
- }
- }
-
- void StdlogHandler::print(const std::string &str, Loglevel lvl) {
- std::string s = format_message_to_string(str, lvl);
- std::clog << s;
- }
-
- void FunctionalLogHandler::print(const std::string &str, Loglevel lvl) {
- std::string s = format_message_to_string(str, lvl);
- log_function(s);
- }
-
- std::string LogHandler::format_message_to_string(const std::string &str, const Loglevel &lvl) {
- static bool last_short = false;
- if (str.length() == 1){
- last_short = true;
- return str;
- }
- time_t t = time(nullptr);
- tm tm = *localtime(&t);
-
- std::stringstream s;
- s
- << (last_short? "\n" : "")
- << "[" << std::put_time(&tm, "%c") << "]"
- << "[" << loglevel_to_str(lvl) << "]\t"
- << str << std::endl;
- last_short = false;
- return s.str();
- }
-
- FunctionalLogHandler::FunctionalLogHandler(log_function_type _log_function) {
- log_function = _log_function;
- }
- }
-}
diff --git a/nitrokey-sys/libnitrokey-v3.4.1/misc.cc b/nitrokey-sys/libnitrokey-v3.4.1/misc.cc
deleted file mode 100644
index 59185f3..0000000
--- a/nitrokey-sys/libnitrokey-v3.4.1/misc.cc
+++ /dev/null
@@ -1,123 +0,0 @@
-/*
- * Copyright (c) 2015-2018 Nitrokey UG
- *
- * This file is part of libnitrokey.
- *
- * libnitrokey is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * any later version.
- *
- * libnitrokey is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with libnitrokey. If not, see <http://www.gnu.org/licenses/>.
- *
- * SPDX-License-Identifier: LGPL-3.0
- */
-
-#include <sstream>
-#include <string>
-#include "misc.h"
-#include "inttypes.h"
-#include <cstdlib>
-#include <cstring>
-#include "LibraryException.h"
-#include <vector>
-
-namespace nitrokey {
-namespace misc {
-
-
-
-::std::vector<uint8_t> hex_string_to_byte(const char* hexString){
- const size_t big_string_size = 257; //arbitrary 'big' number
- const size_t s_size = strnlen(hexString, big_string_size);
- const size_t d_size = s_size/2;
- if (s_size%2!=0 || s_size>=big_string_size){
- throw InvalidHexString(0);
- }
- auto data = ::std::vector<uint8_t>();
- data.reserve(d_size);
-
- char buf[3];
- buf[2] = '\0';
- for(size_t i=0; i<s_size; i++){
-
- char c = hexString[i];
- bool char_from_range = (('0' <= c && c <='9') || ('A' <= c && c <= 'F') || ('a' <= c && c<= 'f'));
- if (!char_from_range){
- throw InvalidHexString(c);
- }
- buf[i%2] = c;
- if (i%2==1){
- data.push_back( strtoul(buf, NULL, 16) & 0xFF );
- }
- }
- return data;
-};
-
-#include <cctype>
-::std::string hexdump(const uint8_t *p, size_t size, bool print_header,
- bool print_ascii, bool print_empty) {
- ::std::stringstream out;
- char formatbuf[128];
- const uint8_t *pstart = p;
-
- for (const uint8_t *pend = p + size; p < pend;) {
- if (print_header){
- snprintf(formatbuf, 128, "%04x\t", static_cast<int> (p - pstart));
- out << formatbuf;
- }
-
- const uint8_t* pp = p;
- for (const uint8_t *le = p + 16; p < le; p++) {
- if (p < pend){
- snprintf(formatbuf, 128, "%02x ", uint8_t(*p));
- out << formatbuf;
- } else {
- if(print_empty)
- out << "-- ";
- }
-
- }
- if(print_ascii){
- out << " ";
- for (const uint8_t *le = pp + 16; pp < le && pp < pend; pp++) {
- if (std::isgraph(*pp))
- out << uint8_t(*pp);
- else
- out << '.';
- }
- }
- out << ::std::endl;
- }
- return out.str();
-}
-
-static uint32_t _crc32(uint32_t crc, uint32_t data) {
- int i;
- crc = crc ^ data;
-
- for (i = 0; i < 32; i++) {
- if (crc & 0x80000000)
- crc = (crc << 1) ^ 0x04C11DB7; // polynomial used in STM32
- else
- crc = (crc << 1);
- }
-
- return crc;
-}
-
-uint32_t stm_crc32(const uint8_t *data, size_t size) {
- uint32_t crc = 0xffffffff;
- const uint32_t *pend = (const uint32_t *)(data + size);
- for (const uint32_t *p = (const uint32_t *)(data); p < pend; p++)
- crc = _crc32(crc, *p);
- return crc;
-}
-}
-}
diff --git a/nitrokey-sys/libnitrokey-v3.4.1/version.cc b/nitrokey-sys/libnitrokey-v3.4.1/version.cc
deleted file mode 100644
index dfdc802..0000000
--- a/nitrokey-sys/libnitrokey-v3.4.1/version.cc
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Copyright (c) 2018 Nitrokey UG
- *
- * This file is part of libnitrokey.
- *
- * libnitrokey is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * any later version.
- *
- * libnitrokey is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with libnitrokey. If not, see <http://www.gnu.org/licenses/>.
- *
- * SPDX-License-Identifier: LGPL-3.0
- */
-
-#include "version.h"
-
-namespace nitrokey {
- unsigned int get_major_library_version() {
- return 3;
- }
-
- unsigned int get_minor_library_version() {
- return 0;
- }
-
- const char* get_library_version() {
- return "unknown";
- }
-}
-
diff --git a/nitrokey-sys/libnitrokey-v3.4.1/version.cc.in b/nitrokey-sys/libnitrokey-v3.4.1/version.cc.in
deleted file mode 100644
index 0eae647..0000000
--- a/nitrokey-sys/libnitrokey-v3.4.1/version.cc.in
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Copyright (c) 2018 Nitrokey UG
- *
- * This file is part of libnitrokey.
- *
- * libnitrokey is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * any later version.
- *
- * libnitrokey is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with libnitrokey. If not, see <http://www.gnu.org/licenses/>.
- *
- * SPDX-License-Identifier: LGPL-3.0
- */
-
-#include "version.h"
-
-namespace nitrokey {
- unsigned int get_major_library_version() {
- return @PROJECT_VERSION_MAJOR@;
- }
-
- unsigned int get_minor_library_version() {
- return @PROJECT_VERSION_MINOR@;
- }
-
- const char* get_library_version() {
- return "@PROJECT_VERSION_GIT@";
- }
-}
-
diff --git a/nitrokey-sys/src/ffi.rs b/nitrokey-sys/src/ffi.rs
deleted file mode 100644
index 58879ad..0000000
--- a/nitrokey-sys/src/ffi.rs
+++ /dev/null
@@ -1,1112 +0,0 @@
-/* automatically generated by rust-bindgen, manually modified */
-
-/// Use, if no supported device is connected
-pub const NK_device_model_NK_DISCONNECTED: NK_device_model = 0;
-/// Nitrokey Pro.
-pub const NK_device_model_NK_PRO: NK_device_model = 1;
-/// Nitrokey Storage.
-pub const NK_device_model_NK_STORAGE: NK_device_model = 2;
-/// The Nitrokey device models supported by the API.
-pub type NK_device_model = u32;
-/// Stores the status of a Storage device.
-#[repr(C)]
-#[derive(Debug, Copy, Clone)]
-pub struct NK_storage_status {
- /// Indicates whether the unencrypted volume is read-only.
- pub unencrypted_volume_read_only: bool,
- /// Indicates whether the unencrypted volume is active.
- pub unencrypted_volume_active: bool,
- /// Indicates whether the encrypted volume is read-only.
- pub encrypted_volume_read_only: bool,
- /// Indicates whether the encrypted volume is active.
- pub encrypted_volume_active: bool,
- /// Indicates whether the hidden volume is read-only.
- pub hidden_volume_read_only: bool,
- /// Indicates whether the hidden volume is active.
- pub hidden_volume_active: bool,
- /// The major firmware version, e. g. 0 in v0.40.
- pub firmware_version_major: u8,
- /// The minor firmware version, e. g. 40 in v0.40.
- pub firmware_version_minor: u8,
- /// Indicates whether the firmware is locked.
- pub firmware_locked: bool,
- /// The serial number of the SD card in the Storage stick.
- pub serial_number_sd_card: u32,
- /// The serial number of the smart card in the Storage stick.
- pub serial_number_smart_card: u32,
- /// The number of remaining login attempts for the user PIN.
- pub user_retry_count: u8,
- /// The number of remaining login attempts for the admin PIN.
- pub admin_retry_count: u8,
- /// Indicates whether a new SD card was found.
- pub new_sd_card_found: bool,
- /// Indicates whether the SD card is filled with random characters.
- pub filled_with_random: bool,
- /// Indicates whether the stick has been initialized by generating
- /// the AES keys.
- pub stick_initialized: bool,
-}
-#[test]
-fn bindgen_test_layout_NK_storage_status() {
- assert_eq!(
- ::std::mem::size_of::<NK_storage_status>(),
- 28usize,
- concat!("Size of: ", stringify!(NK_storage_status))
- );
- assert_eq!(
- ::std::mem::align_of::<NK_storage_status>(),
- 4usize,
- concat!("Alignment of ", stringify!(NK_storage_status))
- );
- assert_eq!(
- unsafe {
- &(*(::std::ptr::null::<NK_storage_status>())).unencrypted_volume_read_only as *const _
- as usize
- },
- 0usize,
- concat!(
- "Offset of field: ",
- stringify!(NK_storage_status),
- "::",
- stringify!(unencrypted_volume_read_only)
- )
- );
- assert_eq!(
- unsafe {
- &(*(::std::ptr::null::<NK_storage_status>())).unencrypted_volume_active as *const _
- as usize
- },
- 1usize,
- concat!(
- "Offset of field: ",
- stringify!(NK_storage_status),
- "::",
- stringify!(unencrypted_volume_active)
- )
- );
- assert_eq!(
- unsafe {
- &(*(::std::ptr::null::<NK_storage_status>())).encrypted_volume_read_only as *const _
- as usize
- },
- 2usize,
- concat!(
- "Offset of field: ",
- stringify!(NK_storage_status),
- "::",
- stringify!(encrypted_volume_read_only)
- )
- );
- assert_eq!(
- unsafe {
- &(*(::std::ptr::null::<NK_storage_status>())).encrypted_volume_active as *const _
- as usize
- },
- 3usize,
- concat!(
- "Offset of field: ",
- stringify!(NK_storage_status),
- "::",
- stringify!(encrypted_volume_active)
- )
- );
- assert_eq!(
- unsafe {
- &(*(::std::ptr::null::<NK_storage_status>())).hidden_volume_read_only as *const _
- as usize
- },
- 4usize,
- concat!(
- "Offset of field: ",
- stringify!(NK_storage_status),
- "::",
- stringify!(hidden_volume_read_only)
- )
- );
- assert_eq!(
- unsafe {
- &(*(::std::ptr::null::<NK_storage_status>())).hidden_volume_active as *const _ as usize
- },
- 5usize,
- concat!(
- "Offset of field: ",
- stringify!(NK_storage_status),
- "::",
- stringify!(hidden_volume_active)
- )
- );
- assert_eq!(
- unsafe {
- &(*(::std::ptr::null::<NK_storage_status>())).firmware_version_major as *const _
- as usize
- },
- 6usize,
- concat!(
- "Offset of field: ",
- stringify!(NK_storage_status),
- "::",
- stringify!(firmware_version_major)
- )
- );
- assert_eq!(
- unsafe {
- &(*(::std::ptr::null::<NK_storage_status>())).firmware_version_minor as *const _
- as usize
- },
- 7usize,
- concat!(
- "Offset of field: ",
- stringify!(NK_storage_status),
- "::",
- stringify!(firmware_version_minor)
- )
- );
- assert_eq!(
- unsafe {
- &(*(::std::ptr::null::<NK_storage_status>())).firmware_locked as *const _ as usize
- },
- 8usize,
- concat!(
- "Offset of field: ",
- stringify!(NK_storage_status),
- "::",
- stringify!(firmware_locked)
- )
- );
- assert_eq!(
- unsafe {
- &(*(::std::ptr::null::<NK_storage_status>())).serial_number_sd_card as *const _ as usize
- },
- 12usize,
- concat!(
- "Offset of field: ",
- stringify!(NK_storage_status),
- "::",
- stringify!(serial_number_sd_card)
- )
- );
- assert_eq!(
- unsafe {
- &(*(::std::ptr::null::<NK_storage_status>())).serial_number_smart_card as *const _
- as usize
- },
- 16usize,
- concat!(
- "Offset of field: ",
- stringify!(NK_storage_status),
- "::",
- stringify!(serial_number_smart_card)
- )
- );
- assert_eq!(
- unsafe {
- &(*(::std::ptr::null::<NK_storage_status>())).user_retry_count as *const _ as usize
- },
- 20usize,
- concat!(
- "Offset of field: ",
- stringify!(NK_storage_status),
- "::",
- stringify!(user_retry_count)
- )
- );
- assert_eq!(
- unsafe {
- &(*(::std::ptr::null::<NK_storage_status>())).admin_retry_count as *const _ as usize
- },
- 21usize,
- concat!(
- "Offset of field: ",
- stringify!(NK_storage_status),
- "::",
- stringify!(admin_retry_count)
- )
- );
- assert_eq!(
- unsafe {
- &(*(::std::ptr::null::<NK_storage_status>())).new_sd_card_found as *const _ as usize
- },
- 22usize,
- concat!(
- "Offset of field: ",
- stringify!(NK_storage_status),
- "::",
- stringify!(new_sd_card_found)
- )
- );
- assert_eq!(
- unsafe {
- &(*(::std::ptr::null::<NK_storage_status>())).filled_with_random as *const _ as usize
- },
- 23usize,
- concat!(
- "Offset of field: ",
- stringify!(NK_storage_status),
- "::",
- stringify!(filled_with_random)
- )
- );
- assert_eq!(
- unsafe {
- &(*(::std::ptr::null::<NK_storage_status>())).stick_initialized as *const _ as usize
- },
- 24usize,
- concat!(
- "Offset of field: ",
- stringify!(NK_storage_status),
- "::",
- stringify!(stick_initialized)
- )
- );
-}
-#[repr(C)]
-#[derive(Debug, Copy, Clone)]
-pub struct NK_storage_ProductionTest {
- pub FirmwareVersion_au8: [u8; 2usize],
- pub FirmwareVersionInternal_u8: u8,
- pub SD_Card_Size_u8: u8,
- pub CPU_CardID_u32: u32,
- pub SmartCardID_u32: u32,
- pub SD_CardID_u32: u32,
- pub SC_UserPwRetryCount: u8,
- pub SC_AdminPwRetryCount: u8,
- pub SD_Card_ManufacturingYear_u8: u8,
- pub SD_Card_ManufacturingMonth_u8: u8,
- pub SD_Card_OEM_u16: u16,
- pub SD_WriteSpeed_u16: u16,
- pub SD_Card_Manufacturer_u8: u8,
-}
-#[test]
-fn bindgen_test_layout_NK_storage_ProductionTest() {
- assert_eq!(
- ::std::mem::size_of::<NK_storage_ProductionTest>(),
- 28usize,
- concat!("Size of: ", stringify!(NK_storage_ProductionTest))
- );
- assert_eq!(
- ::std::mem::align_of::<NK_storage_ProductionTest>(),
- 4usize,
- concat!("Alignment of ", stringify!(NK_storage_ProductionTest))
- );
- assert_eq!(
- unsafe {
- &(*(::std::ptr::null::<NK_storage_ProductionTest>())).FirmwareVersion_au8 as *const _
- as usize
- },
- 0usize,
- concat!(
- "Offset of field: ",
- stringify!(NK_storage_ProductionTest),
- "::",
- stringify!(FirmwareVersion_au8)
- )
- );
- assert_eq!(
- unsafe {
- &(*(::std::ptr::null::<NK_storage_ProductionTest>())).FirmwareVersionInternal_u8
- as *const _ as usize
- },
- 2usize,
- concat!(
- "Offset of field: ",
- stringify!(NK_storage_ProductionTest),
- "::",
- stringify!(FirmwareVersionInternal_u8)
- )
- );
- assert_eq!(
- unsafe {
- &(*(::std::ptr::null::<NK_storage_ProductionTest>())).SD_Card_Size_u8 as *const _
- as usize
- },
- 3usize,
- concat!(
- "Offset of field: ",
- stringify!(NK_storage_ProductionTest),
- "::",
- stringify!(SD_Card_Size_u8)
- )
- );
- assert_eq!(
- unsafe {
- &(*(::std::ptr::null::<NK_storage_ProductionTest>())).CPU_CardID_u32 as *const _
- as usize
- },
- 4usize,
- concat!(
- "Offset of field: ",
- stringify!(NK_storage_ProductionTest),
- "::",
- stringify!(CPU_CardID_u32)
- )
- );
- assert_eq!(
- unsafe {
- &(*(::std::ptr::null::<NK_storage_ProductionTest>())).SmartCardID_u32 as *const _
- as usize
- },
- 8usize,
- concat!(
- "Offset of field: ",
- stringify!(NK_storage_ProductionTest),
- "::",
- stringify!(SmartCardID_u32)
- )
- );
- assert_eq!(
- unsafe {
- &(*(::std::ptr::null::<NK_storage_ProductionTest>())).SD_CardID_u32 as *const _ as usize
- },
- 12usize,
- concat!(
- "Offset of field: ",
- stringify!(NK_storage_ProductionTest),
- "::",
- stringify!(SD_CardID_u32)
- )
- );
- assert_eq!(
- unsafe {
- &(*(::std::ptr::null::<NK_storage_ProductionTest>())).SC_UserPwRetryCount as *const _
- as usize
- },
- 16usize,
- concat!(
- "Offset of field: ",
- stringify!(NK_storage_ProductionTest),
- "::",
- stringify!(SC_UserPwRetryCount)
- )
- );
- assert_eq!(
- unsafe {
- &(*(::std::ptr::null::<NK_storage_ProductionTest>())).SC_AdminPwRetryCount as *const _
- as usize
- },
- 17usize,
- concat!(
- "Offset of field: ",
- stringify!(NK_storage_ProductionTest),
- "::",
- stringify!(SC_AdminPwRetryCount)
- )
- );
- assert_eq!(
- unsafe {
- &(*(::std::ptr::null::<NK_storage_ProductionTest>())).SD_Card_ManufacturingYear_u8
- as *const _ as usize
- },
- 18usize,
- concat!(
- "Offset of field: ",
- stringify!(NK_storage_ProductionTest),
- "::",
- stringify!(SD_Card_ManufacturingYear_u8)
- )
- );
- assert_eq!(
- unsafe {
- &(*(::std::ptr::null::<NK_storage_ProductionTest>())).SD_Card_ManufacturingMonth_u8
- as *const _ as usize
- },
- 19usize,
- concat!(
- "Offset of field: ",
- stringify!(NK_storage_ProductionTest),
- "::",
- stringify!(SD_Card_ManufacturingMonth_u8)
- )
- );
- assert_eq!(
- unsafe {
- &(*(::std::ptr::null::<NK_storage_ProductionTest>())).SD_Card_OEM_u16 as *const _
- as usize
- },
- 20usize,
- concat!(
- "Offset of field: ",
- stringify!(NK_storage_ProductionTest),
- "::",
- stringify!(SD_Card_OEM_u16)
- )
- );
- assert_eq!(
- unsafe {
- &(*(::std::ptr::null::<NK_storage_ProductionTest>())).SD_WriteSpeed_u16 as *const _
- as usize
- },
- 22usize,
- concat!(
- "Offset of field: ",
- stringify!(NK_storage_ProductionTest),
- "::",
- stringify!(SD_WriteSpeed_u16)
- )
- );
- assert_eq!(
- unsafe {
- &(*(::std::ptr::null::<NK_storage_ProductionTest>())).SD_Card_Manufacturer_u8
- as *const _ as usize
- },
- 24usize,
- concat!(
- "Offset of field: ",
- stringify!(NK_storage_ProductionTest),
- "::",
- stringify!(SD_Card_Manufacturer_u8)
- )
- );
-}
-extern "C" {
- pub fn NK_get_storage_production_info(
- out: *mut NK_storage_ProductionTest,
- ) -> ::std::os::raw::c_int;
-}
-extern "C" {
- /// Set debug level of messages written on stderr
- /// @param state state=True - most messages, state=False - only errors level
- pub fn NK_set_debug(state: bool);
-}
-extern "C" {
- /// Set debug level of messages written on stderr
- /// @param level (int) 0-lowest verbosity, 5-highest verbosity
- pub fn NK_set_debug_level(level: ::std::os::raw::c_int);
-}
-extern "C" {
- /// Get the major library version, e. g. the 3 in v3.2.
- /// @return the major library version
- pub fn NK_get_major_library_version() -> ::std::os::raw::c_uint;
-}
-extern "C" {
- /// Get the minor library version, e. g. the 2 in v3.2.
- /// @return the minor library version
- pub fn NK_get_minor_library_version() -> ::std::os::raw::c_uint;
-}
-extern "C" {
- /// Get the library version as a string. This is the output of
- /// `git describe --always` at compile time, for example "v3.3" or
- /// "v3.3-19-gaee920b".
- /// The return value is a string literal and must not be freed.
- /// @return the library version as a string
- pub fn NK_get_library_version() -> *const ::std::os::raw::c_char;
-}
-extern "C" {
- /// Connect to device of given model. Currently library can be connected only to one device at once.
- /// @param device_model char 'S': Nitrokey Storage, 'P': Nitrokey Pro
- /// @return 1 if connected, 0 if wrong model or cannot connect
- pub fn NK_login(device_model: *const ::std::os::raw::c_char) -> ::std::os::raw::c_int;
-}
-extern "C" {
- /// Connect to device of given model. Currently library can be connected only to one device at once.
- /// @param device_model NK_device_model: NK_PRO: Nitrokey Pro, NK_STORAGE: Nitrokey Storage
- /// @return 1 if connected, 0 if wrong model or cannot connect
- pub fn NK_login_enum(device_model: NK_device_model) -> ::std::os::raw::c_int;
-}
-extern "C" {
- /// Connect to first available device, starting checking from Pro 1st to Storage 2nd.
- /// @return 1 if connected, 0 if wrong model or cannot connect
- pub fn NK_login_auto() -> ::std::os::raw::c_int;
-}
-extern "C" {
- /// Disconnect from the device.
- /// @return command processing error code
- pub fn NK_logout() -> ::std::os::raw::c_int;
-}
-extern "C" {
- /// Query the model of the connected device.
- /// Returns the model of the connected device or NK_DISCONNECTED.
- ///
- /// @return true if a device is connected and the out argument has been set
- pub fn NK_get_device_model() -> NK_device_model;
-}
-extern "C" {
- /// Return the debug status string. Debug purposes.
- /// @return command processing error code
- pub fn NK_status() -> *mut ::std::os::raw::c_char;
-}
-extern "C" {
- /// Return the device's serial number string in hex.
- /// @return string device's serial number in hex
- pub fn NK_device_serial_number() -> *mut ::std::os::raw::c_char;
-}
-extern "C" {
- /// Get last command processing status. Useful for commands which returns the results of their own and could not return
- /// an error code.
- /// @return previous command processing error code
- pub fn NK_get_last_command_status() -> u8;
-}
-extern "C" {
- /// Lock device - cancel any user device unlocking.
- /// @return command processing error code
- pub fn NK_lock_device() -> ::std::os::raw::c_int;
-}
-extern "C" {
- /// Authenticates the user on USER privilages with user_password and sets user's temporary password on device to user_temporary_password.
- /// @param user_password char[25] current user password
- /// @param user_temporary_password char[25] user temporary password to be set on device for further communication (authentication command)
- /// @return command processing error code
- pub fn NK_user_authenticate(
- user_password: *const ::std::os::raw::c_char,
- user_temporary_password: *const ::std::os::raw::c_char,
- ) -> ::std::os::raw::c_int;
-}
-extern "C" {
- /// Authenticates the user on ADMIN privilages with admin_password and sets user's temporary password on device to admin_temporary_password.
- /// @param admin_password char[25] current administrator PIN
- /// @param admin_temporary_password char[25] admin temporary password to be set on device for further communication (authentication command)
- /// @return command processing error code
- pub fn NK_first_authenticate(
- admin_password: *const ::std::os::raw::c_char,
- admin_temporary_password: *const ::std::os::raw::c_char,
- ) -> ::std::os::raw::c_int;
-}
-extern "C" {
- /// Execute a factory reset.
- /// @param admin_password char[20] current administrator PIN
- /// @return command processing error code
- pub fn NK_factory_reset(admin_password: *const ::std::os::raw::c_char)
- -> ::std::os::raw::c_int;
-}
-extern "C" {
- /// Generates AES key on the device
- /// @param admin_password char[20] current administrator PIN
- /// @return command processing error code
- pub fn NK_build_aes_key(admin_password: *const ::std::os::raw::c_char)
- -> ::std::os::raw::c_int;
-}
-extern "C" {
- /// Unlock user PIN locked after 3 incorrect codes tries.
- /// @param admin_password char[20] current administrator PIN
- /// @return command processing error code
- pub fn NK_unlock_user_password(
- admin_password: *const ::std::os::raw::c_char,
- new_user_password: *const ::std::os::raw::c_char,
- ) -> ::std::os::raw::c_int;
-}
-extern "C" {
- /// Write general config to the device
- /// @param numlock set value in range [0-1] to send HOTP code from slot 'numlock' after double pressing numlock
- /// or outside the range to disable this function
- /// @param capslock similar to numlock but with capslock
- /// @param scrolllock similar to numlock but with scrolllock
- /// @param enable_user_password set True to enable OTP PIN protection (require PIN each OTP code request)
- /// @param delete_user_password (unused)
- /// @param admin_temporary_password current admin temporary password
- /// @return command processing error code
- pub fn NK_write_config(
- numlock: u8,
- capslock: u8,
- scrolllock: u8,
- enable_user_password: bool,
- delete_user_password: bool,
- admin_temporary_password: *const ::std::os::raw::c_char,
- ) -> ::std::os::raw::c_int;
-}
-extern "C" {
- /// Get currently set config - status of function Numlock/Capslock/Scrollock OTP sending and is enabled PIN protected OTP
- /// @see NK_write_config
- /// @return uint8_t general_config[5]:
- /// uint8_t numlock;
- /// uint8_t capslock;
- /// uint8_t scrolllock;
- /// uint8_t enable_user_password;
- /// uint8_t delete_user_password;
- pub fn NK_read_config() -> *mut u8;
-}
-extern "C" {
- /// Get name of given TOTP slot
- /// @param slot_number TOTP slot number, slot_number<15
- /// @return char[20] the name of the slot
- pub fn NK_get_totp_slot_name(slot_number: u8) -> *mut ::std::os::raw::c_char;
-}
-extern "C" {
- /// @param slot_number HOTP slot number, slot_number<3
- /// @return char[20] the name of the slot
- pub fn NK_get_hotp_slot_name(slot_number: u8) -> *mut ::std::os::raw::c_char;
-}
-extern "C" {
- /// Erase HOTP slot data from the device
- /// @param slot_number HOTP slot number, slot_number<3
- /// @param temporary_password admin temporary password
- /// @return command processing error code
- pub fn NK_erase_hotp_slot(
- slot_number: u8,
- temporary_password: *const ::std::os::raw::c_char,
- ) -> ::std::os::raw::c_int;
-}
-extern "C" {
- /// Erase TOTP slot data from the device
- /// @param slot_number TOTP slot number, slot_number<15
- /// @param temporary_password admin temporary password
- /// @return command processing error code
- pub fn NK_erase_totp_slot(
- slot_number: u8,
- temporary_password: *const ::std::os::raw::c_char,
- ) -> ::std::os::raw::c_int;
-}
-extern "C" {
- /// Write HOTP slot data to the device
- /// @param slot_number HOTP slot number, slot_number<3, 0-numbered
- /// @param slot_name char[15] desired slot name. C string (requires ending '\0'; 16 bytes).
- /// @param secret char[40] 160-bit or 320-bit (currently Pro v0.8 only) secret as a hex string. C string (requires ending '\0'; 41 bytes).
- /// See NitrokeyManager::is_320_OTP_secret_supported.
- /// @param hotp_counter uint32_t starting value of HOTP counter
- /// @param use_8_digits should returned codes be 6 (false) or 8 digits (true)
- /// @param use_enter press ENTER key after sending OTP code using double-pressed scroll/num/capslock
- /// @param use_tokenID @see token_ID
- /// @param token_ID @see https://openauthentication.org/token-specs/, 'Class A' section
- /// @param temporary_password char[25] admin temporary password
- /// @return command processing error code
- pub fn NK_write_hotp_slot(
- slot_number: u8,
- slot_name: *const ::std::os::raw::c_char,
- secret: *const ::std::os::raw::c_char,
- hotp_counter: u64,
- use_8_digits: bool,
- use_enter: bool,
- use_tokenID: bool,
- token_ID: *const ::std::os::raw::c_char,
- temporary_password: *const ::std::os::raw::c_char,
- ) -> ::std::os::raw::c_int;
-}
-extern "C" {
- /// Write TOTP slot data to the device
- /// @param slot_number TOTP slot number, slot_number<15, 0-numbered
- /// @param slot_name char[15] desired slot name. C string (requires ending '\0'; 16 bytes).
- /// @param secret char[40] 160-bit or 320-bit (currently Pro v0.8 only) secret as a hex string. C string (requires ending '\0'; 41 bytes).
- /// See NitrokeyManager::is_320_OTP_secret_supported.
- /// @param time_window uint16_t time window for this TOTP
- /// @param use_8_digits should returned codes be 6 (false) or 8 digits (true)
- /// @param use_enter press ENTER key after sending OTP code using double-pressed scroll/num/capslock
- /// @param use_tokenID @see token_ID
- /// @param token_ID @see https://openauthentication.org/token-specs/, 'Class A' section
- /// @param temporary_password char[20] admin temporary password
- /// @return command processing error code
- pub fn NK_write_totp_slot(
- slot_number: u8,
- slot_name: *const ::std::os::raw::c_char,
- secret: *const ::std::os::raw::c_char,
- time_window: u16,
- use_8_digits: bool,
- use_enter: bool,
- use_tokenID: bool,
- token_ID: *const ::std::os::raw::c_char,
- temporary_password: *const ::std::os::raw::c_char,
- ) -> ::std::os::raw::c_int;
-}
-extern "C" {
- /// Get HOTP code from the device
- /// @param slot_number HOTP slot number, slot_number<3
- /// @return HOTP code
- pub fn NK_get_hotp_code(slot_number: u8) -> *mut ::std::os::raw::c_char;
-}
-extern "C" {
- /// Get HOTP code from the device (PIN protected)
- /// @param slot_number HOTP slot number, slot_number<3
- /// @param user_temporary_password char[25] user temporary password if PIN protected OTP codes are enabled,
- /// otherwise should be set to empty string - ''
- /// @return HOTP code
- pub fn NK_get_hotp_code_PIN(
- slot_number: u8,
- user_temporary_password: *const ::std::os::raw::c_char,
- ) -> *mut ::std::os::raw::c_char;
-}
-extern "C" {
- /// Get TOTP code from the device
- /// @param slot_number TOTP slot number, slot_number<15
- /// @param challenge TOTP challenge -- unused
- /// @param last_totp_time last time -- unused
- /// @param last_interval last interval --unused
- /// @return TOTP code
- pub fn NK_get_totp_code(
- slot_number: u8,
- challenge: u64,
- last_totp_time: u64,
- last_interval: u8,
- ) -> *mut ::std::os::raw::c_char;
-}
-extern "C" {
- /// Get TOTP code from the device (PIN protected)
- /// @param slot_number TOTP slot number, slot_number<15
- /// @param challenge TOTP challenge -- unused
- /// @param last_totp_time last time -- unused
- /// @param last_interval last interval -- unused
- /// @param user_temporary_password char[25] user temporary password if PIN protected OTP codes are enabled,
- /// otherwise should be set to empty string - ''
- /// @return TOTP code
- pub fn NK_get_totp_code_PIN(
- slot_number: u8,
- challenge: u64,
- last_totp_time: u64,
- last_interval: u8,
- user_temporary_password: *const ::std::os::raw::c_char,
- ) -> *mut ::std::os::raw::c_char;
-}
-extern "C" {
- /// Set time on the device (for TOTP requests)
- /// @param time seconds in unix epoch (from 01.01.1970)
- /// @return command processing error code
- pub fn NK_totp_set_time(time: u64) -> ::std::os::raw::c_int;
-}
-extern "C" {
- /// Set the device time used for TOTP to the given time. Contrary to
- /// {@code set_time(uint64_t)}, this command fails if {@code old_time}
- /// &gt; {@code time} or if {@code old_time} is zero (where {@code
- /// old_time} is the current time on the device).
- ///
- /// @param time new device time as Unix timestamp (seconds since
- /// 1970-01-01)
- /// @return command processing error code
- pub fn NK_totp_set_time_soft(time: u64) -> ::std::os::raw::c_int;
-}
-extern "C" {
- pub fn NK_totp_get_time() -> ::std::os::raw::c_int;
-}
-extern "C" {
- /// Change administrator PIN
- /// @param current_PIN char[25] current PIN
- /// @param new_PIN char[25] new PIN
- /// @return command processing error code
- pub fn NK_change_admin_PIN(
- current_PIN: *const ::std::os::raw::c_char,
- new_PIN: *const ::std::os::raw::c_char,
- ) -> ::std::os::raw::c_int;
-}
-extern "C" {
- /// Change user PIN
- /// @param current_PIN char[25] current PIN
- /// @param new_PIN char[25] new PIN
- /// @return command processing error code
- pub fn NK_change_user_PIN(
- current_PIN: *const ::std::os::raw::c_char,
- new_PIN: *const ::std::os::raw::c_char,
- ) -> ::std::os::raw::c_int;
-}
-extern "C" {
- /// Get retry count of user PIN
- /// @return user PIN retry count
- pub fn NK_get_user_retry_count() -> u8;
-}
-extern "C" {
- /// Get retry count of admin PIN
- /// @return admin PIN retry count
- pub fn NK_get_admin_retry_count() -> u8;
-}
-extern "C" {
- /// Enable password safe access
- /// @param user_pin char[30] current user PIN
- /// @return command processing error code
- pub fn NK_enable_password_safe(
- user_pin: *const ::std::os::raw::c_char,
- ) -> ::std::os::raw::c_int;
-}
-extern "C" {
- /// Get password safe slots' status
- /// @return uint8_t[16] slot statuses - each byte represents one slot with 0 (not programmed) and 1 (programmed)
- pub fn NK_get_password_safe_slot_status() -> *mut u8;
-}
-extern "C" {
- /// Get password safe slot name
- /// @param slot_number password safe slot number, slot_number<16
- /// @return slot name
- pub fn NK_get_password_safe_slot_name(slot_number: u8) -> *mut ::std::os::raw::c_char;
-}
-extern "C" {
- /// Get password safe slot login
- /// @param slot_number password safe slot number, slot_number<16
- /// @return login from the PWS slot
- pub fn NK_get_password_safe_slot_login(slot_number: u8) -> *mut ::std::os::raw::c_char;
-}
-extern "C" {
- /// Get the password safe slot password
- /// @param slot_number password safe slot number, slot_number<16
- /// @return password from the PWS slot
- pub fn NK_get_password_safe_slot_password(slot_number: u8) -> *mut ::std::os::raw::c_char;
-}
-extern "C" {
- /// Write password safe data to the slot
- /// @param slot_number password safe slot number, slot_number<16
- /// @param slot_name char[11] name of the slot
- /// @param slot_login char[32] login string
- /// @param slot_password char[20] password string
- /// @return command processing error code
- pub fn NK_write_password_safe_slot(
- slot_number: u8,
- slot_name: *const ::std::os::raw::c_char,
- slot_login: *const ::std::os::raw::c_char,
- slot_password: *const ::std::os::raw::c_char,
- ) -> ::std::os::raw::c_int;
-}
-extern "C" {
- /// Erase the password safe slot from the device
- /// @param slot_number password safe slot number, slot_number<16
- /// @return command processing error code
- pub fn NK_erase_password_safe_slot(slot_number: u8) -> ::std::os::raw::c_int;
-}
-extern "C" {
- /// Check whether AES is supported by the device
- /// @return 0 for no and 1 for yes
- pub fn NK_is_AES_supported(
- user_password: *const ::std::os::raw::c_char,
- ) -> ::std::os::raw::c_int;
-}
-extern "C" {
- /// Get device's major firmware version
- /// @return major part of the version number (e.g. 0 from 0.48, 0 from 0.7 etc.)
- pub fn NK_get_major_firmware_version() -> ::std::os::raw::c_int;
-}
-extern "C" {
- /// Get device's minor firmware version
- /// @return minor part of the version number (e.g. 7 from 0.7, 48 from 0.48 etc.)
- pub fn NK_get_minor_firmware_version() -> ::std::os::raw::c_int;
-}
-extern "C" {
- /// Function to determine unencrypted volume PIN type
- /// @param minor_firmware_version
- /// @return Returns 1, if set unencrypted volume ro/rw pin type is User, 0 otherwise.
- pub fn NK_set_unencrypted_volume_rorw_pin_type_user() -> ::std::os::raw::c_int;
-}
-extern "C" {
- /// This command is typically run to initiate
- /// communication with the device (altough not required).
- /// It sets time on device and returns its current status
- /// - a combination of set_time and get_status_storage commands
- /// Storage only
- /// @param seconds_from_epoch date and time expressed in seconds
- pub fn NK_send_startup(seconds_from_epoch: u64) -> ::std::os::raw::c_int;
-}
-extern "C" {
- /// Unlock encrypted volume.
- /// Storage only
- /// @param user_pin user pin 20 characters
- /// @return command processing error code
- pub fn NK_unlock_encrypted_volume(
- user_pin: *const ::std::os::raw::c_char,
- ) -> ::std::os::raw::c_int;
-}
-extern "C" {
- /// Locks encrypted volume
- /// @return command processing error code
- pub fn NK_lock_encrypted_volume() -> ::std::os::raw::c_int;
-}
-extern "C" {
- /// Unlock hidden volume and lock encrypted volume.
- /// Requires encrypted volume to be unlocked.
- /// Storage only
- /// @param hidden_volume_password 20 characters
- /// @return command processing error code
- pub fn NK_unlock_hidden_volume(
- hidden_volume_password: *const ::std::os::raw::c_char,
- ) -> ::std::os::raw::c_int;
-}
-extern "C" {
- /// Locks hidden volume
- /// @return command processing error code
- pub fn NK_lock_hidden_volume() -> ::std::os::raw::c_int;
-}
-extern "C" {
- /// Create hidden volume.
- /// Requires encrypted volume to be unlocked.
- /// Storage only
- /// @param slot_nr slot number in range 0-3
- /// @param start_percent volume begin expressed in percent of total available storage, int in range 0-99
- /// @param end_percent volume end expressed in percent of total available storage, int in range 1-100
- /// @param hidden_volume_password 20 characters
- /// @return command processing error code
- pub fn NK_create_hidden_volume(
- slot_nr: u8,
- start_percent: u8,
- end_percent: u8,
- hidden_volume_password: *const ::std::os::raw::c_char,
- ) -> ::std::os::raw::c_int;
-}
-extern "C" {
- /// Make unencrypted volume read-only.
- /// Device hides unencrypted volume for a second therefore make sure
- /// buffers are flushed before running.
- /// Does nothing if firmware version is not matched
- /// Firmware range: Storage v0.50, v0.48 and below
- /// Storage only
- /// @param user_pin 20 characters User PIN
- /// @return command processing error code
- pub fn NK_set_unencrypted_read_only(
- user_pin: *const ::std::os::raw::c_char,
- ) -> ::std::os::raw::c_int;
-}
-extern "C" {
- /// Make unencrypted volume read-write.
- /// Device hides unencrypted volume for a second therefore make sure
- /// buffers are flushed before running.
- /// Does nothing if firmware version is not matched
- /// Firmware range: Storage v0.50, v0.48 and below
- /// Storage only
- /// @param user_pin 20 characters User PIN
- /// @return command processing error code
- pub fn NK_set_unencrypted_read_write(
- user_pin: *const ::std::os::raw::c_char,
- ) -> ::std::os::raw::c_int;
-}
-extern "C" {
- /// Make unencrypted volume read-only.
- /// Device hides unencrypted volume for a second therefore make sure
- /// buffers are flushed before running.
- /// Does nothing if firmware version is not matched
- /// Firmware range: Storage v0.49, v0.51+
- /// Storage only
- /// @param admin_pin 20 characters Admin PIN
- /// @return command processing error code
- pub fn NK_set_unencrypted_read_only_admin(
- admin_pin: *const ::std::os::raw::c_char,
- ) -> ::std::os::raw::c_int;
-}
-extern "C" {
- /// Make unencrypted volume read-write.
- /// Device hides unencrypted volume for a second therefore make sure
- /// buffers are flushed before running.
- /// Does nothing if firmware version is not matched
- /// Firmware range: Storage v0.49, v0.51+
- /// Storage only
- /// @param admin_pin 20 characters Admin PIN
- /// @return command processing error code
- pub fn NK_set_unencrypted_read_write_admin(
- admin_pin: *const ::std::os::raw::c_char,
- ) -> ::std::os::raw::c_int;
-}
-extern "C" {
- /// Make encrypted volume read-only.
- /// Device hides encrypted volume for a second therefore make sure
- /// buffers are flushed before running.
- /// Firmware range: v0.49 only, future (see firmware release notes)
- /// Storage only
- /// @param admin_pin 20 characters
- /// @return command processing error code
- pub fn NK_set_encrypted_read_only(
- admin_pin: *const ::std::os::raw::c_char,
- ) -> ::std::os::raw::c_int;
-}
-extern "C" {
- /// Make encrypted volume read-write.
- /// Device hides encrypted volume for a second therefore make sure
- /// buffers are flushed before running.
- /// Firmware range: v0.49 only, future (see firmware release notes)
- /// Storage only
- /// @param admin_pin 20 characters
- /// @return command processing error code
- pub fn NK_set_encrypted_read_write(
- admin_pin: *const ::std::os::raw::c_char,
- ) -> ::std::os::raw::c_int;
-}
-extern "C" {
- /// Exports device's firmware to unencrypted volume.
- /// Storage only
- /// @param admin_pin 20 characters
- /// @return command processing error code
- pub fn NK_export_firmware(admin_pin: *const ::std::os::raw::c_char) -> ::std::os::raw::c_int;
-}
-extern "C" {
- /// Clear new SD card notification. It is set after factory reset.
- /// Storage only
- /// @param admin_pin 20 characters
- /// @return command processing error code
- pub fn NK_clear_new_sd_card_warning(
- admin_pin: *const ::std::os::raw::c_char,
- ) -> ::std::os::raw::c_int;
-}
-extern "C" {
- /// Fill SD card with random data.
- /// Should be done on first stick initialization after creating keys.
- /// Storage only
- /// @param admin_pin 20 characters
- /// @return command processing error code
- pub fn NK_fill_SD_card_with_random_data(
- admin_pin: *const ::std::os::raw::c_char,
- ) -> ::std::os::raw::c_int;
-}
-extern "C" {
- /// Change update password.
- /// Update password is used for entering update mode, where firmware
- /// could be uploaded using dfu-programmer or other means.
- /// Storage only
- /// @param current_update_password 20 characters
- /// @param new_update_password 20 characters
- /// @return command processing error code
- pub fn NK_change_update_password(
- current_update_password: *const ::std::os::raw::c_char,
- new_update_password: *const ::std::os::raw::c_char,
- ) -> ::std::os::raw::c_int;
-}
-extern "C" {
- /// Enter update mode. Needs update password.
- /// When device is in update mode it no longer accepts any HID commands until
- /// firmware is launched (regardless of being updated or not).
- /// Smartcard (through CCID interface) and its all volumes are not visible as well.
- /// Its VID and PID are changed to factory-default (03eb:2ff1 Atmel Corp.)
- /// to be detected by flashing software. Result of this command can be reversed
- /// by using 'launch' command.
- /// For dfu-programmer it would be: 'dfu-programmer at32uc3a3256s launch'.
- /// Storage only
- /// @param update_password 20 characters
- /// @return command processing error code
- pub fn NK_enable_firmware_update(
- update_password: *const ::std::os::raw::c_char,
- ) -> ::std::os::raw::c_int;
-}
-extern "C" {
- /// Get Storage stick status as string.
- /// Storage only
- /// @return string with devices attributes
- pub fn NK_get_status_storage_as_string() -> *mut ::std::os::raw::c_char;
-}
-extern "C" {
- /// Get the Storage stick status and return the command processing
- /// error code. If the code is zero, i. e. the command was successful,
- /// the storage status is written to the output pointer's target.
- /// The output pointer must not be null.
- ///
- /// @param out the output pointer for the storage status
- /// @return command processing error code
- pub fn NK_get_status_storage(out: *mut NK_storage_status) -> ::std::os::raw::c_int;
-}
-extern "C" {
- /// Get SD card usage attributes as string.
- /// Usable during hidden volumes creation.
- /// Storage only
- /// @return string with SD card usage attributes
- pub fn NK_get_SD_usage_data_as_string() -> *mut ::std::os::raw::c_char;
-}
-extern "C" {
- /// Get progress value of current long operation.
- /// Storage only
- /// @return int in range 0-100 or -1 if device is not busy
- pub fn NK_get_progress_bar_value() -> ::std::os::raw::c_int;
-}
-extern "C" {
- /// Returns a list of connected devices' id's, delimited by ';' character. Empty string is returned on no device found.
- /// Each ID could consist of:
- /// 1. SC_id:SD_id_p_path (about 40 bytes)
- /// 2. path (about 10 bytes)
- /// where 'path' is USB path (bus:num), 'SC_id' is smartcard ID, 'SD_id' is storage card ID and
- /// '_p_' and ':' are field delimiters.
- /// Case 2 (USB path only) is used, when the device cannot be asked about its status data (e.g. during a long operation,
- /// like clearing SD card.
- /// Internally connects to all available devices and creates a map between ids and connection objects.
- /// Side effects: changes active device to last detected Storage device.
- /// Storage only
- /// @example Example of returned data: '00005d19:dacc2cb4_p_0001:0010:02;000037c7:4cf12445_p_0001:000f:02;0001:000c:02'
- /// @return string delimited id's of connected devices
- pub fn NK_list_devices_by_cpuID() -> *mut ::std::os::raw::c_char;
-}
-extern "C" {
- /// Connects to the device with given ID. ID's list could be created with NK_list_devices_by_cpuID.
- /// Requires calling to NK_list_devices_by_cpuID first. Connecting to arbitrary ID/USB path is not handled.
- /// On connection requests status from device and disconnects it / removes from map on connection failure.
- /// Storage only
- /// @param id Target device ID (example: '00005d19:dacc2cb4_p_0001:0010:02')
- /// @return 1 on successful connection, 0 otherwise
- pub fn NK_connect_with_ID(id: *const ::std::os::raw::c_char) -> ::std::os::raw::c_int;
-}
-extern "C" {
- /// Blink red and green LED alternatively and infinitely (until device is reconnected).
- /// @return command processing error code
- pub fn NK_wink() -> ::std::os::raw::c_int;
-}
diff --git a/nitrokey-sys/src/lib.rs b/nitrokey-sys/src/lib.rs
deleted file mode 100644
index a179da8..0000000
--- a/nitrokey-sys/src/lib.rs
+++ /dev/null
@@ -1,31 +0,0 @@
-#![allow(non_upper_case_globals)]
-#![allow(non_camel_case_types)]
-#![allow(non_snake_case)]
-
-mod ffi;
-
-pub use crate::ffi::*;
-
-#[cfg(test)]
-mod tests {
- use super::*;
- use std::ffi::CString;
-
- #[test]
- fn login_auto() {
- unsafe {
- assert_eq!(0, NK_login_auto());
- }
- }
-
- #[test]
- fn login() {
- unsafe {
- // Unconnected
- assert_eq!(0, NK_login(CString::new("S").unwrap().as_ptr()));
- assert_eq!(0, NK_login(CString::new("P").unwrap().as_ptr()));
- // Unsupported model
- assert_eq!(0, NK_login(CString::new("T").unwrap().as_ptr()));
- }
- }
-}
diff --git a/nitrokey/.builds/archlinux-use-system-lib.yaml b/nitrokey/.builds/archlinux-use-system-lib.yaml
deleted file mode 100644
index 6fba33a..0000000
--- a/nitrokey/.builds/archlinux-use-system-lib.yaml
+++ /dev/null
@@ -1,22 +0,0 @@
-image: archlinux
-packages:
- - rust
- - libnitrokey
-environment:
- USE_SYSTEM_LIBNITROKEY: "1"
-sources:
- - https://git.sr.ht/~ireas/nitrokey-rs
-tasks:
- - build: |
- cd nitrokey-rs
- cargo build --release
- - test: |
- cd nitrokey-rs
- cargo test
- - format: |
- cd nitrokey-rs
- cargo fmt -- --check
-triggers:
- - action: email
- condition: failure
- to: nitrokey-rs-dev <nitrokey-rs-dev@ireas.org>
diff --git a/nitrokey/.builds/archlinux.yml b/nitrokey/.builds/archlinux.yml
deleted file mode 100644
index 9d45386..0000000
--- a/nitrokey/.builds/archlinux.yml
+++ /dev/null
@@ -1,21 +0,0 @@
-image: archlinux
-packages:
- - rust
- - hidapi
- - gcc
-sources:
- - https://git.sr.ht/~ireas/nitrokey-rs
-tasks:
- - build: |
- cd nitrokey-rs
- cargo build --release
- - test: |
- cd nitrokey-rs
- cargo test
- - format: |
- cd nitrokey-rs
- cargo fmt -- --check
-triggers:
- - action: email
- condition: failure
- to: nitrokey-rs-dev <nitrokey-rs-dev@ireas.org>
diff --git a/nitrokey/.gitignore b/nitrokey/.gitignore
deleted file mode 100644
index 4cdf3b3..0000000
--- a/nitrokey/.gitignore
+++ /dev/null
@@ -1,6 +0,0 @@
-
-/target
-/nitrokey-sys/target
-**/*.rs.bk
-Cargo.lock
-*.swp
diff --git a/nitrokey/CHANGELOG.md b/nitrokey/CHANGELOG.md
deleted file mode 100644
index edc33f6..0000000
--- a/nitrokey/CHANGELOG.md
+++ /dev/null
@@ -1,77 +0,0 @@
-# v0.3.4 (2019-01-20)
-- Fix authentication methods that assumed that `char` is signed.
-
-# v0.3.3 (2019-01-16)
-- Add the `get_production_info` and `clear_new_sd_card_warning` methods to the
- `Storage` struct.
-- Use `rand_os` instead of `rand` for random data creation.
- - (Re-)add `CommandError::RngError` variant.
-- Account for the possibility that an empty string returned by libnitrokey can
- not only indicate an error but also be a valid return value.
-- Make test cases more robust and avoid side effects on other test cases.
-
-# v0.3.2 (2019-01-12)
-- Make three additional error codes known: `CommandError::StringTooLong`,
- `CommandError::InvalidHexString` and `CommandError::TargetBufferTooSmall`.
-- Add the `get_library_version` function to query the libnitrokey version.
-- Add the `wink` method to the `Storage` struct.
-- Add the `set_unencrypted_volume_mode` to set the access mode of the
- unencrypted volume.
-- Add the `export_firmware` method to the `Storage` struct.
-
-# v0.3.1 (2019-01-07)
-- Use `nitrokey-test` to select and execute the unit tests.
-- Add support for the hidden volumes on a Nitrokey Storage
- (`enable_hidden_volume`, `disable_hidden_volume` and `create_hidden_volume`
- methods for the `Storage` struct).
-- Add the `connect_model` function to connect to a specific model using an enum
- variant.
-
-# v0.3.0 (2019-01-04)
-- Add a `force` argument to `ConfigureOtp::set_time`.
-- Remove the obsolete `CommandError::RngError`.
-- Add `CommandError::Undefined` to represent errors without further
- information (e. g. a method returned `NULL` unexpectedly).
-- Add error code to `CommandError::Unknown`.
-- Add the `Storage::change_update_pin` method that changes the firmware update
- PIN.
-- Add the `Device::factory_reset` method that performs a factory reset.
-- Add the `Device::build_aes_key` method that builds a new AES key on the Nitrokey.
-- Add the `Storage::enable_firmware_update` method that puts the Nitrokey
- Storage in update mode so that the firmware can be updated.
-
-# v0.2.3 (2018-12-31)
-
-- Dummy release to fix an issue with the crates.io tarball.
-
-# v0.2.2 (2018-12-30)
-
-- Update to Rust edition 2018.
-- Remove the `test-no-device` feature.
-- Update the rand dependency to version 0.6.
-- Add function `Device::get_model` that returns the connected model.
-- Derive the `Copy` and `Clone` traits for the enums `CommandError`, `LogLevel`
- and `OtpMode`
-
-# v0.2.1 (2018-12-10)
-
-- Re-export `device::{StorageStatus, VolumeStatus}` in `lib.rs`.
-
-# v0.2.0 (2018-12-10)
-
-- Update to libnitrokey v3.4.1.
-- Major refactoring of the existing code structure.
-- Add support for most of the Nitrokey Pro features and some of the Nitrokey
- Storage features. See the `TODO.md` file for more details about the missing
- functionality.
-
-# v0.1.1 (2018-05-21)
-
-- Update the `nitrokey-sys` dependency to version 3.3.0. Now `libnitrokey`
- is built from source and `bindgen` is no longer a build dependency.
-- Add `get_minor_firmware_version` to `Device`.
-- Use `NK_login_enum` instead of `NK_login` in `Device::connect`.
-
-# v0.1.0 (2018-05-19)
-
-- Initial release
diff --git a/nitrokey/Cargo.toml b/nitrokey/Cargo.toml
deleted file mode 100644
index 838ab45..0000000
--- a/nitrokey/Cargo.toml
+++ /dev/null
@@ -1,26 +0,0 @@
-[package]
-name = "nitrokey"
-version = "0.3.4"
-authors = ["Robin Krahl <robin.krahl@ireas.org>"]
-edition = "2018"
-homepage = "https://code.ireas.org/nitrokey-rs/"
-repository = "https://git.ireas.org/nitrokey-rs/"
-documentation = "https://docs.rs/nitrokey"
-description = "Bindings to libnitrokey for communication with Nitrokey devices"
-keywords = ["nitrokey", "otp"]
-categories = ["api-bindings"]
-readme = "README.md"
-license = "MIT"
-
-[features]
-test-pro = []
-test-storage = []
-
-[dependencies]
-libc = "0.2"
-nitrokey-sys = "3.4"
-rand_core = {version = "0.3", default-features = false}
-rand_os = {version = "0.1"}
-
-[dev-dependencies]
-nitrokey-test = {version = "0.1"}
diff --git a/nitrokey/LICENSE b/nitrokey/LICENSE
deleted file mode 100644
index 1a3601d..0000000
--- a/nitrokey/LICENSE
+++ /dev/null
@@ -1,21 +0,0 @@
-The MIT License (MIT)
-
-Copyright (c) 2018 Robin Krahl <robin.krahl@ireas.org>
-
-Permission is hereby granted, free of charge, to any person obtaining a copy of
-this software and associated documentation files (the "Software"), to deal in
-the Software without restriction, including without limitation the rights to
-use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
-of the Software, and to permit persons to whom the Software is furnished to do
-so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in all
-copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-SOFTWARE.
diff --git a/nitrokey/README.md b/nitrokey/README.md
deleted file mode 100644
index 567ae58..0000000
--- a/nitrokey/README.md
+++ /dev/null
@@ -1,81 +0,0 @@
-# nitrokey-rs
-
-A libnitrokey wrapper for Rust providing access to Nitrokey devices.
-
-[Documentation][]
-
-## Compatibility
-
-The required [`libnitrokey`][] version is built from source. The host system
-must provide `libhidapi-libusb0` (Linux) or `libhidapi` (non-Linux) in the
-default library search path. Depending on your system, you might also have to
-install the [Nitrokey udev rules][].
-
-Currently, this crate provides access to the common features of the Nitrokey
-Pro and the Nitrokey Storage: general configuration, OTP generation and the
-password safe. Basic support for the secure storage on the Nitrokey Storage is
-available but still under development.
-
-### Unsupported Functions
-
-The following functions provided by `libnitrokey` are deliberately not
-supported by `nitrokey-rs`:
-
-- `NK_get_device_model`. We know which model we connected to, so we can
- provide this information without calling `libnitrokey`.
-- `NK_get_time`. This method is useless as it will always cause a timestamp
- error on the device (see [pull request #114][] for `libnitrokey` for details).
-- `NK_get_status`. This method only provides a string representation of
- data that can be accessed by other methods (firmware version, serial number,
- configuration).
-- `NK_get_status_storage_as_string`. This method only provides an incomplete
- string representation of the data returned by `NK_get_status_storage`.
-- `NK_set_unencrypted_volume_rorw_pin_type_user`,
- `NK_set_unencrypted_read_only`, `NK_set_unencrypted_read_write`,
- `NK_set_encrypted_read_only` and `NK_set_encrypted_read_write`. These
- methods are only relevant for older firmware versions (pre-v0.51). As the
- Nitrokey Storage firmware can be updated easily, we do not support these
- outdated versions.
-
-## Tests
-
-This crate has tests for different scenarios: Some tests require that no
-Nitrokey device is connected, others require a Nitrokey Storage or a Nitrokey
-Pro. We use the [`nitrokey-test`][] crate to select the test cases. You can
-just run `cargo test` to auto-detect connected Nitrokey devices and to run the
-appropriate tests. If you want to manually select the tests, set the
-`NITROKEY_TEST_GROUP` environment variable to `nodev` (no device connected),
-`pro` (Nitrokey Pro connected) or `storage` (Nitrokey Storage connected).
-
-Note that the tests assume that the device’s passwords are the factory defaults
-(admin PIN `12345678`, user PIN `123456`, update password `12345678`) and that
-an AES key has been built. Some tests will overwrite the data stored on the
-Nitrokey device or perform a factory reset. Never execute the tests if you
-unless yout want to destroy all data on all connected Nitrokey devices!
-
-The `totp_no_pin` and `totp_pin` tests can occasionally fail due to bad timing.
-
-## Acknowledgments
-
-Thanks to Nitrokey UG for providing a Nitrokey Storage to support the
-development of this crate. Thanks to Daniel Mueller for contributions to
-`nitrokey-rs` and for the `nitrokey-test` crate.
-
-## Contact
-
-For bug reports, patches, feature requests or other messages, please send a
-mail to [nitrokey-rs-dev@ireas.org][].
-
-## License
-
-This project is licensed under the [MIT License][]. `libnitrokey` is licensed
-under the [LGPL-3.0][].
-
-[Documentation]: https://docs.rs/nitrokey
-[Nitrokey udev rules]: https://www.nitrokey.com/documentation/frequently-asked-questions-faq#openpgp-card-not-available
-[`libnitrokey`]: https://github.com/nitrokey/libnitrokey
-[`nitrokey-test`]: https://github.com/d-e-s-o/nitrokey-test
-[nitrokey-rs-dev@ireas.org]: mailto:nitrokey-rs-dev@ireas.org
-[pull request #114]: https://github.com/Nitrokey/libnitrokey/pull/114
-[MIT license]: https://opensource.org/licenses/MIT
-[LGPL-3.0]: https://opensource.org/licenses/lgpl-3.0.html
diff --git a/nitrokey/TODO.md b/nitrokey/TODO.md
deleted file mode 100644
index 28bd3b8..0000000
--- a/nitrokey/TODO.md
+++ /dev/null
@@ -1,22 +0,0 @@
-- Add support for the currently unsupported commands:
- - `NK_is_AES_supported`
- - `NK_send_startup`
- - `NK_fill_SD_card_with_random_data`
- - `NK_get_SD_usage_data_as_string`
- - `NK_get_progress_bar_value`
- - `NK_list_devices_by_cpuID`
- - `NK_connect_with_ID`
-- Fix timing issues with the `totp_no_pin` and `totp_pin` test cases.
-- Clear passwords from memory.
-- Find a nicer syntax for the `write_config` test.
-- Prevent construction of internal types.
-- More specific error checking in the tests.
-- Check integer conversions.
-- Consider implementing `Into<CommandError>` for `(Device, CommandError)`
-- Lock password safe in `PasswordSafe::drop()` (see [nitrokey-storage-firmware
- issue 65][]).
-- Disable creation of multiple password safes at the same time.
-- Check timing in Storage tests.
-- Consider restructuring `device::StorageStatus`.
-
-[nitrokey-storage-firmware issue 65]: https://github.com/Nitrokey/nitrokey-storage-firmware/issues/65
diff --git a/nitrokey/src/auth.rs b/nitrokey/src/auth.rs
deleted file mode 100644
index 2d61d4b..0000000
--- a/nitrokey/src/auth.rs
+++ /dev/null
@@ -1,417 +0,0 @@
-use std::ops::Deref;
-use std::os::raw::c_char;
-use std::os::raw::c_int;
-
-use nitrokey_sys;
-
-use crate::config::{Config, RawConfig};
-use crate::device::{Device, DeviceWrapper, Pro, Storage};
-use crate::otp::{ConfigureOtp, GenerateOtp, OtpMode, OtpSlotData, RawOtpSlotData};
-use crate::util::{
- generate_password, get_command_result, get_cstring, result_from_string, CommandError,
-};
-
-static TEMPORARY_PASSWORD_LENGTH: usize = 25;
-
-/// Provides methods to authenticate as a user or as an admin using a PIN. The authenticated
-/// methods will consume the current device instance. On success, they return the authenticated
-/// device. Otherwise, they return the current unauthenticated device and the error code.
-pub trait Authenticate {
- /// Performs user authentication. This method consumes the device. If successful, an
- /// authenticated device is returned. Otherwise, the current unauthenticated device and the
- /// error are returned.
- ///
- /// This method generates a random temporary password that is used for all operations that
- /// require user access.
- ///
- /// # Errors
- ///
- /// - [`InvalidString`][] if the provided user password contains a null byte
- /// - [`RngError`][] if the generation of the temporary password failed
- /// - [`WrongPassword`][] if the provided user password is wrong
- ///
- /// # Example
- ///
- /// ```no_run
- /// use nitrokey::{Authenticate, DeviceWrapper, User};
- /// # use nitrokey::CommandError;
- ///
- /// fn perform_user_task(device: &User<DeviceWrapper>) {}
- /// fn perform_other_task(device: &DeviceWrapper) {}
- ///
- /// # fn try_main() -> Result<(), CommandError> {
- /// let device = nitrokey::connect()?;
- /// let device = match device.authenticate_user("123456") {
- /// Ok(user) => {
- /// perform_user_task(&user);
- /// user.device()
- /// },
- /// Err((device, err)) => {
- /// println!("Could not authenticate as user: {}", err);
- /// device
- /// },
- /// };
- /// perform_other_task(&device);
- /// # Ok(())
- /// # }
- /// ```
- ///
- /// [`InvalidString`]: enum.CommandError.html#variant.InvalidString
- /// [`RngError`]: enum.CommandError.html#variant.RngError
- /// [`WrongPassword`]: enum.CommandError.html#variant.WrongPassword
- fn authenticate_user(self, password: &str) -> Result<User<Self>, (Self, CommandError)>
- where
- Self: Device + Sized;
-
- /// Performs admin authentication. This method consumes the device. If successful, an
- /// authenticated device is returned. Otherwise, the current unauthenticated device and the
- /// error are returned.
- ///
- /// This method generates a random temporary password that is used for all operations that
- /// require admin access.
- ///
- /// # Errors
- ///
- /// - [`InvalidString`][] if the provided admin password contains a null byte
- /// - [`RngError`][] if the generation of the temporary password failed
- /// - [`WrongPassword`][] if the provided admin password is wrong
- ///
- /// # Example
- ///
- /// ```no_run
- /// use nitrokey::{Authenticate, Admin, DeviceWrapper};
- /// # use nitrokey::CommandError;
- ///
- /// fn perform_admin_task(device: &Admin<DeviceWrapper>) {}
- /// fn perform_other_task(device: &DeviceWrapper) {}
- ///
- /// # fn try_main() -> Result<(), CommandError> {
- /// let device = nitrokey::connect()?;
- /// let device = match device.authenticate_admin("123456") {
- /// Ok(admin) => {
- /// perform_admin_task(&admin);
- /// admin.device()
- /// },
- /// Err((device, err)) => {
- /// println!("Could not authenticate as admin: {}", err);
- /// device
- /// },
- /// };
- /// perform_other_task(&device);
- /// # Ok(())
- /// # }
- /// ```
- ///
- /// [`InvalidString`]: enum.CommandError.html#variant.InvalidString
- /// [`RngError`]: enum.CommandError.html#variant.RngError
- /// [`WrongPassword`]: enum.CommandError.html#variant.WrongPassword
- fn authenticate_admin(self, password: &str) -> Result<Admin<Self>, (Self, CommandError)>
- where
- Self: Device + Sized;
-}
-
-trait AuthenticatedDevice<T> {
- fn new(device: T, temp_password: Vec<u8>) -> Self;
-}
-
-/// A Nitrokey device with user authentication.
-///
-/// To obtain an instance of this struct, use the [`authenticate_user`][] method from the
-/// [`Authenticate`][] trait. To get back to an unauthenticated device, use the [`device`][]
-/// method.
-///
-/// [`Authenticate`]: trait.Authenticate.html
-/// [`authenticate_admin`]: trait.Authenticate.html#method.authenticate_admin
-/// [`device`]: #method.device
-#[derive(Debug)]
-pub struct User<T: Device> {
- device: T,
- temp_password: Vec<u8>,
-}
-
-/// A Nitrokey device with admin authentication.
-///
-/// To obtain an instance of this struct, use the [`authenticate_admin`][] method from the
-/// [`Authenticate`][] trait. To get back to an unauthenticated device, use the [`device`][]
-/// method.
-///
-/// [`Authenticate`]: trait.Authenticate.html
-/// [`authenticate_admin`]: trait.Authenticate.html#method.authenticate_admin
-/// [`device`]: #method.device
-#[derive(Debug)]
-pub struct Admin<T: Device> {
- device: T,
- temp_password: Vec<u8>,
-}
-
-fn authenticate<D, A, T>(device: D, password: &str, callback: T) -> Result<A, (D, CommandError)>
-where
- D: Device,
- A: AuthenticatedDevice<D>,
- T: Fn(*const c_char, *const c_char) -> c_int,
-{
- let temp_password = match generate_password(TEMPORARY_PASSWORD_LENGTH) {
- Ok(temp_password) => temp_password,
- Err(err) => return Err((device, err)),
- };
- let password = match get_cstring(password) {
- Ok(password) => password,
- Err(err) => return Err((device, err)),
- };
- let password_ptr = password.as_ptr();
- let temp_password_ptr = temp_password.as_ptr() as *const c_char;
- return match callback(password_ptr, temp_password_ptr) {
- 0 => Ok(A::new(device, temp_password)),
- rv => Err((device, CommandError::from(rv))),
- };
-}
-
-fn authenticate_user_wrapper<T, C>(
- device: T,
- constructor: C,
- password: &str,
-) -> Result<User<DeviceWrapper>, (DeviceWrapper, CommandError)>
-where
- T: Device,
- C: Fn(T) -> DeviceWrapper,
-{
- let result = device.authenticate_user(password);
- match result {
- Ok(user) => Ok(User::new(constructor(user.device), user.temp_password)),
- Err((device, err)) => Err((constructor(device), err)),
- }
-}
-
-fn authenticate_admin_wrapper<T, C>(
- device: T,
- constructor: C,
- password: &str,
-) -> Result<Admin<DeviceWrapper>, (DeviceWrapper, CommandError)>
-where
- T: Device,
- C: Fn(T) -> DeviceWrapper,
-{
- let result = device.authenticate_admin(password);
- match result {
- Ok(user) => Ok(Admin::new(constructor(user.device), user.temp_password)),
- Err((device, err)) => Err((constructor(device), err)),
- }
-}
-
-impl<T: Device> User<T> {
- /// Forgets the user authentication and returns an unauthenticated device. This method
- /// consumes the authenticated device. It does not perform any actual commands on the
- /// Nitrokey.
- pub fn device(self) -> T {
- self.device
- }
-}
-
-impl<T: Device> Deref for User<T> {
- type Target = T;
-
- fn deref(&self) -> &Self::Target {
- &self.device
- }
-}
-
-impl<T: Device> GenerateOtp for User<T> {
- fn get_hotp_code(&self, slot: u8) -> Result<String, CommandError> {
- unsafe {
- let temp_password_ptr = self.temp_password.as_ptr() as *const c_char;
- return result_from_string(nitrokey_sys::NK_get_hotp_code_PIN(slot, temp_password_ptr));
- }
- }
-
- fn get_totp_code(&self, slot: u8) -> Result<String, CommandError> {
- unsafe {
- let temp_password_ptr = self.temp_password.as_ptr() as *const c_char;
- return result_from_string(nitrokey_sys::NK_get_totp_code_PIN(
- slot,
- 0,
- 0,
- 0,
- temp_password_ptr,
- ));
- }
- }
-}
-
-impl<T: Device> AuthenticatedDevice<T> for User<T> {
- fn new(device: T, temp_password: Vec<u8>) -> Self {
- User {
- device,
- temp_password,
- }
- }
-}
-
-impl<T: Device> Deref for Admin<T> {
- type Target = T;
-
- fn deref(&self) -> &Self::Target {
- &self.device
- }
-}
-
-impl<T: Device> Admin<T> {
- /// Forgets the user authentication and returns an unauthenticated device. This method
- /// consumes the authenticated device. It does not perform any actual commands on the
- /// Nitrokey.
- pub fn device(self) -> T {
- self.device
- }
-
- /// Writes the given configuration to the Nitrokey device.
- ///
- /// # Errors
- ///
- /// - [`InvalidSlot`][] if the provided numlock, capslock or scrolllock slot is larger than two
- ///
- /// # Example
- ///
- /// ```no_run
- /// use nitrokey::{Authenticate, Config};
- /// # use nitrokey::CommandError;
- ///
- /// # fn try_main() -> Result<(), CommandError> {
- /// let device = nitrokey::connect()?;
- /// let config = Config::new(None, None, None, false);
- /// match device.authenticate_admin("12345678") {
- /// Ok(admin) => {
- /// admin.write_config(config);
- /// ()
- /// },
- /// Err((_, err)) => println!("Could not authenticate as admin: {}", err),
- /// };
- /// # Ok(())
- /// # }
- /// ```
- ///
- /// [`InvalidSlot`]: enum.CommandError.html#variant.InvalidSlot
- pub fn write_config(&self, config: Config) -> Result<(), CommandError> {
- let raw_config = RawConfig::try_from(config)?;
- unsafe {
- get_command_result(nitrokey_sys::NK_write_config(
- raw_config.numlock,
- raw_config.capslock,
- raw_config.scrollock,
- raw_config.user_password,
- false,
- self.temp_password.as_ptr() as *const c_char,
- ))
- }
- }
-
- fn write_otp_slot<C>(&self, data: OtpSlotData, callback: C) -> Result<(), CommandError>
- where
- C: Fn(RawOtpSlotData, *const c_char) -> c_int,
- {
- let raw_data = RawOtpSlotData::new(data)?;
- let temp_password_ptr = self.temp_password.as_ptr() as *const c_char;
- get_command_result(callback(raw_data, temp_password_ptr))
- }
-}
-
-impl<T: Device> ConfigureOtp for Admin<T> {
- fn write_hotp_slot(&self, data: OtpSlotData, counter: u64) -> Result<(), CommandError> {
- self.write_otp_slot(data, |raw_data: RawOtpSlotData, temp_password_ptr| unsafe {
- nitrokey_sys::NK_write_hotp_slot(
- raw_data.number,
- raw_data.name.as_ptr(),
- raw_data.secret.as_ptr(),
- counter,
- raw_data.mode == OtpMode::EightDigits,
- raw_data.use_enter,
- raw_data.use_token_id,
- raw_data.token_id.as_ptr(),
- temp_password_ptr,
- )
- })
- }
-
- fn write_totp_slot(&self, data: OtpSlotData, time_window: u16) -> Result<(), CommandError> {
- self.write_otp_slot(data, |raw_data: RawOtpSlotData, temp_password_ptr| unsafe {
- nitrokey_sys::NK_write_totp_slot(
- raw_data.number,
- raw_data.name.as_ptr(),
- raw_data.secret.as_ptr(),
- time_window,
- raw_data.mode == OtpMode::EightDigits,
- raw_data.use_enter,
- raw_data.use_token_id,
- raw_data.token_id.as_ptr(),
- temp_password_ptr,
- )
- })
- }
-
- fn erase_hotp_slot(&self, slot: u8) -> Result<(), CommandError> {
- let temp_password_ptr = self.temp_password.as_ptr() as *const c_char;
- unsafe { get_command_result(nitrokey_sys::NK_erase_hotp_slot(slot, temp_password_ptr)) }
- }
-
- fn erase_totp_slot(&self, slot: u8) -> Result<(), CommandError> {
- let temp_password_ptr = self.temp_password.as_ptr() as *const c_char;
- unsafe { get_command_result(nitrokey_sys::NK_erase_totp_slot(slot, temp_password_ptr)) }
- }
-}
-
-impl<T: Device> AuthenticatedDevice<T> for Admin<T> {
- fn new(device: T, temp_password: Vec<u8>) -> Self {
- Admin {
- device,
- temp_password,
- }
- }
-}
-
-impl Authenticate for DeviceWrapper {
- fn authenticate_user(self, password: &str) -> Result<User<Self>, (Self, CommandError)> {
- match self {
- DeviceWrapper::Storage(storage) => {
- authenticate_user_wrapper(storage, DeviceWrapper::Storage, password)
- }
- DeviceWrapper::Pro(pro) => authenticate_user_wrapper(pro, DeviceWrapper::Pro, password),
- }
- }
-
- fn authenticate_admin(self, password: &str) -> Result<Admin<Self>, (Self, CommandError)> {
- match self {
- DeviceWrapper::Storage(storage) => {
- authenticate_admin_wrapper(storage, DeviceWrapper::Storage, password)
- }
- DeviceWrapper::Pro(pro) => {
- authenticate_admin_wrapper(pro, DeviceWrapper::Pro, password)
- }
- }
- }
-}
-
-impl Authenticate for Pro {
- fn authenticate_user(self, password: &str) -> Result<User<Self>, (Self, CommandError)> {
- authenticate(self, password, |password_ptr, temp_password_ptr| unsafe {
- nitrokey_sys::NK_user_authenticate(password_ptr, temp_password_ptr)
- })
- }
-
- fn authenticate_admin(self, password: &str) -> Result<Admin<Self>, (Self, CommandError)> {
- authenticate(self, password, |password_ptr, temp_password_ptr| unsafe {
- nitrokey_sys::NK_first_authenticate(password_ptr, temp_password_ptr)
- })
- }
-}
-
-impl Authenticate for Storage {
- fn authenticate_user(self, password: &str) -> Result<User<Self>, (Self, CommandError)> {
- authenticate(self, password, |password_ptr, temp_password_ptr| unsafe {
- nitrokey_sys::NK_user_authenticate(password_ptr, temp_password_ptr)
- })
- }
-
- fn authenticate_admin(self, password: &str) -> Result<Admin<Self>, (Self, CommandError)> {
- authenticate(self, password, |password_ptr, temp_password_ptr| unsafe {
- nitrokey_sys::NK_first_authenticate(password_ptr, temp_password_ptr)
- })
- }
-}
diff --git a/nitrokey/src/config.rs b/nitrokey/src/config.rs
deleted file mode 100644
index 2ce6f77..0000000
--- a/nitrokey/src/config.rs
+++ /dev/null
@@ -1,99 +0,0 @@
-use crate::util::CommandError;
-
-/// The configuration for a Nitrokey.
-#[derive(Clone, Copy, Debug, PartialEq)]
-pub struct Config {
- /// If set, the stick will generate a code from the HOTP slot with the given number if numlock
- /// is pressed. The slot number must be 0, 1 or 2.
- pub numlock: Option<u8>,
- /// If set, the stick will generate a code from the HOTP slot with the given number if capslock
- /// is pressed. The slot number must be 0, 1 or 2.
- pub capslock: Option<u8>,
- /// If set, the stick will generate a code from the HOTP slot with the given number if
- /// scrollock is pressed. The slot number must be 0, 1 or 2.
- pub scrollock: Option<u8>,
- /// If set, OTP generation using [`get_hotp_code`][] or [`get_totp_code`][] requires user
- /// authentication. Otherwise, OTPs can be generated without authentication.
- ///
- /// [`get_hotp_code`]: trait.ProvideOtp.html#method.get_hotp_code
- /// [`get_totp_code`]: trait.ProvideOtp.html#method.get_totp_code
- pub user_password: bool,
-}
-
-#[derive(Debug)]
-pub struct RawConfig {
- pub numlock: u8,
- pub capslock: u8,
- pub scrollock: u8,
- pub user_password: bool,
-}
-
-fn config_otp_slot_to_option(value: u8) -> Option<u8> {
- if value < 3 {
- return Some(value);
- }
- None
-}
-
-fn option_to_config_otp_slot(value: Option<u8>) -> Result<u8, CommandError> {
- match value {
- Some(value) => {
- if value < 3 {
- Ok(value)
- } else {
- Err(CommandError::InvalidSlot)
- }
- }
- None => Ok(255),
- }
-}
-
-impl Config {
- /// Constructs a new instance of this struct.
- pub fn new(
- numlock: Option<u8>,
- capslock: Option<u8>,
- scrollock: Option<u8>,
- user_password: bool,
- ) -> Config {
- Config {
- numlock,
- capslock,
- scrollock,
- user_password,
- }
- }
-}
-
-impl RawConfig {
- pub fn try_from(config: Config) -> Result<RawConfig, CommandError> {
- Ok(RawConfig {
- numlock: option_to_config_otp_slot(config.numlock)?,
- capslock: option_to_config_otp_slot(config.capslock)?,
- scrollock: option_to_config_otp_slot(config.scrollock)?,
- user_password: config.user_password,
- })
- }
-}
-
-impl From<[u8; 5]> for RawConfig {
- fn from(data: [u8; 5]) -> Self {
- RawConfig {
- numlock: data[0],
- capslock: data[1],
- scrollock: data[2],
- user_password: data[3] != 0,
- }
- }
-}
-
-impl Into<Config> for RawConfig {
- fn into(self) -> Config {
- Config {
- numlock: config_otp_slot_to_option(self.numlock),
- capslock: config_otp_slot_to_option(self.capslock),
- scrollock: config_otp_slot_to_option(self.scrollock),
- user_password: self.user_password,
- }
- }
-}
diff --git a/nitrokey/src/device.rs b/nitrokey/src/device.rs
deleted file mode 100644
index 9813c50..0000000
--- a/nitrokey/src/device.rs
+++ /dev/null
@@ -1,1367 +0,0 @@
-use std::fmt;
-
-use libc;
-use nitrokey_sys;
-
-use crate::auth::Authenticate;
-use crate::config::{Config, RawConfig};
-use crate::otp::GenerateOtp;
-use crate::pws::GetPasswordSafe;
-use crate::util::{
- get_command_result, get_cstring, get_last_error, result_from_string, CommandError,
-};
-
-/// Available Nitrokey models.
-#[derive(Clone, Copy, Debug, PartialEq)]
-pub enum Model {
- /// The Nitrokey Storage.
- Storage,
- /// The Nitrokey Pro.
- Pro,
-}
-
-impl fmt::Display for Model {
- fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
- write!(
- f,
- "{}",
- match *self {
- Model::Pro => "Pro",
- Model::Storage => "Storage",
- }
- )
- }
-}
-
-/// The access mode of a volume on the Nitrokey Storage.
-#[derive(Clone, Copy, Debug, PartialEq)]
-pub enum VolumeMode {
- /// A read-only volume.
- ReadOnly,
- /// A read-write volume.
- ReadWrite,
-}
-
-impl fmt::Display for VolumeMode {
- fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
- match *self {
- VolumeMode::ReadOnly => f.write_str("read-only"),
- VolumeMode::ReadWrite => f.write_str("read-write"),
- }
- }
-}
-
-/// A wrapper for a Nitrokey device of unknown type.
-///
-/// Use the function [`connect`][] to obtain a wrapped instance. The wrapper implements all traits
-/// that are shared between all Nitrokey devices so that the shared functionality can be used
-/// without knowing the type of the underlying device. If you want to use functionality that is
-/// not available for all devices, you have to extract the device.
-///
-/// # Examples
-///
-/// Authentication with error handling:
-///
-/// ```no_run
-/// use nitrokey::{Authenticate, DeviceWrapper, User};
-/// # use nitrokey::CommandError;
-///
-/// fn perform_user_task(device: &User<DeviceWrapper>) {}
-/// fn perform_other_task(device: &DeviceWrapper) {}
-///
-/// # fn try_main() -> Result<(), CommandError> {
-/// let device = nitrokey::connect()?;
-/// let device = match device.authenticate_user("123456") {
-/// Ok(user) => {
-/// perform_user_task(&user);
-/// user.device()
-/// },
-/// Err((device, err)) => {
-/// println!("Could not authenticate as user: {}", err);
-/// device
-/// },
-/// };
-/// perform_other_task(&device);
-/// # Ok(())
-/// # }
-/// ```
-///
-/// Device-specific commands:
-///
-/// ```no_run
-/// use nitrokey::{DeviceWrapper, Storage};
-/// # use nitrokey::CommandError;
-///
-/// fn perform_common_task(device: &DeviceWrapper) {}
-/// fn perform_storage_task(device: &Storage) {}
-///
-/// # fn try_main() -> Result<(), CommandError> {
-/// let device = nitrokey::connect()?;
-/// perform_common_task(&device);
-/// match device {
-/// DeviceWrapper::Storage(storage) => perform_storage_task(&storage),
-/// _ => (),
-/// };
-/// # Ok(())
-/// # }
-/// ```
-///
-/// [`connect`]: fn.connect.html
-#[derive(Debug)]
-pub enum DeviceWrapper {
- /// A Nitrokey Storage device.
- Storage(Storage),
- /// A Nitrokey Pro device.
- Pro(Pro),
-}
-
-/// A Nitrokey Pro device without user or admin authentication.
-///
-/// Use the global function [`connect`][] to obtain an instance wrapper or the method
-/// [`connect`][`Pro::connect`] to directly obtain an instance. If you want to execute a command
-/// that requires user or admin authentication, use [`authenticate_admin`][] or
-/// [`authenticate_user`][].
-///
-/// # Examples
-///
-/// Authentication with error handling:
-///
-/// ```no_run
-/// use nitrokey::{Authenticate, User, Pro};
-/// # use nitrokey::CommandError;
-///
-/// fn perform_user_task(device: &User<Pro>) {}
-/// fn perform_other_task(device: &Pro) {}
-///
-/// # fn try_main() -> Result<(), CommandError> {
-/// let device = nitrokey::Pro::connect()?;
-/// let device = match device.authenticate_user("123456") {
-/// Ok(user) => {
-/// perform_user_task(&user);
-/// user.device()
-/// },
-/// Err((device, err)) => {
-/// println!("Could not authenticate as user: {}", err);
-/// device
-/// },
-/// };
-/// perform_other_task(&device);
-/// # Ok(())
-/// # }
-/// ```
-///
-/// [`authenticate_admin`]: trait.Authenticate.html#method.authenticate_admin
-/// [`authenticate_user`]: trait.Authenticate.html#method.authenticate_user
-/// [`connect`]: fn.connect.html
-/// [`Pro::connect`]: #method.connect
-#[derive(Debug)]
-pub struct Pro {}
-
-/// A Nitrokey Storage device without user or admin authentication.
-///
-/// Use the global function [`connect`][] to obtain an instance wrapper or the method
-/// [`connect`][`Storage::connect`] to directly obtain an instance. If you want to execute a
-/// command that requires user or admin authentication, use [`authenticate_admin`][] or
-/// [`authenticate_user`][].
-///
-/// # Examples
-///
-/// Authentication with error handling:
-///
-/// ```no_run
-/// use nitrokey::{Authenticate, User, Storage};
-/// # use nitrokey::CommandError;
-///
-/// fn perform_user_task(device: &User<Storage>) {}
-/// fn perform_other_task(device: &Storage) {}
-///
-/// # fn try_main() -> Result<(), CommandError> {
-/// let device = nitrokey::Storage::connect()?;
-/// let device = match device.authenticate_user("123456") {
-/// Ok(user) => {
-/// perform_user_task(&user);
-/// user.device()
-/// },
-/// Err((device, err)) => {
-/// println!("Could not authenticate as user: {}", err);
-/// device
-/// },
-/// };
-/// perform_other_task(&device);
-/// # Ok(())
-/// # }
-/// ```
-///
-/// [`authenticate_admin`]: trait.Authenticate.html#method.authenticate_admin
-/// [`authenticate_user`]: trait.Authenticate.html#method.authenticate_user
-/// [`connect`]: fn.connect.html
-/// [`Storage::connect`]: #method.connect
-#[derive(Debug)]
-pub struct Storage {}
-
-/// The status of a volume on a Nitrokey Storage device.
-#[derive(Debug)]
-pub struct VolumeStatus {
- /// Indicates whether the volume is read-only.
- pub read_only: bool,
- /// Indicates whether the volume is active.
- pub active: bool,
-}
-
-/// Information about the SD card in a Storage device.
-#[derive(Debug)]
-pub struct SdCardData {
- /// The serial number of the SD card.
- pub serial_number: u32,
- /// The size of the SD card in GB.
- pub size: u8,
- /// The year the card was manufactured, e. g. 17 for 2017.
- pub manufacturing_year: u8,
- /// The month the card was manufactured.
- pub manufacturing_month: u8,
- /// The OEM ID.
- pub oem: u16,
- /// The manufacturer ID.
- pub manufacturer: u8,
-}
-
-#[derive(Debug)]
-/// Production information for a Storage device.
-pub struct StorageProductionInfo {
- /// The major firmware version, e. g. 0 in v0.40.
- pub firmware_version_major: u8,
- /// The minor firmware version, e. g. 40 in v0.40.
- pub firmware_version_minor: u8,
- /// The internal firmware version.
- pub firmware_version_internal: u8,
- /// The serial number of the CPU.
- pub serial_number_cpu: u32,
- /// Information about the SD card.
- pub sd_card: SdCardData,
-}
-
-/// The status of a Nitrokey Storage device.
-#[derive(Debug)]
-pub struct StorageStatus {
- /// The status of the unencrypted volume.
- pub unencrypted_volume: VolumeStatus,
- /// The status of the encrypted volume.
- pub encrypted_volume: VolumeStatus,
- /// The status of the hidden volume.
- pub hidden_volume: VolumeStatus,
- /// The major firmware version, e. g. 0 in v0.40.
- pub firmware_version_major: u8,
- /// The minor firmware version, e. g. 40 in v0.40.
- pub firmware_version_minor: u8,
- /// Indicates whether the firmware is locked.
- pub firmware_locked: bool,
- /// The serial number of the SD card in the Storage stick.
- pub serial_number_sd_card: u32,
- /// The serial number of the smart card in the Storage stick.
- pub serial_number_smart_card: u32,
- /// The number of remaining login attempts for the user PIN.
- pub user_retry_count: u8,
- /// The number of remaining login attempts for the admin PIN.
- pub admin_retry_count: u8,
- /// Indicates whether a new SD card was found.
- pub new_sd_card_found: bool,
- /// Indicates whether the SD card is filled with random characters.
- pub filled_with_random: bool,
- /// Indicates whether the stick has been initialized by generating
- /// the AES keys.
- pub stick_initialized: bool,
-}
-
-/// A Nitrokey device.
-///
-/// This trait provides the commands that can be executed without authentication and that are
-/// present on all supported Nitrokey devices.
-pub trait Device: Authenticate + GetPasswordSafe + GenerateOtp {
- /// Returns the model of the connected Nitrokey device.
- ///
- /// # Example
- ///
- /// ```no_run
- /// use nitrokey::Device;
- /// # use nitrokey::CommandError;
- ///
- /// # fn try_main() -> Result<(), CommandError> {
- /// let device = nitrokey::connect()?;
- /// println!("Connected to a Nitrokey {}", device.get_model());
- /// # Ok(())
- /// # }
- fn get_model(&self) -> Model;
-
- /// Returns the serial number of the Nitrokey device. The serial number is the string
- /// representation of a hex number.
- ///
- /// # Example
- ///
- /// ```no_run
- /// use nitrokey::Device;
- /// # use nitrokey::CommandError;
- ///
- /// # fn try_main() -> Result<(), CommandError> {
- /// let device = nitrokey::connect()?;
- /// match device.get_serial_number() {
- /// Ok(number) => println!("serial no: {}", number),
- /// Err(err) => println!("Could not get serial number: {}", err),
- /// };
- /// # Ok(())
- /// # }
- /// ```
- fn get_serial_number(&self) -> Result<String, CommandError> {
- unsafe { result_from_string(nitrokey_sys::NK_device_serial_number()) }
- }
-
- /// Returns the number of remaining authentication attempts for the user. The total number of
- /// available attempts is three.
- ///
- /// # Example
- ///
- /// ```no_run
- /// use nitrokey::Device;
- /// # use nitrokey::CommandError;
- ///
- /// # fn try_main() -> Result<(), CommandError> {
- /// let device = nitrokey::connect()?;
- /// let count = device.get_user_retry_count();
- /// println!("{} remaining authentication attempts (user)", count);
- /// # Ok(())
- /// # }
- /// ```
- fn get_user_retry_count(&self) -> u8 {
- unsafe { nitrokey_sys::NK_get_user_retry_count() }
- }
-
- /// Returns the number of remaining authentication attempts for the admin. The total number of
- /// available attempts is three.
- ///
- /// # Example
- ///
- /// ```no_run
- /// use nitrokey::Device;
- /// # use nitrokey::CommandError;
- ///
- /// # fn try_main() -> Result<(), CommandError> {
- /// let device = nitrokey::connect()?;
- /// let count = device.get_admin_retry_count();
- /// println!("{} remaining authentication attempts (admin)", count);
- /// # Ok(())
- /// # }
- /// ```
- fn get_admin_retry_count(&self) -> u8 {
- unsafe { nitrokey_sys::NK_get_admin_retry_count() }
- }
-
- /// Returns the major part of the firmware version (should be zero).
- ///
- /// # Example
- ///
- /// ```no_run
- /// use nitrokey::Device;
- /// # use nitrokey::CommandError;
- ///
- /// # fn try_main() -> Result<(), CommandError> {
- /// let device = nitrokey::connect()?;
- /// println!(
- /// "Firmware version: {}.{}",
- /// device.get_major_firmware_version(),
- /// device.get_minor_firmware_version(),
- /// );
- /// # Ok(())
- /// # }
- /// ```
- fn get_major_firmware_version(&self) -> i32 {
- unsafe { nitrokey_sys::NK_get_major_firmware_version() }
- }
-
- /// Returns the minor part of the firmware version (for example 8 for version 0.8).
- ///
- /// # Example
- ///
- /// ```no_run
- /// use nitrokey::Device;
- /// # use nitrokey::CommandError;
- ///
- /// # fn try_main() -> Result<(), CommandError> {
- /// let device = nitrokey::connect()?;
- /// println!(
- /// "Firmware version: {}.{}",
- /// device.get_major_firmware_version(),
- /// device.get_minor_firmware_version(),
- /// );
- /// # Ok(())
- /// # }
- fn get_minor_firmware_version(&self) -> i32 {
- unsafe { nitrokey_sys::NK_get_minor_firmware_version() }
- }
-
- /// Returns the current configuration of the Nitrokey device.
- ///
- /// # Example
- ///
- /// ```no_run
- /// use nitrokey::Device;
- /// # use nitrokey::CommandError;
- ///
- /// # fn try_main() -> Result<(), CommandError> {
- /// let device = nitrokey::connect()?;
- /// let config = device.get_config()?;
- /// println!("numlock binding: {:?}", config.numlock);
- /// println!("capslock binding: {:?}", config.capslock);
- /// println!("scrollock binding: {:?}", config.scrollock);
- /// println!("require password for OTP: {:?}", config.user_password);
- /// # Ok(())
- /// # }
- /// ```
- fn get_config(&self) -> Result<Config, CommandError> {
- unsafe {
- let config_ptr = nitrokey_sys::NK_read_config();
- if config_ptr.is_null() {
- return Err(get_last_error());
- }
- let config_array_ptr = config_ptr as *const [u8; 5];
- let raw_config = RawConfig::from(*config_array_ptr);
- libc::free(config_ptr as *mut libc::c_void);
- return Ok(raw_config.into());
- }
- }
-
- /// Changes the administrator PIN.
- ///
- /// # Errors
- ///
- /// - [`InvalidString`][] if one of the provided passwords contains a null byte
- /// - [`WrongPassword`][] if the current admin password is wrong
- ///
- /// # Example
- ///
- /// ```no_run
- /// use nitrokey::Device;
- /// # use nitrokey::CommandError;
- ///
- /// # fn try_main() -> Result<(), CommandError> {
- /// let device = nitrokey::connect()?;
- /// match device.change_admin_pin("12345678", "12345679") {
- /// Ok(()) => println!("Updated admin PIN."),
- /// Err(err) => println!("Failed to update admin PIN: {}", err),
- /// };
- /// # Ok(())
- /// # }
- /// ```
- ///
- /// [`InvalidString`]: enum.CommandError.html#variant.InvalidString
- /// [`WrongPassword`]: enum.CommandError.html#variant.WrongPassword
- fn change_admin_pin(&self, current: &str, new: &str) -> Result<(), CommandError> {
- let current_string = get_cstring(current)?;
- let new_string = get_cstring(new)?;
- unsafe {
- get_command_result(nitrokey_sys::NK_change_admin_PIN(
- current_string.as_ptr(),
- new_string.as_ptr(),
- ))
- }
- }
-
- /// Changes the user PIN.
- ///
- /// # Errors
- ///
- /// - [`InvalidString`][] if one of the provided passwords contains a null byte
- /// - [`WrongPassword`][] if the current user password is wrong
- ///
- /// # Example
- ///
- /// ```no_run
- /// use nitrokey::Device;
- /// # use nitrokey::CommandError;
- ///
- /// # fn try_main() -> Result<(), CommandError> {
- /// let device = nitrokey::connect()?;
- /// match device.change_user_pin("123456", "123457") {
- /// Ok(()) => println!("Updated admin PIN."),
- /// Err(err) => println!("Failed to update admin PIN: {}", err),
- /// };
- /// # Ok(())
- /// # }
- /// ```
- ///
- /// [`InvalidString`]: enum.CommandError.html#variant.InvalidString
- /// [`WrongPassword`]: enum.CommandError.html#variant.WrongPassword
- fn change_user_pin(&self, current: &str, new: &str) -> Result<(), CommandError> {
- let current_string = get_cstring(current)?;
- let new_string = get_cstring(new)?;
- unsafe {
- get_command_result(nitrokey_sys::NK_change_user_PIN(
- current_string.as_ptr(),
- new_string.as_ptr(),
- ))
- }
- }
-
- /// Unlocks the user PIN after three failed login attempts and sets it to the given value.
- ///
- /// # Errors
- ///
- /// - [`InvalidString`][] if one of the provided passwords contains a null byte
- /// - [`WrongPassword`][] if the admin password is wrong
- ///
- /// # Example
- ///
- /// ```no_run
- /// use nitrokey::Device;
- /// # use nitrokey::CommandError;
- ///
- /// # fn try_main() -> Result<(), CommandError> {
- /// let device = nitrokey::connect()?;
- /// match device.unlock_user_pin("12345678", "123456") {
- /// Ok(()) => println!("Unlocked user PIN."),
- /// Err(err) => println!("Failed to unlock user PIN: {}", err),
- /// };
- /// # Ok(())
- /// # }
- /// ```
- ///
- /// [`InvalidString`]: enum.CommandError.html#variant.InvalidString
- /// [`WrongPassword`]: enum.CommandError.html#variant.WrongPassword
- fn unlock_user_pin(&self, admin_pin: &str, user_pin: &str) -> Result<(), CommandError> {
- let admin_pin_string = get_cstring(admin_pin)?;
- let user_pin_string = get_cstring(user_pin)?;
- unsafe {
- get_command_result(nitrokey_sys::NK_unlock_user_password(
- admin_pin_string.as_ptr(),
- user_pin_string.as_ptr(),
- ))
- }
- }
-
- /// Locks the Nitrokey device.
- ///
- /// This disables the password store if it has been unlocked. On the Nitrokey Storage, this
- /// also disables the volumes if they have been enabled.
- ///
- /// # Example
- ///
- /// ```no_run
- /// use nitrokey::Device;
- /// # use nitrokey::CommandError;
- ///
- /// # fn try_main() -> Result<(), CommandError> {
- /// let device = nitrokey::connect()?;
- /// match device.lock() {
- /// Ok(()) => println!("Locked the Nitrokey device."),
- /// Err(err) => println!("Could not lock the Nitrokey device: {}", err),
- /// };
- /// # Ok(())
- /// # }
- /// ```
- fn lock(&self) -> Result<(), CommandError> {
- unsafe { get_command_result(nitrokey_sys::NK_lock_device()) }
- }
-
- /// Performs a factory reset on the Nitrokey device.
- ///
- /// This commands performs a factory reset on the smart card (like the factory reset via `gpg
- /// --card-edit`) and then clears the flash memory (password safe, one-time passwords etc.).
- /// After a factory reset, [`build_aes_key`][] has to be called before the password safe or the
- /// encrypted volume can be used.
- ///
- /// # Errors
- ///
- /// - [`InvalidString`][] if the provided password contains a null byte
- /// - [`WrongPassword`][] if the admin password is wrong
- ///
- /// # Example
- ///
- /// ```no_run
- /// use nitrokey::Device;
- /// # use nitrokey::CommandError;
- ///
- /// # fn try_main() -> Result<(), CommandError> {
- /// let device = nitrokey::connect()?;
- /// match device.factory_reset("12345678") {
- /// Ok(()) => println!("Performed a factory reset."),
- /// Err(err) => println!("Could not perform a factory reset: {}", err),
- /// };
- /// # Ok(())
- /// # }
- /// ```
- ///
- /// [`build_aes_key`]: #method.build_aes_key
- fn factory_reset(&self, admin_pin: &str) -> Result<(), CommandError> {
- let admin_pin_string = get_cstring(admin_pin)?;
- unsafe { get_command_result(nitrokey_sys::NK_factory_reset(admin_pin_string.as_ptr())) }
- }
-
- /// Builds a new AES key on the Nitrokey.
- ///
- /// The AES key is used to encrypt the password safe and the encrypted volume. You may need
- /// to call this method after a factory reset, either using [`factory_reset`][] or using `gpg
- /// --card-edit`. You can also use it to destroy the data stored in the password safe or on
- /// the encrypted volume.
- ///
- /// # Errors
- ///
- /// - [`InvalidString`][] if the provided password contains a null byte
- /// - [`WrongPassword`][] if the admin password is wrong
- ///
- /// # Example
- ///
- /// ```no_run
- /// use nitrokey::Device;
- /// # use nitrokey::CommandError;
- ///
- /// # fn try_main() -> Result<(), CommandError> {
- /// let device = nitrokey::connect()?;
- /// match device.build_aes_key("12345678") {
- /// Ok(()) => println!("New AES keys have been built."),
- /// Err(err) => println!("Could not build new AES keys: {}", err),
- /// };
- /// # Ok(())
- /// # }
- /// ```
- ///
- /// [`factory_reset`]: #method.factory_reset
- fn build_aes_key(&self, admin_pin: &str) -> Result<(), CommandError> {
- let admin_pin_string = get_cstring(admin_pin)?;
- unsafe { get_command_result(nitrokey_sys::NK_build_aes_key(admin_pin_string.as_ptr())) }
- }
-}
-
-/// Connects to a Nitrokey device. This method can be used to connect to any connected device,
-/// both a Nitrokey Pro and a Nitrokey Storage.
-///
-/// # Errors
-///
-/// - [`Undefined`][] if no Nitrokey device is connected
-///
-/// # Example
-///
-/// ```
-/// use nitrokey::DeviceWrapper;
-///
-/// fn do_something(device: DeviceWrapper) {}
-///
-/// match nitrokey::connect() {
-/// Ok(device) => do_something(device),
-/// Err(err) => println!("Could not connect to a Nitrokey: {}", err),
-/// }
-/// ```
-///
-/// [`Undefined`]: enum.CommandError.html#variant.Undefined
-pub fn connect() -> Result<DeviceWrapper, CommandError> {
- unsafe {
- match nitrokey_sys::NK_login_auto() {
- 1 => match get_connected_device() {
- Some(wrapper) => Ok(wrapper),
- None => Err(CommandError::Undefined),
- },
- _ => Err(CommandError::Undefined),
- }
- }
-}
-
-/// Connects to a Nitrokey device of the given model.
-///
-/// # Errors
-///
-/// - [`Undefined`][] if no Nitrokey device of the given model is connected
-///
-/// # Example
-///
-/// ```
-/// use nitrokey::DeviceWrapper;
-/// use nitrokey::Model;
-///
-/// fn do_something(device: DeviceWrapper) {}
-///
-/// match nitrokey::connect_model(Model::Pro) {
-/// Ok(device) => do_something(device),
-/// Err(err) => println!("Could not connect to a Nitrokey Pro: {}", err),
-/// }
-/// ```
-///
-/// [`Undefined`]: enum.CommandError.html#variant.Undefined
-pub fn connect_model(model: Model) -> Result<DeviceWrapper, CommandError> {
- if connect_enum(model) {
- Ok(create_device_wrapper(model))
- } else {
- Err(CommandError::Undefined)
- }
-}
-
-fn get_connected_model() -> Option<Model> {
- unsafe {
- match nitrokey_sys::NK_get_device_model() {
- nitrokey_sys::NK_device_model_NK_PRO => Some(Model::Pro),
- nitrokey_sys::NK_device_model_NK_STORAGE => Some(Model::Storage),
- _ => None,
- }
- }
-}
-
-fn create_device_wrapper(model: Model) -> DeviceWrapper {
- match model {
- Model::Pro => DeviceWrapper::Pro(Pro {}),
- Model::Storage => DeviceWrapper::Storage(Storage {}),
- }
-}
-
-fn get_connected_device() -> Option<DeviceWrapper> {
- get_connected_model().map(create_device_wrapper)
-}
-
-fn connect_enum(model: Model) -> bool {
- let model = match model {
- Model::Storage => nitrokey_sys::NK_device_model_NK_STORAGE,
- Model::Pro => nitrokey_sys::NK_device_model_NK_PRO,
- };
- unsafe { nitrokey_sys::NK_login_enum(model) == 1 }
-}
-
-impl DeviceWrapper {
- fn device(&self) -> &dyn Device {
- match *self {
- DeviceWrapper::Storage(ref storage) => storage,
- DeviceWrapper::Pro(ref pro) => pro,
- }
- }
-}
-
-impl GenerateOtp for DeviceWrapper {
- fn get_hotp_slot_name(&self, slot: u8) -> Result<String, CommandError> {
- self.device().get_hotp_slot_name(slot)
- }
-
- fn get_totp_slot_name(&self, slot: u8) -> Result<String, CommandError> {
- self.device().get_totp_slot_name(slot)
- }
-
- fn get_hotp_code(&self, slot: u8) -> Result<String, CommandError> {
- self.device().get_hotp_code(slot)
- }
-
- fn get_totp_code(&self, slot: u8) -> Result<String, CommandError> {
- self.device().get_totp_code(slot)
- }
-}
-
-impl Device for DeviceWrapper {
- fn get_model(&self) -> Model {
- match *self {
- DeviceWrapper::Pro(_) => Model::Pro,
- DeviceWrapper::Storage(_) => Model::Storage,
- }
- }
-}
-
-impl Pro {
- /// Connects to a Nitrokey Pro.
- ///
- /// # Errors
- ///
- /// - [`Undefined`][] if no Nitrokey device of the given model is connected
- ///
- /// # Example
- ///
- /// ```
- /// use nitrokey::Pro;
- ///
- /// fn use_pro(device: Pro) {}
- ///
- /// match nitrokey::Pro::connect() {
- /// Ok(device) => use_pro(device),
- /// Err(err) => println!("Could not connect to the Nitrokey Pro: {}", err),
- /// }
- /// ```
- ///
- /// [`Undefined`]: enum.CommandError.html#variant.Undefined
- pub fn connect() -> Result<Pro, CommandError> {
- // TODO: maybe Option instead of Result?
- match connect_enum(Model::Pro) {
- true => Ok(Pro {}),
- false => Err(CommandError::Undefined),
- }
- }
-}
-
-impl Drop for Pro {
- fn drop(&mut self) {
- unsafe {
- nitrokey_sys::NK_logout();
- }
- }
-}
-
-impl Device for Pro {
- fn get_model(&self) -> Model {
- Model::Pro
- }
-}
-
-impl GenerateOtp for Pro {}
-
-impl Storage {
- /// Connects to a Nitrokey Storage.
- ///
- /// # Errors
- ///
- /// - [`Undefined`][] if no Nitrokey device of the given model is connected
- ///
- /// # Example
- ///
- /// ```
- /// use nitrokey::Storage;
- ///
- /// fn use_storage(device: Storage) {}
- ///
- /// match nitrokey::Storage::connect() {
- /// Ok(device) => use_storage(device),
- /// Err(err) => println!("Could not connect to the Nitrokey Storage: {}", err),
- /// }
- /// ```
- ///
- /// [`Undefined`]: enum.CommandError.html#variant.Undefined
- pub fn connect() -> Result<Storage, CommandError> {
- // TODO: maybe Option instead of Result?
- match connect_enum(Model::Storage) {
- true => Ok(Storage {}),
- false => Err(CommandError::Undefined),
- }
- }
-
- /// Changes the update PIN.
- ///
- /// The update PIN is used to enable firmware updates. Unlike the user and the admin PIN, the
- /// update PIN is not managed by the OpenPGP smart card but by the Nitrokey firmware. There is
- /// no retry counter as with the other PIN types.
- ///
- /// # Errors
- ///
- /// - [`InvalidString`][] if one of the provided passwords contains a null byte
- /// - [`WrongPassword`][] if the current update password is wrong
- ///
- /// # Example
- ///
- /// ```no_run
- /// # use nitrokey::CommandError;
- ///
- /// # fn try_main() -> Result<(), CommandError> {
- /// let device = nitrokey::Storage::connect()?;
- /// match device.change_update_pin("12345678", "87654321") {
- /// Ok(()) => println!("Updated update PIN."),
- /// Err(err) => println!("Failed to update update PIN: {}", err),
- /// };
- /// # Ok(())
- /// # }
- /// ```
- ///
- /// [`InvalidString`]: enum.CommandError.html#variant.InvalidString
- /// [`WrongPassword`]: enum.CommandError.html#variant.WrongPassword
- pub fn change_update_pin(&self, current: &str, new: &str) -> Result<(), CommandError> {
- let current_string = get_cstring(current)?;
- let new_string = get_cstring(new)?;
- unsafe {
- get_command_result(nitrokey_sys::NK_change_update_password(
- current_string.as_ptr(),
- new_string.as_ptr(),
- ))
- }
- }
-
- /// Enables the firmware update mode.
- ///
- /// During firmware update mode, the Nitrokey can no longer be accessed using HID commands.
- /// To resume normal operation, run `dfu-programmer at32uc3a3256s launch`. In order to enter
- /// the firmware update mode, you need the update password that can be changed using the
- /// [`change_update_pin`][] method.
- ///
- /// # Errors
- ///
- /// - [`InvalidString`][] if one of the provided passwords contains a null byte
- /// - [`WrongPassword`][] if the current update password is wrong
- ///
- /// # Example
- ///
- /// ```no_run
- /// # use nitrokey::CommandError;
- ///
- /// # fn try_main() -> Result<(), CommandError> {
- /// let device = nitrokey::Storage::connect()?;
- /// match device.enable_firmware_update("12345678") {
- /// Ok(()) => println!("Nitrokey entered update mode."),
- /// Err(err) => println!("Could not enter update mode: {}", err),
- /// };
- /// # Ok(())
- /// # }
- /// ```
- ///
- /// [`InvalidString`]: enum.CommandError.html#variant.InvalidString
- /// [`WrongPassword`]: enum.CommandError.html#variant.WrongPassword
- pub fn enable_firmware_update(&self, update_pin: &str) -> Result<(), CommandError> {
- let update_pin_string = get_cstring(update_pin)?;
- unsafe {
- get_command_result(nitrokey_sys::NK_enable_firmware_update(
- update_pin_string.as_ptr(),
- ))
- }
- }
-
- /// Enables the encrypted storage volume.
- ///
- /// Once the encrypted volume is enabled, it is presented to the operating system as a block
- /// device. The API does not provide any information on the name or path of this block device.
- ///
- /// # Errors
- ///
- /// - [`InvalidString`][] if the provided password contains a null byte
- /// - [`WrongPassword`][] if the provided user password is wrong
- ///
- /// # Example
- ///
- /// ```no_run
- /// # use nitrokey::CommandError;
- ///
- /// # fn try_main() -> Result<(), CommandError> {
- /// let device = nitrokey::Storage::connect()?;
- /// match device.enable_encrypted_volume("123456") {
- /// Ok(()) => println!("Enabled the encrypted volume."),
- /// Err(err) => println!("Could not enable the encrypted volume: {}", err),
- /// };
- /// # Ok(())
- /// # }
- /// ```
- ///
- /// [`InvalidString`]: enum.CommandError.html#variant.InvalidString
- /// [`WrongPassword`]: enum.CommandError.html#variant.WrongPassword
- pub fn enable_encrypted_volume(&self, user_pin: &str) -> Result<(), CommandError> {
- let user_pin = get_cstring(user_pin)?;
- unsafe { get_command_result(nitrokey_sys::NK_unlock_encrypted_volume(user_pin.as_ptr())) }
- }
-
- /// Disables the encrypted storage volume.
- ///
- /// Once the volume is disabled, it can be no longer accessed as a block device. If the
- /// encrypted volume has not been enabled, this method still returns a success.
- ///
- /// # Example
- ///
- /// ```no_run
- /// # use nitrokey::CommandError;
- ///
- /// fn use_volume() {}
- ///
- /// # fn try_main() -> Result<(), CommandError> {
- /// let device = nitrokey::Storage::connect()?;
- /// match device.enable_encrypted_volume("123456") {
- /// Ok(()) => {
- /// println!("Enabled the encrypted volume.");
- /// use_volume();
- /// match device.disable_encrypted_volume() {
- /// Ok(()) => println!("Disabled the encrypted volume."),
- /// Err(err) => {
- /// println!("Could not disable the encrypted volume: {}", err);
- /// },
- /// };
- /// },
- /// Err(err) => println!("Could not enable the encrypted volume: {}", err),
- /// };
- /// # Ok(())
- /// # }
- /// ```
- pub fn disable_encrypted_volume(&self) -> Result<(), CommandError> {
- unsafe { get_command_result(nitrokey_sys::NK_lock_encrypted_volume()) }
- }
-
- /// Enables a hidden storage volume.
- ///
- /// This function will only succeed if the encrypted storage ([`enable_encrypted_volume`][]) or
- /// another hidden volume has been enabled previously. Once the hidden volume is enabled, it
- /// is presented to the operating system as a block device and any previously opened encrypted
- /// or hidden volumes are closed. The API does not provide any information on the name or path
- /// of this block device.
- ///
- /// Note that the encrypted and the hidden volumes operate on the same storage area, so using
- /// both at the same time might lead to data loss.
- ///
- /// The hidden volume to unlock is selected based on the provided password.
- ///
- /// # Errors
- ///
- /// - [`AesDecryptionFailed`][] if the encrypted storage has not been opened before calling
- /// this method or the AES key has not been built
- /// - [`InvalidString`][] if the provided password contains a null byte
- ///
- /// # Example
- ///
- /// ```no_run
- /// # use nitrokey::CommandError;
- ///
- /// # fn try_main() -> Result<(), CommandError> {
- /// let device = nitrokey::Storage::connect()?;
- /// device.enable_encrypted_volume("123445")?;
- /// match device.enable_hidden_volume("hidden-pw") {
- /// Ok(()) => println!("Enabled a hidden volume."),
- /// Err(err) => println!("Could not enable the hidden volume: {}", err),
- /// };
- /// # Ok(())
- /// # }
- /// ```
- ///
- /// [`enable_encrypted_volume`]: #method.enable_encrypted_volume
- /// [`AesDecryptionFailed`]: enum.CommandError.html#variant.AesDecryptionFailed
- /// [`InvalidString`]: enum.CommandError.html#variant.InvalidString
- pub fn enable_hidden_volume(&self, volume_password: &str) -> Result<(), CommandError> {
- let volume_password = get_cstring(volume_password)?;
- unsafe {
- get_command_result(nitrokey_sys::NK_unlock_hidden_volume(
- volume_password.as_ptr(),
- ))
- }
- }
-
- /// Disables a hidden storage volume.
- ///
- /// Once the volume is disabled, it can be no longer accessed as a block device. If no hidden
- /// volume has been enabled, this method still returns a success.
- ///
- /// # Example
- ///
- /// ```no_run
- /// # use nitrokey::CommandError;
- ///
- /// fn use_volume() {}
- ///
- /// # fn try_main() -> Result<(), CommandError> {
- /// let device = nitrokey::Storage::connect()?;
- /// device.enable_encrypted_volume("123445")?;
- /// match device.enable_hidden_volume("hidden-pw") {
- /// Ok(()) => {
- /// println!("Enabled the hidden volume.");
- /// use_volume();
- /// match device.disable_hidden_volume() {
- /// Ok(()) => println!("Disabled the hidden volume."),
- /// Err(err) => {
- /// println!("Could not disable the hidden volume: {}", err);
- /// },
- /// };
- /// },
- /// Err(err) => println!("Could not enable the hidden volume: {}", err),
- /// };
- /// # Ok(())
- /// # }
- /// ```
- pub fn disable_hidden_volume(&self) -> Result<(), CommandError> {
- unsafe { get_command_result(nitrokey_sys::NK_lock_hidden_volume()) }
- }
-
- /// Creates a hidden volume.
- ///
- /// The volume is crated in the given slot and in the given range of the available memory,
- /// where `start` is the start position as a percentage of the available memory, and `end` is
- /// the end position as a percentage of the available memory. The volume will be protected by
- /// the given password.
- ///
- /// Note that the encrypted and the hidden volumes operate on the same storage area, so using
- /// both at the same time might lead to data loss.
- ///
- /// According to the libnitrokey documentation, this function only works if the encrypted
- /// storage has been opened.
- ///
- /// # Errors
- ///
- /// - [`AesDecryptionFailed`][] if the encrypted storage has not been opened before calling
- /// this method or the AES key has not been built
- /// - [`InvalidString`][] if the provided password contains a null byte
- ///
- /// # Example
- ///
- /// ```no_run
- /// # use nitrokey::CommandError;
- ///
- /// # fn try_main() -> Result<(), CommandError> {
- /// let device = nitrokey::Storage::connect()?;
- /// device.enable_encrypted_volume("123445")?;
- /// device.create_hidden_volume(0, 0, 100, "hidden-pw")?;
- /// # Ok(())
- /// # }
- /// ```
- ///
- /// [`AesDecryptionFailed`]: enum.CommandError.html#variant.AesDecryptionFailed
- /// [`InvalidString`]: enum.CommandError.html#variant.InvalidString
- pub fn create_hidden_volume(
- &self,
- slot: u8,
- start: u8,
- end: u8,
- password: &str,
- ) -> Result<(), CommandError> {
- let password = get_cstring(password)?;
- unsafe {
- get_command_result(nitrokey_sys::NK_create_hidden_volume(
- slot,
- start,
- end,
- password.as_ptr(),
- ))
- }
- }
-
- /// Sets the access mode of the unencrypted volume.
- ///
- /// This command will reconnect the unencrypted volume so buffers should be flushed before
- /// calling it. Since firmware version v0.51, this command requires the admin PIN. Older
- /// firmware versions are not supported.
- ///
- /// # Errors
- ///
- /// - [`InvalidString`][] if the provided password contains a null byte
- /// - [`WrongPassword`][] if the provided admin password is wrong
- ///
- /// # Example
- ///
- /// ```no_run
- /// # use nitrokey::CommandError;
- /// use nitrokey::VolumeMode;
- ///
- /// # fn try_main() -> Result<(), CommandError> {
- /// let device = nitrokey::Storage::connect()?;
- /// match device.set_unencrypted_volume_mode("123456", VolumeMode::ReadWrite) {
- /// Ok(()) => println!("Set the unencrypted volume to read-write mode."),
- /// Err(err) => println!("Could not set the unencrypted volume to read-write mode: {}", err),
- /// };
- /// # Ok(())
- /// # }
- /// ```
- ///
- /// [`InvalidString`]: enum.CommandError.html#variant.InvalidString
- /// [`WrongPassword`]: enum.CommandError.html#variant.WrongPassword
- pub fn set_unencrypted_volume_mode(
- &self,
- admin_pin: &str,
- mode: VolumeMode,
- ) -> Result<(), CommandError> {
- let admin_pin = get_cstring(admin_pin)?;
- let result = match mode {
- VolumeMode::ReadOnly => unsafe {
- nitrokey_sys::NK_set_unencrypted_read_only_admin(admin_pin.as_ptr())
- },
- VolumeMode::ReadWrite => unsafe {
- nitrokey_sys::NK_set_unencrypted_read_write_admin(admin_pin.as_ptr())
- },
- };
- get_command_result(result)
- }
-
- /// Returns the status of the connected storage device.
- ///
- /// # Example
- ///
- /// ```no_run
- /// # use nitrokey::CommandError;
- ///
- /// fn use_volume() {}
- ///
- /// # fn try_main() -> Result<(), CommandError> {
- /// let device = nitrokey::Storage::connect()?;
- /// match device.get_status() {
- /// Ok(status) => {
- /// println!("SD card ID: {:#x}", status.serial_number_sd_card);
- /// },
- /// Err(err) => println!("Could not get Storage status: {}", err),
- /// };
- /// # Ok(())
- /// # }
- /// ```
- pub fn get_status(&self) -> Result<StorageStatus, CommandError> {
- let mut raw_status = nitrokey_sys::NK_storage_status {
- unencrypted_volume_read_only: false,
- unencrypted_volume_active: false,
- encrypted_volume_read_only: false,
- encrypted_volume_active: false,
- hidden_volume_read_only: false,
- hidden_volume_active: false,
- firmware_version_major: 0,
- firmware_version_minor: 0,
- firmware_locked: false,
- serial_number_sd_card: 0,
- serial_number_smart_card: 0,
- user_retry_count: 0,
- admin_retry_count: 0,
- new_sd_card_found: false,
- filled_with_random: false,
- stick_initialized: false,
- };
- let raw_result = unsafe { nitrokey_sys::NK_get_status_storage(&mut raw_status) };
- let result = get_command_result(raw_result);
- result.and(Ok(StorageStatus::from(raw_status)))
- }
-
- /// Returns the production information for the connected storage device.
- ///
- /// # Example
- ///
- /// ```no_run
- /// # use nitrokey::CommandError;
- ///
- /// fn use_volume() {}
- ///
- /// # fn try_main() -> Result<(), CommandError> {
- /// let device = nitrokey::Storage::connect()?;
- /// match device.get_production_info() {
- /// Ok(data) => {
- /// println!("SD card ID: {:#x}", data.sd_card.serial_number);
- /// println!("SD card size: {} GB", data.sd_card.size);
- /// },
- /// Err(err) => println!("Could not get Storage production info: {}", err),
- /// };
- /// # Ok(())
- /// # }
- /// ```
- pub fn get_production_info(&self) -> Result<StorageProductionInfo, CommandError> {
- let mut raw_data = nitrokey_sys::NK_storage_ProductionTest {
- FirmwareVersion_au8: [0, 2],
- FirmwareVersionInternal_u8: 0,
- SD_Card_Size_u8: 0,
- CPU_CardID_u32: 0,
- SmartCardID_u32: 0,
- SD_CardID_u32: 0,
- SC_UserPwRetryCount: 0,
- SC_AdminPwRetryCount: 0,
- SD_Card_ManufacturingYear_u8: 0,
- SD_Card_ManufacturingMonth_u8: 0,
- SD_Card_OEM_u16: 0,
- SD_WriteSpeed_u16: 0,
- SD_Card_Manufacturer_u8: 0,
- };
- let raw_result = unsafe { nitrokey_sys::NK_get_storage_production_info(&mut raw_data) };
- let result = get_command_result(raw_result);
- result.and(Ok(StorageProductionInfo::from(raw_data)))
- }
-
- /// Clears the warning for a new SD card.
- ///
- /// The Storage status contains a field for a new SD card warning. After a factory reset, the
- /// field is set to true. After filling the SD card with random data, it is set to false.
- /// This method can be used to set it to false without filling the SD card with random data.
- ///
- /// # Errors
- ///
- /// - [`InvalidString`][] if the provided password contains a null byte
- /// - [`WrongPassword`][] if the provided admin password is wrong
- ///
- /// # Example
- ///
- /// ```no_run
- /// # use nitrokey::CommandError;
- ///
- /// # fn try_main() -> Result<(), CommandError> {
- /// let device = nitrokey::Storage::connect()?;
- /// match device.clear_new_sd_card_warning("12345678") {
- /// Ok(()) => println!("Cleared the new SD card warning."),
- /// Err(err) => println!("Could not set the clear the new SD card warning: {}", err),
- /// };
- /// # Ok(())
- /// # }
- /// ```
- ///
- /// [`InvalidString`]: enum.CommandError.html#variant.InvalidString
- /// [`WrongPassword`]: enum.CommandError.html#variant.WrongPassword
- pub fn clear_new_sd_card_warning(&self, admin_pin: &str) -> Result<(), CommandError> {
- let admin_pin = get_cstring(admin_pin)?;
- get_command_result(unsafe {
- nitrokey_sys::NK_clear_new_sd_card_warning(admin_pin.as_ptr())
- })
- }
-
- /// Blinks the red and green LED alternatively and infinitely until the device is reconnected.
- pub fn wink(&self) -> Result<(), CommandError> {
- get_command_result(unsafe { nitrokey_sys::NK_wink() })
- }
-
- /// Exports the firmware to the unencrypted volume.
- ///
- /// This command requires the admin PIN. The unencrypted volume must be in read-write mode
- /// when this command is executed. Otherwise, it will still return `Ok` but not write the
- /// firmware.
- ///
- /// This command unmounts the unencrypted volume if it has been mounted, so all buffers should
- /// be flushed. The firmware is written to the `firmware.bin` file on the unencrypted volume.
- ///
- /// # Errors
- ///
- /// - [`InvalidString`][] if one of the provided passwords contains a null byte
- /// - [`WrongPassword`][] if the admin password is wrong
- ///
- /// [`InvalidString`]: enum.CommandError.html#variant.InvalidString
- /// [`WrongPassword`]: enum.CommandError.html#variant.WrongPassword
- pub fn export_firmware(&self, admin_pin: &str) -> Result<(), CommandError> {
- let admin_pin_string = get_cstring(admin_pin)?;
- get_command_result(unsafe { nitrokey_sys::NK_export_firmware(admin_pin_string.as_ptr()) })
- }
-}
-
-impl Drop for Storage {
- fn drop(&mut self) {
- unsafe {
- nitrokey_sys::NK_logout();
- }
- }
-}
-
-impl Device for Storage {
- fn get_model(&self) -> Model {
- Model::Storage
- }
-}
-
-impl GenerateOtp for Storage {}
-
-impl From<nitrokey_sys::NK_storage_ProductionTest> for StorageProductionInfo {
- fn from(data: nitrokey_sys::NK_storage_ProductionTest) -> Self {
- Self {
- firmware_version_major: data.FirmwareVersion_au8[0],
- firmware_version_minor: data.FirmwareVersion_au8[1],
- firmware_version_internal: data.FirmwareVersionInternal_u8,
- serial_number_cpu: data.CPU_CardID_u32,
- sd_card: SdCardData {
- serial_number: data.SD_CardID_u32,
- size: data.SD_Card_Size_u8,
- manufacturing_year: data.SD_Card_ManufacturingYear_u8,
- manufacturing_month: data.SD_Card_ManufacturingMonth_u8,
- oem: data.SD_Card_OEM_u16,
- manufacturer: data.SD_Card_Manufacturer_u8,
- },
- }
- }
-}
-
-impl From<nitrokey_sys::NK_storage_status> for StorageStatus {
- fn from(status: nitrokey_sys::NK_storage_status) -> Self {
- StorageStatus {
- unencrypted_volume: VolumeStatus {
- read_only: status.unencrypted_volume_read_only,
- active: status.unencrypted_volume_active,
- },
- encrypted_volume: VolumeStatus {
- read_only: status.encrypted_volume_read_only,
- active: status.encrypted_volume_active,
- },
- hidden_volume: VolumeStatus {
- read_only: status.hidden_volume_read_only,
- active: status.hidden_volume_active,
- },
- firmware_version_major: status.firmware_version_major,
- firmware_version_minor: status.firmware_version_minor,
- firmware_locked: status.firmware_locked,
- serial_number_sd_card: status.serial_number_sd_card,
- serial_number_smart_card: status.serial_number_smart_card,
- user_retry_count: status.user_retry_count,
- admin_retry_count: status.admin_retry_count,
- new_sd_card_found: status.new_sd_card_found,
- filled_with_random: status.filled_with_random,
- stick_initialized: status.stick_initialized,
- }
- }
-}
diff --git a/nitrokey/src/lib.rs b/nitrokey/src/lib.rs
deleted file mode 100644
index 02a622b..0000000
--- a/nitrokey/src/lib.rs
+++ /dev/null
@@ -1,169 +0,0 @@
-//! Provides access to a Nitrokey device using the native libnitrokey API.
-//!
-//! # Usage
-//!
-//! Operations on the Nitrokey require different authentication levels. Some operations can be
-//! performed without authentication, some require user access, and some require admin access.
-//! This is modelled using the types [`User`][] and [`Admin`][].
-//!
-//! Use [`connect`][] to connect to any Nitrokey device. The method will return a
-//! [`DeviceWrapper`][] that abstracts over the supported Nitrokey devices. You can also use
-//! [`Pro::connect`][] or [`Storage::connect`][] to connect to a specific device.
-//!
-//! You can then use [`authenticate_user`][] or [`authenticate_admin`][] to get an authenticated
-//! device that can perform operations that require authentication. You can use [`device`][] to go
-//! back to the unauthenticated device.
-//!
-//! This makes sure that you can only execute a command if you have the required access rights.
-//! Otherwise, your code will not compile. The only exception are the methods to generate one-time
-//! passwords – [`get_hotp_code`][] and [`get_totp_code`][]. Depending on the stick configuration,
-//! these operations are available without authentication or with user authentication.
-//!
-//! # Examples
-//!
-//! Connect to any Nitrokey and print its serial number:
-//!
-//! ```no_run
-//! use nitrokey::Device;
-//! # use nitrokey::CommandError;
-//!
-//! # fn try_main() -> Result<(), CommandError> {
-//! let device = nitrokey::connect()?;
-//! println!("{}", device.get_serial_number()?);
-//! # Ok(())
-//! # }
-//! ```
-//!
-//! Configure an HOTP slot:
-//!
-//! ```no_run
-//! use nitrokey::{Authenticate, ConfigureOtp, OtpMode, OtpSlotData};
-//! # use nitrokey::CommandError;
-//!
-//! # fn try_main() -> Result<(), (CommandError)> {
-//! let device = nitrokey::connect()?;
-//! let slot_data = OtpSlotData::new(1, "test", "01234567890123456689", OtpMode::SixDigits);
-//! match device.authenticate_admin("12345678") {
-//! Ok(admin) => {
-//! match admin.write_hotp_slot(slot_data, 0) {
-//! Ok(()) => println!("Successfully wrote slot."),
-//! Err(err) => println!("Could not write slot: {}", err),
-//! }
-//! },
-//! Err((_, err)) => println!("Could not authenticate as admin: {}", err),
-//! }
-//! # Ok(())
-//! # }
-//! ```
-//!
-//! Generate an HOTP one-time password:
-//!
-//! ```no_run
-//! use nitrokey::{Device, GenerateOtp};
-//! # use nitrokey::CommandError;
-//!
-//! # fn try_main() -> Result<(), (CommandError)> {
-//! let device = nitrokey::connect()?;
-//! match device.get_hotp_code(1) {
-//! Ok(code) => println!("Generated HOTP code: {}", code),
-//! Err(err) => println!("Could not generate HOTP code: {}", err),
-//! }
-//! # Ok(())
-//! # }
-//! ```
-//!
-//! [`authenticate_admin`]: trait.Authenticate.html#method.authenticate_admin
-//! [`authenticate_user`]: trait.Authenticate.html#method.authenticate_user
-//! [`connect`]: fn.connect.html
-//! [`Pro::connect`]: struct.Pro.html#fn.connect.html
-//! [`Storage::connect`]: struct.Storage.html#fn.connect.html
-//! [`device`]: struct.User.html#method.device
-//! [`get_hotp_code`]: trait.GenerateOtp.html#method.get_hotp_code
-//! [`get_totp_code`]: trait.GenerateOtp.html#method.get_totp_code
-//! [`Admin`]: struct.Admin.html
-//! [`DeviceWrapper`]: enum.DeviceWrapper.html
-//! [`User`]: struct.User.html
-
-#![warn(missing_docs, rust_2018_compatibility, rust_2018_idioms, unused)]
-
-mod auth;
-mod config;
-mod device;
-mod otp;
-mod pws;
-mod util;
-
-use nitrokey_sys;
-
-pub use crate::auth::{Admin, Authenticate, User};
-pub use crate::config::Config;
-pub use crate::device::{
- connect, connect_model, Device, DeviceWrapper, Model, Pro, SdCardData, Storage,
- StorageProductionInfo, StorageStatus, VolumeMode, VolumeStatus,
-};
-pub use crate::otp::{ConfigureOtp, GenerateOtp, OtpMode, OtpSlotData};
-pub use crate::pws::{GetPasswordSafe, PasswordSafe, SLOT_COUNT};
-pub use crate::util::{CommandError, LogLevel};
-
-/// A version of the libnitrokey library.
-///
-/// Use the [`get_library_version`](fn.get_library_version.html) function to query the library
-/// version.
-#[derive(Clone, Debug, PartialEq)]
-pub struct Version {
- /// The Git library version as a string.
- ///
- /// The library version is the output of `git describe --always` at compile time, for example
- /// `v3.3` or `v3.4.1`. If the library has not been built from a release, the version string
- /// contains the number of commits since the last release and the hash of the current commit, for
- /// example `v3.3-19-gaee920b`. If the library has not been built from a Git checkout, this
- /// string may be empty.
- pub git: String,
- /// The major library version.
- pub major: u32,
- /// The minor library version.
- pub minor: u32,
-}
-
-/// Enables or disables debug output. Calling this method with `true` is equivalent to setting the
-/// log level to `Debug`; calling it with `false` is equivalent to the log level `Error` (see
-/// [`set_log_level`][]).
-///
-/// If debug output is enabled, detailed information about the communication with the Nitrokey
-/// device is printed to the standard output.
-///
-/// [`set_log_level`]: fn.set_log_level.html
-pub fn set_debug(state: bool) {
- unsafe {
- nitrokey_sys::NK_set_debug(state);
- }
-}
-
-/// Sets the log level for libnitrokey. All log messages are written to the standard error stream.
-/// Setting the log level enables all log messages on the same or on a higher log level.
-pub fn set_log_level(level: LogLevel) {
- unsafe {
- nitrokey_sys::NK_set_debug_level(level.into());
- }
-}
-
-/// Returns the libnitrokey library version.
-///
-/// # Example
-///
-/// ```
-/// let version = nitrokey::get_library_version();
-/// println!("Using libnitrokey {}", version.git);
-/// ```
-pub fn get_library_version() -> Version {
- // NK_get_library_version returns a static string, so we don’t have to free the pointer.
- let git = unsafe { nitrokey_sys::NK_get_library_version() };
- let git = if git.is_null() {
- String::new()
- } else {
- util::owned_str_from_ptr(git)
- };
- let major = unsafe { nitrokey_sys::NK_get_major_library_version() };
- let minor = unsafe { nitrokey_sys::NK_get_minor_library_version() };
- Version { git, major, minor }
-}
diff --git a/nitrokey/src/otp.rs b/nitrokey/src/otp.rs
deleted file mode 100644
index 901bef9..0000000
--- a/nitrokey/src/otp.rs
+++ /dev/null
@@ -1,414 +0,0 @@
-use std::ffi::CString;
-
-use nitrokey_sys;
-
-use crate::util::{get_command_result, get_cstring, result_from_string, CommandError};
-
-/// Modes for one-time password generation.
-#[derive(Clone, Copy, Debug, PartialEq)]
-pub enum OtpMode {
- /// Generate one-time passwords with six digits.
- SixDigits,
- /// Generate one-time passwords with eight digits.
- EightDigits,
-}
-
-/// Provides methods to configure and erase OTP slots on a Nitrokey device.
-pub trait ConfigureOtp {
- /// Configure an HOTP slot with the given data and set the HOTP counter to the given value
- /// (default 0).
- ///
- /// # Errors
- ///
- /// - [`InvalidSlot`][] if there is no slot with the given number
- /// - [`InvalidString`][] if the provided token ID contains a null byte
- /// - [`NoName`][] if the provided name is empty
- ///
- /// # Example
- ///
- /// ```no_run
- /// use nitrokey::{Authenticate, ConfigureOtp, OtpMode, OtpSlotData};
- /// # use nitrokey::CommandError;
- ///
- /// # fn try_main() -> Result<(), (CommandError)> {
- /// let device = nitrokey::connect()?;
- /// let slot_data = OtpSlotData::new(1, "test", "01234567890123456689", OtpMode::SixDigits);
- /// match device.authenticate_admin("12345678") {
- /// Ok(admin) => {
- /// match admin.write_hotp_slot(slot_data, 0) {
- /// Ok(()) => println!("Successfully wrote slot."),
- /// Err(err) => println!("Could not write slot: {}", err),
- /// }
- /// },
- /// Err((_, err)) => println!("Could not authenticate as admin: {}", err),
- /// }
- /// # Ok(())
- /// # }
- /// ```
- ///
- /// [`InvalidSlot`]: enum.CommandError.html#variant.InvalidSlot
- /// [`InvalidString`]: enum.CommandError.html#variant.InvalidString
- /// [`NoName`]: enum.CommandError.html#variant.NoName
- fn write_hotp_slot(&self, data: OtpSlotData, counter: u64) -> Result<(), CommandError>;
-
- /// Configure a TOTP slot with the given data and set the TOTP time window to the given value
- /// (default 30).
- ///
- /// # Errors
- ///
- /// - [`InvalidSlot`][] if there is no slot with the given number
- /// - [`InvalidString`][] if the provided token ID contains a null byte
- /// - [`NoName`][] if the provided name is empty
- ///
- /// # Example
- ///
- /// ```no_run
- /// use nitrokey::{Authenticate, ConfigureOtp, OtpMode, OtpSlotData};
- /// # use nitrokey::CommandError;
- ///
- /// # fn try_main() -> Result<(), (CommandError)> {
- /// let device = nitrokey::connect()?;
- /// let slot_data = OtpSlotData::new(1, "test", "01234567890123456689", OtpMode::EightDigits);
- /// match device.authenticate_admin("12345678") {
- /// Ok(admin) => {
- /// match admin.write_totp_slot(slot_data, 30) {
- /// Ok(()) => println!("Successfully wrote slot."),
- /// Err(err) => println!("Could not write slot: {}", err),
- /// }
- /// },
- /// Err((_, err)) => println!("Could not authenticate as admin: {}", err),
- /// }
- /// # Ok(())
- /// # }
- /// ```
- ///
- /// [`InvalidSlot`]: enum.CommandError.html#variant.InvalidSlot
- /// [`InvalidString`]: enum.CommandError.html#variant.InvalidString
- /// [`NoName`]: enum.CommandError.html#variant.NoName
- fn write_totp_slot(&self, data: OtpSlotData, time_window: u16) -> Result<(), CommandError>;
-
- /// Erases an HOTP slot.
- ///
- /// # Errors
- ///
- /// - [`InvalidSlot`][] if there is no slot with the given number
- ///
- /// # Example
- ///
- /// ```no_run
- /// use nitrokey::{Authenticate, ConfigureOtp};
- /// # use nitrokey::CommandError;
- ///
- /// # fn try_main() -> Result<(), (CommandError)> {
- /// let device = nitrokey::connect()?;
- /// match device.authenticate_admin("12345678") {
- /// Ok(admin) => {
- /// match admin.erase_hotp_slot(1) {
- /// Ok(()) => println!("Successfully erased slot."),
- /// Err(err) => println!("Could not erase slot: {}", err),
- /// }
- /// },
- /// Err((_, err)) => println!("Could not authenticate as admin: {}", err),
- /// }
- /// # Ok(())
- /// # }
- /// ```
- ///
- /// [`InvalidSlot`]: enum.CommandError.html#variant.InvalidSlot
- fn erase_hotp_slot(&self, slot: u8) -> Result<(), CommandError>;
-
- /// Erases a TOTP slot.
- ///
- /// # Errors
- ///
- /// - [`InvalidSlot`][] if there is no slot with the given number
- ///
- /// # Example
- ///
- /// ```no_run
- /// use nitrokey::{Authenticate, ConfigureOtp};
- /// # use nitrokey::CommandError;
- ///
- /// # fn try_main() -> Result<(), (CommandError)> {
- /// let device = nitrokey::connect()?;
- /// match device.authenticate_admin("12345678") {
- /// Ok(admin) => {
- /// match admin.erase_totp_slot(1) {
- /// Ok(()) => println!("Successfully erased slot."),
- /// Err(err) => println!("Could not erase slot: {}", err),
- /// }
- /// },
- /// Err((_, err)) => println!("Could not authenticate as admin: {}", err),
- /// }
- /// # Ok(())
- /// # }
- /// ```
- ///
- /// [`InvalidSlot`]: enum.CommandError.html#variant.InvalidSlot
- fn erase_totp_slot(&self, slot: u8) -> Result<(), CommandError>;
-}
-
-/// Provides methods to generate OTP codes and to query OTP slots on a Nitrokey
-/// device.
-pub trait GenerateOtp {
- /// Sets the time on the Nitrokey.
- ///
- /// `time` is the number of seconds since January 1st, 1970 (Unix timestamp). Unless `force`
- /// is set to `true`, this command fails if the timestamp on the device is larger than the
- /// given timestamp or if it is zero.
- ///
- /// The time is used for TOTP generation (see [`get_totp_code`][]).
- ///
- /// # Example
- ///
- /// ```no_run
- /// use std::time;
- /// use nitrokey::GenerateOtp;
- /// # use nitrokey::CommandError;
- ///
- /// # fn try_main() -> Result<(), CommandError> {
- /// let device = nitrokey::connect()?;
- /// let time = time::SystemTime::now().duration_since(time::UNIX_EPOCH);
- /// match time {
- /// Ok(time) => device.set_time(time.as_secs(), false)?,
- /// Err(_) => println!("The system time is before the Unix epoch!"),
- /// }
- /// # Ok(())
- /// # }
- /// ```
- ///
- /// # Errors
- ///
- /// - [`Timestamp`][] if the time could not be set
- ///
- /// [`get_totp_code`]: #method.get_totp_code
- /// [`Timestamp`]: enum.CommandError.html#variant.Timestamp
- fn set_time(&self, time: u64, force: bool) -> Result<(), CommandError> {
- let result = if force {
- unsafe { nitrokey_sys::NK_totp_set_time(time) }
- } else {
- unsafe { nitrokey_sys::NK_totp_set_time_soft(time) }
- };
- get_command_result(result)
- }
-
- /// Returns the name of the given HOTP slot.
- ///
- /// # Errors
- ///
- /// - [`InvalidSlot`][] if there is no slot with the given number
- /// - [`SlotNotProgrammed`][] if the given slot is not configured
- ///
- /// # Example
- ///
- /// ```no_run
- /// use nitrokey::{CommandError, GenerateOtp};
- ///
- /// # fn try_main() -> Result<(), CommandError> {
- /// let device = nitrokey::connect()?;
- /// match device.get_hotp_slot_name(1) {
- /// Ok(name) => println!("HOTP slot 1: {}", name),
- /// Err(CommandError::SlotNotProgrammed) => println!("HOTP slot 1 not programmed"),
- /// Err(err) => println!("Could not get slot name: {}", err),
- /// };
- /// # Ok(())
- /// # }
- /// ```
- ///
- /// [`InvalidSlot`]: enum.CommandError.html#variant.InvalidSlot
- /// [`SlotNotProgrammed`]: enum.CommandError.html#variant.SlotNotProgrammed
- fn get_hotp_slot_name(&self, slot: u8) -> Result<String, CommandError> {
- unsafe { result_from_string(nitrokey_sys::NK_get_hotp_slot_name(slot)) }
- }
-
- /// Returns the name of the given TOTP slot.
- ///
- /// # Errors
- ///
- /// - [`InvalidSlot`][] if there is no slot with the given number
- /// - [`SlotNotProgrammed`][] if the given slot is not configured
- ///
- /// # Example
- ///
- /// ```no_run
- /// use nitrokey::{CommandError, GenerateOtp};
- ///
- /// # fn try_main() -> Result<(), CommandError> {
- /// let device = nitrokey::connect()?;
- /// match device.get_totp_slot_name(1) {
- /// Ok(name) => println!("TOTP slot 1: {}", name),
- /// Err(CommandError::SlotNotProgrammed) => println!("TOTP slot 1 not programmed"),
- /// Err(err) => println!("Could not get slot name: {}", err),
- /// };
- /// # Ok(())
- /// # }
- /// ```
- ///
- /// [`InvalidSlot`]: enum.CommandError.html#variant.InvalidSlot
- /// [`SlotNotProgrammed`]: enum.CommandError.html#variant.SlotNotProgrammed
- fn get_totp_slot_name(&self, slot: u8) -> Result<String, CommandError> {
- unsafe { result_from_string(nitrokey_sys::NK_get_totp_slot_name(slot)) }
- }
-
- /// Generates an HOTP code on the given slot. This operation may require user authorization,
- /// depending on the device configuration (see [`get_config`][]).
- ///
- /// # Errors
- ///
- /// - [`InvalidSlot`][] if there is no slot with the given number
- /// - [`NotAuthorized`][] if OTP generation requires user authentication
- /// - [`SlotNotProgrammed`][] if the given slot is not configured
- ///
- /// # Example
- ///
- /// ```no_run
- /// use nitrokey::GenerateOtp;
- /// # use nitrokey::CommandError;
- ///
- /// # fn try_main() -> Result<(), CommandError> {
- /// let device = nitrokey::connect()?;
- /// let code = device.get_hotp_code(1)?;
- /// println!("Generated HOTP code on slot 1: {}", code);
- /// # Ok(())
- /// # }
- /// ```
- ///
- /// [`get_config`]: trait.Device.html#method.get_config
- /// [`InvalidSlot`]: enum.CommandError.html#variant.InvalidSlot
- /// [`NotAuthorized`]: enum.CommandError.html#variant.NotAuthorized
- /// [`SlotNotProgrammed`]: enum.CommandError.html#variant.SlotNotProgrammed
- fn get_hotp_code(&self, slot: u8) -> Result<String, CommandError> {
- unsafe {
- return result_from_string(nitrokey_sys::NK_get_hotp_code(slot));
- }
- }
-
- /// Generates a TOTP code on the given slot. This operation may require user authorization,
- /// depending on the device configuration (see [`get_config`][]).
- ///
- /// To make sure that the Nitrokey’s time is in sync, consider calling [`set_time`][] before
- /// calling this method.
- ///
- /// # Errors
- ///
- /// - [`InvalidSlot`][] if there is no slot with the given number
- /// - [`NotAuthorized`][] if OTP generation requires user authentication
- /// - [`SlotNotProgrammed`][] if the given slot is not configured
- ///
- /// # Example
- ///
- /// ```no_run
- /// use std::time;
- /// use nitrokey::GenerateOtp;
- /// # use nitrokey::CommandError;
- ///
- /// # fn try_main() -> Result<(), CommandError> {
- /// let device = nitrokey::connect()?;
- /// let time = time::SystemTime::now().duration_since(time::UNIX_EPOCH);
- /// match time {
- /// Ok(time) => {
- /// device.set_time(time.as_secs(), false)?;
- /// let code = device.get_totp_code(1)?;
- /// println!("Generated TOTP code on slot 1: {}", code);
- /// },
- /// Err(_) => println!("Timestamps before 1970-01-01 are not supported!"),
- /// }
- /// # Ok(())
- /// # }
- /// ```
- ///
- /// [`set_time`]: #method.set_time
- /// [`get_config`]: trait.Device.html#method.get_config
- /// [`InvalidSlot`]: enum.CommandError.html#variant.InvalidSlot
- /// [`NotAuthorized`]: enum.CommandError.html#variant.NotAuthorized
- /// [`SlotNotProgrammed`]: enum.CommandError.html#variant.SlotNotProgrammed
- fn get_totp_code(&self, slot: u8) -> Result<String, CommandError> {
- unsafe {
- return result_from_string(nitrokey_sys::NK_get_totp_code(slot, 0, 0, 0));
- }
- }
-}
-
-/// The configuration for an OTP slot.
-#[derive(Debug)]
-pub struct OtpSlotData {
- /// The number of the slot – must be less than three for HOTP and less than 15 for TOTP.
- pub number: u8,
- /// The name of the slot – must not be empty.
- pub name: String,
- /// The secret for the slot.
- pub secret: String,
- /// The OTP generation mode.
- pub mode: OtpMode,
- /// If true, press the enter key after sending an OTP code using double-pressed
- /// numlock, capslock or scrolllock.
- pub use_enter: bool,
- /// Set the token ID, see [OATH Token Identifier Specification][tokspec], section “Class A”.
- ///
- /// [tokspec]: https://openauthentication.org/token-specs/
- pub token_id: Option<String>,
-}
-
-#[derive(Debug)]
-pub struct RawOtpSlotData {
- pub number: u8,
- pub name: CString,
- pub secret: CString,
- pub mode: OtpMode,
- pub use_enter: bool,
- pub use_token_id: bool,
- pub token_id: CString,
-}
-
-impl OtpSlotData {
- /// Constructs a new instance of this struct.
- pub fn new<S: Into<String>, T: Into<String>>(
- number: u8,
- name: S,
- secret: T,
- mode: OtpMode,
- ) -> OtpSlotData {
- OtpSlotData {
- number,
- name: name.into(),
- secret: secret.into(),
- mode,
- use_enter: false,
- token_id: None,
- }
- }
-
- /// Enables pressing the enter key after sending an OTP code using double-pressed numlock,
- /// capslock or scrollock.
- pub fn use_enter(mut self) -> OtpSlotData {
- self.use_enter = true;
- self
- }
-
- /// Sets the token ID, see [OATH Token Identifier Specification][tokspec], section “Class A”.
- ///
- /// [tokspec]: https://openauthentication.org/token-specs/
- pub fn token_id<S: Into<String>>(mut self, id: S) -> OtpSlotData {
- self.token_id = Some(id.into());
- self
- }
-}
-
-impl RawOtpSlotData {
- pub fn new(data: OtpSlotData) -> Result<RawOtpSlotData, CommandError> {
- let name = get_cstring(data.name)?;
- let secret = get_cstring(data.secret)?;
- let use_token_id = data.token_id.is_some();
- let token_id = get_cstring(data.token_id.unwrap_or_else(String::new))?;
-
- Ok(RawOtpSlotData {
- number: data.number,
- name,
- secret,
- mode: data.mode,
- use_enter: data.use_enter,
- use_token_id,
- token_id,
- })
- }
-}
diff --git a/nitrokey/src/pws.rs b/nitrokey/src/pws.rs
deleted file mode 100644
index 28f0681..0000000
--- a/nitrokey/src/pws.rs
+++ /dev/null
@@ -1,383 +0,0 @@
-use libc;
-use nitrokey_sys;
-
-use crate::device::{Device, DeviceWrapper, Pro, Storage};
-use crate::util::{
- get_command_result, get_cstring, get_last_error, result_from_string, CommandError,
-};
-
-/// The number of slots in a [`PasswordSafe`][].
-///
-/// [`PasswordSafe`]: struct.PasswordSafe.html
-pub const SLOT_COUNT: u8 = 16;
-
-/// A password safe on a Nitrokey device.
-///
-/// The password safe stores a tuple consisting of a name, a login and a password on a slot. The
-/// number of available slots is [`SLOT_COUNT`][]. The slots are addressed starting with zero. To
-/// retrieve a password safe from a Nitrokey device, use the [`get_password_safe`][] method from
-/// the [`GetPasswordSafe`][] trait. Note that the device must live at least as long as the
-/// password safe.
-///
-/// Once the password safe has been unlocked, it can be accessed without a password. Therefore it
-/// is mandatory to call [`lock`][] on the corresponding device after the password store is used.
-/// As this command may have side effects on the Nitrokey Storage, it cannot be called
-/// automatically once the password safe is destroyed.
-///
-/// # Examples
-///
-/// Open a password safe and access a password:
-///
-/// ```no_run
-/// use nitrokey::{Device, GetPasswordSafe, PasswordSafe};
-/// # use nitrokey::CommandError;
-///
-/// fn use_password_safe(pws: &PasswordSafe) -> Result<(), CommandError> {
-/// let name = pws.get_slot_name(0)?;
-/// let login = pws.get_slot_login(0)?;
-/// let password = pws.get_slot_login(0)?;
-/// println!("Credentials for {}: login {}, password {}", name, login, password);
-/// Ok(())
-/// }
-///
-/// # fn try_main() -> Result<(), CommandError> {
-/// let device = nitrokey::connect()?;
-/// let pws = device.get_password_safe("123456")?;
-/// use_password_safe(&pws);
-/// device.lock()?;
-/// # Ok(())
-/// # }
-/// ```
-///
-/// [`SLOT_COUNT`]: constant.SLOT_COUNT.html
-/// [`get_password_safe`]: trait.GetPasswordSafe.html#method.get_password_safe
-/// [`lock`]: trait.Device.html#method.lock
-/// [`GetPasswordSafe`]: trait.GetPasswordSafe.html
-pub struct PasswordSafe<'a> {
- _device: &'a dyn Device,
-}
-
-/// Provides access to a [`PasswordSafe`][].
-///
-/// The device that implements this trait must always live at least as long as a password safe
-/// retrieved from it.
-///
-/// [`PasswordSafe`]: struct.PasswordSafe.html
-pub trait GetPasswordSafe {
- /// Enables and returns the password safe.
- ///
- /// The underlying device must always live at least as long as a password safe retrieved from
- /// it. It is mandatory to lock the underlying device using [`lock`][] after the password safe
- /// has been used. Otherwise, other applications can access the password store without
- /// authentication.
- ///
- /// If this method returns an `AesDecryptionFailed` (Nitrokey Pro) or `Unknown` (Nitrokey
- /// Storage) error, the AES data object on the smart card could not be accessed. This problem
- /// occurs after a factory reset using `gpg --card-edit` and can be fixed using the
- /// [`Device::build_aes_key`][] command.
- ///
- /// # Errors
- ///
- /// - [`AesDecryptionFailed`][] if the secret for the password safe could not be decrypted
- /// (Nitrokey Pro only)
- /// - [`InvalidString`][] if one of the provided passwords contains a null byte
- /// - [`Unknown`][] if the secret for the password safe could not be decrypted (Nitrokey
- /// Storage only)
- /// - [`WrongPassword`][] if the current user password is wrong
- ///
- /// # Example
- ///
- /// ```no_run
- /// use nitrokey::{Device, GetPasswordSafe, PasswordSafe};
- /// # use nitrokey::CommandError;
- ///
- /// fn use_password_safe(pws: &PasswordSafe) {}
- ///
- /// # fn try_main() -> Result<(), CommandError> {
- /// let device = nitrokey::connect()?;
- /// match device.get_password_safe("123456") {
- /// Ok(pws) => {
- /// use_password_safe(&pws);
- /// device.lock()?;
- /// },
- /// Err(err) => println!("Could not open the password safe: {}", err),
- /// };
- /// # Ok(())
- /// # }
- /// ```
- ///
- /// [`device`]: struct.PasswordSafe.html#method.device
- /// [`lock`]: trait.Device.html#method.lock
- /// [`AesDecryptionFailed`]: enum.CommandError.html#variant.AesDecryptionFailed
- /// [`Device::build_aes_key`]: trait.Device.html#method.build_aes_key
- /// [`InvalidString`]: enum.CommandError.html#variant.InvalidString
- /// [`Unknown`]: enum.CommandError.html#variant.Unknown
- /// [`WrongPassword`]: enum.CommandError.html#variant.WrongPassword
- fn get_password_safe(&self, user_pin: &str) -> Result<PasswordSafe<'_>, CommandError>;
-}
-
-fn get_password_safe<'a>(
- device: &'a dyn Device,
- user_pin: &str,
-) -> Result<PasswordSafe<'a>, CommandError> {
- let user_pin_string = get_cstring(user_pin)?;
- let result = unsafe {
- get_command_result(nitrokey_sys::NK_enable_password_safe(
- user_pin_string.as_ptr(),
- ))
- };
- result.map(|()| PasswordSafe { _device: device })
-}
-
-fn get_pws_result(s: String) -> Result<String, CommandError> {
- if s.is_empty() {
- Err(CommandError::SlotNotProgrammed)
- } else {
- Ok(s)
- }
-}
-
-impl<'a> PasswordSafe<'a> {
- /// Returns the status of all password slots.
- ///
- /// The status indicates whether a slot is programmed or not.
- ///
- /// # Example
- ///
- /// ```no_run
- /// use nitrokey::{GetPasswordSafe, SLOT_COUNT};
- /// # use nitrokey::CommandError;
- ///
- /// # fn try_main() -> Result<(), CommandError> {
- /// let device = nitrokey::connect()?;
- /// let pws = device.get_password_safe("123456")?;
- /// pws.get_slot_status()?.iter().enumerate().for_each(|(slot, programmed)| {
- /// let status = match *programmed {
- /// true => "programmed",
- /// false => "not programmed",
- /// };
- /// println!("Slot {}: {}", slot, status);
- /// });
- /// # Ok(())
- /// # }
- /// ```
- pub fn get_slot_status(&self) -> Result<[bool; SLOT_COUNT as usize], CommandError> {
- let status_ptr = unsafe { nitrokey_sys::NK_get_password_safe_slot_status() };
- if status_ptr.is_null() {
- return Err(get_last_error());
- }
- let status_array_ptr = status_ptr as *const [u8; SLOT_COUNT as usize];
- let status_array = unsafe { *status_array_ptr };
- let mut result = [false; SLOT_COUNT as usize];
- for i in 0..SLOT_COUNT {
- result[i as usize] = status_array[i as usize] == 1;
- }
- unsafe {
- libc::free(status_ptr as *mut libc::c_void);
- }
- Ok(result)
- }
-
- /// Returns the name of the given slot (if it is programmed).
- ///
- /// This method also returns a `SlotNotProgrammed` error if the name is empty.
- ///
- /// # Errors
- ///
- /// - [`InvalidSlot`][] if the given slot is out of range
- /// - [`SlotNotProgrammed`][] if the slot is not programmed
- ///
- /// # Example
- ///
- /// ```no_run
- /// use nitrokey::GetPasswordSafe;
- /// # use nitrokey::CommandError;
- ///
- /// # fn try_main() -> Result<(), CommandError> {
- /// let device = nitrokey::connect()?;
- /// match device.get_password_safe("123456") {
- /// Ok(pws) => {
- /// let name = pws.get_slot_name(0)?;
- /// let login = pws.get_slot_login(0)?;
- /// let password = pws.get_slot_login(0)?;
- /// println!("Credentials for {}: login {}, password {}", name, login, password);
- /// },
- /// Err(err) => println!("Could not open the password safe: {}", err),
- /// };
- /// # Ok(())
- /// # }
- /// ```
- ///
- /// [`InvalidSlot`]: enum.CommandError.html#variant.InvalidSlot
- /// [`SlotNotProgrammed`]: enum.CommandError.html#variant.SlotNotProgrammed
- pub fn get_slot_name(&self, slot: u8) -> Result<String, CommandError> {
- unsafe { result_from_string(nitrokey_sys::NK_get_password_safe_slot_name(slot)) }
- .and_then(get_pws_result)
- }
-
- /// Returns the login for the given slot (if it is programmed).
- ///
- /// This method also returns a `SlotNotProgrammed` error if the login is empty.
- ///
- /// # Errors
- ///
- /// - [`InvalidSlot`][] if the given slot is out of range
- /// - [`SlotNotProgrammed`][] if the slot is not programmed
- ///
- /// # Example
- ///
- /// ```no_run
- /// use nitrokey::GetPasswordSafe;
- /// # use nitrokey::CommandError;
- ///
- /// # fn try_main() -> Result<(), CommandError> {
- /// let device = nitrokey::connect()?;
- /// let pws = device.get_password_safe("123456")?;
- /// let name = pws.get_slot_name(0)?;
- /// let login = pws.get_slot_login(0)?;
- /// let password = pws.get_slot_login(0)?;
- /// println!("Credentials for {}: login {}, password {}", name, login, password);
- /// # Ok(())
- /// # }
- /// ```
- ///
- /// [`InvalidSlot`]: enum.CommandError.html#variant.InvalidSlot
- /// [`SlotNotProgrammed`]: enum.CommandError.html#variant.SlotNotProgrammed
- pub fn get_slot_login(&self, slot: u8) -> Result<String, CommandError> {
- unsafe { result_from_string(nitrokey_sys::NK_get_password_safe_slot_login(slot)) }
- .and_then(get_pws_result)
- }
-
- /// Returns the password for the given slot (if it is programmed).
- ///
- /// This method also returns a `SlotNotProgrammed` error if the password is empty.
- ///
- /// # Errors
- ///
- /// - [`InvalidSlot`][] if the given slot is out of range
- /// - [`SlotNotProgrammed`][] if the slot is not programmed
- ///
- /// # Example
- ///
- /// ```no_run
- /// use nitrokey::GetPasswordSafe;
- /// # use nitrokey::CommandError;
- ///
- /// # fn try_main() -> Result<(), CommandError> {
- /// let device = nitrokey::connect()?;
- /// let pws = device.get_password_safe("123456")?;
- /// let name = pws.get_slot_name(0)?;
- /// let login = pws.get_slot_login(0)?;
- /// let password = pws.get_slot_login(0)?;
- /// println!("Credentials for {}: login {}, password {}", name, login, password);
- /// # Ok(())
- /// # }
- /// ```
- ///
- /// [`InvalidSlot`]: enum.CommandError.html#variant.InvalidSlot
- /// [`SlotNotProgrammed`]: enum.CommandError.html#variant.SlotNotProgrammed
- pub fn get_slot_password(&self, slot: u8) -> Result<String, CommandError> {
- unsafe { result_from_string(nitrokey_sys::NK_get_password_safe_slot_password(slot)) }
- .and_then(get_pws_result)
- }
-
- /// Writes the given slot with the given name, login and password.
- ///
- /// # Errors
- ///
- /// - [`InvalidSlot`][] if the given slot is out of range
- /// - [`InvalidString`][] if the provided token ID contains a null byte
- ///
- /// # Example
- ///
- /// ```no_run
- /// use nitrokey::GetPasswordSafe;
- /// # use nitrokey::CommandError;
- ///
- /// # fn try_main() -> Result<(), CommandError> {
- /// let device = nitrokey::connect()?;
- /// let pws = device.get_password_safe("123456")?;
- /// let name = pws.get_slot_name(0)?;
- /// let login = pws.get_slot_login(0)?;
- /// let password = pws.get_slot_login(0)?;
- /// println!("Credentials for {}: login {}, password {}", name, login, password);
- /// # Ok(())
- /// # }
- /// ```
- ///
- /// [`InvalidSlot`]: enum.CommandError.html#variant.InvalidSlot
- /// [`InvalidString`]: enum.CommandError.html#variant.InvalidString
- pub fn write_slot(
- &self,
- slot: u8,
- name: &str,
- login: &str,
- password: &str,
- ) -> Result<(), CommandError> {
- let name_string = get_cstring(name)?;
- let login_string = get_cstring(login)?;
- let password_string = get_cstring(password)?;
- unsafe {
- get_command_result(nitrokey_sys::NK_write_password_safe_slot(
- slot,
- name_string.as_ptr(),
- login_string.as_ptr(),
- password_string.as_ptr(),
- ))
- }
- }
-
- /// Erases the given slot. Erasing clears the stored name, login and password (if the slot was
- /// programmed).
- ///
- /// # Errors
- ///
- /// - [`InvalidSlot`][] if the given slot is out of range
- ///
- /// # Example
- ///
- /// ```no_run
- /// use nitrokey::GetPasswordSafe;
- /// # use nitrokey::CommandError;
- ///
- /// # fn try_main() -> Result<(), CommandError> {
- /// let device = nitrokey::connect()?;
- /// let pws = device.get_password_safe("123456")?;
- /// match pws.erase_slot(0) {
- /// Ok(()) => println!("Erased slot 0."),
- /// Err(err) => println!("Could not erase slot 0: {}", err),
- /// };
- /// # Ok(())
- /// # }
- /// ```
- ///
- /// [`InvalidSlot`]: enum.CommandError.html#variant.InvalidSlot
- pub fn erase_slot(&self, slot: u8) -> Result<(), CommandError> {
- unsafe { get_command_result(nitrokey_sys::NK_erase_password_safe_slot(slot)) }
- }
-}
-
-impl<'a> Drop for PasswordSafe<'a> {
- fn drop(&mut self) {
- // TODO: disable the password safe -- NK_lock_device has side effects on the Nitrokey
- // Storage, see https://github.com/Nitrokey/nitrokey-storage-firmware/issues/65
- }
-}
-
-impl GetPasswordSafe for Pro {
- fn get_password_safe(&self, user_pin: &str) -> Result<PasswordSafe<'_>, CommandError> {
- get_password_safe(self, user_pin)
- }
-}
-
-impl GetPasswordSafe for Storage {
- fn get_password_safe(&self, user_pin: &str) -> Result<PasswordSafe<'_>, CommandError> {
- get_password_safe(self, user_pin)
- }
-}
-
-impl GetPasswordSafe for DeviceWrapper {
- fn get_password_safe(&self, user_pin: &str) -> Result<PasswordSafe<'_>, CommandError> {
- get_password_safe(self, user_pin)
- }
-}
diff --git a/nitrokey/src/util.rs b/nitrokey/src/util.rs
deleted file mode 100644
index 567c478..0000000
--- a/nitrokey/src/util.rs
+++ /dev/null
@@ -1,206 +0,0 @@
-use std::borrow;
-use std::ffi::{CStr, CString};
-use std::fmt;
-use std::os::raw::{c_char, c_int};
-
-use libc::{c_void, free};
-use rand_core::RngCore;
-use rand_os::OsRng;
-
-/// Error types returned by Nitrokey device or by the library.
-#[derive(Clone, Copy, Debug, PartialEq)]
-pub enum CommandError {
- /// A packet with a wrong checksum has been sent or received.
- WrongCrc,
- /// A command tried to access an OTP slot that does not exist.
- WrongSlot,
- /// A command tried to generate an OTP on a slot that is not configured.
- SlotNotProgrammed,
- /// The provided password is wrong.
- WrongPassword,
- /// You are not authorized for this command or provided a wrong temporary
- /// password.
- NotAuthorized,
- /// An error occurred when getting or setting the time.
- Timestamp,
- /// You did not provide a name for the OTP slot.
- NoName,
- /// This command is not supported by this device.
- NotSupported,
- /// This command is unknown.
- UnknownCommand,
- /// AES decryption failed.
- AesDecryptionFailed,
- /// An unknown error occurred.
- Unknown(i64),
- /// An unspecified error occurred.
- Undefined,
- /// You passed a string containing a null byte.
- InvalidString,
- /// A supplied string exceeded a length limit.
- StringTooLong,
- /// You passed an invalid slot.
- InvalidSlot,
- /// The supplied string was not in hexadecimal format.
- InvalidHexString,
- /// The target buffer was smaller than the source.
- TargetBufferTooSmall,
- /// An error occurred during random number generation.
- RngError,
-}
-
-/// Log level for libnitrokey.
-///
-/// Setting the log level to a lower level enables all output from higher levels too. Currently,
-/// only the log levels `Warning`, `DebugL1`, `Debug` and `DebugL2` are actually used.
-#[derive(Clone, Copy, Debug, PartialEq)]
-pub enum LogLevel {
- /// Error messages. Currently not used.
- Error,
- /// Warning messages.
- Warning,
- /// Informational messages. Currently not used.
- Info,
- /// Basic debug messages, especially basic information on the sent and received packets.
- DebugL1,
- /// Detailed debug messages, especially detailed information on the sent and received packets.
- Debug,
- /// Very detailed debug messages, especially detailed information about the control flow for
- /// device communication (for example function entries and exits).
- DebugL2,
-}
-
-pub fn owned_str_from_ptr(ptr: *const c_char) -> String {
- unsafe {
- return CStr::from_ptr(ptr).to_string_lossy().into_owned();
- }
-}
-
-pub fn result_from_string(ptr: *const c_char) -> Result<String, CommandError> {
- if ptr.is_null() {
- return Err(CommandError::Undefined);
- }
- unsafe {
- let s = owned_str_from_ptr(ptr);
- free(ptr as *mut c_void);
- // An empty string can both indicate an error or be a valid return value. In this case, we
- // have to check the last command status to decide what to return.
- if s.is_empty() {
- get_last_result().map(|_| s)
- } else {
- Ok(s)
- }
- }
-}
-
-pub fn get_command_result(value: c_int) -> Result<(), CommandError> {
- match value {
- 0 => Ok(()),
- other => Err(CommandError::from(other)),
- }
-}
-
-pub fn get_last_result() -> Result<(), CommandError> {
- let value = unsafe { nitrokey_sys::NK_get_last_command_status() } as c_int;
- get_command_result(value)
-}
-
-pub fn get_last_error() -> CommandError {
- return match get_last_result() {
- Ok(()) => CommandError::Undefined,
- Err(err) => err,
- };
-}
-
-pub fn generate_password(length: usize) -> Result<Vec<u8>, CommandError> {
- let mut rng = OsRng::new()?;
- let mut data = vec![0u8; length];
- rng.fill_bytes(&mut data[..]);
- Ok(data)
-}
-
-pub fn get_cstring<T: Into<Vec<u8>>>(s: T) -> Result<CString, CommandError> {
- CString::new(s).or(Err(CommandError::InvalidString))
-}
-
-impl CommandError {
- fn as_str(&self) -> borrow::Cow<'static, str> {
- match *self {
- CommandError::WrongCrc => {
- "A packet with a wrong checksum has been sent or received".into()
- }
- CommandError::WrongSlot => "The given OTP slot does not exist".into(),
- CommandError::SlotNotProgrammed => "The given OTP slot is not programmed".into(),
- CommandError::WrongPassword => "The given password is wrong".into(),
- CommandError::NotAuthorized => {
- "You are not authorized for this command or provided a wrong temporary \
- password"
- .into()
- }
- CommandError::Timestamp => "An error occurred when getting or setting the time".into(),
- CommandError::NoName => "You did not provide a name for the OTP slot".into(),
- CommandError::NotSupported => "This command is not supported by this device".into(),
- CommandError::UnknownCommand => "This command is unknown".into(),
- CommandError::AesDecryptionFailed => "AES decryption failed".into(),
- CommandError::Unknown(x) => {
- borrow::Cow::from(format!("An unknown error occurred ({})", x))
- }
- CommandError::Undefined => "An unspecified error occurred".into(),
- CommandError::InvalidString => "You passed a string containing a null byte".into(),
- CommandError::StringTooLong => "The supplied string is too long".into(),
- CommandError::InvalidSlot => "The given slot is invalid".into(),
- CommandError::InvalidHexString => {
- "The supplied string is not in hexadecimal format".into()
- }
- CommandError::TargetBufferTooSmall => "The target buffer is too small".into(),
- CommandError::RngError => "An error occurred during random number generation".into(),
- }
- }
-}
-
-impl fmt::Display for CommandError {
- fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
- write!(f, "{}", self.as_str())
- }
-}
-
-impl From<c_int> for CommandError {
- fn from(value: c_int) -> Self {
- match value {
- 1 => CommandError::WrongCrc,
- 2 => CommandError::WrongSlot,
- 3 => CommandError::SlotNotProgrammed,
- 4 => CommandError::WrongPassword,
- 5 => CommandError::NotAuthorized,
- 6 => CommandError::Timestamp,
- 7 => CommandError::NoName,
- 8 => CommandError::NotSupported,
- 9 => CommandError::UnknownCommand,
- 10 => CommandError::AesDecryptionFailed,
- 200 => CommandError::StringTooLong,
- 201 => CommandError::InvalidSlot,
- 202 => CommandError::InvalidHexString,
- 203 => CommandError::TargetBufferTooSmall,
- x => CommandError::Unknown(x.into()),
- }
- }
-}
-
-impl From<rand_core::Error> for CommandError {
- fn from(_error: rand_core::Error) -> Self {
- CommandError::RngError
- }
-}
-
-impl Into<i32> for LogLevel {
- fn into(self) -> i32 {
- match self {
- LogLevel::Error => 0,
- LogLevel::Warning => 1,
- LogLevel::Info => 2,
- LogLevel::DebugL1 => 3,
- LogLevel::Debug => 4,
- LogLevel::DebugL2 => 5,
- }
- }
-}
diff --git a/nitrokey/tests/device.rs b/nitrokey/tests/device.rs
deleted file mode 100644
index 849d2ff..0000000
--- a/nitrokey/tests/device.rs
+++ /dev/null
@@ -1,496 +0,0 @@
-mod util;
-
-use std::ffi::CStr;
-use std::process::Command;
-use std::{thread, time};
-
-use nitrokey::{
- Authenticate, CommandError, Config, ConfigureOtp, Device, GenerateOtp, GetPasswordSafe,
- OtpMode, OtpSlotData, Storage, VolumeMode,
-};
-use nitrokey_test::test as test_device;
-
-use crate::util::{ADMIN_PASSWORD, USER_PASSWORD};
-
-static ADMIN_NEW_PASSWORD: &str = "1234567890";
-static UPDATE_PIN: &str = "12345678";
-static UPDATE_NEW_PIN: &str = "87654321";
-static USER_NEW_PASSWORD: &str = "abcdefghij";
-
-fn count_nitrokey_block_devices() -> usize {
- thread::sleep(time::Duration::from_secs(2));
- let output = Command::new("lsblk")
- .args(&["-o", "MODEL"])
- .output()
- .expect("Could not list block devices");
- String::from_utf8_lossy(&output.stdout)
- .split("\n")
- .filter(|&s| s.replace("_", " ") == "Nitrokey Storage")
- .count()
-}
-
-#[test_device]
-fn connect_no_device() {
- assert!(nitrokey::connect().is_err());
- assert!(nitrokey::connect_model(nitrokey::Model::Pro).is_err());
- assert!(nitrokey::connect_model(nitrokey::Model::Storage).is_err());
- assert!(nitrokey::Pro::connect().is_err());
- assert!(nitrokey::Storage::connect().is_err());
-}
-
-#[test_device]
-fn connect_pro(device: Pro) {
- assert_eq!(device.get_model(), nitrokey::Model::Pro);
- drop(device);
-
- assert!(nitrokey::connect().is_ok());
- assert!(nitrokey::connect_model(nitrokey::Model::Pro).is_ok());
- assert!(nitrokey::Pro::connect().is_ok());
-}
-
-#[test_device]
-fn connect_storage(device: Storage) {
- assert_eq!(device.get_model(), nitrokey::Model::Storage);
- drop(device);
-
- assert!(nitrokey::connect().is_ok());
- assert!(nitrokey::connect_model(nitrokey::Model::Storage).is_ok());
- assert!(nitrokey::Storage::connect().is_ok());
-}
-
-fn assert_empty_serial_number() {
- unsafe {
- let ptr = nitrokey_sys::NK_device_serial_number();
- assert!(!ptr.is_null());
- let cstr = CStr::from_ptr(ptr);
- assert_eq!(cstr.to_string_lossy(), "");
- }
-}
-
-#[test_device]
-fn disconnect(device: DeviceWrapper) {
- drop(device);
- assert_empty_serial_number();
-}
-
-#[test_device]
-fn get_serial_number(device: DeviceWrapper) {
- let result = device.get_serial_number();
- assert!(result.is_ok());
- let serial_number = result.unwrap();
- assert!(serial_number.is_ascii());
- assert!(serial_number.chars().all(|c| c.is_ascii_hexdigit()));
-}
-#[test_device]
-fn get_firmware_version(device: Pro) {
- assert_eq!(0, device.get_major_firmware_version());
- let minor = device.get_minor_firmware_version();
- assert!(minor > 0);
-}
-
-fn admin_retry<T: Authenticate + Device>(device: T, suffix: &str, count: u8) -> T {
- let result = device.authenticate_admin(&(ADMIN_PASSWORD.to_owned() + suffix));
- let device = match result {
- Ok(admin) => admin.device(),
- Err((device, _)) => device,
- };
- assert_eq!(count, device.get_admin_retry_count());
- return device;
-}
-
-fn user_retry<T: Authenticate + Device>(device: T, suffix: &str, count: u8) -> T {
- let result = device.authenticate_user(&(USER_PASSWORD.to_owned() + suffix));
- let device = match result {
- Ok(admin) => admin.device(),
- Err((device, _)) => device,
- };
- assert_eq!(count, device.get_user_retry_count());
- return device;
-}
-
-#[test_device]
-fn get_retry_count(device: DeviceWrapper) {
- let device = admin_retry(device, "", 3);
- let device = admin_retry(device, "123", 2);
- let device = admin_retry(device, "456", 1);
- let device = admin_retry(device, "", 3);
-
- let device = user_retry(device, "", 3);
- let device = user_retry(device, "123", 2);
- let device = user_retry(device, "456", 1);
- user_retry(device, "", 3);
-}
-
-#[test_device]
-fn config(device: DeviceWrapper) {
- let admin = device.authenticate_admin(ADMIN_PASSWORD).unwrap();
- let config = Config::new(None, None, None, true);
- assert_eq!(Ok(()), admin.write_config(config));
- let get_config = admin.get_config().unwrap();
- assert_eq!(config, get_config);
-
- let config = Config::new(None, Some(9), None, true);
- assert_eq!(Err(CommandError::InvalidSlot), admin.write_config(config));
-
- let config = Config::new(Some(1), None, Some(0), false);
- assert_eq!(Ok(()), admin.write_config(config));
- let get_config = admin.get_config().unwrap();
- assert_eq!(config, get_config);
-
- let config = Config::new(None, None, None, false);
- assert_eq!(Ok(()), admin.write_config(config));
- let get_config = admin.get_config().unwrap();
- assert_eq!(config, get_config);
-}
-
-#[test_device]
-fn change_user_pin(device: DeviceWrapper) {
- let device = device.authenticate_user(USER_PASSWORD).unwrap().device();
- let device = device.authenticate_user(USER_NEW_PASSWORD).unwrap_err().0;
-
- assert!(device
- .change_user_pin(USER_PASSWORD, USER_NEW_PASSWORD)
- .is_ok());
-
- let device = device.authenticate_user(USER_PASSWORD).unwrap_err().0;
- let device = device
- .authenticate_user(USER_NEW_PASSWORD)
- .unwrap()
- .device();
-
- let result = device.change_user_pin(USER_PASSWORD, USER_PASSWORD);
- assert_eq!(Err(CommandError::WrongPassword), result);
-
- assert!(device
- .change_user_pin(USER_NEW_PASSWORD, USER_PASSWORD)
- .is_ok());
-
- let device = device.authenticate_user(USER_PASSWORD).unwrap().device();
- assert!(device.authenticate_user(USER_NEW_PASSWORD).is_err());
-}
-
-#[test_device]
-fn change_admin_pin(device: DeviceWrapper) {
- let device = device.authenticate_admin(ADMIN_PASSWORD).unwrap().device();
- let device = device.authenticate_admin(ADMIN_NEW_PASSWORD).unwrap_err().0;
-
- assert!(device
- .change_admin_pin(ADMIN_PASSWORD, ADMIN_NEW_PASSWORD)
- .is_ok());
-
- let device = device.authenticate_admin(ADMIN_PASSWORD).unwrap_err().0;
- let device = device
- .authenticate_admin(ADMIN_NEW_PASSWORD)
- .unwrap()
- .device();
-
- assert_eq!(
- Err(CommandError::WrongPassword),
- device.change_admin_pin(ADMIN_PASSWORD, ADMIN_PASSWORD)
- );
-
- assert!(device
- .change_admin_pin(ADMIN_NEW_PASSWORD, ADMIN_PASSWORD)
- .is_ok());
-
- let device = device.authenticate_admin(ADMIN_PASSWORD).unwrap().device();
- device.authenticate_admin(ADMIN_NEW_PASSWORD).unwrap_err();
-}
-
-fn require_failed_user_login<D>(device: D, password: &str, error: CommandError) -> D
-where
- D: Device + Authenticate,
- nitrokey::User<D>: std::fmt::Debug,
-{
- let result = device.authenticate_user(password);
- assert!(result.is_err());
- let err = result.unwrap_err();
- assert_eq!(error, err.1);
- err.0
-}
-
-#[test_device]
-fn unlock_user_pin(device: DeviceWrapper) {
- let device = device.authenticate_user(USER_PASSWORD).unwrap().device();
- assert!(device
- .unlock_user_pin(ADMIN_PASSWORD, USER_PASSWORD)
- .is_ok());
- assert_eq!(
- Err(CommandError::WrongPassword),
- device.unlock_user_pin(USER_PASSWORD, USER_PASSWORD)
- );
-
- // block user PIN
- let wrong_password = USER_PASSWORD.to_owned() + "foo";
- let device = require_failed_user_login(device, &wrong_password, CommandError::WrongPassword);
- let device = require_failed_user_login(device, &wrong_password, CommandError::WrongPassword);
- let device = require_failed_user_login(device, &wrong_password, CommandError::WrongPassword);
- let device = require_failed_user_login(device, USER_PASSWORD, CommandError::WrongPassword);
-
- // unblock with current PIN
- assert_eq!(
- Err(CommandError::WrongPassword),
- device.unlock_user_pin(USER_PASSWORD, USER_PASSWORD)
- );
- assert!(device
- .unlock_user_pin(ADMIN_PASSWORD, USER_PASSWORD)
- .is_ok());
- let device = device.authenticate_user(USER_PASSWORD).unwrap().device();
-
- // block user PIN
- let device = require_failed_user_login(device, &wrong_password, CommandError::WrongPassword);
- let device = require_failed_user_login(device, &wrong_password, CommandError::WrongPassword);
- let device = require_failed_user_login(device, &wrong_password, CommandError::WrongPassword);
- let device = require_failed_user_login(device, USER_PASSWORD, CommandError::WrongPassword);
-
- // unblock with new PIN
- assert_eq!(
- Err(CommandError::WrongPassword),
- device.unlock_user_pin(USER_PASSWORD, USER_PASSWORD)
- );
- assert!(device
- .unlock_user_pin(ADMIN_PASSWORD, USER_NEW_PASSWORD)
- .is_ok());
-
- // reset user PIN
- assert!(device
- .change_user_pin(USER_NEW_PASSWORD, USER_PASSWORD)
- .is_ok());
-}
-
-#[test_device]
-fn factory_reset(device: DeviceWrapper) {
- let admin = device.authenticate_admin(ADMIN_PASSWORD).unwrap();
- let otp_data = OtpSlotData::new(1, "test", "0123468790", OtpMode::SixDigits);
- assert_eq!(Ok(()), admin.write_totp_slot(otp_data, 30));
-
- let device = admin.device();
- let pws = device.get_password_safe(USER_PASSWORD).unwrap();
- assert_eq!(Ok(()), pws.write_slot(0, "test", "testlogin", "testpw"));
- drop(pws);
-
- assert_eq!(
- Ok(()),
- device.change_user_pin(USER_PASSWORD, USER_NEW_PASSWORD)
- );
- assert_eq!(
- Ok(()),
- device.change_admin_pin(ADMIN_PASSWORD, ADMIN_NEW_PASSWORD)
- );
-
- assert_eq!(
- Err(CommandError::WrongPassword),
- device.factory_reset(USER_NEW_PASSWORD)
- );
- assert_eq!(
- Err(CommandError::WrongPassword),
- device.factory_reset(ADMIN_PASSWORD)
- );
- assert_eq!(Ok(()), device.factory_reset(ADMIN_NEW_PASSWORD));
-
- let device = device.authenticate_admin(ADMIN_PASSWORD).unwrap().device();
-
- let user = device.authenticate_user(USER_PASSWORD).unwrap();
- assert_eq!(
- Err(CommandError::SlotNotProgrammed),
- user.get_totp_slot_name(1)
- );
-
- let device = user.device();
- let pws = device.get_password_safe(USER_PASSWORD).unwrap();
- assert_ne!("test".to_string(), pws.get_slot_name(0).unwrap());
- assert_ne!("testlogin".to_string(), pws.get_slot_login(0).unwrap());
- assert_ne!("testpw".to_string(), pws.get_slot_password(0).unwrap());
-
- assert_eq!(Ok(()), device.build_aes_key(ADMIN_PASSWORD));
-}
-
-#[test_device]
-fn build_aes_key(device: DeviceWrapper) {
- let pws = device.get_password_safe(USER_PASSWORD).unwrap();
- assert_eq!(Ok(()), pws.write_slot(0, "test", "testlogin", "testpw"));
- drop(pws);
-
- assert_eq!(
- Err(CommandError::WrongPassword),
- device.build_aes_key(USER_PASSWORD)
- );
- assert_eq!(Ok(()), device.build_aes_key(ADMIN_PASSWORD));
-
- let device = device.authenticate_admin(ADMIN_PASSWORD).unwrap().device();
-
- let pws = device.get_password_safe(USER_PASSWORD).unwrap();
- assert_ne!("test".to_string(), pws.get_slot_name(0).unwrap());
- assert_ne!("testlogin".to_string(), pws.get_slot_login(0).unwrap());
- assert_ne!("testpw".to_string(), pws.get_slot_password(0).unwrap());
-}
-
-#[test_device]
-fn change_update_pin(device: Storage) {
- assert_eq!(
- Err(CommandError::WrongPassword),
- device.change_update_pin(UPDATE_NEW_PIN, UPDATE_PIN)
- );
- assert_eq!(Ok(()), device.change_update_pin(UPDATE_PIN, UPDATE_NEW_PIN));
- assert_eq!(Ok(()), device.change_update_pin(UPDATE_NEW_PIN, UPDATE_PIN));
-}
-
-#[test_device]
-fn encrypted_volume(device: Storage) {
- assert_eq!(Ok(()), device.lock());
-
- assert_eq!(1, count_nitrokey_block_devices());
- assert_eq!(Ok(()), device.disable_encrypted_volume());
- assert_eq!(1, count_nitrokey_block_devices());
- assert_eq!(
- Err(CommandError::WrongPassword),
- device.enable_encrypted_volume("123")
- );
- assert_eq!(1, count_nitrokey_block_devices());
- assert_eq!(Ok(()), device.enable_encrypted_volume(USER_PASSWORD));
- assert_eq!(2, count_nitrokey_block_devices());
- assert_eq!(Ok(()), device.disable_encrypted_volume());
- assert_eq!(1, count_nitrokey_block_devices());
-}
-
-#[test_device]
-fn hidden_volume(device: Storage) {
- assert_eq!(Ok(()), device.lock());
-
- assert_eq!(1, count_nitrokey_block_devices());
- assert_eq!(Ok(()), device.disable_hidden_volume());
- assert_eq!(1, count_nitrokey_block_devices());
-
- assert_eq!(Ok(()), device.enable_encrypted_volume(USER_PASSWORD));
- assert_eq!(2, count_nitrokey_block_devices());
-
- // TODO: why this error code?
- assert_eq!(
- Err(CommandError::WrongPassword),
- device.create_hidden_volume(5, 0, 100, "hiddenpw")
- );
- assert_eq!(Ok(()), device.create_hidden_volume(0, 20, 21, "hidden-pw"));
- assert_eq!(
- Ok(()),
- device.create_hidden_volume(0, 20, 21, "hiddenpassword")
- );
- assert_eq!(Ok(()), device.create_hidden_volume(1, 0, 1, "otherpw"));
- // TODO: test invalid range (not handled by libnitrokey)
- assert_eq!(2, count_nitrokey_block_devices());
-
- assert_eq!(
- Err(CommandError::WrongPassword),
- device.enable_hidden_volume("blubb")
- );
- assert_eq!(Ok(()), device.enable_hidden_volume("hiddenpassword"));
- assert_eq!(2, count_nitrokey_block_devices());
- assert_eq!(Ok(()), device.enable_hidden_volume("otherpw"));
- assert_eq!(2, count_nitrokey_block_devices());
-
- assert_eq!(Ok(()), device.disable_hidden_volume());
- assert_eq!(1, count_nitrokey_block_devices());
-}
-
-#[test_device]
-fn lock(device: Storage) {
- assert_eq!(Ok(()), device.enable_encrypted_volume(USER_PASSWORD));
- assert_eq!(Ok(()), device.lock());
- assert_eq!(1, count_nitrokey_block_devices());
-}
-
-#[test_device]
-fn set_unencrypted_volume_mode(device: Storage) {
- fn assert_mode(device: &Storage, mode: VolumeMode) {
- let status = device.get_status();
- assert!(status.is_ok());
- assert_eq!(
- status.unwrap().unencrypted_volume.read_only,
- mode == VolumeMode::ReadOnly
- );
- }
-
- fn assert_success(device: &Storage, mode: VolumeMode) {
- assert_eq!(
- Ok(()),
- device.set_unencrypted_volume_mode(ADMIN_PASSWORD, mode)
- );
- assert_mode(&device, mode);
- }
-
- assert_success(&device, VolumeMode::ReadOnly);
-
- assert_eq!(
- Err(CommandError::WrongPassword),
- device.set_unencrypted_volume_mode(USER_PASSWORD, VolumeMode::ReadOnly)
- );
- assert_mode(&device, VolumeMode::ReadOnly);
-
- assert_success(&device, VolumeMode::ReadWrite);
- assert_success(&device, VolumeMode::ReadWrite);
- assert_success(&device, VolumeMode::ReadOnly);
-}
-
-#[test_device]
-fn get_storage_status(device: Storage) {
- let status = device.get_status().unwrap();
-
- assert!(status.serial_number_sd_card > 0);
- assert!(status.serial_number_smart_card > 0);
-}
-
-#[test_device]
-fn get_production_info(device: Storage) {
- let info = device.get_production_info().unwrap();
- assert_eq!(0, info.firmware_version_major);
- assert!(info.firmware_version_minor != 0);
- assert!(info.serial_number_cpu != 0);
- assert!(info.sd_card.serial_number != 0);
- assert!(info.sd_card.size > 0);
- assert!(info.sd_card.manufacturing_year > 10);
- assert!(info.sd_card.manufacturing_year < 100);
- // TODO: month value is not valid atm
- // assert!(info.sd_card.manufacturing_month < 12);
- assert!(info.sd_card.oem != 0);
- assert!(info.sd_card.manufacturer != 0);
-
- let status = device.get_status().unwrap();
- assert_eq!(status.firmware_version_major, info.firmware_version_major);
- assert_eq!(status.firmware_version_minor, info.firmware_version_minor);
- assert_eq!(status.serial_number_sd_card, info.sd_card.serial_number);
-}
-
-#[test_device]
-fn clear_new_sd_card_warning(device: Storage) {
- assert_eq!(Ok(()), device.factory_reset(ADMIN_PASSWORD));
- thread::sleep(time::Duration::from_secs(3));
- assert_eq!(Ok(()), device.build_aes_key(ADMIN_PASSWORD));
-
- // We have to perform an SD card operation to reset the new_sd_card_found field
- assert_eq!(Ok(()), device.lock());
-
- let status = device.get_status().unwrap();
- assert!(status.new_sd_card_found);
-
- assert_eq!(Ok(()), device.clear_new_sd_card_warning(ADMIN_PASSWORD));
-
- let status = device.get_status().unwrap();
- assert!(!status.new_sd_card_found);
-}
-
-#[test_device]
-fn export_firmware(device: Storage) {
- assert_eq!(
- Err(CommandError::WrongPassword),
- device.export_firmware("someadminpn")
- );
- assert_eq!(Ok(()), device.export_firmware(ADMIN_PASSWORD));
- assert_eq!(
- Ok(()),
- device.set_unencrypted_volume_mode(ADMIN_PASSWORD, VolumeMode::ReadWrite)
- );
- assert_eq!(Ok(()), device.export_firmware(ADMIN_PASSWORD));
- assert_eq!(
- Ok(()),
- device.set_unencrypted_volume_mode(ADMIN_PASSWORD, VolumeMode::ReadOnly)
- );
-}
diff --git a/nitrokey/tests/lib.rs b/nitrokey/tests/lib.rs
deleted file mode 100644
index c92e224..0000000
--- a/nitrokey/tests/lib.rs
+++ /dev/null
@@ -1,7 +0,0 @@
-#[test]
-fn get_library_version() {
- let version = nitrokey::get_library_version();
-
- assert!(version.git.is_empty() || version.git.starts_with("v"));
- assert!(version.major > 0);
-}
diff --git a/nitrokey/tests/otp.rs b/nitrokey/tests/otp.rs
deleted file mode 100644
index 712f7a2..0000000
--- a/nitrokey/tests/otp.rs
+++ /dev/null
@@ -1,302 +0,0 @@
-mod util;
-
-use std::fmt::Debug;
-use std::ops::Deref;
-
-use nitrokey::{
- Admin, Authenticate, CommandError, Config, ConfigureOtp, Device, GenerateOtp, OtpMode,
- OtpSlotData,
-};
-use nitrokey_test::test as test_device;
-
-use crate::util::{ADMIN_PASSWORD, USER_PASSWORD};
-
-// test suite according to RFC 4226, Appendix D
-static HOTP_SECRET: &str = "3132333435363738393031323334353637383930";
-static HOTP_CODES: &[&str] = &[
- "755224", "287082", "359152", "969429", "338314", "254676", "287922", "162583", "399871",
- "520489",
-];
-
-// test suite according to RFC 6238, Appendix B
-static TOTP_SECRET: &str = "3132333435363738393031323334353637383930";
-static TOTP_CODES: &[(u64, &str)] = &[
- (59, "94287082"),
- (1111111109, "07081804"),
- (1111111111, "14050471"),
- (1234567890, "89005924"),
- (2000000000, "69279037"),
- (20000000000, "65353130"),
-];
-
-#[derive(PartialEq)]
-enum TotpTimestampSize {
- U32,
- U64,
-}
-
-fn make_admin_test_device<T>(device: T) -> Admin<T>
-where
- T: Device,
- (T, nitrokey::CommandError): Debug,
-{
- device
- .authenticate_admin(ADMIN_PASSWORD)
- .expect("Could not login as admin.")
-}
-
-fn configure_hotp(admin: &ConfigureOtp, counter: u8) {
- let slot_data = OtpSlotData::new(1, "test-hotp", HOTP_SECRET, OtpMode::SixDigits);
- assert_eq!(Ok(()), admin.write_hotp_slot(slot_data, counter.into()));
-}
-
-fn check_hotp_codes(device: &GenerateOtp, offset: u8) {
- HOTP_CODES.iter().enumerate().for_each(|(i, code)| {
- if i >= offset as usize {
- let result = device.get_hotp_code(1);
- assert_eq!(code, &result.unwrap());
- }
- });
-}
-
-#[test_device]
-fn set_time(device: DeviceWrapper) {
- assert_eq!(Ok(()), device.set_time(1546385382, true));
- assert_eq!(Ok(()), device.set_time(1546385392, false));
- assert_eq!(
- Err(CommandError::Timestamp),
- device.set_time(1546385292, false)
- );
- assert_eq!(Ok(()), device.set_time(1546385382, true));
-}
-
-#[test_device]
-fn hotp_no_pin(device: DeviceWrapper) {
- let admin = make_admin_test_device(device);
- let config = Config::new(None, None, None, false);
- assert_eq!(Ok(()), admin.write_config(config));
-
- configure_hotp(&admin, 0);
- check_hotp_codes(admin.deref(), 0);
-
- configure_hotp(&admin, 5);
- check_hotp_codes(admin.deref(), 5);
-
- configure_hotp(&admin, 0);
- check_hotp_codes(&admin.device(), 0);
-}
-
-#[test_device]
-fn hotp_pin(device: DeviceWrapper) {
- let admin = make_admin_test_device(device);
- let config = Config::new(None, None, None, true);
- assert_eq!(Ok(()), admin.write_config(config));
-
- configure_hotp(&admin, 0);
- let user = admin.device().authenticate_user(USER_PASSWORD).unwrap();
- check_hotp_codes(&user, 0);
-
- assert!(user.device().get_hotp_code(1).is_err());
-}
-
-#[test_device]
-fn hotp_slot_name(device: DeviceWrapper) {
- let admin = make_admin_test_device(device);
- let slot_data = OtpSlotData::new(1, "test-hotp", HOTP_SECRET, OtpMode::SixDigits);
- assert_eq!(Ok(()), admin.write_hotp_slot(slot_data, 0));
-
- let device = admin.device();
- let result = device.get_hotp_slot_name(1);
- assert_eq!("test-hotp", result.unwrap());
- let result = device.get_hotp_slot_name(4);
- assert_eq!(CommandError::InvalidSlot, result.unwrap_err());
-}
-
-#[test_device]
-fn hotp_error(device: DeviceWrapper) {
- let admin = make_admin_test_device(device);
- let slot_data = OtpSlotData::new(1, "", HOTP_SECRET, OtpMode::SixDigits);
- assert_eq!(
- Err(CommandError::NoName),
- admin.write_hotp_slot(slot_data, 0)
- );
- let slot_data = OtpSlotData::new(4, "test", HOTP_SECRET, OtpMode::SixDigits);
- assert_eq!(
- Err(CommandError::InvalidSlot),
- admin.write_hotp_slot(slot_data, 0)
- );
- let slot_data = OtpSlotData::new(1, "test", "foobar", OtpMode::SixDigits);
- assert_eq!(
- Err(CommandError::InvalidHexString),
- admin.write_hotp_slot(slot_data, 0)
- );
- let code = admin.get_hotp_code(4);
- assert_eq!(CommandError::InvalidSlot, code.unwrap_err());
-}
-
-#[test_device]
-fn hotp_erase(device: DeviceWrapper) {
- let admin = make_admin_test_device(device);
- let config = Config::new(None, None, None, false);
- assert_eq!(Ok(()), admin.write_config(config));
- let slot_data = OtpSlotData::new(1, "test1", HOTP_SECRET, OtpMode::SixDigits);
- assert_eq!(Ok(()), admin.write_hotp_slot(slot_data, 0));
- let slot_data = OtpSlotData::new(2, "test2", HOTP_SECRET, OtpMode::SixDigits);
- assert_eq!(Ok(()), admin.write_hotp_slot(slot_data, 0));
-
- assert_eq!(Ok(()), admin.erase_hotp_slot(1));
-
- let device = admin.device();
- let result = device.get_hotp_slot_name(1);
- assert_eq!(CommandError::SlotNotProgrammed, result.unwrap_err());
- let result = device.get_hotp_code(1);
- assert_eq!(CommandError::SlotNotProgrammed, result.unwrap_err());
-
- assert_eq!("test2", device.get_hotp_slot_name(2).unwrap());
-}
-
-fn configure_totp(admin: &ConfigureOtp, factor: u64) {
- let slot_data = OtpSlotData::new(1, "test-totp", TOTP_SECRET, OtpMode::EightDigits);
- let time_window = 30u64.checked_mul(factor).unwrap();
- assert_eq!(Ok(()), admin.write_totp_slot(slot_data, time_window as u16));
-}
-
-fn check_totp_codes(device: &GenerateOtp, factor: u64, timestamp_size: TotpTimestampSize) {
- for (i, &(base_time, code)) in TOTP_CODES.iter().enumerate() {
- let time = base_time.checked_mul(factor).unwrap();
- let is_u64 = time > u32::max_value() as u64;
- if is_u64 != (timestamp_size == TotpTimestampSize::U64) {
- continue;
- }
-
- assert_eq!(Ok(()), device.set_time(time, true));
- let result = device.get_totp_code(1);
- assert!(result.is_ok());
- let result_code = result.unwrap();
- assert_eq!(
- code, result_code,
- "TOTP code {} should be {} but is {}",
- i, code, result_code
- );
- }
-}
-
-#[test_device]
-fn totp_no_pin(device: DeviceWrapper) {
- // TODO: this test may fail due to bad timing --> find solution
- let admin = make_admin_test_device(device);
- let config = Config::new(None, None, None, false);
- assert_eq!(Ok(()), admin.write_config(config));
-
- configure_totp(&admin, 1);
- check_totp_codes(admin.deref(), 1, TotpTimestampSize::U32);
-
- configure_totp(&admin, 2);
- check_totp_codes(admin.deref(), 2, TotpTimestampSize::U32);
-
- configure_totp(&admin, 1);
- check_totp_codes(&admin.device(), 1, TotpTimestampSize::U32);
-}
-
-#[test_device]
-// Nitrokey Storage does only support timestamps that fit in a 32-bit
-// unsigned integer, so don't test with it.
-fn totp_no_pin_64(device: Pro) {
- let admin = make_admin_test_device(device);
- let config = Config::new(None, None, None, false);
- assert_eq!(Ok(()), admin.write_config(config));
-
- configure_totp(&admin, 1);
- check_totp_codes(admin.deref(), 1, TotpTimestampSize::U64);
-
- configure_totp(&admin, 2);
- check_totp_codes(admin.deref(), 2, TotpTimestampSize::U64);
-
- configure_totp(&admin, 1);
- check_totp_codes(&admin.device(), 1, TotpTimestampSize::U64);
-}
-
-#[test_device]
-fn totp_pin(device: DeviceWrapper) {
- // TODO: this test may fail due to bad timing --> find solution
- let admin = make_admin_test_device(device);
- let config = Config::new(None, None, None, true);
- assert_eq!(Ok(()), admin.write_config(config));
-
- configure_totp(&admin, 1);
- let user = admin.device().authenticate_user(USER_PASSWORD).unwrap();
- check_totp_codes(&user, 1, TotpTimestampSize::U32);
-
- assert!(user.device().get_totp_code(1).is_err());
-}
-
-#[test_device]
-// See comment for totp_no_pin_64.
-fn totp_pin_64(device: Pro) {
- let admin = make_admin_test_device(device);
- let config = Config::new(None, None, None, true);
- assert_eq!(Ok(()), admin.write_config(config));
-
- configure_totp(&admin, 1);
- let user = admin.device().authenticate_user(USER_PASSWORD).unwrap();
- check_totp_codes(&user, 1, TotpTimestampSize::U64);
-
- assert!(user.device().get_totp_code(1).is_err());
-}
-
-#[test_device]
-fn totp_slot_name(device: DeviceWrapper) {
- let admin = make_admin_test_device(device);
- let slot_data = OtpSlotData::new(1, "test-totp", TOTP_SECRET, OtpMode::EightDigits);
- assert_eq!(Ok(()), admin.write_totp_slot(slot_data, 0));
-
- let device = admin.device();
- let result = device.get_totp_slot_name(1);
- assert!(result.is_ok());
- assert_eq!("test-totp", result.unwrap());
- let result = device.get_totp_slot_name(16);
- assert_eq!(CommandError::InvalidSlot, result.unwrap_err());
-}
-
-#[test_device]
-fn totp_error(device: DeviceWrapper) {
- let admin = make_admin_test_device(device);
- let slot_data = OtpSlotData::new(1, "", TOTP_SECRET, OtpMode::SixDigits);
- assert_eq!(
- Err(CommandError::NoName),
- admin.write_totp_slot(slot_data, 0)
- );
- let slot_data = OtpSlotData::new(20, "test", TOTP_SECRET, OtpMode::SixDigits);
- assert_eq!(
- Err(CommandError::InvalidSlot),
- admin.write_totp_slot(slot_data, 0)
- );
- let slot_data = OtpSlotData::new(4, "test", "foobar", OtpMode::SixDigits);
- assert_eq!(
- Err(CommandError::InvalidHexString),
- admin.write_totp_slot(slot_data, 0)
- );
- let code = admin.get_totp_code(20);
- assert_eq!(CommandError::InvalidSlot, code.unwrap_err());
-}
-
-#[test_device]
-fn totp_erase(device: DeviceWrapper) {
- let admin = make_admin_test_device(device);
- let config = Config::new(None, None, None, false);
- assert_eq!(Ok(()), admin.write_config(config));
- let slot_data = OtpSlotData::new(1, "test1", TOTP_SECRET, OtpMode::SixDigits);
- assert_eq!(Ok(()), admin.write_totp_slot(slot_data, 0));
- let slot_data = OtpSlotData::new(2, "test2", TOTP_SECRET, OtpMode::SixDigits);
- assert_eq!(Ok(()), admin.write_totp_slot(slot_data, 0));
-
- assert_eq!(Ok(()), admin.erase_totp_slot(1));
-
- let device = admin.device();
- let result = device.get_totp_slot_name(1);
- assert_eq!(CommandError::SlotNotProgrammed, result.unwrap_err());
- let result = device.get_totp_code(1);
- assert_eq!(CommandError::SlotNotProgrammed, result.unwrap_err());
-
- assert_eq!("test2", device.get_totp_slot_name(2).unwrap());
-}
diff --git a/nitrokey/tests/pws.rs b/nitrokey/tests/pws.rs
deleted file mode 100644
index fbcc0c1..0000000
--- a/nitrokey/tests/pws.rs
+++ /dev/null
@@ -1,161 +0,0 @@
-mod util;
-
-use std::ffi::CStr;
-
-use libc::{c_int, c_void, free};
-use nitrokey::{CommandError, Device, GetPasswordSafe, PasswordSafe, SLOT_COUNT};
-use nitrokey_sys;
-use nitrokey_test::test as test_device;
-
-use crate::util::{ADMIN_PASSWORD, USER_PASSWORD};
-
-fn get_slot_name_direct(slot: u8) -> Result<String, CommandError> {
- let ptr = unsafe { nitrokey_sys::NK_get_password_safe_slot_name(slot) };
- if ptr.is_null() {
- return Err(CommandError::Undefined);
- }
- let s = unsafe { CStr::from_ptr(ptr).to_string_lossy().into_owned() };
- unsafe { free(ptr as *mut c_void) };
- match s.is_empty() {
- true => {
- let error = unsafe { nitrokey_sys::NK_get_last_command_status() } as c_int;
- match error {
- 0 => Ok(s),
- other => Err(CommandError::from(other)),
- }
- }
- false => Ok(s),
- }
-}
-
-fn get_pws<T>(device: &T) -> PasswordSafe
-where
- T: Device,
-{
- device.get_password_safe(USER_PASSWORD).unwrap()
-}
-
-#[test_device]
-fn enable(device: DeviceWrapper) {
- assert!(device
- .get_password_safe(&(USER_PASSWORD.to_owned() + "123"))
- .is_err());
- assert!(device.get_password_safe(USER_PASSWORD).is_ok());
- assert!(device.get_password_safe(ADMIN_PASSWORD).is_err());
- assert!(device.get_password_safe(USER_PASSWORD).is_ok());
-}
-
-#[test_device]
-fn drop(device: DeviceWrapper) {
- {
- let pws = get_pws(&device);
- assert_eq!(Ok(()), pws.write_slot(1, "name", "login", "password"));
- assert_eq!("name", pws.get_slot_name(1).unwrap());
- let result = get_slot_name_direct(1);
- assert_eq!(Ok(String::from("name")), result);
- }
- let result = get_slot_name_direct(1);
- assert_eq!(Ok(String::from("name")), result);
- assert_eq!(Ok(()), device.lock());
- let result = get_slot_name_direct(1);
- assert_eq!(Err(CommandError::NotAuthorized), result);
-}
-
-#[test_device]
-fn get_status(device: DeviceWrapper) {
- let pws = get_pws(&device);
- for i in 0..SLOT_COUNT {
- assert_eq!(Ok(()), pws.erase_slot(i), "Could not erase slot {}", i);
- }
- let status = pws.get_slot_status().unwrap();
- assert_eq!(status, [false; SLOT_COUNT as usize]);
-
- assert_eq!(Ok(()), pws.write_slot(1, "name", "login", "password"));
- let status = pws.get_slot_status().unwrap();
- for i in 0..SLOT_COUNT {
- assert_eq!(i == 1, status[i as usize]);
- }
-
- for i in 0..SLOT_COUNT {
- assert_eq!(Ok(()), pws.write_slot(i, "name", "login", "password"));
- }
- let status = pws.get_slot_status().unwrap();
- assert_eq!(status, [true; SLOT_COUNT as usize]);
-}
-
-#[test_device]
-fn get_data(device: DeviceWrapper) {
- let pws = get_pws(&device);
- assert_eq!(Ok(()), pws.write_slot(1, "name", "login", "password"));
- assert_eq!("name", pws.get_slot_name(1).unwrap());
- assert_eq!("login", pws.get_slot_login(1).unwrap());
- assert_eq!("password", pws.get_slot_password(1).unwrap());
-
- assert_eq!(Ok(()), pws.erase_slot(1));
- assert_eq!(Err(CommandError::SlotNotProgrammed), pws.get_slot_name(1));
- assert_eq!(Err(CommandError::SlotNotProgrammed), pws.get_slot_login(1));
- assert_eq!(
- Err(CommandError::SlotNotProgrammed),
- pws.get_slot_password(1)
- );
-
- let name = "with å";
- let login = "pär@test.com";
- let password = "'i3lJc[09?I:,[u7dWz9";
- assert_eq!(Ok(()), pws.write_slot(1, name, login, password));
- assert_eq!(name, pws.get_slot_name(1).unwrap());
- assert_eq!(login, pws.get_slot_login(1).unwrap());
- assert_eq!(password, pws.get_slot_password(1).unwrap());
-
- assert_eq!(
- Err(CommandError::InvalidSlot),
- pws.get_slot_name(SLOT_COUNT)
- );
- assert_eq!(
- Err(CommandError::InvalidSlot),
- pws.get_slot_login(SLOT_COUNT)
- );
- assert_eq!(
- Err(CommandError::InvalidSlot),
- pws.get_slot_password(SLOT_COUNT)
- );
-}
-
-#[test_device]
-fn write(device: DeviceWrapper) {
- let pws = get_pws(&device);
-
- assert_eq!(
- Err(CommandError::InvalidSlot),
- pws.write_slot(SLOT_COUNT, "name", "login", "password")
- );
-
- assert_eq!(Ok(()), pws.write_slot(0, "", "login", "password"));
- assert_eq!(Err(CommandError::SlotNotProgrammed), pws.get_slot_name(0));
- assert_eq!(Ok(String::from("login")), pws.get_slot_login(0));
- assert_eq!(Ok(String::from("password")), pws.get_slot_password(0));
-
- assert_eq!(Ok(()), pws.write_slot(0, "name", "", "password"));
- assert_eq!(Ok(String::from("name")), pws.get_slot_name(0));
- assert_eq!(Err(CommandError::SlotNotProgrammed), pws.get_slot_login(0));
- assert_eq!(Ok(String::from("password")), pws.get_slot_password(0));
-
- assert_eq!(Ok(()), pws.write_slot(0, "name", "login", ""));
- assert_eq!(Ok(String::from("name")), pws.get_slot_name(0));
- assert_eq!(Ok(String::from("login")), pws.get_slot_login(0));
- assert_eq!(
- Err(CommandError::SlotNotProgrammed),
- pws.get_slot_password(0)
- );
-}
-
-#[test_device]
-fn erase(device: DeviceWrapper) {
- let pws = get_pws(&device);
- assert_eq!(Err(CommandError::InvalidSlot), pws.erase_slot(SLOT_COUNT));
-
- assert_eq!(Ok(()), pws.write_slot(0, "name", "login", "password"));
- assert_eq!(Ok(()), pws.erase_slot(0));
- assert_eq!(Ok(()), pws.erase_slot(0));
- assert_eq!(Err(CommandError::SlotNotProgrammed), pws.get_slot_name(0));
-}
diff --git a/nitrokey/tests/util/mod.rs b/nitrokey/tests/util/mod.rs
deleted file mode 100644
index cbf6b93..0000000
--- a/nitrokey/tests/util/mod.rs
+++ /dev/null
@@ -1,2 +0,0 @@
-pub static ADMIN_PASSWORD: &str = "12345678";
-pub static USER_PASSWORD: &str = "123456";
diff --git a/rand/.gitignore b/rand/.gitignore
deleted file mode 100644
index a9d37c5..0000000
--- a/rand/.gitignore
+++ /dev/null
@@ -1,2 +0,0 @@
-target
-Cargo.lock
diff --git a/rand/.travis.yml b/rand/.travis.yml
deleted file mode 100644
index b41e681..0000000
--- a/rand/.travis.yml
+++ /dev/null
@@ -1,230 +0,0 @@
-language: rust
-sudo: false
-
-# We support too many combinations of Rust releases, crate features, operating
-# systems, and architectures to even remotely test all combinations.
-# Yet it turns out we can test most of these independent of each other, because
-# they serve different goals or test different pieces of code.
-#
-# RUST RELEASES
-# Goal: make sure we don't use language features unavailable on a certain
-# version, and build without warnings.
-# We have different builders use 4 Rust releases, a pinned stable release,
-# the latest stable, beta and nightly.
-#
-# ARCHITECTURES
-# Goal: test against issues caused by differences in endianness, pointer sizes,
-# etc.
-# We run tests on 4 different architectures.
-# - x64_84, default on Travis (Linux) and AppVeyor (Windows)
-# - i686, second AppVeyor (Windows) configuration
-# - MIPS, big-endian Linux emulated with QEMU (thanks to Trust)
-# - ARMv7, Android emulated with QEMU (thanks to Trust)
-#
-# OPERATING SYSTEMS
-# Goal: test on many operating systems, to verify the OsRng code, which is
-# mostly architecture-independent.
-# We run tests on Linux, OS X, Windows, Android (emulated), and Node.js (using
-# cargo-web).
-# One builder cross-compiles for many of the remaining OSes, which ensures we
-# keep building, but doesn't run tests.
-# OSes supported by Rand but which we can't cross-compile because there
-# is no pre-built standard library available: Dragonfly BSD, Haiku, OpenBSD.
-#
-# CRATE FEATURES, TESTS, AND SUB-CRATES
-# Goal: Run unit tests, doctests, examples, and test benchmarks for all crates,
-# in configurations that cover all interesting combinations of features.
-# (`--lib` only runs unit tests just like `--tests`, but the latter is not
-# available in Rust 1.22.0)
-# Tests run on rand:
-# - test no_std support, but only the unit tests:
-# `cargo test --lib --no-default-features`
-# - run unit tests and doctests with all features which are available on stable:
-# `cargo test --features=serde1,log`
-# - test examples:
-# `cargo test --examples`
-# Additional tests on nightly:
-# - run unit tests and doctests with all features which are available on nightly:
-# `cargo test --all-features`
-# - test no_std support, including the nightly alloc feature:
-# cargo test --lib --no-default-features --features=alloc
-# - run benchmarks as tests:
-# `cargo test --benches --features=nightly`
-# Tests on subcrates:
-# - select crates via --manifest-path (more reliable than --package)
-# - test appropriate feature matrix
-#
-# TODO: SIMD support on stable releases
-# NOTE: SIMD support is unreliable on nightly; we track the latest release
-matrix:
- include:
- - rust: 1.22.0
- env: DESCRIPTION="pinned stable Rust release"
- script:
- # Differs from standard script: rand_pcg features
- - cargo test --lib --no-default-features
- # TODO: add simd_support feature:
- - cargo test --features=serde1,log
- - cargo test --examples
- - cargo test --manifest-path rand_core/Cargo.toml
- - cargo test --manifest-path rand_core/Cargo.toml --no-default-features
- - cargo test --manifest-path rand_isaac/Cargo.toml --features=serde1
- # TODO: cannot test rand_pcg due to explicit dependency on i128
- - cargo test --manifest-path rand_xorshift/Cargo.toml --features=serde1
- - cargo test --manifest-path rand_xoshiro/Cargo.toml
- - cargo test --manifest-path rand_chacha/Cargo.toml
- - cargo test --manifest-path rand_hc/Cargo.toml
- - cargo test --manifest-path rand_os/Cargo.toml
-
- - rust: stable
- env: DESCRIPTION="stable Rust release, macOS, iOS (cross-compile only)"
- os: osx
- install:
- - rustup target add aarch64-apple-ios
- script:
- # Differs from standard script: includes aarch64-apple-ios cross-build
- - cargo test --lib --no-default-features
- # TODO: add simd_support feature:
- - cargo test --features=serde1,log
- - cargo test --examples
- - cargo test --manifest-path rand_core/Cargo.toml
- - cargo test --manifest-path rand_core/Cargo.toml --no-default-features
- - cargo test --manifest-path rand_isaac/Cargo.toml --features=serde1
- - cargo test --manifest-path rand_pcg/Cargo.toml --features=serde1
- - cargo test --manifest-path rand_xorshift/Cargo.toml --features=serde1
- - cargo test --manifest-path rand_xoshiro/Cargo.toml
- - cargo test --manifest-path rand_chacha/Cargo.toml
- - cargo test --manifest-path rand_hc/Cargo.toml
- - cargo test --manifest-path rand_os/Cargo.toml
- - cargo build --target=aarch64-apple-ios
-
- - rust: beta
- env: DESCRIPTION="beta Rust release"
-
- - rust: nightly
- env: DESCRIPTION="nightly features, benchmarks, documentation"
- install:
- - cargo --list | egrep "^\s*deadlinks$" -q || cargo install cargo-deadlinks
- - cargo deadlinks -V
- before_script:
- - pip install 'travis-cargo<0.2' --user && export PATH=$HOME/.local/bin:$PATH
- script:
- # Differs from standard script: alloc feature, all features, doc build
- - cargo test --lib --no-default-features --features=alloc
- - cargo test --all-features
- - cargo test --benches --features=nightly
- - cargo test --examples
- - cargo test --manifest-path rand_core/Cargo.toml
- - cargo test --manifest-path rand_core/Cargo.toml --no-default-features --features=alloc
- - cargo test --manifest-path rand_isaac/Cargo.toml --features=serde1
- - cargo test --manifest-path rand_pcg/Cargo.toml --features=serde1
- - cargo test --manifest-path rand_xorshift/Cargo.toml --features=serde1
- - cargo test --manifest-path rand_xoshiro/Cargo.toml
- - cargo test --manifest-path rand_chacha/Cargo.toml
- - cargo test --manifest-path rand_hc/Cargo.toml
- - cargo test --manifest-path rand_os/Cargo.toml
- # remove cached documentation, otherwise files from previous PRs can get included
- - rm -rf target/doc
- - cargo doc --no-deps --all --all-features
- - cargo deadlinks --dir target/doc
- after_success:
- - travis-cargo --only nightly doc-upload
-
- - rust: nightly
- env: DESCRIPTION="WASM via emscripten, stdweb and wasm-bindgen"
- install:
- - rustup target add wasm32-unknown-unknown
- - rustup target add wasm32-unknown-emscripten
- - nvm install 9
- - ./utils/ci/install_cargo_web.sh
- - cargo web prepare-emscripten
- - cargo web -V
- addons:
- chrome: stable
- script:
- # Testing wasm32-unknown-emscripten fails because of rust-lang/rust#49877
- # However, we can still build and link all tests to make sure that works.
- # This is actually useful as it finds stuff such as rust-random/rand#669
- - EMCC_CFLAGS="-s ERROR_ON_UNDEFINED_SYMBOLS=0" cargo web test --target wasm32-unknown-emscripten --no-run
- #- cargo web test --target wasm32-unknown-emscripten
- #- cargo web test --nodejs --target wasm32-unknown-emscripten
- #- cargo build --target wasm32-unknown-unknown # without any features
- - cargo build --target wasm32-unknown-unknown --features=wasm-bindgen
- - cargo web test --target wasm32-unknown-unknown --features=stdweb
-
- - rust: nightly
- env: DESCRIPTION="cross-platform builder (doesn't run tests)"
- install:
- - rustup target add x86_64-sun-solaris
- - rustup target add x86_64-unknown-cloudabi
- - rustup target add x86_64-unknown-freebsd
- #- rustup target add x86_64-unknown-fuchsia
- - rustup target add x86_64-unknown-netbsd
- - rustup target add x86_64-unknown-redox
- script:
- - cargo build --target=x86_64-sun-solaris --all-features
- - cargo build --target=x86_64-unknown-cloudabi --all-features
- - cargo build --target=x86_64-unknown-freebsd --all-features
- #- cargo build --target=x86_64-unknown-fuchsia --all-features
- - cargo build --target=x86_64-unknown-netbsd --all-features
- - cargo build --target=x86_64-unknown-redox --all-features
-
- # Trust cross-built/emulated targets. We must repeat all non-default values.
- - rust: stable
- sudo: required
- dist: trusty
- services: docker
- env: DESCRIPTION="Linux (MIPS, big-endian)" TARGET=mips-unknown-linux-gnu
- install:
- - sh utils/ci/install.sh
- - source ~/.cargo/env || true
- script:
- - bash utils/ci/script.sh
- - rust: stable
- sudo: required
- dist: trusty
- services: docker
- env: DESCRIPTION="Android (ARMv7)" TARGET=armv7-linux-androideabi
- install:
- - sh utils/ci/install.sh
- - source ~/.cargo/env || true
- script:
- - bash utils/ci/script.sh
-
-before_install:
- - set -e
- - rustup self update
-
-script:
- - cargo test --lib --no-default-features
- # TODO: add simd_support feature:
- - cargo test --features=serde1,log
- - cargo test --examples
- - cargo test --manifest-path rand_core/Cargo.toml
- - cargo test --manifest-path rand_core/Cargo.toml --no-default-features
- - cargo test --manifest-path rand_isaac/Cargo.toml --features=serde1
- - cargo test --manifest-path rand_pcg/Cargo.toml --features=serde1
- - cargo test --manifest-path rand_xorshift/Cargo.toml --features=serde1
- - cargo test --manifest-path rand_xoshiro/Cargo.toml
- - cargo test --manifest-path rand_chacha/Cargo.toml
- - cargo test --manifest-path rand_hc/Cargo.toml
- - cargo test --manifest-path rand_os/Cargo.toml
-
-after_script: set +e
-
-cache:
- cargo: true
- directories:
- - .local/share/cargo-web
-
-before_cache:
- # Travis can't cache files that are not readable by "others"
- - chmod -R a+r $HOME/.cargo
-
-env:
- global:
- secure: "BdDntVHSompN+Qxz5Rz45VI4ZqhD72r6aPl166FADlnkIwS6N6FLWdqs51O7G5CpoMXEDvyYrjmRMZe/GYLIG9cmqmn/wUrWPO+PauGiIuG/D2dmfuUNvSTRcIe7UQLXrfP3yyfZPgqsH6pSnNEVopquQKy3KjzqepgriOJtbyY="
-
-notifications:
- email:
- on_success: never
diff --git a/rand/CHANGELOG.md b/rand/CHANGELOG.md
deleted file mode 100644
index 6aa0a24..0000000
--- a/rand/CHANGELOG.md
+++ /dev/null
@@ -1,509 +0,0 @@
-# Changelog
-All notable changes to this project will be documented in this file.
-
-The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
-and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
-
-A [separate changelog is kept for rand_core](rand_core/CHANGELOG.md).
-
-You may also find the [Upgrade Guide](https://rust-random.github.io/book/update.html) useful.
-
-
-## [0.6.4] - 2019-01-08
-### Fixes
-- Move wasm-bindgen shims to correct crate (#686)
-- Make `wasm32-unknown-unknown` compile but fail at run-time if missing bindingsg (#686)
-
-## [0.6.3] - 2019-01-04
-### Fixes
-- Make the `std` feature require the optional `rand_os` dependency (#675)
-- Re-export the optional WASM dependencies of `rand_os` from `rand` to avoid breakage (#674)
-
-## [0.6.2] - 2019-01-04
-### Additions
-- Add `Default` for `ThreadRng` (#657)
-- Move `rngs::OsRng` to `rand_os` sub-crate; clean up code; use as dependency (#643) ##BLOCKER##
-- Add `rand_xoshiro` sub-crate, plus benchmarks (#642, #668)
-
-### Fixes
-- Fix bias in `UniformInt::sample_single` (#662)
-- Use `autocfg` instead of `rustc_version` for rustc version detection (#664)
-- Disable `i128` and `u128` if the `target_os` is `emscripten` (#671: work-around Emscripten limitation)
-- CI fixes (#660, #671)
-
-### Optimisations
-- Optimise memory usage of `UnitCircle` and `UnitSphereSurface` distributions (no PR)
-
-## [0.6.1] - 2018-11-22
-- Support sampling `Duration` also for `no_std` (only since Rust 1.25) (#649)
-- Disable default features of `libc` (#647)
-
-## [0.6.0] - 2018-11-14
-
-### Project organisation
-- Rand has moved from [rust-lang-nursery](https://github.com/rust-lang-nursery/rand)
- to [rust-random](https://github.com/rust-random/rand)! (#578)
-- Created [The Rust Random Book](https://rust-random.github.io/book/)
- ([source](https://github.com/rust-random/book))
-- Update copyright and licence notices (#591, #611)
-- Migrate policy documentation from the wiki (#544)
-
-### Platforms
-- Add fork protection on Unix (#466)
-- Added support for wasm-bindgen. (#541, #559, #562, #600)
-- Enable `OsRng` for powerpc64, sparc and sparc64 (#609)
-- Use `syscall` from `libc` on Linux instead of redefining it (#629)
-
-### RNGs
-- Switch `SmallRng` to use PCG (#623)
-- Implement `Pcg32` and `Pcg64Mcg` generators (#632)
-- Move ISAAC RNGs to a dedicated crate (#551)
-- Move Xorshift RNG to its own crate (#557)
-- Move ChaCha and HC128 RNGs to dedicated crates (#607, #636)
-- Remove usage of `Rc` from `ThreadRng` (#615)
-
-### Sampling and distributions
-- Implement `Rng.gen_ratio()` and `Bernoulli::new_ratio()` (#491)
-- Make `Uniform` strictly respect `f32` / `f64` high/low bounds (#477)
-- Allow `gen_range` and `Uniform` to work on non-`Copy` types (#506)
-- `Uniform` supports inclusive ranges: `Uniform::from(a..=b)`. This is
- automatically enabled for Rust >= 1.27. (#566)
-- Implement `TrustedLen` and `FusedIterator` for `DistIter` (#620)
-
-#### New distributions
-- Add the `Dirichlet` distribution (#485)
-- Added sampling from the unit sphere and circle. (#567)
-- Implement the triangular distribution (#575)
-- Implement the Weibull distribution (#576)
-- Implement the Beta distribution (#574)
-
-#### Optimisations
-
-- Optimise `Bernoulli::new` (#500)
-- Optimise `char` sampling (#519)
-- Optimise sampling of `std::time::Duration` (#583)
-
-### Sequences
-- Redesign the `seq` module (#483, #515)
-- Add `WeightedIndex` and `choose_weighted` (#518, #547)
-- Optimised and changed return type of the `sample_indices` function. (#479)
-- Use `Iterator::size_hint()` to speed up `IteratorRandom::choose` (#593)
-
-### SIMD
-- Support for generating SIMD types (#523, #542, #561, #630)
-
-### Other
-- Revise CI scripts (#632, #635)
-- Remove functionality already deprecated in 0.5 (#499)
-- Support for `i128` and `u128` is automatically enabled for Rust >= 1.26. This
- renders the `i128_support` feature obsolete. It still exists for backwards
- compatibility but does not have any effect. This breaks programs using Rand
- with `i128_support` on nightlies older than Rust 1.26. (#571)
-
-
-## [0.5.5] - 2018-08-07
-### Documentation
-- Fix links in documentation (#582)
-
-
-## [0.5.4] - 2018-07-11
-### Platform support
-- Make `OsRng` work via WASM/stdweb for WebWorkers
-
-
-## [0.5.3] - 2018-06-26
-### Platform support
-- OpenBSD, Bitrig: fix compilation (broken in 0.5.1) (#530)
-
-
-## [0.5.2] - 2018-06-18
-### Platform support
-- Hide `OsRng` and `JitterRng` on unsupported platforms (#512; fixes #503).
-
-
-## [0.5.1] - 2018-06-08
-
-### New distributions
-- Added Cauchy distribution. (#474, #486)
-- Added Pareto distribution. (#495)
-
-### Platform support and `OsRng`
-- Remove blanket Unix implementation. (#484)
-- Remove Wasm unimplemented stub. (#484)
-- Dragonfly BSD: read from `/dev/random`. (#484)
-- Bitrig: use `getentropy` like OpenBSD. (#484)
-- Solaris: (untested) use `getrandom` if available, otherwise `/dev/random`. (#484)
-- Emscripten, `stdweb`: split the read up in chunks. (#484)
-- Emscripten, Haiku: don't do an extra blocking read from `/dev/random`. (#484)
-- Linux, NetBSD, Solaris: read in blocking mode on first use in `fill_bytes`. (#484)
-- Fuchsia, CloudABI: fix compilation (broken in Rand 0.5). (#484)
-
-
-## [0.5.0] - 2018-05-21
-
-### Crate features and organisation
-- Minimum Rust version update: 1.22.0. (#239)
-- Create a separate `rand_core` crate. (#288)
-- Deprecate `rand_derive`. (#256)
-- Add `prelude` (and module reorganisation). (#435)
-- Add `log` feature. Logging is now available in `JitterRng`, `OsRng`, `EntropyRng` and `ReseedingRng`. (#246)
-- Add `serde1` feature for some PRNGs. (#189)
-- `stdweb` feature for `OsRng` support on WASM via stdweb. (#272, #336)
-
-### `Rng` trait
-- Split `Rng` in `RngCore` and `Rng` extension trait.
- `next_u32`, `next_u64` and `fill_bytes` are now part of `RngCore`. (#265)
-- Add `Rng::sample`. (#256)
-- Deprecate `Rng::gen_weighted_bool`. (#308)
-- Add `Rng::gen_bool`. (#308)
-- Remove `Rng::next_f32` and `Rng::next_f64`. (#273)
-- Add optimized `Rng::fill` and `Rng::try_fill` methods. (#247)
-- Deprecate `Rng::gen_iter`. (#286)
-- Deprecate `Rng::gen_ascii_chars`. (#279)
-
-### `rand_core` crate
-- `rand` now depends on new `rand_core` crate (#288)
-- `RngCore` and `SeedableRng` are now part of `rand_core`. (#288)
-- Add modules to help implementing RNGs `impl` and `le`. (#209, #228)
-- Add `Error` and `ErrorKind`. (#225)
-- Add `CryptoRng` marker trait. (#273)
-- Add `BlockRngCore` trait. (#281)
-- Add `BlockRng` and `BlockRng64` wrappers to help implementations. (#281, #325)
-- Revise the `SeedableRng` trait. (#233)
-- Remove default implementations for `RngCore::next_u64` and `RngCore::fill_bytes`. (#288)
-- Add `RngCore::try_fill_bytes`. (#225)
-
-### Other traits and types
-- Add `FromEntropy` trait. (#233, #375)
-- Add `SmallRng` wrapper. (#296)
-- Rewrite `ReseedingRng` to only work with `BlockRngCore` (substantial performance improvement). (#281)
-- Deprecate `weak_rng`. Use `SmallRng` instead. (#296)
-- Deprecate `AsciiGenerator`. (#279)
-
-### Random number generators
-- Switch `StdRng` and `thread_rng` to HC-128. (#277)
-- `StdRng` must now be created with `from_entropy` instead of `new`
-- Change `thread_rng` reseeding threshold to 32 MiB. (#277)
-- PRNGs no longer implement `Copy`. (#209)
-- `Debug` implementations no longer show internals. (#209)
-- Implement `Clone` for `ReseedingRng`, `JitterRng`, OsRng`. (#383, #384)
-- Implement serialization for `XorShiftRng`, `IsaacRng` and `Isaac64Rng` under the `serde1` feature. (#189)
-- Implement `BlockRngCore` for `ChaChaCore` and `Hc128Core`. (#281)
-- All PRNGs are now portable across big- and little-endian architectures. (#209)
-- `Isaac64Rng::next_u32` no longer throws away half the results. (#209)
-- Add `IsaacRng::new_from_u64` and `Isaac64Rng::new_from_u64`. (#209)
-- Add the HC-128 CSPRNG `Hc128Rng`. (#210)
-- Change ChaCha20 to have 64-bit counter and 64-bit stream. (#349)
-- Changes to `JitterRng` to get its size down from 2112 to 24 bytes. (#251)
-- Various performance improvements to all PRNGs.
-
-### Platform support and `OsRng`
-- Add support for CloudABI. (#224)
-- Remove support for NaCl. (#225)
-- WASM support for `OsRng` via stdweb, behind the `stdweb` feature. (#272, #336)
-- Use `getrandom` on more platforms for Linux, and on Android. (#338)
-- Use the `SecRandomCopyBytes` interface on macOS. (#322)
-- On systems that do not have a syscall interface, only keep a single file descriptor open for `OsRng`. (#239)
-- On Unix, first try a single read from `/dev/random`, then `/dev/urandom`. (#338)
-- Better error handling and reporting in `OsRng` (using new error type). (#225)
-- `OsRng` now uses non-blocking when available. (#225)
-- Add `EntropyRng`, which provides `OsRng`, but has `JitterRng` as a fallback. (#235)
-
-### Distributions
-- New `Distribution` trait. (#256)
-- Add `Distribution::sample_iter` and `Rng::::sample_iter`. (#361)
-- Deprecate `Rand`, `Sample` and `IndependentSample` traits. (#256)
-- Add a `Standard` distribution (replaces most `Rand` implementations). (#256)
-- Add `Binomial` and `Poisson` distributions. (#96)
-- Add `Bernoulli` dsitribution. (#411)
-- Add `Alphanumeric` distribution. (#279)
-- Remove `Closed01` distribution, add `OpenClosed01`. (#274, #420)
-- Rework `Range` type, making it possible to implement it for user types. (#274)
-- Rename `Range` to `Uniform`. (#395)
-- Add `Uniform::new_inclusive` for inclusive ranges. (#274)
-- Use widening multiply method for much faster integer range reduction. (#274)
-- `Standard` distribution for `char` uses `Uniform` internally. (#274)
-- `Standard` distribution for `bool` uses sign test. (#274)
-- Implement `Standard` distribution for `Wrapping<T>`. (#436)
-- Implement `Uniform` distribution for `Duration`. (#427)
-
-
-## [0.4.3] - 2018-08-16
-### Fixed
-- Use correct syscall number for PowerPC (#589)
-
-
-## [0.4.2] - 2018-01-06
-### Changed
-- Use `winapi` on Windows
-- Update for Fuchsia OS
-- Remove dev-dependency on `log`
-
-
-## [0.4.1] - 2017-12-17
-### Added
-- `no_std` support
-
-
-## [0.4.0-pre.0] - 2017-12-11
-### Added
-- `JitterRng` added as a high-quality alternative entropy source using the
- system timer
-- new `seq` module with `sample_iter`, `sample_slice`, etc.
-- WASM support via dummy implementations (fail at run-time)
-- Additional benchmarks, covering generators and new seq code
-
-### Changed
-- `thread_rng` uses `JitterRng` if seeding from system time fails
- (slower but more secure than previous method)
-
-### Deprecated
- - `sample` function deprecated (replaced by `sample_iter`)
-
-
-## [0.3.20] - 2018-01-06
-### Changed
-- Remove dev-dependency on `log`
-- Update `fuchsia-zircon` dependency to 0.3.2
-
-
-## [0.3.19] - 2017-12-27
-### Changed
-- Require `log <= 0.3.8` for dev builds
-- Update `fuchsia-zircon` dependency to 0.3
-- Fix broken links in docs (to unblock compiler docs testing CI)
-
-
-## [0.3.18] - 2017-11-06
-### Changed
-- `thread_rng` is seeded from the system time if `OsRng` fails
-- `weak_rng` now uses `thread_rng` internally
-
-
-## [0.3.17] - 2017-10-07
-### Changed
- - Fuchsia: Magenta was renamed Zircon
-
-## [0.3.16] - 2017-07-27
-### Added
-- Implement Debug for mote non-public types
-- implement `Rand` for (i|u)i128
-- Support for Fuchsia
-
-### Changed
-- Add inline attribute to SampleRange::construct_range.
- This improves the benchmark for sample in 11% and for shuffle in 16%.
-- Use `RtlGenRandom` instead of `CryptGenRandom`
-
-
-## [0.3.15] - 2016-11-26
-### Added
-- Add `Rng` trait method `choose_mut`
-- Redox support
-
-### Changed
-- Use `arc4rand` for `OsRng` on FreeBSD.
-- Use `arc4random(3)` for `OsRng` on OpenBSD.
-
-### Fixed
-- Fix filling buffers 4 GiB or larger with `OsRng::fill_bytes` on Windows
-
-
-## [0.3.14] - 2016-02-13
-### Fixed
-- Inline definitions from winapi/advapi32, wich decreases build times
-
-
-## [0.3.13] - 2016-01-09
-### Fixed
-- Compatible with Rust 1.7.0-nightly (needed some extra type annotations)
-
-
-## [0.3.12] - 2015-11-09
-### Changed
-- Replaced the methods in `next_f32` and `next_f64` with the technique described
- Saito & Matsumoto at MCQMC'08. The new method should exhibit a slightly more
- uniform distribution.
-- Depend on libc 0.2
-
-### Fixed
-- Fix iterator protocol issue in `rand::sample`
-
-
-## [0.3.11] - 2015-08-31
-### Added
-- Implement `Rand` for arrays with n <= 32
-
-
-## [0.3.10] - 2015-08-17
-### Added
-- Support for NaCl platforms
-
-### Changed
-- Allow `Rng` to be `?Sized`, impl for `&mut R` and `Box<R>` where `R: ?Sized + Rng`
-
-
-## [0.3.9] - 2015-06-18
-### Changed
-- Use `winapi` for Windows API things
-
-### Fixed
-- Fixed test on stable/nightly
-- Fix `getrandom` syscall number for aarch64-unknown-linux-gnu
-
-
-## [0.3.8] - 2015-04-23
-### Changed
-- `log` is a dev dependency
-
-### Fixed
-- Fix race condition of atomics in `is_getrandom_available`
-
-
-## [0.3.7] - 2015-04-03
-### Fixed
-- Derive Copy/Clone changes
-
-
-## [0.3.6] - 2015-04-02
-### Changed
-- Move to stable Rust!
-
-
-## [0.3.5] - 2015-04-01
-### Fixed
-- Compatible with Rust master
-
-
-## [0.3.4] - 2015-03-31
-### Added
-- Implement Clone for `Weighted`
-
-### Fixed
-- Compatible with Rust master
-
-
-## [0.3.3] - 2015-03-26
-### Fixed
-- Fix compile on Windows
-
-
-## [0.3.2] - 2015-03-26
-
-
-## [0.3.1] - 2015-03-26
-### Fixed
-- Fix compile on Windows
-
-
-## [0.3.0] - 2015-03-25
-### Changed
-- Update to use log version 0.3.x
-
-
-## [0.2.1] - 2015-03-22
-### Fixed
-- Compatible with Rust master
-- Fixed iOS compilation
-
-
-## [0.2.0] - 2015-03-06
-### Fixed
-- Compatible with Rust master (move from `old_io` to `std::io`)
-
-
-## [0.1.4] - 2015-03-04
-### Fixed
-- Compatible with Rust master (use wrapping ops)
-
-
-## [0.1.3] - 2015-02-20
-### Fixed
-- Compatible with Rust master
-
-### Removed
-- Removed Copy implementations from RNGs
-
-
-## [0.1.2] - 2015-02-03
-### Added
-- Imported functionality from `std::rand`, including:
- - `StdRng`, `SeedableRng`, `TreadRng`, `weak_rng()`
- - `ReaderRng`: A wrapper around any Reader to treat it as an RNG.
-- Imported documentation from `std::rand`
-- Imported tests from `std::rand`
-
-
-## [0.1.1] - 2015-02-03
-### Added
-- Migrate to a cargo-compatible directory structure.
-
-### Fixed
-- Do not use entropy during `gen_weighted_bool(1)`
-
-
-## [Rust 0.12.0] - 2014-10-09
-### Added
-- Impl Rand for tuples of arity 11 and 12
-- Include ChaCha pseudorandom generator
-- Add `next_f64` and `next_f32` to Rng
-- Implement Clone for PRNGs
-
-### Changed
-- Rename `TaskRng` to `ThreadRng` and `task_rng` to `thread_rng` (since a
- runtime is removed from Rust).
-
-### Fixed
-- Improved performance of ISAAC and ISAAC64 by 30% and 12 % respectively, by
- informing the optimiser that indexing is never out-of-bounds.
-
-### Removed
-- Removed the Deprecated `choose_option`
-
-
-## [Rust 0.11.0] - 2014-07-02
-### Added
-- document when to use `OSRng` in cryptographic context, and explain why we use `/dev/urandom` instead of `/dev/random`
-- `Rng::gen_iter()` which will return an infinite stream of random values
-- `Rng::gen_ascii_chars()` which will return an infinite stream of random ascii characters
-
-### Changed
-- Now only depends on libcore!
-- Remove `Rng.choose()`, rename `Rng.choose_option()` to `.choose()`
-- Rename OSRng to OsRng
-- The WeightedChoice structure is no longer built with a `Vec<Weighted<T>>`,
- but rather a `&mut [Weighted<T>]`. This means that the WeightedChoice
- structure now has a lifetime associated with it.
-- The `sample` method on `Rng` has been moved to a top-level function in the
- `rand` module due to its dependence on `Vec`.
-
-### Removed
-- `Rng::gen_vec()` was removed. Previous behavior can be regained with
- `rng.gen_iter().take(n).collect()`
-- `Rng::gen_ascii_str()` was removed. Previous behavior can be regained with
- `rng.gen_ascii_chars().take(n).collect()`
-- {IsaacRng, Isaac64Rng, XorShiftRng}::new() have all been removed. These all
- relied on being able to use an OSRng for seeding, but this is no longer
- available in librand (where these types are defined). To retain the same
- functionality, these types now implement the `Rand` trait so they can be
- generated with a random seed from another random number generator. This allows
- the stdlib to use an OSRng to create seeded instances of these RNGs.
-- Rand implementations for `Box<T>` and `@T` were removed. These seemed to be
- pretty rare in the codebase, and it allows for librand to not depend on
- liballoc. Additionally, other pointer types like Rc<T> and Arc<T> were not
- supported.
-- Remove a slew of old deprecated functions
-
-
-## [Rust 0.10] - 2014-04-03
-### Changed
-- replace `Rng.shuffle's` functionality with `.shuffle_mut`
-- bubble up IO errors when creating an OSRng
-
-### Fixed
-- Use `fill()` instead of `read()`
-- Rewrite OsRng in Rust for windows
-
-## [0.10-pre] - 2014-03-02
-### Added
-- Seperate `rand` out of the standard library
diff --git a/rand/COPYRIGHT b/rand/COPYRIGHT
deleted file mode 100644
index 468d907..0000000
--- a/rand/COPYRIGHT
+++ /dev/null
@@ -1,12 +0,0 @@
-Copyrights in the Rand project are retained by their contributors. No
-copyright assignment is required to contribute to the Rand project.
-
-For full authorship information, see the version control history.
-
-Except as otherwise noted (below and/or in individual files), Rand is
-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.
-
-The Rand project includes code from the Rust project
-published under these same licenses.
diff --git a/rand/Cargo.toml b/rand/Cargo.toml
deleted file mode 100644
index d802d36..0000000
--- a/rand/Cargo.toml
+++ /dev/null
@@ -1,84 +0,0 @@
-[package]
-name = "rand"
-version = "0.6.4"
-authors = ["The Rand Project Developers", "The Rust Project Developers"]
-license = "MIT/Apache-2.0"
-readme = "README.md"
-repository = "https://github.com/rust-random/rand"
-documentation = "https://rust-random.github.io/rand"
-homepage = "https://crates.io/crates/rand"
-description = """
-Random number generators and other randomness functionality.
-"""
-keywords = ["random", "rng"]
-categories = ["algorithms", "no-std"]
-build = "build.rs"
-exclude = ["/utils/*", "/.travis.yml", "/appveyor.yml", ".gitignore"]
-
-[badges]
-travis-ci = { repository = "rust-random/rand" }
-appveyor = { repository = "rust-random/rand" }
-
-[features]
-default = ["std", "rand_os"] # without "std" rand uses libcore
-nightly = ["simd_support"] # enables all features requiring nightly rust
-std = ["rand_core/std", "alloc", "rand_os"]
-alloc = ["rand_core/alloc"] # enables Vec and Box support (without std)
-i128_support = [] # enables i128 and u128 support
-simd_support = ["packed_simd"] # enables SIMD support
-serde1 = ["rand_core/serde1", "rand_isaac/serde1", "rand_xorshift/serde1"] # enables serialization for PRNGs
-# re-export optional WASM dependencies to avoid breakage:
-wasm-bindgen = ["rand_os/wasm-bindgen"]
-stdweb = ["rand_os/stdweb"]
-
-[workspace]
-members = [
- "rand_core",
- "rand_os",
- "rand_isaac",
- "rand_chacha",
- "rand_hc",
- "rand_pcg",
- "rand_xorshift",
- "rand_xoshiro",
-]
-
-[dependencies]
-rand_core = { path = "rand_core", version = "0.3", default-features = false }
-rand_pcg = { path = "rand_pcg", version = "0.1" }
-rand_os = { path = "rand_os", version = "0.1", optional = true }
-# only for deprecations and benches:
-rand_isaac = { path = "rand_isaac", version = "0.1" }
-rand_chacha = { path = "rand_chacha", version = "0.1" }
-rand_hc = { path = "rand_hc", version = "0.1" }
-rand_xorshift = { path = "rand_xorshift", version = "0.1" }
-log = { version = "0.4", optional = true }
-
-[dependencies.packed_simd]
-# NOTE: so far no version works reliably due to dependence on unstable features
-version = "0.3"
-# git = "https://github.com/rust-lang-nursery/packed_simd"
-optional = true
-features = ["into_bits"]
-
-[target.'cfg(unix)'.dependencies]
-libc = { version = "0.2", default-features = false }
-
-# TODO: check if all features are required
-[target.'cfg(windows)'.dependencies]
-winapi = { version = "0.3", features = ["minwindef", "ntsecapi", "profileapi", "winnt"] }
-
-[dev-dependencies]
-# This has a histogram implementation used for testing uniformity.
-average = "0.9.2"
-# Only for benches:
-rand_xoshiro = { path = "rand_xoshiro", version = "0.1" }
-
-[build-dependencies]
-autocfg = "0.1"
-
-[package.metadata.docs.rs]
-all-features = true
-
-[patch.crates-io]
-rand_core = { path = "rand_core", version = "0.3", default-features = false }
diff --git a/rand/LICENSE-APACHE b/rand/LICENSE-APACHE
deleted file mode 100644
index 17d7468..0000000
--- a/rand/LICENSE-APACHE
+++ /dev/null
@@ -1,201 +0,0 @@
- Apache License
- Version 2.0, January 2004
- https://www.apache.org/licenses/
-
-TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
-1. Definitions.
-
- "License" shall mean the terms and conditions for use, reproduction,
- and distribution as defined by Sections 1 through 9 of this document.
-
- "Licensor" shall mean the copyright owner or entity authorized by
- the copyright owner that is granting the License.
-
- "Legal Entity" shall mean the union of the acting entity and all
- other entities that control, are controlled by, or are under common
- control with that entity. For the purposes of this definition,
- "control" means (i) the power, direct or indirect, to cause the
- direction or management of such entity, whether by contract or
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
- outstanding shares, or (iii) beneficial ownership of such entity.
-
- "You" (or "Your") shall mean an individual or Legal Entity
- exercising permissions granted by this License.
-
- "Source" form shall mean the preferred form for making modifications,
- including but not limited to software source code, documentation
- source, and configuration files.
-
- "Object" form shall mean any form resulting from mechanical
- transformation or translation of a Source form, including but
- not limited to compiled object code, generated documentation,
- and conversions to other media types.
-
- "Work" shall mean the work of authorship, whether in Source or
- Object form, made available under the License, as indicated by a
- copyright notice that is included in or attached to the work
- (an example is provided in the Appendix below).
-
- "Derivative Works" shall mean any work, whether in Source or Object
- form, that is based on (or derived from) the Work and for which the
- editorial revisions, annotations, elaborations, or other modifications
- represent, as a whole, an original work of authorship. For the purposes
- of this License, Derivative Works shall not include works that remain
- separable from, or merely link (or bind by name) to the interfaces of,
- the Work and Derivative Works thereof.
-
- "Contribution" shall mean any work of authorship, including
- the original version of the Work and any modifications or additions
- to that Work or Derivative Works thereof, that is intentionally
- submitted to Licensor for inclusion in the Work by the copyright owner
- or by an individual or Legal Entity authorized to submit on behalf of
- the copyright owner. For the purposes of this definition, "submitted"
- means any form of electronic, verbal, or written communication sent
- to the Licensor or its representatives, including but not limited to
- communication on electronic mailing lists, source code control systems,
- and issue tracking systems that are managed by, or on behalf of, the
- Licensor for the purpose of discussing and improving the Work, but
- excluding communication that is conspicuously marked or otherwise
- designated in writing by the copyright owner as "Not a Contribution."
-
- "Contributor" shall mean Licensor and any individual or Legal Entity
- on behalf of whom a Contribution has been received by Licensor and
- subsequently incorporated within the Work.
-
-2. Grant of Copyright License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- copyright license to reproduce, prepare Derivative Works of,
- publicly display, publicly perform, sublicense, and distribute the
- Work and such Derivative Works in Source or Object form.
-
-3. Grant of Patent License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- (except as stated in this section) patent license to make, have made,
- use, offer to sell, sell, import, and otherwise transfer the Work,
- where such license applies only to those patent claims licensable
- by such Contributor that are necessarily infringed by their
- Contribution(s) alone or by combination of their Contribution(s)
- with the Work to which such Contribution(s) was submitted. If You
- institute patent litigation against any entity (including a
- cross-claim or counterclaim in a lawsuit) alleging that the Work
- or a Contribution incorporated within the Work constitutes direct
- or contributory patent infringement, then any patent licenses
- granted to You under this License for that Work shall terminate
- as of the date such litigation is filed.
-
-4. Redistribution. You may reproduce and distribute copies of the
- Work or Derivative Works thereof in any medium, with or without
- modifications, and in Source or Object form, provided that You
- meet the following conditions:
-
- (a) You must give any other recipients of the Work or
- Derivative Works a copy of this License; and
-
- (b) You must cause any modified files to carry prominent notices
- stating that You changed the files; and
-
- (c) You must retain, in the Source form of any Derivative Works
- that You distribute, all copyright, patent, trademark, and
- attribution notices from the Source form of the Work,
- excluding those notices that do not pertain to any part of
- the Derivative Works; and
-
- (d) If the Work includes a "NOTICE" text file as part of its
- distribution, then any Derivative Works that You distribute must
- include a readable copy of the attribution notices contained
- within such NOTICE file, excluding those notices that do not
- pertain to any part of the Derivative Works, in at least one
- of the following places: within a NOTICE text file distributed
- as part of the Derivative Works; within the Source form or
- documentation, if provided along with the Derivative Works; or,
- within a display generated by the Derivative Works, if and
- wherever such third-party notices normally appear. The contents
- of the NOTICE file are for informational purposes only and
- do not modify the License. You may add Your own attribution
- notices within Derivative Works that You distribute, alongside
- or as an addendum to the NOTICE text from the Work, provided
- that such additional attribution notices cannot be construed
- as modifying the License.
-
- You may add Your own copyright statement to Your modifications and
- may provide additional or different license terms and conditions
- for use, reproduction, or distribution of Your modifications, or
- for any such Derivative Works as a whole, provided Your use,
- reproduction, and distribution of the Work otherwise complies with
- the conditions stated in this License.
-
-5. Submission of Contributions. Unless You explicitly state otherwise,
- any Contribution intentionally submitted for inclusion in the Work
- by You to the Licensor shall be under the terms and conditions of
- this License, without any additional terms or conditions.
- Notwithstanding the above, nothing herein shall supersede or modify
- the terms of any separate license agreement you may have executed
- with Licensor regarding such Contributions.
-
-6. Trademarks. This License does not grant permission to use the trade
- names, trademarks, service marks, or product names of the Licensor,
- except as required for reasonable and customary use in describing the
- origin of the Work and reproducing the content of the NOTICE file.
-
-7. Disclaimer of Warranty. Unless required by applicable law or
- agreed to in writing, Licensor provides the Work (and each
- Contributor provides its Contributions) on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- implied, including, without limitation, any warranties or conditions
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
- PARTICULAR PURPOSE. You are solely responsible for determining the
- appropriateness of using or redistributing the Work and assume any
- risks associated with Your exercise of permissions under this License.
-
-8. Limitation of Liability. In no event and under no legal theory,
- whether in tort (including negligence), contract, or otherwise,
- unless required by applicable law (such as deliberate and grossly
- negligent acts) or agreed to in writing, shall any Contributor be
- liable to You for damages, including any direct, indirect, special,
- incidental, or consequential damages of any character arising as a
- result of this License or out of the use or inability to use the
- Work (including but not limited to damages for loss of goodwill,
- work stoppage, computer failure or malfunction, or any and all
- other commercial damages or losses), even if such Contributor
- has been advised of the possibility of such damages.
-
-9. Accepting Warranty or Additional Liability. While redistributing
- the Work or Derivative Works thereof, You may choose to offer,
- and charge a fee for, acceptance of support, warranty, indemnity,
- or other liability obligations and/or rights consistent with this
- License. However, in accepting such obligations, You may act only
- on Your own behalf and on Your sole responsibility, not on behalf
- of any other Contributor, and only if You agree to indemnify,
- defend, and hold each Contributor harmless for any liability
- incurred by, or claims asserted against, such Contributor by reason
- of your accepting any such warranty or additional liability.
-
-END OF TERMS AND CONDITIONS
-
-APPENDIX: How to apply the Apache License to your work.
-
- To apply the Apache License to your work, attach the following
- boilerplate notice, with the fields enclosed by brackets "[]"
- replaced with your own identifying information. (Don't include
- the brackets!) The text should be enclosed in the appropriate
- comment syntax for the file format. We also recommend that a
- file or class name and description of purpose be included on the
- same "printed page" as the copyright notice for easier
- identification within third-party archives.
-
-Copyright [yyyy] [name of copyright owner]
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
- https://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
diff --git a/rand/LICENSE-MIT b/rand/LICENSE-MIT
deleted file mode 100644
index d93b5ba..0000000
--- a/rand/LICENSE-MIT
+++ /dev/null
@@ -1,26 +0,0 @@
-Copyright 2018 Developers of the Rand project
-Copyright (c) 2014 The Rust Project Developers
-
-Permission is hereby granted, free of charge, to any
-person obtaining a copy of this software and associated
-documentation files (the "Software"), to deal in the
-Software without restriction, including without
-limitation the rights to use, copy, modify, merge,
-publish, distribute, sublicense, and/or sell copies of
-the Software, and to permit persons to whom the Software
-is furnished to do so, subject to the following
-conditions:
-
-The above copyright notice and this permission notice
-shall be included in all copies or substantial portions
-of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
-ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
-TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
-PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
-SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
-CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
-IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
-DEALINGS IN THE SOFTWARE.
diff --git a/rand/README.md b/rand/README.md
deleted file mode 100644
index 314a57f..0000000
--- a/rand/README.md
+++ /dev/null
@@ -1,122 +0,0 @@
-# Rand
-
-[![Build Status](https://travis-ci.org/rust-random/rand.svg?branch=master)](https://travis-ci.org/rust-random/rand)
-[![Build Status](https://ci.appveyor.com/api/projects/status/github/rust-random/rand?svg=true)](https://ci.appveyor.com/project/rust-random/rand)
-[![Crate](https://img.shields.io/crates/v/rand.svg)](https://crates.io/crates/rand)
-[![Book](https://img.shields.io/badge/book-master-yellow.svg)](https://rust-random.github.io/book/)
-[![API](https://img.shields.io/badge/api-master-yellow.svg)](https://rust-random.github.io/rand)
-[![API](https://docs.rs/rand/badge.svg)](https://docs.rs/rand)
-[![Minimum rustc version](https://img.shields.io/badge/rustc-1.22+-lightgray.svg)](https://github.com/rust-random/rand#rust-version-requirements)
-
-A Rust library for random number generation.
-
-Rand provides utilities to generate random numbers, to convert them to useful
-types and distributions, and some randomness-related algorithms.
-
-The core random number generation traits of Rand live in the [rand_core](
-https://crates.io/crates/rand_core) crate but are also exposed here; RNG
-implementations should prefer to use `rand_core` while most other users should
-depend on `rand`.
-
-Documentation:
-- [The Rust Rand Book](https://rust-random.github.io/book)
-- [API reference (master)](https://rust-random.github.io/rand)
-- [API reference (docs.rs)](https://docs.rs/rand)
-
-
-## Usage
-
-Add this to your `Cargo.toml`:
-
-```toml
-[dependencies]
-rand = "0.6"
-```
-
-To get started using Rand, see [The Book](https://rust-random.github.io/book).
-
-
-## Versions
-
-The Rand lib is not yet stable, however we are careful to limit breaking changes
-and warn via deprecation wherever possible. Patch versions never introduce
-breaking changes. The following minor versions are supported:
-
-- Version 0.6 was released in November 2018, redesigning the `seq` module,
- moving most PRNGs to external crates, and many small changes.
-- Version 0.5 was released in May 2018, as a major reorganisation
- (introducing `RngCore` and `rand_core`, and deprecating `Rand` and the
- previous distribution traits).
-- Version 0.4 was released in December 2017, but contained almost no breaking
- changes from the 0.3 series.
-
-A detailed [changelog](CHANGELOG.md) is available.
-
-When upgrading to the next minor series (especially 0.4 → 0.5), we recommend
-reading the [Upgrade Guide](https://rust-random.github.io/book/update.html).
-
-### Rust version requirements
-
-Since version 0.5, Rand requires **Rustc version 1.22 or greater**.
-Rand 0.4 and 0.3 (since approx. June 2017) require Rustc version 1.15 or
-greater. Subsets of the Rand code may work with older Rust versions, but this
-is not supported.
-
-Travis CI always has a build with a pinned version of Rustc matching the oldest
-supported Rust release. The current policy is that this can be updated in any
-Rand release if required, but the change must be noted in the changelog.
-
-To avoid bumping the required version unnecessarily, we use a `build.rs` script
-to auto-detect the compiler version and enable certain features or change code
-paths automatically. Since this makes it easy to unintentionally make use of
-features requiring a more recent Rust version, we recommend testing with a
-pinned version of Rustc if you require compatibility with a specific version.
-
-## Crate Features
-
-Rand is built with the `std` and `rand_os` features enabled by default:
-
-- `std` enables functionality dependent on the `std` lib and implies `alloc`
- and `rand_os`
-- `rand_os` enables the `rand_os` crate, `rngs::OsRng` and enables its usage;
- the continued existance of this feature is not guaranteed so users are
- encouraged to specify `std` instead
-
-The following optional features are available:
-
-- `alloc` can be used instead of `std` to provide `Vec` and `Box`.
-- `log` enables some logging via the `log` crate.
-- `nightly` enables all unstable features (`simd_support`).
-- `serde1` enables serialization for some types, via Serde version 1.
-- `simd_support` enables uniform sampling of SIMD types (integers and floats).
-- `stdweb` enables support for `OsRng` on `wasm32-unknown-unknown` via `stdweb`
- combined with `cargo-web`.
-- `wasm-bindgen` enables support for `OsRng` on `wasm32-unknown-unknown` via
- [`wasm-bindgen`]
-
-[`wasm-bindgen`]: https://github.com/rustwasm/wasm-bindgen
-
-`no_std` mode is activated by setting `default-features = false`; this removes
-functionality depending on `std`:
-
-- `thread_rng()`, and `random()` are not available, as they require thread-local
- storage and an entropy source.
-- `OsRng` and `EntropyRng` are unavailable.
-- `JitterRng` code is still present, but a nanosecond timer must be provided via
- `JitterRng::new_with_timer`
-- Since no external entropy is available, it is not possible to create
- generators with fresh seeds using the `FromEntropy` trait (user must provide
- a seed).
-- Several non-linear distributions distributions are unavailable since `exp`
- and `log` functions are not provided in `core`.
-- Large parts of the `seq`-uence module are unavailable, unless the `alloc`
- feature is used (several APIs and many implementations require `Vec`).
-
-
-# License
-
-Rand is distributed under the terms of both the MIT license and the
-Apache License (Version 2.0).
-
-See [LICENSE-APACHE](LICENSE-APACHE) and [LICENSE-MIT](LICENSE-MIT), and
-[COPYRIGHT](COPYRIGHT) for details.
diff --git a/rand/appveyor.yml b/rand/appveyor.yml
deleted file mode 100644
index 70e4326..0000000
--- a/rand/appveyor.yml
+++ /dev/null
@@ -1,55 +0,0 @@
-environment:
-
- # At the time this was added AppVeyor was having troubles with checking
- # revocation of SSL certificates of sites like static.rust-lang.org and what
- # we think is crates.io. The libcurl HTTP client by default checks for
- # revocation on Windows and according to a mailing list [1] this can be
- # disabled.
- #
- # The `CARGO_HTTP_CHECK_REVOKE` env var here tells cargo to disable SSL
- # revocation checking on Windows in libcurl. Note, though, that rustup, which
- # we're using to download Rust here, also uses libcurl as the default backend.
- # Unlike Cargo, however, rustup doesn't have a mechanism to disable revocation
- # checking. To get rustup working we set `RUSTUP_USE_HYPER` which forces it to
- # use the Hyper instead of libcurl backend. Both Hyper and libcurl use
- # schannel on Windows but it appears that Hyper configures it slightly
- # differently such that revocation checking isn't turned on by default.
- #
- # [1]: https://curl.haxx.se/mail/lib-2016-03/0202.html
- RUSTUP_USE_HYPER: 1
- CARGO_HTTP_CHECK_REVOKE: false
-
- matrix:
- - TARGET: x86_64-pc-windows-msvc
- - TARGET: i686-pc-windows-msvc
-install:
- - appveyor DownloadFile https://win.rustup.rs/ -FileName rustup-init.exe
- - rustup-init.exe -y --default-host %TARGET% --default-toolchain nightly
- - set PATH=%PATH%;C:\Users\appveyor\.cargo\bin
- - rustc -V
- - cargo -V
-
-build: false
-
-test_script:
- - cargo test --lib --no-default-features --features alloc
- # TODO: use --all-features once simd_support is sufficiently stable:
- - cargo test --features=serde1,log
- - cargo test --benches --features=nightly
- - cargo test --examples
- - cargo test --package rand_core
- - cargo test --package rand_core --no-default-features --features=alloc
- - cargo test --package rand_isaac --features=serde1
- - cargo test --package rand_xorshift --features=serde1
- - cargo test --package rand_xoshiro
- - cargo test --package rand_chacha
- - cargo test --package rand_hc
- - cargo test --manifest-path rand_core/Cargo.toml
- - cargo test --manifest-path rand_core/Cargo.toml --no-default-features --features=alloc
- - cargo test --manifest-path rand_isaac/Cargo.toml --features=serde1
- - cargo test --manifest-path rand_pcg/Cargo.toml --features=serde1
- - cargo test --manifest-path rand_xorshift/Cargo.toml --features=serde1
- - cargo test --manifest-path rand_xoshiro/Cargo.toml
- - cargo test --manifest-path rand_chacha/Cargo.toml
- - cargo test --manifest-path rand_hc/Cargo.toml
- - cargo test --manifest-path rand_os/Cargo.toml
diff --git a/rand/benches/distributions.rs b/rand/benches/distributions.rs
deleted file mode 100644
index 069a828..0000000
--- a/rand/benches/distributions.rs
+++ /dev/null
@@ -1,259 +0,0 @@
-// Copyright 2018 Developers of the Rand project.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-#![feature(test)]
-
-extern crate test;
-extern crate rand;
-
-const RAND_BENCH_N: u64 = 1000;
-
-use std::mem::size_of;
-use test::Bencher;
-use std::time::Duration;
-
-use rand::{Rng, FromEntropy};
-use rand::rngs::SmallRng;
-use rand::distributions::*;
-
-macro_rules! distr_int {
- ($fnn:ident, $ty:ty, $distr:expr) => {
- #[bench]
- fn $fnn(b: &mut Bencher) {
- let mut rng = SmallRng::from_entropy();
- let distr = $distr;
-
- b.iter(|| {
- let mut accum = 0 as $ty;
- for _ in 0..::RAND_BENCH_N {
- let x: $ty = distr.sample(&mut rng);
- accum = accum.wrapping_add(x);
- }
- accum
- });
- b.bytes = size_of::<$ty>() as u64 * ::RAND_BENCH_N;
- }
- }
-}
-
-macro_rules! distr_float {
- ($fnn:ident, $ty:ty, $distr:expr) => {
- #[bench]
- fn $fnn(b: &mut Bencher) {
- let mut rng = SmallRng::from_entropy();
- let distr = $distr;
-
- b.iter(|| {
- let mut accum = 0.0;
- for _ in 0..::RAND_BENCH_N {
- let x: $ty = distr.sample(&mut rng);
- accum += x;
- }
- accum
- });
- b.bytes = size_of::<$ty>() as u64 * ::RAND_BENCH_N;
- }
- }
-}
-
-macro_rules! distr_duration {
- ($fnn:ident, $distr:expr) => {
- #[bench]
- fn $fnn(b: &mut Bencher) {
- let mut rng = SmallRng::from_entropy();
- let distr = $distr;
-
- b.iter(|| {
- let mut accum = Duration::new(0, 0);
- for _ in 0..::RAND_BENCH_N {
- let x: Duration = distr.sample(&mut rng);
- accum = accum.checked_add(x).unwrap_or(Duration::new(u64::max_value(), 999_999_999));
- }
- accum
- });
- b.bytes = size_of::<Duration>() as u64 * ::RAND_BENCH_N;
- }
- }
-}
-
-macro_rules! distr {
- ($fnn:ident, $ty:ty, $distr:expr) => {
- #[bench]
- fn $fnn(b: &mut Bencher) {
- let mut rng = SmallRng::from_entropy();
- let distr = $distr;
-
- b.iter(|| {
- let mut accum = 0u32;
- for _ in 0..::RAND_BENCH_N {
- let x: $ty = distr.sample(&mut rng);
- accum = accum.wrapping_add(x as u32);
- }
- accum
- });
- b.bytes = size_of::<$ty>() as u64 * ::RAND_BENCH_N;
- }
- }
-}
-
-macro_rules! distr_arr {
- ($fnn:ident, $ty:ty, $distr:expr) => {
- #[bench]
- fn $fnn(b: &mut Bencher) {
- let mut rng = SmallRng::from_entropy();
- let distr = $distr;
-
- b.iter(|| {
- let mut accum = 0u32;
- for _ in 0..::RAND_BENCH_N {
- let x: $ty = distr.sample(&mut rng);
- accum = accum.wrapping_add(x[0] as u32);
- }
- accum
- });
- b.bytes = size_of::<$ty>() as u64 * ::RAND_BENCH_N;
- }
- }
-}
-
-// uniform
-distr_int!(distr_uniform_i8, i8, Uniform::new(20i8, 100));
-distr_int!(distr_uniform_i16, i16, Uniform::new(-500i16, 2000));
-distr_int!(distr_uniform_i32, i32, Uniform::new(-200_000_000i32, 800_000_000));
-distr_int!(distr_uniform_i64, i64, Uniform::new(3i64, 123_456_789_123));
-distr_int!(distr_uniform_i128, i128, Uniform::new(-123_456_789_123i128, 123_456_789_123_456_789));
-
-distr_float!(distr_uniform_f32, f32, Uniform::new(2.26f32, 2.319));
-distr_float!(distr_uniform_f64, f64, Uniform::new(2.26f64, 2.319));
-
-const LARGE_SEC: u64 = u64::max_value() / 1000;
-
-distr_duration!(distr_uniform_duration_largest,
- Uniform::new_inclusive(Duration::new(0, 0), Duration::new(u64::max_value(), 999_999_999))
-);
-distr_duration!(distr_uniform_duration_large,
- Uniform::new(Duration::new(0, 0), Duration::new(LARGE_SEC, 1_000_000_000 / 2))
-);
-distr_duration!(distr_uniform_duration_one,
- Uniform::new(Duration::new(0, 0), Duration::new(1, 0))
-);
-distr_duration!(distr_uniform_duration_variety,
- Uniform::new(Duration::new(10000, 423423), Duration::new(200000, 6969954))
-);
-distr_duration!(distr_uniform_duration_edge,
- Uniform::new_inclusive(Duration::new(LARGE_SEC, 999_999_999), Duration::new(LARGE_SEC + 1, 1))
-);
-
-
-// standard
-distr_int!(distr_standard_i8, i8, Standard);
-distr_int!(distr_standard_i16, i16, Standard);
-distr_int!(distr_standard_i32, i32, Standard);
-distr_int!(distr_standard_i64, i64, Standard);
-distr_int!(distr_standard_i128, i128, Standard);
-
-distr!(distr_standard_bool, bool, Standard);
-distr!(distr_standard_alphanumeric, char, Alphanumeric);
-distr!(distr_standard_codepoint, char, Standard);
-
-distr_float!(distr_standard_f32, f32, Standard);
-distr_float!(distr_standard_f64, f64, Standard);
-distr_float!(distr_open01_f32, f32, Open01);
-distr_float!(distr_open01_f64, f64, Open01);
-distr_float!(distr_openclosed01_f32, f32, OpenClosed01);
-distr_float!(distr_openclosed01_f64, f64, OpenClosed01);
-
-// distributions
-distr_float!(distr_exp, f64, Exp::new(1.23 * 4.56));
-distr_float!(distr_normal, f64, Normal::new(-1.23, 4.56));
-distr_float!(distr_log_normal, f64, LogNormal::new(-1.23, 4.56));
-distr_float!(distr_gamma_large_shape, f64, Gamma::new(10., 1.0));
-distr_float!(distr_gamma_small_shape, f64, Gamma::new(0.1, 1.0));
-distr_float!(distr_cauchy, f64, Cauchy::new(4.2, 6.9));
-distr_int!(distr_binomial, u64, Binomial::new(20, 0.7));
-distr_int!(distr_poisson, u64, Poisson::new(4.0));
-distr!(distr_bernoulli, bool, Bernoulli::new(0.18));
-distr_arr!(distr_circle, [f64; 2], UnitCircle::new());
-distr_arr!(distr_sphere_surface, [f64; 3], UnitSphereSurface::new());
-
-// Weighted
-distr_int!(distr_weighted_i8, usize, WeightedIndex::new(&[1i8, 2, 3, 4, 12, 0, 2, 1]).unwrap());
-distr_int!(distr_weighted_u32, usize, WeightedIndex::new(&[1u32, 2, 3, 4, 12, 0, 2, 1]).unwrap());
-distr_int!(distr_weighted_f64, usize, WeightedIndex::new(&[1.0f64, 0.001, 1.0/3.0, 4.01, 0.0, 3.3, 22.0, 0.001]).unwrap());
-distr_int!(distr_weighted_large_set, usize, WeightedIndex::new((0..10000).rev().chain(1..10001)).unwrap());
-
-// construct and sample from a range
-macro_rules! gen_range_int {
- ($fnn:ident, $ty:ident, $low:expr, $high:expr) => {
- #[bench]
- fn $fnn(b: &mut Bencher) {
- let mut rng = SmallRng::from_entropy();
-
- b.iter(|| {
- let mut high = $high;
- let mut accum: $ty = 0;
- for _ in 0..::RAND_BENCH_N {
- accum = accum.wrapping_add(rng.gen_range($low, high));
- // force recalculation of range each time
- high = high.wrapping_add(1) & std::$ty::MAX;
- }
- accum
- });
- b.bytes = size_of::<$ty>() as u64 * ::RAND_BENCH_N;
- }
- }
-}
-
-gen_range_int!(gen_range_i8, i8, -20i8, 100);
-gen_range_int!(gen_range_i16, i16, -500i16, 2000);
-gen_range_int!(gen_range_i32, i32, -200_000_000i32, 800_000_000);
-gen_range_int!(gen_range_i64, i64, 3i64, 123_456_789_123);
-gen_range_int!(gen_range_i128, i128, -12345678901234i128, 123_456_789_123_456_789);
-
-// construct and sample from a floating-point range
-macro_rules! gen_range_float {
- ($fnn:ident, $ty:ident, $low:expr, $high:expr) => {
- #[bench]
- fn $fnn(b: &mut Bencher) {
- let mut rng = SmallRng::from_entropy();
-
- b.iter(|| {
- let mut high = $high;
- let mut low = $low;
- let mut accum: $ty = 0.0;
- for _ in 0..::RAND_BENCH_N {
- accum += rng.gen_range(low, high);
- // force recalculation of range each time
- low += 0.9;
- high += 1.1;
- }
- accum
- });
- b.bytes = size_of::<$ty>() as u64 * ::RAND_BENCH_N;
- }
- }
-}
-
-gen_range_float!(gen_range_f32, f32, -20000.0f32, 100000.0);
-gen_range_float!(gen_range_f64, f64, 123.456f64, 7890.12);
-
-#[bench]
-fn dist_iter(b: &mut Bencher) {
- let mut rng = SmallRng::from_entropy();
- let distr = Normal::new(-2.71828, 3.14159);
- let mut iter = distr.sample_iter(&mut rng);
-
- b.iter(|| {
- let mut accum = 0.0;
- for _ in 0..::RAND_BENCH_N {
- accum += iter.next().unwrap();
- }
- accum
- });
- b.bytes = size_of::<f64>() as u64 * ::RAND_BENCH_N;
-}
diff --git a/rand/benches/generators.rs b/rand/benches/generators.rs
deleted file mode 100644
index a6e3a42..0000000
--- a/rand/benches/generators.rs
+++ /dev/null
@@ -1,240 +0,0 @@
-// Copyright 2018 Developers of the Rand project.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-#![feature(test)]
-
-extern crate test;
-extern crate rand;
-extern crate rand_isaac;
-extern crate rand_chacha;
-extern crate rand_hc;
-extern crate rand_pcg;
-extern crate rand_xorshift;
-extern crate rand_xoshiro;
-
-const RAND_BENCH_N: u64 = 1000;
-const BYTES_LEN: usize = 1024;
-
-use std::mem::size_of;
-use test::{black_box, Bencher};
-
-use rand::prelude::*;
-use rand::rngs::adapter::ReseedingRng;
-use rand::rngs::{OsRng, JitterRng, EntropyRng};
-use rand_isaac::{IsaacRng, Isaac64Rng};
-use rand_chacha::ChaChaRng;
-use rand_hc::{Hc128Rng, Hc128Core};
-use rand_pcg::{Lcg64Xsh32, Mcg128Xsl64};
-use rand_xorshift::XorShiftRng;
-use rand_xoshiro::{Xoshiro256StarStar, Xoshiro256Plus, Xoshiro128StarStar,
- Xoshiro128Plus, Xoroshiro128StarStar, Xoroshiro128Plus, SplitMix64,
- Xoroshiro64StarStar, Xoroshiro64Star};
-
-macro_rules! gen_bytes {
- ($fnn:ident, $gen:expr) => {
- #[bench]
- fn $fnn(b: &mut Bencher) {
- let mut rng = $gen;
- let mut buf = [0u8; BYTES_LEN];
- b.iter(|| {
- for _ in 0..RAND_BENCH_N {
- rng.fill_bytes(&mut buf);
- black_box(buf);
- }
- });
- b.bytes = BYTES_LEN as u64 * RAND_BENCH_N;
- }
- }
-}
-
-gen_bytes!(gen_bytes_xorshift, XorShiftRng::from_entropy());
-gen_bytes!(gen_bytes_xoshiro256starstar, Xoshiro256StarStar::from_entropy());
-gen_bytes!(gen_bytes_xoshiro256plus, Xoshiro256Plus::from_entropy());
-gen_bytes!(gen_bytes_xoshiro128starstar, Xoshiro128StarStar::from_entropy());
-gen_bytes!(gen_bytes_xoshiro128plus, Xoshiro128Plus::from_entropy());
-gen_bytes!(gen_bytes_xoroshiro128starstar, Xoroshiro128StarStar::from_entropy());
-gen_bytes!(gen_bytes_xoroshiro128plus, Xoroshiro128Plus::from_entropy());
-gen_bytes!(gen_bytes_xoroshiro64starstar, Xoroshiro64StarStar::from_entropy());
-gen_bytes!(gen_bytes_xoroshiro64star, Xoroshiro64Star::from_entropy());
-gen_bytes!(gen_bytes_splitmix64, SplitMix64::from_entropy());
-gen_bytes!(gen_bytes_lcg64_xsh32, Lcg64Xsh32::from_entropy());
-gen_bytes!(gen_bytes_mcg128_xsh64, Mcg128Xsl64::from_entropy());
-gen_bytes!(gen_bytes_chacha20, ChaChaRng::from_entropy());
-gen_bytes!(gen_bytes_hc128, Hc128Rng::from_entropy());
-gen_bytes!(gen_bytes_isaac, IsaacRng::from_entropy());
-gen_bytes!(gen_bytes_isaac64, Isaac64Rng::from_entropy());
-gen_bytes!(gen_bytes_std, StdRng::from_entropy());
-gen_bytes!(gen_bytes_small, SmallRng::from_entropy());
-gen_bytes!(gen_bytes_os, OsRng::new().unwrap());
-
-macro_rules! gen_uint {
- ($fnn:ident, $ty:ty, $gen:expr) => {
- #[bench]
- fn $fnn(b: &mut Bencher) {
- let mut rng = $gen;
- b.iter(|| {
- let mut accum: $ty = 0;
- for _ in 0..RAND_BENCH_N {
- accum = accum.wrapping_add(rng.gen::<$ty>());
- }
- accum
- });
- b.bytes = size_of::<$ty>() as u64 * RAND_BENCH_N;
- }
- }
-}
-
-gen_uint!(gen_u32_xorshift, u32, XorShiftRng::from_entropy());
-gen_uint!(gen_u32_xoshiro256starstar, u32, Xoshiro256StarStar::from_entropy());
-gen_uint!(gen_u32_xoshiro256plus, u32, Xoshiro256Plus::from_entropy());
-gen_uint!(gen_u32_xoshiro128starstar, u32, Xoshiro128StarStar::from_entropy());
-gen_uint!(gen_u32_xoshiro128plus, u32, Xoshiro128Plus::from_entropy());
-gen_uint!(gen_u32_xoroshiro128starstar, u32, Xoroshiro128StarStar::from_entropy());
-gen_uint!(gen_u32_xoroshiro128plus, u32, Xoroshiro128Plus::from_entropy());
-gen_uint!(gen_u32_xoroshiro64starstar, u32, Xoroshiro64StarStar::from_entropy());
-gen_uint!(gen_u32_xoroshiro64star, u32, Xoroshiro64Star::from_entropy());
-gen_uint!(gen_u32_splitmix64, u32, SplitMix64::from_entropy());
-gen_uint!(gen_u32_lcg64_xsh32, u32, Lcg64Xsh32::from_entropy());
-gen_uint!(gen_u32_mcg128_xsh64, u32, Mcg128Xsl64::from_entropy());
-gen_uint!(gen_u32_chacha20, u32, ChaChaRng::from_entropy());
-gen_uint!(gen_u32_hc128, u32, Hc128Rng::from_entropy());
-gen_uint!(gen_u32_isaac, u32, IsaacRng::from_entropy());
-gen_uint!(gen_u32_isaac64, u32, Isaac64Rng::from_entropy());
-gen_uint!(gen_u32_std, u32, StdRng::from_entropy());
-gen_uint!(gen_u32_small, u32, SmallRng::from_entropy());
-gen_uint!(gen_u32_os, u32, OsRng::new().unwrap());
-
-gen_uint!(gen_u64_xorshift, u64, XorShiftRng::from_entropy());
-gen_uint!(gen_u64_xoshiro256starstar, u64, Xoshiro256StarStar::from_entropy());
-gen_uint!(gen_u64_xoshiro256plus, u64, Xoshiro256Plus::from_entropy());
-gen_uint!(gen_u64_xoshiro128starstar, u64, Xoshiro128StarStar::from_entropy());
-gen_uint!(gen_u64_xoshiro128plus, u64, Xoshiro128Plus::from_entropy());
-gen_uint!(gen_u64_xoroshiro128starstar, u64, Xoroshiro128StarStar::from_entropy());
-gen_uint!(gen_u64_xoroshiro128plus, u64, Xoroshiro128Plus::from_entropy());
-gen_uint!(gen_u64_xoroshiro64starstar, u64, Xoroshiro64StarStar::from_entropy());
-gen_uint!(gen_u64_xoroshiro64star, u64, Xoroshiro64Star::from_entropy());
-gen_uint!(gen_u64_splitmix64, u64, SplitMix64::from_entropy());
-gen_uint!(gen_u64_lcg64_xsh32, u64, Lcg64Xsh32::from_entropy());
-gen_uint!(gen_u64_mcg128_xsh64, u64, Mcg128Xsl64::from_entropy());
-gen_uint!(gen_u64_chacha20, u64, ChaChaRng::from_entropy());
-gen_uint!(gen_u64_hc128, u64, Hc128Rng::from_entropy());
-gen_uint!(gen_u64_isaac, u64, IsaacRng::from_entropy());
-gen_uint!(gen_u64_isaac64, u64, Isaac64Rng::from_entropy());
-gen_uint!(gen_u64_std, u64, StdRng::from_entropy());
-gen_uint!(gen_u64_small, u64, SmallRng::from_entropy());
-gen_uint!(gen_u64_os, u64, OsRng::new().unwrap());
-
-// Do not test JitterRng like the others by running it RAND_BENCH_N times per,
-// measurement, because it is way too slow. Only run it once.
-#[bench]
-fn gen_u64_jitter(b: &mut Bencher) {
- let mut rng = JitterRng::new().unwrap();
- b.iter(|| {
- rng.gen::<u64>()
- });
- b.bytes = size_of::<u64>() as u64;
-}
-
-macro_rules! init_gen {
- ($fnn:ident, $gen:ident) => {
- #[bench]
- fn $fnn(b: &mut Bencher) {
- let mut rng = XorShiftRng::from_entropy();
- b.iter(|| {
- let r2 = $gen::from_rng(&mut rng).unwrap();
- r2
- });
- }
- }
-}
-
-init_gen!(init_xorshift, XorShiftRng);
-init_gen!(init_xoshiro256starstar, Xoshiro256StarStar);
-init_gen!(init_xoshiro256plus, Xoshiro256Plus);
-init_gen!(init_xoshiro128starstar, Xoshiro128StarStar);
-init_gen!(init_xoshiro128plus, Xoshiro128Plus);
-init_gen!(init_xoroshiro128starstar, Xoroshiro128StarStar);
-init_gen!(init_xoroshiro128plus, Xoroshiro128Plus);
-init_gen!(init_xoroshiro64starstar, Xoroshiro64StarStar);
-init_gen!(init_xoroshiro64star, Xoroshiro64Star);
-init_gen!(init_splitmix64, SplitMix64);
-init_gen!(init_lcg64_xsh32, Lcg64Xsh32);
-init_gen!(init_mcg128_xsh64, Mcg128Xsl64);
-init_gen!(init_hc128, Hc128Rng);
-init_gen!(init_isaac, IsaacRng);
-init_gen!(init_isaac64, Isaac64Rng);
-init_gen!(init_chacha, ChaChaRng);
-
-#[bench]
-fn init_jitter(b: &mut Bencher) {
- b.iter(|| {
- JitterRng::new().unwrap()
- });
-}
-
-
-const RESEEDING_THRESHOLD: u64 = 1024*1024*1024; // something high enough to get
- // deterministic measurements
-
-#[bench]
-fn reseeding_hc128_bytes(b: &mut Bencher) {
- let mut rng = ReseedingRng::new(Hc128Core::from_entropy(),
- RESEEDING_THRESHOLD,
- EntropyRng::new());
- let mut buf = [0u8; BYTES_LEN];
- b.iter(|| {
- for _ in 0..RAND_BENCH_N {
- rng.fill_bytes(&mut buf);
- black_box(buf);
- }
- });
- b.bytes = BYTES_LEN as u64 * RAND_BENCH_N;
-}
-
-macro_rules! reseeding_uint {
- ($fnn:ident, $ty:ty) => {
- #[bench]
- fn $fnn(b: &mut Bencher) {
- let mut rng = ReseedingRng::new(Hc128Core::from_entropy(),
- RESEEDING_THRESHOLD,
- EntropyRng::new());
- b.iter(|| {
- let mut accum: $ty = 0;
- for _ in 0..RAND_BENCH_N {
- accum = accum.wrapping_add(rng.gen::<$ty>());
- }
- accum
- });
- b.bytes = size_of::<$ty>() as u64 * RAND_BENCH_N;
- }
- }
-}
-
-reseeding_uint!(reseeding_hc128_u32, u32);
-reseeding_uint!(reseeding_hc128_u64, u64);
-
-
-macro_rules! threadrng_uint {
- ($fnn:ident, $ty:ty) => {
- #[bench]
- fn $fnn(b: &mut Bencher) {
- let mut rng = thread_rng();
- b.iter(|| {
- let mut accum: $ty = 0;
- for _ in 0..RAND_BENCH_N {
- accum = accum.wrapping_add(rng.gen::<$ty>());
- }
- accum
- });
- b.bytes = size_of::<$ty>() as u64 * RAND_BENCH_N;
- }
- }
-}
-
-threadrng_uint!(thread_rng_u32, u32);
-threadrng_uint!(thread_rng_u64, u64);
diff --git a/rand/benches/misc.rs b/rand/benches/misc.rs
deleted file mode 100644
index 8fb3a83..0000000
--- a/rand/benches/misc.rs
+++ /dev/null
@@ -1,160 +0,0 @@
-// Copyright 2018 Developers of the Rand project.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-#![feature(test)]
-
-extern crate test;
-extern crate rand;
-
-const RAND_BENCH_N: u64 = 1000;
-
-use test::Bencher;
-
-use rand::prelude::*;
-
-#[bench]
-fn misc_gen_bool_const(b: &mut Bencher) {
- let mut rng = StdRng::from_rng(&mut thread_rng()).unwrap();
- b.iter(|| {
- let mut accum = true;
- for _ in 0..::RAND_BENCH_N {
- accum ^= rng.gen_bool(0.18);
- }
- accum
- })
-}
-
-#[bench]
-fn misc_gen_bool_var(b: &mut Bencher) {
- let mut rng = StdRng::from_rng(&mut thread_rng()).unwrap();
- b.iter(|| {
- let mut accum = true;
- let mut p = 0.18;
- for _ in 0..::RAND_BENCH_N {
- accum ^= rng.gen_bool(p);
- p += 0.0001;
- }
- accum
- })
-}
-
-#[bench]
-fn misc_gen_ratio_const(b: &mut Bencher) {
- let mut rng = StdRng::from_rng(&mut thread_rng()).unwrap();
- b.iter(|| {
- let mut accum = true;
- for _ in 0..::RAND_BENCH_N {
- accum ^= rng.gen_ratio(2, 3);
- }
- accum
- })
-}
-
-#[bench]
-fn misc_gen_ratio_var(b: &mut Bencher) {
- let mut rng = StdRng::from_rng(&mut thread_rng()).unwrap();
- b.iter(|| {
- let mut accum = true;
- for i in 2..(::RAND_BENCH_N as u32 + 2) {
- accum ^= rng.gen_ratio(i, i + 1);
- }
- accum
- })
-}
-
-#[bench]
-fn misc_bernoulli_const(b: &mut Bencher) {
- let mut rng = StdRng::from_rng(&mut thread_rng()).unwrap();
- b.iter(|| {
- let d = rand::distributions::Bernoulli::new(0.18);
- let mut accum = true;
- for _ in 0..::RAND_BENCH_N {
- accum ^= rng.sample(d);
- }
- accum
- })
-}
-
-#[bench]
-fn misc_bernoulli_var(b: &mut Bencher) {
- let mut rng = StdRng::from_rng(&mut thread_rng()).unwrap();
- b.iter(|| {
- let mut accum = true;
- let mut p = 0.18;
- for _ in 0..::RAND_BENCH_N {
- let d = rand::distributions::Bernoulli::new(p);
- accum ^= rng.sample(d);
- p += 0.0001;
- }
- accum
- })
-}
-
-macro_rules! sample_binomial {
- ($name:ident, $n:expr, $p:expr) => {
- #[bench]
- fn $name(b: &mut Bencher) {
- let mut rng = SmallRng::from_rng(&mut thread_rng()).unwrap();
- let (n, p) = ($n, $p);
- b.iter(|| {
- let d = rand::distributions::Binomial::new(n, p);
- rng.sample(d)
- })
- }
- }
-}
-
-sample_binomial!(misc_binomial_1, 1, 0.9);
-sample_binomial!(misc_binomial_10, 10, 0.9);
-sample_binomial!(misc_binomial_100, 100, 0.99);
-sample_binomial!(misc_binomial_1000, 1000, 0.01);
-sample_binomial!(misc_binomial_1e12, 1000_000_000_000, 0.2);
-
-#[bench]
-fn gen_1k_iter_repeat(b: &mut Bencher) {
- use std::iter;
- let mut rng = SmallRng::from_rng(&mut thread_rng()).unwrap();
- b.iter(|| {
- let v: Vec<u64> = iter::repeat(()).map(|()| rng.gen()).take(128).collect();
- v
- });
- b.bytes = 1024;
-}
-
-#[bench]
-fn gen_1k_sample_iter(b: &mut Bencher) {
- use rand::distributions::{Distribution, Standard};
- let mut rng = SmallRng::from_rng(&mut thread_rng()).unwrap();
- b.iter(|| {
- let v: Vec<u64> = Standard.sample_iter(&mut rng).take(128).collect();
- v
- });
- b.bytes = 1024;
-}
-
-#[bench]
-fn gen_1k_gen_array(b: &mut Bencher) {
- let mut rng = SmallRng::from_rng(&mut thread_rng()).unwrap();
- b.iter(|| {
- // max supported array length is 32!
- let v: [[u64; 32]; 4] = rng.gen();
- v
- });
- b.bytes = 1024;
-}
-
-#[bench]
-fn gen_1k_fill(b: &mut Bencher) {
- let mut rng = SmallRng::from_rng(&mut thread_rng()).unwrap();
- let mut buf = [0u64; 128];
- b.iter(|| {
- rng.fill(&mut buf[..]);
- buf
- });
- b.bytes = 1024;
-}
diff --git a/rand/benches/seq.rs b/rand/benches/seq.rs
deleted file mode 100644
index 0ca3398..0000000
--- a/rand/benches/seq.rs
+++ /dev/null
@@ -1,174 +0,0 @@
-// Copyright 2018 Developers of the Rand project.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-#![feature(test)]
-#![allow(non_snake_case)]
-
-extern crate test;
-extern crate rand;
-
-use test::Bencher;
-
-use rand::prelude::*;
-use rand::seq::*;
-use std::mem::size_of;
-
-const RAND_BENCH_N: u64 = 1000;
-
-#[bench]
-fn seq_shuffle_100(b: &mut Bencher) {
- let mut rng = SmallRng::from_rng(thread_rng()).unwrap();
- let x : &mut [usize] = &mut [1; 100];
- b.iter(|| {
- x.shuffle(&mut rng);
- x[0]
- })
-}
-
-#[bench]
-fn seq_slice_choose_1_of_1000(b: &mut Bencher) {
- let mut rng = SmallRng::from_rng(thread_rng()).unwrap();
- let x : &mut [usize] = &mut [1; 1000];
- for i in 0..1000 {
- x[i] = i;
- }
- b.iter(|| {
- let mut s = 0;
- for _ in 0..RAND_BENCH_N {
- s += x.choose(&mut rng).unwrap();
- }
- s
- });
- b.bytes = size_of::<usize>() as u64 * ::RAND_BENCH_N;
-}
-
-macro_rules! seq_slice_choose_multiple {
- ($name:ident, $amount:expr, $length:expr) => {
- #[bench]
- fn $name(b: &mut Bencher) {
- let mut rng = SmallRng::from_rng(thread_rng()).unwrap();
- let x : &[i32] = &[$amount; $length];
- let mut result = [0i32; $amount];
- b.iter(|| {
- // Collect full result to prevent unwanted shortcuts getting
- // first element (in case sample_indices returns an iterator).
- for (slot, sample) in result.iter_mut().zip(
- x.choose_multiple(&mut rng, $amount)) {
- *slot = *sample;
- }
- result[$amount-1]
- })
- }
- }
-}
-
-seq_slice_choose_multiple!(seq_slice_choose_multiple_1_of_1000, 1, 1000);
-seq_slice_choose_multiple!(seq_slice_choose_multiple_950_of_1000, 950, 1000);
-seq_slice_choose_multiple!(seq_slice_choose_multiple_10_of_100, 10, 100);
-seq_slice_choose_multiple!(seq_slice_choose_multiple_90_of_100, 90, 100);
-
-#[bench]
-fn seq_iter_choose_from_1000(b: &mut Bencher) {
- let mut rng = SmallRng::from_rng(thread_rng()).unwrap();
- let x : &mut [usize] = &mut [1; 1000];
- for i in 0..1000 {
- x[i] = i;
- }
- b.iter(|| {
- let mut s = 0;
- for _ in 0..RAND_BENCH_N {
- s += x.iter().choose(&mut rng).unwrap();
- }
- s
- });
- b.bytes = size_of::<usize>() as u64 * ::RAND_BENCH_N;
-}
-
-#[derive(Clone)]
-struct UnhintedIterator<I: Iterator + Clone> {
- iter: I,
-}
-impl<I: Iterator + Clone> Iterator for UnhintedIterator<I> {
- type Item = I::Item;
- fn next(&mut self) -> Option<Self::Item> {
- self.iter.next()
- }
-}
-
-#[derive(Clone)]
-struct WindowHintedIterator<I: ExactSizeIterator + Iterator + Clone> {
- iter: I,
- window_size: usize,
-}
-impl<I: ExactSizeIterator + Iterator + Clone> Iterator for WindowHintedIterator<I> {
- type Item = I::Item;
- fn next(&mut self) -> Option<Self::Item> {
- self.iter.next()
- }
- fn size_hint(&self) -> (usize, Option<usize>) {
- (std::cmp::min(self.iter.len(), self.window_size), None)
- }
-}
-
-#[bench]
-fn seq_iter_unhinted_choose_from_1000(b: &mut Bencher) {
- let mut rng = SmallRng::from_rng(thread_rng()).unwrap();
- let x : &[usize] = &[1; 1000];
- b.iter(|| {
- UnhintedIterator { iter: x.iter() }.choose(&mut rng).unwrap()
- })
-}
-
-#[bench]
-fn seq_iter_window_hinted_choose_from_1000(b: &mut Bencher) {
- let mut rng = SmallRng::from_rng(thread_rng()).unwrap();
- let x : &[usize] = &[1; 1000];
- b.iter(|| {
- WindowHintedIterator { iter: x.iter(), window_size: 7 }.choose(&mut rng)
- })
-}
-
-#[bench]
-fn seq_iter_choose_multiple_10_of_100(b: &mut Bencher) {
- let mut rng = SmallRng::from_rng(thread_rng()).unwrap();
- let x : &[usize] = &[1; 100];
- b.iter(|| {
- x.iter().cloned().choose_multiple(&mut rng, 10)
- })
-}
-
-#[bench]
-fn seq_iter_choose_multiple_fill_10_of_100(b: &mut Bencher) {
- let mut rng = SmallRng::from_rng(thread_rng()).unwrap();
- let x : &[usize] = &[1; 100];
- let mut buf = [0; 10];
- b.iter(|| {
- x.iter().cloned().choose_multiple_fill(&mut rng, &mut buf)
- })
-}
-
-macro_rules! sample_indices {
- ($name:ident, $fn:ident, $amount:expr, $length:expr) => {
- #[bench]
- fn $name(b: &mut Bencher) {
- let mut rng = SmallRng::from_rng(thread_rng()).unwrap();
- b.iter(|| {
- index::$fn(&mut rng, $length, $amount)
- })
- }
- }
-}
-
-sample_indices!(misc_sample_indices_1_of_1k, sample, 1, 1000);
-sample_indices!(misc_sample_indices_10_of_1k, sample, 10, 1000);
-sample_indices!(misc_sample_indices_100_of_1k, sample, 100, 1000);
-sample_indices!(misc_sample_indices_100_of_1M, sample, 100, 1000_000);
-sample_indices!(misc_sample_indices_100_of_1G, sample, 100, 1000_000_000);
-sample_indices!(misc_sample_indices_200_of_1G, sample, 200, 1000_000_000);
-sample_indices!(misc_sample_indices_400_of_1G, sample, 400, 1000_000_000);
-sample_indices!(misc_sample_indices_600_of_1G, sample, 600, 1000_000_000);
diff --git a/rand/build.rs b/rand/build.rs
deleted file mode 100644
index a554ad9..0000000
--- a/rand/build.rs
+++ /dev/null
@@ -1,10 +0,0 @@
-extern crate autocfg;
-
-fn main() {
- println!("cargo:rerun-if-changed=build.rs");
-
- let ac = autocfg::new();
- ac.emit_rustc_version(1, 25);
- ac.emit_rustc_version(1, 26);
- ac.emit_rustc_version(1, 27);
-}
diff --git a/rand/examples/monte-carlo.rs b/rand/examples/monte-carlo.rs
deleted file mode 100644
index 9162996..0000000
--- a/rand/examples/monte-carlo.rs
+++ /dev/null
@@ -1,51 +0,0 @@
-// Copyright 2018 Developers of the Rand project.
-// Copyright 2013-2018 The Rust Project Developers.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-//! # Monte Carlo estimation of π
-//!
-//! Imagine that we have a square with sides of length 2 and a unit circle
-//! (radius = 1), both centered at the origin. The areas are:
-//!
-//! ```text
-//! area of circle = πr² = π * r * r = π
-//! area of square = 2² = 4
-//! ```
-//!
-//! The circle is entirely within the square, so if we sample many points
-//! randomly from the square, roughly π / 4 of them should be inside the circle.
-//!
-//! We can use the above fact to estimate the value of π: pick many points in
-//! the square at random, calculate the fraction that fall within the circle,
-//! and multiply this fraction by 4.
-
-#![cfg(feature="std")]
-
-
-extern crate rand;
-
-use rand::distributions::{Distribution, Uniform};
-
-fn main() {
- let range = Uniform::new(-1.0f64, 1.0);
- let mut rng = rand::thread_rng();
-
- let total = 1_000_000;
- let mut in_circle = 0;
-
- for _ in 0..total {
- let a = range.sample(&mut rng);
- let b = range.sample(&mut rng);
- if a*a + b*b <= 1.0 {
- in_circle += 1;
- }
- }
-
- // prints something close to 3.14159...
- println!("π is approximately {}", 4. * (in_circle as f64) / (total as f64));
-}
diff --git a/rand/examples/monty-hall.rs b/rand/examples/monty-hall.rs
deleted file mode 100644
index 0932c5e..0000000
--- a/rand/examples/monty-hall.rs
+++ /dev/null
@@ -1,116 +0,0 @@
-// Copyright 2018 Developers of the Rand project.
-// Copyright 2013-2018 The Rust Project Developers.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-//! ## Monty Hall Problem
-//!
-//! This is a simulation of the [Monty Hall Problem][]:
-//!
-//! > Suppose you're on a game show, and you're given the choice of three doors:
-//! > Behind one door is a car; behind the others, goats. You pick a door, say
-//! > No. 1, and the host, who knows what's behind the doors, opens another
-//! > door, say No. 3, which has a goat. He then says to you, "Do you want to
-//! > pick door No. 2?" Is it to your advantage to switch your choice?
-//!
-//! The rather unintuitive answer is that you will have a 2/3 chance of winning
-//! if you switch and a 1/3 chance of winning if you don't, so it's better to
-//! switch.
-//!
-//! This program will simulate the game show and with large enough simulation
-//! steps it will indeed confirm that it is better to switch.
-//!
-//! [Monty Hall Problem]: https://en.wikipedia.org/wiki/Monty_Hall_problem
-
-#![cfg(feature="std")]
-
-
-extern crate rand;
-
-use rand::Rng;
-use rand::distributions::{Distribution, Uniform};
-
-struct SimulationResult {
- win: bool,
- switch: bool,
-}
-
-// Run a single simulation of the Monty Hall problem.
-fn simulate<R: Rng>(random_door: &Uniform<u32>, rng: &mut R)
- -> SimulationResult {
- let car = random_door.sample(rng);
-
- // This is our initial choice
- let mut choice = random_door.sample(rng);
-
- // The game host opens a door
- let open = game_host_open(car, choice, rng);
-
- // Shall we switch?
- let switch = rng.gen();
- if switch {
- choice = switch_door(choice, open);
- }
-
- SimulationResult { win: choice == car, switch }
-}
-
-// Returns the door the game host opens given our choice and knowledge of
-// where the car is. The game host will never open the door with the car.
-fn game_host_open<R: Rng>(car: u32, choice: u32, rng: &mut R) -> u32 {
- use rand::seq::SliceRandom;
- *free_doors(&[car, choice]).choose(rng).unwrap()
-}
-
-// Returns the door we switch to, given our current choice and
-// the open door. There will only be one valid door.
-fn switch_door(choice: u32, open: u32) -> u32 {
- free_doors(&[choice, open])[0]
-}
-
-fn free_doors(blocked: &[u32]) -> Vec<u32> {
- (0..3).filter(|x| !blocked.contains(x)).collect()
-}
-
-fn main() {
- // The estimation will be more accurate with more simulations
- let num_simulations = 10000;
-
- let mut rng = rand::thread_rng();
- let random_door = Uniform::new(0u32, 3);
-
- let (mut switch_wins, mut switch_losses) = (0, 0);
- let (mut keep_wins, mut keep_losses) = (0, 0);
-
- println!("Running {} simulations...", num_simulations);
- for _ in 0..num_simulations {
- let result = simulate(&random_door, &mut rng);
-
- match (result.win, result.switch) {
- (true, true) => switch_wins += 1,
- (true, false) => keep_wins += 1,
- (false, true) => switch_losses += 1,
- (false, false) => keep_losses += 1,
- }
- }
-
- let total_switches = switch_wins + switch_losses;
- let total_keeps = keep_wins + keep_losses;
-
- println!("Switched door {} times with {} wins and {} losses",
- total_switches, switch_wins, switch_losses);
-
- println!("Kept our choice {} times with {} wins and {} losses",
- total_keeps, keep_wins, keep_losses);
-
- // With a large number of simulations, the values should converge to
- // 0.667 and 0.333 respectively.
- println!("Estimated chance to win if we switch: {}",
- switch_wins as f32 / total_switches as f32);
- println!("Estimated chance to win if we don't: {}",
- keep_wins as f32 / total_keeps as f32);
-}
diff --git a/rand/rand_chacha/CHANGELOG.md b/rand/rand_chacha/CHANGELOG.md
deleted file mode 100644
index a1979f6..0000000
--- a/rand/rand_chacha/CHANGELOG.md
+++ /dev/null
@@ -1,12 +0,0 @@
-# Changelog
-All notable changes to this project will be documented in this file.
-
-The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
-and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
-
-## [0.1.1] - 2019-01-04
-- Disable `i128` and `u128` if the `target_os` is `emscripten` (#671: work-around Emscripten limitation)
-- Update readme and doc links
-
-## [0.1.0] - 2018-10-17
-- Pulled out of the Rand crate
diff --git a/rand/rand_chacha/COPYRIGHT b/rand/rand_chacha/COPYRIGHT
deleted file mode 100644
index 468d907..0000000
--- a/rand/rand_chacha/COPYRIGHT
+++ /dev/null
@@ -1,12 +0,0 @@
-Copyrights in the Rand project are retained by their contributors. No
-copyright assignment is required to contribute to the Rand project.
-
-For full authorship information, see the version control history.
-
-Except as otherwise noted (below and/or in individual files), Rand is
-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.
-
-The Rand project includes code from the Rust project
-published under these same licenses.
diff --git a/rand/rand_chacha/Cargo.toml b/rand/rand_chacha/Cargo.toml
deleted file mode 100644
index 028428c..0000000
--- a/rand/rand_chacha/Cargo.toml
+++ /dev/null
@@ -1,25 +0,0 @@
-[package]
-name = "rand_chacha"
-version = "0.1.1"
-authors = ["The Rand Project Developers", "The Rust Project Developers"]
-license = "MIT/Apache-2.0"
-readme = "README.md"
-repository = "https://github.com/rust-random/rand"
-documentation = "https://rust-random.github.io/rand/rand_chacha"
-homepage = "https://crates.io/crates/rand_chacha"
-description = """
-ChaCha random number generator
-"""
-keywords = ["random", "rng", "chacha"]
-categories = ["algorithms", "no-std"]
-build = "build.rs"
-
-[badges]
-travis-ci = { repository = "rust-random/rand" }
-appveyor = { repository = "rust-random/rand" }
-
-[dependencies]
-rand_core = { path = "../rand_core", version = ">=0.2, <0.4", default-features=false }
-
-[build-dependencies]
-autocfg = "0.1"
diff --git a/rand/rand_chacha/LICENSE-APACHE b/rand/rand_chacha/LICENSE-APACHE
deleted file mode 100644
index 17d7468..0000000
--- a/rand/rand_chacha/LICENSE-APACHE
+++ /dev/null
@@ -1,201 +0,0 @@
- Apache License
- Version 2.0, January 2004
- https://www.apache.org/licenses/
-
-TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
-1. Definitions.
-
- "License" shall mean the terms and conditions for use, reproduction,
- and distribution as defined by Sections 1 through 9 of this document.
-
- "Licensor" shall mean the copyright owner or entity authorized by
- the copyright owner that is granting the License.
-
- "Legal Entity" shall mean the union of the acting entity and all
- other entities that control, are controlled by, or are under common
- control with that entity. For the purposes of this definition,
- "control" means (i) the power, direct or indirect, to cause the
- direction or management of such entity, whether by contract or
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
- outstanding shares, or (iii) beneficial ownership of such entity.
-
- "You" (or "Your") shall mean an individual or Legal Entity
- exercising permissions granted by this License.
-
- "Source" form shall mean the preferred form for making modifications,
- including but not limited to software source code, documentation
- source, and configuration files.
-
- "Object" form shall mean any form resulting from mechanical
- transformation or translation of a Source form, including but
- not limited to compiled object code, generated documentation,
- and conversions to other media types.
-
- "Work" shall mean the work of authorship, whether in Source or
- Object form, made available under the License, as indicated by a
- copyright notice that is included in or attached to the work
- (an example is provided in the Appendix below).
-
- "Derivative Works" shall mean any work, whether in Source or Object
- form, that is based on (or derived from) the Work and for which the
- editorial revisions, annotations, elaborations, or other modifications
- represent, as a whole, an original work of authorship. For the purposes
- of this License, Derivative Works shall not include works that remain
- separable from, or merely link (or bind by name) to the interfaces of,
- the Work and Derivative Works thereof.
-
- "Contribution" shall mean any work of authorship, including
- the original version of the Work and any modifications or additions
- to that Work or Derivative Works thereof, that is intentionally
- submitted to Licensor for inclusion in the Work by the copyright owner
- or by an individual or Legal Entity authorized to submit on behalf of
- the copyright owner. For the purposes of this definition, "submitted"
- means any form of electronic, verbal, or written communication sent
- to the Licensor or its representatives, including but not limited to
- communication on electronic mailing lists, source code control systems,
- and issue tracking systems that are managed by, or on behalf of, the
- Licensor for the purpose of discussing and improving the Work, but
- excluding communication that is conspicuously marked or otherwise
- designated in writing by the copyright owner as "Not a Contribution."
-
- "Contributor" shall mean Licensor and any individual or Legal Entity
- on behalf of whom a Contribution has been received by Licensor and
- subsequently incorporated within the Work.
-
-2. Grant of Copyright License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- copyright license to reproduce, prepare Derivative Works of,
- publicly display, publicly perform, sublicense, and distribute the
- Work and such Derivative Works in Source or Object form.
-
-3. Grant of Patent License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- (except as stated in this section) patent license to make, have made,
- use, offer to sell, sell, import, and otherwise transfer the Work,
- where such license applies only to those patent claims licensable
- by such Contributor that are necessarily infringed by their
- Contribution(s) alone or by combination of their Contribution(s)
- with the Work to which such Contribution(s) was submitted. If You
- institute patent litigation against any entity (including a
- cross-claim or counterclaim in a lawsuit) alleging that the Work
- or a Contribution incorporated within the Work constitutes direct
- or contributory patent infringement, then any patent licenses
- granted to You under this License for that Work shall terminate
- as of the date such litigation is filed.
-
-4. Redistribution. You may reproduce and distribute copies of the
- Work or Derivative Works thereof in any medium, with or without
- modifications, and in Source or Object form, provided that You
- meet the following conditions:
-
- (a) You must give any other recipients of the Work or
- Derivative Works a copy of this License; and
-
- (b) You must cause any modified files to carry prominent notices
- stating that You changed the files; and
-
- (c) You must retain, in the Source form of any Derivative Works
- that You distribute, all copyright, patent, trademark, and
- attribution notices from the Source form of the Work,
- excluding those notices that do not pertain to any part of
- the Derivative Works; and
-
- (d) If the Work includes a "NOTICE" text file as part of its
- distribution, then any Derivative Works that You distribute must
- include a readable copy of the attribution notices contained
- within such NOTICE file, excluding those notices that do not
- pertain to any part of the Derivative Works, in at least one
- of the following places: within a NOTICE text file distributed
- as part of the Derivative Works; within the Source form or
- documentation, if provided along with the Derivative Works; or,
- within a display generated by the Derivative Works, if and
- wherever such third-party notices normally appear. The contents
- of the NOTICE file are for informational purposes only and
- do not modify the License. You may add Your own attribution
- notices within Derivative Works that You distribute, alongside
- or as an addendum to the NOTICE text from the Work, provided
- that such additional attribution notices cannot be construed
- as modifying the License.
-
- You may add Your own copyright statement to Your modifications and
- may provide additional or different license terms and conditions
- for use, reproduction, or distribution of Your modifications, or
- for any such Derivative Works as a whole, provided Your use,
- reproduction, and distribution of the Work otherwise complies with
- the conditions stated in this License.
-
-5. Submission of Contributions. Unless You explicitly state otherwise,
- any Contribution intentionally submitted for inclusion in the Work
- by You to the Licensor shall be under the terms and conditions of
- this License, without any additional terms or conditions.
- Notwithstanding the above, nothing herein shall supersede or modify
- the terms of any separate license agreement you may have executed
- with Licensor regarding such Contributions.
-
-6. Trademarks. This License does not grant permission to use the trade
- names, trademarks, service marks, or product names of the Licensor,
- except as required for reasonable and customary use in describing the
- origin of the Work and reproducing the content of the NOTICE file.
-
-7. Disclaimer of Warranty. Unless required by applicable law or
- agreed to in writing, Licensor provides the Work (and each
- Contributor provides its Contributions) on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- implied, including, without limitation, any warranties or conditions
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
- PARTICULAR PURPOSE. You are solely responsible for determining the
- appropriateness of using or redistributing the Work and assume any
- risks associated with Your exercise of permissions under this License.
-
-8. Limitation of Liability. In no event and under no legal theory,
- whether in tort (including negligence), contract, or otherwise,
- unless required by applicable law (such as deliberate and grossly
- negligent acts) or agreed to in writing, shall any Contributor be
- liable to You for damages, including any direct, indirect, special,
- incidental, or consequential damages of any character arising as a
- result of this License or out of the use or inability to use the
- Work (including but not limited to damages for loss of goodwill,
- work stoppage, computer failure or malfunction, or any and all
- other commercial damages or losses), even if such Contributor
- has been advised of the possibility of such damages.
-
-9. Accepting Warranty or Additional Liability. While redistributing
- the Work or Derivative Works thereof, You may choose to offer,
- and charge a fee for, acceptance of support, warranty, indemnity,
- or other liability obligations and/or rights consistent with this
- License. However, in accepting such obligations, You may act only
- on Your own behalf and on Your sole responsibility, not on behalf
- of any other Contributor, and only if You agree to indemnify,
- defend, and hold each Contributor harmless for any liability
- incurred by, or claims asserted against, such Contributor by reason
- of your accepting any such warranty or additional liability.
-
-END OF TERMS AND CONDITIONS
-
-APPENDIX: How to apply the Apache License to your work.
-
- To apply the Apache License to your work, attach the following
- boilerplate notice, with the fields enclosed by brackets "[]"
- replaced with your own identifying information. (Don't include
- the brackets!) The text should be enclosed in the appropriate
- comment syntax for the file format. We also recommend that a
- file or class name and description of purpose be included on the
- same "printed page" as the copyright notice for easier
- identification within third-party archives.
-
-Copyright [yyyy] [name of copyright owner]
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
- https://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
diff --git a/rand/rand_chacha/LICENSE-MIT b/rand/rand_chacha/LICENSE-MIT
deleted file mode 100644
index d93b5ba..0000000
--- a/rand/rand_chacha/LICENSE-MIT
+++ /dev/null
@@ -1,26 +0,0 @@
-Copyright 2018 Developers of the Rand project
-Copyright (c) 2014 The Rust Project Developers
-
-Permission is hereby granted, free of charge, to any
-person obtaining a copy of this software and associated
-documentation files (the "Software"), to deal in the
-Software without restriction, including without
-limitation the rights to use, copy, modify, merge,
-publish, distribute, sublicense, and/or sell copies of
-the Software, and to permit persons to whom the Software
-is furnished to do so, subject to the following
-conditions:
-
-The above copyright notice and this permission notice
-shall be included in all copies or substantial portions
-of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
-ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
-TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
-PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
-SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
-CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
-IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
-DEALINGS IN THE SOFTWARE.
diff --git a/rand/rand_chacha/README.md b/rand/rand_chacha/README.md
deleted file mode 100644
index 5a1dbac..0000000
--- a/rand/rand_chacha/README.md
+++ /dev/null
@@ -1,45 +0,0 @@
-# rand_chacha
-
-[![Build Status](https://travis-ci.org/rust-random/rand.svg)](https://travis-ci.org/rust-random/rand)
-[![Build Status](https://ci.appveyor.com/api/projects/status/github/rust-random/rand?svg=true)](https://ci.appveyor.com/project/rust-random/rand)
-[![Latest version](https://img.shields.io/crates/v/rand_chacha.svg)](https://crates.io/crates/rand_chacha)
-[![Book](https://img.shields.io/badge/book-master-yellow.svg)](https://rust-random.github.io/book/)
-[![API](https://img.shields.io/badge/api-master-yellow.svg)](https://rust-random.github.io/rand/rand_chacha)
-[![API](https://docs.rs/rand_chacha/badge.svg)](https://docs.rs/rand_chacha)
-[![Minimum rustc version](https://img.shields.io/badge/rustc-1.22+-lightgray.svg)](https://github.com/rust-random/rand#rust-version-requirements)
-
-A cryptographically secure random number generator that uses the ChaCha
-algorithm.
-
-ChaCha is a stream cipher designed by Daniel J. Bernstein[^1], that we use
-as an RNG. It is an improved variant of the Salsa20 cipher family, which was
-selected as one of the "stream ciphers suitable for widespread adoption" by
-eSTREAM[^2].
-
-Links:
-
-- [API documentation (master)](https://rust-random.github.io/rand/rand_chacha)
-- [API documentation (docs.rs)](https://docs.rs/rand_chacha)
-- [Changelog](CHANGELOG.md)
-
-[rand]: https://crates.io/crates/rand
-[^1]: D. J. Bernstein, [*ChaCha, a variant of Salsa20*](
- https://cr.yp.to/chacha.html)
-
-[^2]: [eSTREAM: the ECRYPT Stream Cipher Project](
- http://www.ecrypt.eu.org/stream/)
-
-
-## Crate Features
-
-`rand_chacha` is `no_std` compatible. It does not require any functionality
-outside of the `core` lib, thus there are no features to configure.
-
-
-# License
-
-`rand_chacha` is distributed under the terms of both the MIT license and the
-Apache License (Version 2.0).
-
-See [LICENSE-APACHE](LICENSE-APACHE) and [LICENSE-MIT](LICENSE-MIT), and
-[COPYRIGHT](COPYRIGHT) for details.
diff --git a/rand/rand_chacha/build.rs b/rand/rand_chacha/build.rs
deleted file mode 100644
index 06e12a4..0000000
--- a/rand/rand_chacha/build.rs
+++ /dev/null
@@ -1,7 +0,0 @@
-extern crate autocfg;
-
-fn main() {
- println!("cargo:rerun-if-changed=build.rs");
- let ac = autocfg::new();
- ac.emit_rustc_version(1, 26);
-}
diff --git a/rand/rand_chacha/src/chacha.rs b/rand/rand_chacha/src/chacha.rs
deleted file mode 100644
index 86f191e..0000000
--- a/rand/rand_chacha/src/chacha.rs
+++ /dev/null
@@ -1,449 +0,0 @@
-// Copyright 2018 Developers of the Rand project.
-// Copyright 2014 The Rust Project Developers.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-//! The ChaCha random number generator.
-
-use core::fmt;
-use rand_core::{CryptoRng, RngCore, SeedableRng, Error, le};
-use rand_core::block::{BlockRngCore, BlockRng};
-
-const SEED_WORDS: usize = 8; // 8 words for the 256-bit key
-const STATE_WORDS: usize = 16;
-
-/// A cryptographically secure random number generator that uses the ChaCha
-/// algorithm.
-///
-/// ChaCha is a stream cipher designed by Daniel J. Bernstein[^1], that we use
-/// as an RNG. It is an improved variant of the Salsa20 cipher family, which was
-/// selected as one of the "stream ciphers suitable for widespread adoption" by
-/// eSTREAM[^2].
-///
-/// ChaCha uses add-rotate-xor (ARX) operations as its basis. These are safe
-/// against timing attacks, although that is mostly a concern for ciphers and
-/// not for RNGs. Also it is very suitable for SIMD implementation.
-/// Here we do not provide a SIMD implementation yet, except for what is
-/// provided by auto-vectorisation.
-///
-/// With the ChaCha algorithm it is possible to choose the number of rounds the
-/// core algorithm should run. The number of rounds is a tradeoff between
-/// performance and security, where 8 rounds is the minimum potentially
-/// secure configuration, and 20 rounds is widely used as a conservative choice.
-/// We use 20 rounds in this implementation, but hope to allow type-level
-/// configuration in the future.
-///
-/// We use a 64-bit counter and 64-bit stream identifier as in Bernstein's
-/// implementation[^1] except that we use a stream identifier in place of a
-/// nonce. A 64-bit counter over 64-byte (16 word) blocks allows 1 ZiB of output
-/// before cycling, and the stream identifier allows 2<sup>64</sup> unique
-/// streams of output per seed. Both counter and stream are initialized to zero
-/// but may be set via [`set_word_pos`] and [`set_stream`].
-///
-/// The word layout is:
-///
-/// ```text
-/// constant constant constant constant
-/// seed seed seed seed
-/// seed seed seed seed
-/// counter counter stream_id stream_id
-/// ```
-///
-/// This implementation uses an output buffer of sixteen `u32` words, and uses
-/// [`BlockRng`] to implement the [`RngCore`] methods.
-///
-/// [^1]: D. J. Bernstein, [*ChaCha, a variant of Salsa20*](
-/// https://cr.yp.to/chacha.html)
-///
-/// [^2]: [eSTREAM: the ECRYPT Stream Cipher Project](
-/// http://www.ecrypt.eu.org/stream/)
-///
-/// [`set_word_pos`]: #method.set_word_pos
-/// [`set_stream`]: #method.set_stream
-/// [`BlockRng`]: ../rand_core/block/struct.BlockRng.html
-/// [`RngCore`]: ../rand_core/trait.RngCore.html
-#[derive(Clone, Debug)]
-pub struct ChaChaRng(BlockRng<ChaChaCore>);
-
-impl RngCore for ChaChaRng {
- #[inline]
- fn next_u32(&mut self) -> u32 {
- self.0.next_u32()
- }
-
- #[inline]
- fn next_u64(&mut self) -> u64 {
- self.0.next_u64()
- }
-
- #[inline]
- fn fill_bytes(&mut self, dest: &mut [u8]) {
- self.0.fill_bytes(dest)
- }
-
- #[inline]
- fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), Error> {
- self.0.try_fill_bytes(dest)
- }
-}
-
-impl SeedableRng for ChaChaRng {
- type Seed = <ChaChaCore as SeedableRng>::Seed;
-
- fn from_seed(seed: Self::Seed) -> Self {
- ChaChaRng(BlockRng::<ChaChaCore>::from_seed(seed))
- }
-
- fn from_rng<R: RngCore>(rng: R) -> Result<Self, Error> {
- BlockRng::<ChaChaCore>::from_rng(rng).map(ChaChaRng)
- }
-}
-
-impl CryptoRng for ChaChaRng {}
-
-impl ChaChaRng {
- /// Get the offset from the start of the stream, in 32-bit words.
- ///
- /// Since the generated blocks are 16 words (2<sup>4</sup>) long and the
- /// counter is 64-bits, the offset is a 68-bit number. Sub-word offsets are
- /// not supported, hence the result can simply be multiplied by 4 to get a
- /// byte-offset.
- ///
- /// Note: this function is currently only available with Rust 1.26 or later.
- #[cfg(all(rustc_1_26, not(target_os = "emscripten")))]
- pub fn get_word_pos(&self) -> u128 {
- let mut c = (self.0.core.state[13] as u64) << 32
- | (self.0.core.state[12] as u64);
- let mut index = self.0.index();
- // c is the end of the last block generated, unless index is at end
- if index >= STATE_WORDS {
- index = 0;
- } else {
- c = c.wrapping_sub(1);
- }
- ((c as u128) << 4) | (index as u128)
- }
-
- /// Set the offset from the start of the stream, in 32-bit words.
- ///
- /// As with `get_word_pos`, we use a 68-bit number. Since the generator
- /// simply cycles at the end of its period (1 ZiB), we ignore the upper
- /// 60 bits.
- ///
- /// Note: this function is currently only available with Rust 1.26 or later.
- #[cfg(all(rustc_1_26, not(target_os = "emscripten")))]
- pub fn set_word_pos(&mut self, word_offset: u128) {
- let index = (word_offset as usize) & 0xF;
- let counter = (word_offset >> 4) as u64;
- self.0.core.state[12] = counter as u32;
- self.0.core.state[13] = (counter >> 32) as u32;
- if index != 0 {
- self.0.generate_and_set(index); // also increments counter
- } else {
- self.0.reset();
- }
- }
-
- /// Set the stream number.
- ///
- /// This is initialized to zero; 2<sup>64</sup> unique streams of output
- /// are available per seed/key.
- ///
- /// Note that in order to reproduce ChaCha output with a specific 64-bit
- /// nonce, one can convert that nonce to a `u64` in little-endian fashion
- /// and pass to this function. In theory a 96-bit nonce can be used by
- /// passing the last 64-bits to this function and using the first 32-bits as
- /// the most significant half of the 64-bit counter (which may be set
- /// indirectly via `set_word_pos`), but this is not directly supported.
- pub fn set_stream(&mut self, stream: u64) {
- let index = self.0.index();
- self.0.core.state[14] = stream as u32;
- self.0.core.state[15] = (stream >> 32) as u32;
- if index < STATE_WORDS {
- // we need to regenerate a partial result buffer
- {
- // reverse of counter adjustment in generate()
- if self.0.core.state[12] == 0 {
- self.0.core.state[13] = self.0.core.state[13].wrapping_sub(1);
- }
- self.0.core.state[12] = self.0.core.state[12].wrapping_sub(1);
- }
- self.0.generate_and_set(index);
- }
- }
-}
-
-/// The core of `ChaChaRng`, used with `BlockRng`.
-#[derive(Clone)]
-pub struct ChaChaCore {
- state: [u32; STATE_WORDS],
-}
-
-// Custom Debug implementation that does not expose the internal state
-impl fmt::Debug for ChaChaCore {
- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
- write!(f, "ChaChaCore {{}}")
- }
-}
-
-macro_rules! quarter_round{
- ($a: expr, $b: expr, $c: expr, $d: expr) => {{
- $a = $a.wrapping_add($b); $d ^= $a; $d = $d.rotate_left(16);
- $c = $c.wrapping_add($d); $b ^= $c; $b = $b.rotate_left(12);
- $a = $a.wrapping_add($b); $d ^= $a; $d = $d.rotate_left( 8);
- $c = $c.wrapping_add($d); $b ^= $c; $b = $b.rotate_left( 7);
- }}
-}
-
-macro_rules! double_round{
- ($x: expr) => {{
- // Column round
- quarter_round!($x[ 0], $x[ 4], $x[ 8], $x[12]);
- quarter_round!($x[ 1], $x[ 5], $x[ 9], $x[13]);
- quarter_round!($x[ 2], $x[ 6], $x[10], $x[14]);
- quarter_round!($x[ 3], $x[ 7], $x[11], $x[15]);
- // Diagonal round
- quarter_round!($x[ 0], $x[ 5], $x[10], $x[15]);
- quarter_round!($x[ 1], $x[ 6], $x[11], $x[12]);
- quarter_round!($x[ 2], $x[ 7], $x[ 8], $x[13]);
- quarter_round!($x[ 3], $x[ 4], $x[ 9], $x[14]);
- }}
-}
-
-impl BlockRngCore for ChaChaCore {
- type Item = u32;
- type Results = [u32; STATE_WORDS];
-
- fn generate(&mut self, results: &mut Self::Results) {
- // For some reason extracting this part into a separate function
- // improves performance by 50%.
- fn core(results: &mut [u32; STATE_WORDS],
- state: &[u32; STATE_WORDS])
- {
- let mut tmp = *state;
- let rounds = 20;
- for _ in 0..rounds / 2 {
- double_round!(tmp);
- }
- for i in 0..STATE_WORDS {
- results[i] = tmp[i].wrapping_add(state[i]);
- }
- }
-
- core(results, &self.state);
-
- // update 64-bit counter
- self.state[12] = self.state[12].wrapping_add(1);
- if self.state[12] != 0 { return; };
- self.state[13] = self.state[13].wrapping_add(1);
- }
-}
-
-impl SeedableRng for ChaChaCore {
- type Seed = [u8; SEED_WORDS*4];
-
- fn from_seed(seed: Self::Seed) -> Self {
- let mut seed_le = [0u32; SEED_WORDS];
- le::read_u32_into(&seed, &mut seed_le);
- Self {
- state: [0x61707865, 0x3320646E, 0x79622D32, 0x6B206574, // constants
- seed_le[0], seed_le[1], seed_le[2], seed_le[3], // seed
- seed_le[4], seed_le[5], seed_le[6], seed_le[7], // seed
- 0, 0, 0, 0], // counter
- }
- }
-}
-
-impl CryptoRng for ChaChaCore {}
-
-impl From<ChaChaCore> for ChaChaRng {
- fn from(core: ChaChaCore) -> Self {
- ChaChaRng(BlockRng::new(core))
- }
-}
-
-#[cfg(test)]
-mod test {
- use ::rand_core::{RngCore, SeedableRng};
- use super::ChaChaRng;
-
- #[test]
- fn test_chacha_construction() {
- let seed = [0,0,0,0,0,0,0,0,
- 1,0,0,0,0,0,0,0,
- 2,0,0,0,0,0,0,0,
- 3,0,0,0,0,0,0,0];
- let mut rng1 = ChaChaRng::from_seed(seed);
- assert_eq!(rng1.next_u32(), 137206642);
-
- let mut rng2 = ChaChaRng::from_rng(rng1).unwrap();
- assert_eq!(rng2.next_u32(), 1325750369);
- }
-
- #[test]
- fn test_chacha_true_values_a() {
- // Test vectors 1 and 2 from
- // https://tools.ietf.org/html/draft-nir-cfrg-chacha20-poly1305-04
- let seed = [0u8; 32];
- let mut rng = ChaChaRng::from_seed(seed);
-
- let mut results = [0u32; 16];
- for i in results.iter_mut() { *i = rng.next_u32(); }
- let expected = [0xade0b876, 0x903df1a0, 0xe56a5d40, 0x28bd8653,
- 0xb819d2bd, 0x1aed8da0, 0xccef36a8, 0xc70d778b,
- 0x7c5941da, 0x8d485751, 0x3fe02477, 0x374ad8b8,
- 0xf4b8436a, 0x1ca11815, 0x69b687c3, 0x8665eeb2];
- assert_eq!(results, expected);
-
- for i in results.iter_mut() { *i = rng.next_u32(); }
- let expected = [0xbee7079f, 0x7a385155, 0x7c97ba98, 0x0d082d73,
- 0xa0290fcb, 0x6965e348, 0x3e53c612, 0xed7aee32,
- 0x7621b729, 0x434ee69c, 0xb03371d5, 0xd539d874,
- 0x281fed31, 0x45fb0a51, 0x1f0ae1ac, 0x6f4d794b];
- assert_eq!(results, expected);
- }
-
- #[test]
- fn test_chacha_true_values_b() {
- // Test vector 3 from
- // https://tools.ietf.org/html/draft-nir-cfrg-chacha20-poly1305-04
- let seed = [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, 1];
- let mut rng = ChaChaRng::from_seed(seed);
-
- // Skip block 0
- for _ in 0..16 { rng.next_u32(); }
-
- let mut results = [0u32; 16];
- for i in results.iter_mut() { *i = rng.next_u32(); }
- let expected = [0x2452eb3a, 0x9249f8ec, 0x8d829d9b, 0xddd4ceb1,
- 0xe8252083, 0x60818b01, 0xf38422b8, 0x5aaa49c9,
- 0xbb00ca8e, 0xda3ba7b4, 0xc4b592d1, 0xfdf2732f,
- 0x4436274e, 0x2561b3c8, 0xebdd4aa6, 0xa0136c00];
- assert_eq!(results, expected);
- }
-
- #[test]
- #[cfg(all(rustc_1_26, not(target_os = "emscripten")))]
- fn test_chacha_true_values_c() {
- // Test vector 4 from
- // https://tools.ietf.org/html/draft-nir-cfrg-chacha20-poly1305-04
- let seed = [0, 0xff, 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];
- let expected = [0xfb4dd572, 0x4bc42ef1, 0xdf922636, 0x327f1394,
- 0xa78dea8f, 0x5e269039, 0xa1bebbc1, 0xcaf09aae,
- 0xa25ab213, 0x48a6b46c, 0x1b9d9bcb, 0x092c5be6,
- 0x546ca624, 0x1bec45d5, 0x87f47473, 0x96f0992e];
- let expected_end = 3 * 16;
- let mut results = [0u32; 16];
-
- // Test block 2 by skipping block 0 and 1
- let mut rng1 = ChaChaRng::from_seed(seed);
- for _ in 0..32 { rng1.next_u32(); }
- for i in results.iter_mut() { *i = rng1.next_u32(); }
- assert_eq!(results, expected);
- assert_eq!(rng1.get_word_pos(), expected_end);
-
- // Test block 2 by using `set_word_pos`
- let mut rng2 = ChaChaRng::from_seed(seed);
- rng2.set_word_pos(2 * 16);
- for i in results.iter_mut() { *i = rng2.next_u32(); }
- assert_eq!(results, expected);
- assert_eq!(rng2.get_word_pos(), expected_end);
-
- // Test skipping behaviour with other types
- let mut buf = [0u8; 32];
- rng2.fill_bytes(&mut buf[..]);
- assert_eq!(rng2.get_word_pos(), expected_end + 8);
- rng2.fill_bytes(&mut buf[0..25]);
- assert_eq!(rng2.get_word_pos(), expected_end + 15);
- rng2.next_u64();
- assert_eq!(rng2.get_word_pos(), expected_end + 17);
- rng2.next_u32();
- rng2.next_u64();
- assert_eq!(rng2.get_word_pos(), expected_end + 20);
- rng2.fill_bytes(&mut buf[0..1]);
- assert_eq!(rng2.get_word_pos(), expected_end + 21);
- }
-
- #[test]
- fn test_chacha_multiple_blocks() {
- let seed = [0,0,0,0, 1,0,0,0, 2,0,0,0, 3,0,0,0, 4,0,0,0, 5,0,0,0, 6,0,0,0, 7,0,0,0];
- let mut rng = ChaChaRng::from_seed(seed);
-
- // Store the 17*i-th 32-bit word,
- // i.e., the i-th word of the i-th 16-word block
- let mut results = [0u32; 16];
- for i in results.iter_mut() {
- *i = rng.next_u32();
- for _ in 0..16 {
- rng.next_u32();
- }
- }
- let expected = [0xf225c81a, 0x6ab1be57, 0x04d42951, 0x70858036,
- 0x49884684, 0x64efec72, 0x4be2d186, 0x3615b384,
- 0x11cfa18e, 0xd3c50049, 0x75c775f6, 0x434c6530,
- 0x2c5bad8f, 0x898881dc, 0x5f1c86d9, 0xc1f8e7f4];
- assert_eq!(results, expected);
- }
-
- #[test]
- fn test_chacha_true_bytes() {
- let seed = [0u8; 32];
- let mut rng = ChaChaRng::from_seed(seed);
- let mut results = [0u8; 32];
- rng.fill_bytes(&mut results);
- let expected = [118, 184, 224, 173, 160, 241, 61, 144,
- 64, 93, 106, 229, 83, 134, 189, 40,
- 189, 210, 25, 184, 160, 141, 237, 26,
- 168, 54, 239, 204, 139, 119, 13, 199];
- assert_eq!(results, expected);
- }
-
- #[test]
- fn test_chacha_nonce() {
- // Test vector 5 from
- // https://tools.ietf.org/html/draft-nir-cfrg-chacha20-poly1305-04
- // Although we do not support setting a nonce, we try it here anyway so
- // we can use this test vector.
- let seed = [0u8; 32];
- let mut rng = ChaChaRng::from_seed(seed);
- // 96-bit nonce in LE order is: 0,0,0,0, 0,0,0,0, 0,0,0,2
- rng.set_stream(2u64 << (24 + 32));
-
- let mut results = [0u32; 16];
- for i in results.iter_mut() { *i = rng.next_u32(); }
- let expected = [0x374dc6c2, 0x3736d58c, 0xb904e24a, 0xcd3f93ef,
- 0x88228b1a, 0x96a4dfb3, 0x5b76ab72, 0xc727ee54,
- 0x0e0e978a, 0xf3145c95, 0x1b748ea8, 0xf786c297,
- 0x99c28f5f, 0x628314e8, 0x398a19fa, 0x6ded1b53];
- assert_eq!(results, expected);
- }
-
- #[test]
- fn test_chacha_clone_streams() {
- let seed = [0,0,0,0, 1,0,0,0, 2,0,0,0, 3,0,0,0, 4,0,0,0, 5,0,0,0, 6,0,0,0, 7,0,0,0];
- let mut rng = ChaChaRng::from_seed(seed);
- let mut clone = rng.clone();
- for _ in 0..16 {
- assert_eq!(rng.next_u64(), clone.next_u64());
- }
-
- rng.set_stream(51);
- for _ in 0..7 {
- assert!(rng.next_u32() != clone.next_u32());
- }
- clone.set_stream(51); // switch part way through block
- for _ in 7..16 {
- assert_eq!(rng.next_u32(), clone.next_u32());
- }
- }
-}
diff --git a/rand/rand_chacha/src/lib.rs b/rand/rand_chacha/src/lib.rs
deleted file mode 100644
index 74ad466..0000000
--- a/rand/rand_chacha/src/lib.rs
+++ /dev/null
@@ -1,25 +0,0 @@
-// Copyright 2018 Developers of the Rand project.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-//! The ChaCha random number generator.
-
-#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk.png",
- html_favicon_url = "https://www.rust-lang.org/favicon.ico",
- html_root_url = "https://rust-random.github.io/rand/")]
-
-#![deny(missing_docs)]
-#![deny(missing_debug_implementations)]
-#![doc(test(attr(allow(unused_variables), deny(warnings))))]
-
-#![no_std]
-
-pub extern crate rand_core;
-
-mod chacha;
-
-pub use chacha::{ChaChaRng, ChaChaCore};
diff --git a/rand/rand_core/CHANGELOG.md b/rand/rand_core/CHANGELOG.md
deleted file mode 100644
index 2cbb259..0000000
--- a/rand/rand_core/CHANGELOG.md
+++ /dev/null
@@ -1,33 +0,0 @@
-# Changelog
-All notable changes to this project will be documented in this file.
-
-The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
-and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
-
-## [0.3.0] - 2018-09-24
-- Add `SeedableRng::seed_from_u64` for convenient seeding. (#537)
-
-## [0.2.1] - 2018-06-08
-- References to a `CryptoRng` now also implement `CryptoRng`. (#470)
-
-## [0.2.0] - 2018-05-21
-- Enable the `std` feature by default. (#409)
-- Remove `BlockRng{64}::inner` and `BlockRng::inner_mut`; instead making `core` public
-- Add `BlockRng{64}::index` and `BlockRng{64}::generate_and_set`. (#374, #419)
-- Change `BlockRngCore::Results` bound to also require `AsMut<[Self::Item]>`. (#419)
-- Implement `std::io::Read` for RngCore. (#434)
-
-## [0.1.0] - 2018-04-17
-(Split out of the Rand crate, changes here are relative to rand 0.4.2)
-- `RngCore` and `SeedableRng` are now part of `rand_core`. (#288)
-- Add modules to help implementing RNGs `impl` and `le`. (#209, #228)
-- Add `Error` and `ErrorKind`. (#225)
-- Add `CryptoRng` marker trait. (#273)
-- Add `BlockRngCore` trait. (#281)
-- Add `BlockRng` and `BlockRng64` wrappers to help implementations. (#281, #325)
-- Revise the `SeedableRng` trait. (#233)
-- Remove default implementations for `RngCore::next_u64` and `RngCore::fill_bytes`. (#288)
-- Add `RngCore::try_fill_bytes`. (#225)
-
-## [0.0.1] - 2017-09-14 (yanked)
-Experimental version as part of the rand crate refactor.
diff --git a/rand/rand_core/COPYRIGHT b/rand/rand_core/COPYRIGHT
deleted file mode 100644
index 468d907..0000000
--- a/rand/rand_core/COPYRIGHT
+++ /dev/null
@@ -1,12 +0,0 @@
-Copyrights in the Rand project are retained by their contributors. No
-copyright assignment is required to contribute to the Rand project.
-
-For full authorship information, see the version control history.
-
-Except as otherwise noted (below and/or in individual files), Rand is
-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.
-
-The Rand project includes code from the Rust project
-published under these same licenses.
diff --git a/rand/rand_core/Cargo.toml b/rand/rand_core/Cargo.toml
deleted file mode 100644
index 1678773..0000000
--- a/rand/rand_core/Cargo.toml
+++ /dev/null
@@ -1,28 +0,0 @@
-[package]
-name = "rand_core"
-version = "0.3.0"
-authors = ["The Rand Project Developers", "The Rust Project Developers"]
-license = "MIT/Apache-2.0"
-readme = "README.md"
-repository = "https://github.com/rust-random/rand"
-documentation = "https://rust-random.github.io/rand/rand_core"
-homepage = "https://crates.io/crates/rand_core"
-description = """
-Core random number generator traits and tools for implementation.
-"""
-keywords = ["random", "rng"]
-categories = ["algorithms", "no-std"]
-
-[badges]
-travis-ci = { repository = "rust-random/rand" }
-appveyor = { repository = "rust-random/rand" }
-
-[features]
-default = ["std"]
-std = ["alloc"] # use std library; should be default but for above bug
-alloc = [] # enables Vec and Box support without std
-serde1 = ["serde", "serde_derive"] # enables serde for BlockRng wrapper
-
-[dependencies]
-serde = { version = "1", optional = true }
-serde_derive = { version = "^1.0.38", optional = true }
diff --git a/rand/rand_core/LICENSE-APACHE b/rand/rand_core/LICENSE-APACHE
deleted file mode 100644
index 17d7468..0000000
--- a/rand/rand_core/LICENSE-APACHE
+++ /dev/null
@@ -1,201 +0,0 @@
- Apache License
- Version 2.0, January 2004
- https://www.apache.org/licenses/
-
-TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
-1. Definitions.
-
- "License" shall mean the terms and conditions for use, reproduction,
- and distribution as defined by Sections 1 through 9 of this document.
-
- "Licensor" shall mean the copyright owner or entity authorized by
- the copyright owner that is granting the License.
-
- "Legal Entity" shall mean the union of the acting entity and all
- other entities that control, are controlled by, or are under common
- control with that entity. For the purposes of this definition,
- "control" means (i) the power, direct or indirect, to cause the
- direction or management of such entity, whether by contract or
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
- outstanding shares, or (iii) beneficial ownership of such entity.
-
- "You" (or "Your") shall mean an individual or Legal Entity
- exercising permissions granted by this License.
-
- "Source" form shall mean the preferred form for making modifications,
- including but not limited to software source code, documentation
- source, and configuration files.
-
- "Object" form shall mean any form resulting from mechanical
- transformation or translation of a Source form, including but
- not limited to compiled object code, generated documentation,
- and conversions to other media types.
-
- "Work" shall mean the work of authorship, whether in Source or
- Object form, made available under the License, as indicated by a
- copyright notice that is included in or attached to the work
- (an example is provided in the Appendix below).
-
- "Derivative Works" shall mean any work, whether in Source or Object
- form, that is based on (or derived from) the Work and for which the
- editorial revisions, annotations, elaborations, or other modifications
- represent, as a whole, an original work of authorship. For the purposes
- of this License, Derivative Works shall not include works that remain
- separable from, or merely link (or bind by name) to the interfaces of,
- the Work and Derivative Works thereof.
-
- "Contribution" shall mean any work of authorship, including
- the original version of the Work and any modifications or additions
- to that Work or Derivative Works thereof, that is intentionally
- submitted to Licensor for inclusion in the Work by the copyright owner
- or by an individual or Legal Entity authorized to submit on behalf of
- the copyright owner. For the purposes of this definition, "submitted"
- means any form of electronic, verbal, or written communication sent
- to the Licensor or its representatives, including but not limited to
- communication on electronic mailing lists, source code control systems,
- and issue tracking systems that are managed by, or on behalf of, the
- Licensor for the purpose of discussing and improving the Work, but
- excluding communication that is conspicuously marked or otherwise
- designated in writing by the copyright owner as "Not a Contribution."
-
- "Contributor" shall mean Licensor and any individual or Legal Entity
- on behalf of whom a Contribution has been received by Licensor and
- subsequently incorporated within the Work.
-
-2. Grant of Copyright License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- copyright license to reproduce, prepare Derivative Works of,
- publicly display, publicly perform, sublicense, and distribute the
- Work and such Derivative Works in Source or Object form.
-
-3. Grant of Patent License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- (except as stated in this section) patent license to make, have made,
- use, offer to sell, sell, import, and otherwise transfer the Work,
- where such license applies only to those patent claims licensable
- by such Contributor that are necessarily infringed by their
- Contribution(s) alone or by combination of their Contribution(s)
- with the Work to which such Contribution(s) was submitted. If You
- institute patent litigation against any entity (including a
- cross-claim or counterclaim in a lawsuit) alleging that the Work
- or a Contribution incorporated within the Work constitutes direct
- or contributory patent infringement, then any patent licenses
- granted to You under this License for that Work shall terminate
- as of the date such litigation is filed.
-
-4. Redistribution. You may reproduce and distribute copies of the
- Work or Derivative Works thereof in any medium, with or without
- modifications, and in Source or Object form, provided that You
- meet the following conditions:
-
- (a) You must give any other recipients of the Work or
- Derivative Works a copy of this License; and
-
- (b) You must cause any modified files to carry prominent notices
- stating that You changed the files; and
-
- (c) You must retain, in the Source form of any Derivative Works
- that You distribute, all copyright, patent, trademark, and
- attribution notices from the Source form of the Work,
- excluding those notices that do not pertain to any part of
- the Derivative Works; and
-
- (d) If the Work includes a "NOTICE" text file as part of its
- distribution, then any Derivative Works that You distribute must
- include a readable copy of the attribution notices contained
- within such NOTICE file, excluding those notices that do not
- pertain to any part of the Derivative Works, in at least one
- of the following places: within a NOTICE text file distributed
- as part of the Derivative Works; within the Source form or
- documentation, if provided along with the Derivative Works; or,
- within a display generated by the Derivative Works, if and
- wherever such third-party notices normally appear. The contents
- of the NOTICE file are for informational purposes only and
- do not modify the License. You may add Your own attribution
- notices within Derivative Works that You distribute, alongside
- or as an addendum to the NOTICE text from the Work, provided
- that such additional attribution notices cannot be construed
- as modifying the License.
-
- You may add Your own copyright statement to Your modifications and
- may provide additional or different license terms and conditions
- for use, reproduction, or distribution of Your modifications, or
- for any such Derivative Works as a whole, provided Your use,
- reproduction, and distribution of the Work otherwise complies with
- the conditions stated in this License.
-
-5. Submission of Contributions. Unless You explicitly state otherwise,
- any Contribution intentionally submitted for inclusion in the Work
- by You to the Licensor shall be under the terms and conditions of
- this License, without any additional terms or conditions.
- Notwithstanding the above, nothing herein shall supersede or modify
- the terms of any separate license agreement you may have executed
- with Licensor regarding such Contributions.
-
-6. Trademarks. This License does not grant permission to use the trade
- names, trademarks, service marks, or product names of the Licensor,
- except as required for reasonable and customary use in describing the
- origin of the Work and reproducing the content of the NOTICE file.
-
-7. Disclaimer of Warranty. Unless required by applicable law or
- agreed to in writing, Licensor provides the Work (and each
- Contributor provides its Contributions) on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- implied, including, without limitation, any warranties or conditions
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
- PARTICULAR PURPOSE. You are solely responsible for determining the
- appropriateness of using or redistributing the Work and assume any
- risks associated with Your exercise of permissions under this License.
-
-8. Limitation of Liability. In no event and under no legal theory,
- whether in tort (including negligence), contract, or otherwise,
- unless required by applicable law (such as deliberate and grossly
- negligent acts) or agreed to in writing, shall any Contributor be
- liable to You for damages, including any direct, indirect, special,
- incidental, or consequential damages of any character arising as a
- result of this License or out of the use or inability to use the
- Work (including but not limited to damages for loss of goodwill,
- work stoppage, computer failure or malfunction, or any and all
- other commercial damages or losses), even if such Contributor
- has been advised of the possibility of such damages.
-
-9. Accepting Warranty or Additional Liability. While redistributing
- the Work or Derivative Works thereof, You may choose to offer,
- and charge a fee for, acceptance of support, warranty, indemnity,
- or other liability obligations and/or rights consistent with this
- License. However, in accepting such obligations, You may act only
- on Your own behalf and on Your sole responsibility, not on behalf
- of any other Contributor, and only if You agree to indemnify,
- defend, and hold each Contributor harmless for any liability
- incurred by, or claims asserted against, such Contributor by reason
- of your accepting any such warranty or additional liability.
-
-END OF TERMS AND CONDITIONS
-
-APPENDIX: How to apply the Apache License to your work.
-
- To apply the Apache License to your work, attach the following
- boilerplate notice, with the fields enclosed by brackets "[]"
- replaced with your own identifying information. (Don't include
- the brackets!) The text should be enclosed in the appropriate
- comment syntax for the file format. We also recommend that a
- file or class name and description of purpose be included on the
- same "printed page" as the copyright notice for easier
- identification within third-party archives.
-
-Copyright [yyyy] [name of copyright owner]
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
- https://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
diff --git a/rand/rand_core/LICENSE-MIT b/rand/rand_core/LICENSE-MIT
deleted file mode 100644
index d93b5ba..0000000
--- a/rand/rand_core/LICENSE-MIT
+++ /dev/null
@@ -1,26 +0,0 @@
-Copyright 2018 Developers of the Rand project
-Copyright (c) 2014 The Rust Project Developers
-
-Permission is hereby granted, free of charge, to any
-person obtaining a copy of this software and associated
-documentation files (the "Software"), to deal in the
-Software without restriction, including without
-limitation the rights to use, copy, modify, merge,
-publish, distribute, sublicense, and/or sell copies of
-the Software, and to permit persons to whom the Software
-is furnished to do so, subject to the following
-conditions:
-
-The above copyright notice and this permission notice
-shall be included in all copies or substantial portions
-of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
-ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
-TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
-PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
-SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
-CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
-IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
-DEALINGS IN THE SOFTWARE.
diff --git a/rand/rand_core/README.md b/rand/rand_core/README.md
deleted file mode 100644
index dee6504..0000000
--- a/rand/rand_core/README.md
+++ /dev/null
@@ -1,65 +0,0 @@
-# rand_core
-
-[![Build Status](https://travis-ci.org/rust-random/rand.svg)](https://travis-ci.org/rust-random/rand)
-[![Build Status](https://ci.appveyor.com/api/projects/status/github/rust-random/rand?svg=true)](https://ci.appveyor.com/project/rust-random/rand)
-[![Latest version](https://img.shields.io/crates/v/rand_core.svg)](https://crates.io/crates/rand_core)
-[![Book](https://img.shields.io/badge/book-master-yellow.svg)](https://rust-random.github.io/book/)
-[![API](https://img.shields.io/badge/api-master-yellow.svg)](https://rust-random.github.io/rand/rand_core)
-[![API](https://docs.rs/rand_core/badge.svg)](https://docs.rs/rand_core)
-[![Minimum rustc version](https://img.shields.io/badge/rustc-1.22+-lightgray.svg)](https://github.com/rust-random/rand#rust-version-requirements)
-
-Core traits and error types of the [rand] library, plus tools for implementing
-RNGs.
-
-This crate is intended for use when implementing the core trait, `RngCore`; it
-defines the core traits to be implemented as well as several small functions to
-aid in their implementation and types required for error handling.
-
-The main [rand] crate re-exports most items defined in this crate, along with
-tools to convert the integer samples generated by `RngCore` to many different
-applications (including sampling from restricted ranges, conversion to floating
-point, list permutations and secure initialisation of RNGs). Most users should
-prefer to use the main [rand] crate.
-
-Links:
-
-- [API documentation (master)](https://rust-random.github.io/rand/rand_core)
-- [API documentation (docs.rs)](https://docs.rs/rand_core)
-- [Changelog](CHANGELOG.md)
-
-[rand]: https://crates.io/crates/rand
-
-
-## Functionality
-
-The `rand_core` crate provides:
-
-- base random number generator traits
-- error-reporting types
-- functionality to aid implementation of RNGs
-
-The traits and error types are also available via `rand`.
-
-## Crate Features
-
-`rand_core` supports `no_std` and `alloc`-only configurations, as well as full
-`std` functionality. The differences between `no_std` and full `std` are small,
-comprising `RngCore` support for `Box<R>` types where `R: RngCore`, as well as
-extensions to the `Error` type's functionality.
-
-Due to [rust-lang/cargo#1596](https://github.com/rust-lang/cargo/issues/1596),
-`rand_core` is built without `std` support by default. Since features are
-unioned across the whole dependency tree, any crate using `rand` with its
-default features will also enable `std` support in `rand_core`.
-
-The `serde1` feature can be used to derive `Serialize` and `Deserialize` for RNG
-implementations that use the `BlockRng` or `BlockRng64` wrappers.
-
-
-# License
-
-`rand_core` is distributed under the terms of both the MIT license and the
-Apache License (Version 2.0).
-
-See [LICENSE-APACHE](LICENSE-APACHE) and [LICENSE-MIT](LICENSE-MIT), and
-[COPYRIGHT](COPYRIGHT) for details.
diff --git a/rand/rand_core/src/block.rs b/rand/rand_core/src/block.rs
deleted file mode 100644
index de480e4..0000000
--- a/rand/rand_core/src/block.rs
+++ /dev/null
@@ -1,508 +0,0 @@
-// Copyright 2018 Developers of the Rand project.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-//! The `BlockRngCore` trait and implementation helpers
-//!
-//! The [`BlockRngCore`] trait exists to assist in the implementation of RNGs
-//! which generate a block of data in a cache instead of returning generated
-//! values directly.
-//!
-//! Usage of this trait is optional, but provides two advantages:
-//! implementations only need to concern themselves with generation of the
-//! block, not the various [`RngCore`] methods (especially [`fill_bytes`], where
-//! the optimal implementations are not trivial), and this allows
-//! [`ReseedingRng`] perform periodic reseeding with very low overhead.
-//!
-//! # Example
-//!
-//! ```norun
-//! use rand_core::block::{BlockRngCore, BlockRng};
-//!
-//! struct MyRngCore;
-//!
-//! impl BlockRngCore for MyRngCore {
-//! type Results = [u32; 16];
-//!
-//! fn generate(&mut self, results: &mut Self::Results) {
-//! unimplemented!()
-//! }
-//! }
-//!
-//! impl SeedableRng for MyRngCore {
-//! type Seed = unimplemented!();
-//! fn from_seed(seed: Self::Seed) -> Self {
-//! unimplemented!()
-//! }
-//! }
-//!
-//! // optionally, also implement CryptoRng for MyRngCore
-//!
-//! // Final RNG.
-//! type MyRng = BlockRng<u32, MyRngCore>;
-//! ```
-//!
-//! [`BlockRngCore`]: trait.BlockRngCore.html
-//! [`RngCore`]: ../trait.RngCore.html
-//! [`fill_bytes`]: ../trait.RngCore.html#tymethod.fill_bytes
-//! [`ReseedingRng`]: ../../rand/rngs/adapter/struct.ReseedingRng.html
-
-use core::convert::AsRef;
-use core::fmt;
-use {RngCore, CryptoRng, SeedableRng, Error};
-use impls::{fill_via_u32_chunks, fill_via_u64_chunks};
-
-/// A trait for RNGs which do not generate random numbers individually, but in
-/// blocks (typically `[u32; N]`). This technique is commonly used by
-/// cryptographic RNGs to improve performance.
-///
-/// See the [module documentation](index.html) for details.
-pub trait BlockRngCore {
- /// Results element type, e.g. `u32`.
- type Item;
-
- /// Results type. This is the 'block' an RNG implementing `BlockRngCore`
- /// generates, which will usually be an array like `[u32; 16]`.
- type Results: AsRef<[Self::Item]> + AsMut<[Self::Item]> + Default;
-
- /// Generate a new block of results.
- fn generate(&mut self, results: &mut Self::Results);
-}
-
-
-/// A wrapper type implementing [`RngCore`] for some type implementing
-/// [`BlockRngCore`] with `u32` array buffer; i.e. this can be used to implement
-/// a full RNG from just a `generate` function.
-///
-/// The `core` field may be accessed directly but the results buffer may not.
-/// PRNG implementations can simply use a type alias
-/// (`pub type MyRng = BlockRng<MyRngCore>;`) but might prefer to use a
-/// wrapper type (`pub struct MyRng(BlockRng<MyRngCore>);`); the latter must
-/// re-implement `RngCore` but hides the implementation details and allows
-/// extra functionality to be defined on the RNG
-/// (e.g. `impl MyRng { fn set_stream(...){...} }`).
-///
-/// `BlockRng` has heavily optimized implementations of the [`RngCore`] methods
-/// reading values from the results buffer, as well as
-/// calling [`BlockRngCore::generate`] directly on the output array when
-/// [`fill_bytes`] / [`try_fill_bytes`] is called on a large array. These methods
-/// also handle the bookkeeping of when to generate a new batch of values.
-///
-/// No whole generated `u32` values are thown away and all values are consumed
-/// in-order. [`next_u32`] simply takes the next available `u32` value.
-/// [`next_u64`] is implemented by combining two `u32` values, least
-/// significant first. [`fill_bytes`] and [`try_fill_bytes`] consume a whole
-/// number of `u32` values, converting each `u32` to a byte slice in
-/// little-endian order. If the requested byte length is not a multiple of 4,
-/// some bytes will be discarded.
-///
-/// See also [`BlockRng64`] which uses `u64` array buffers. Currently there is
-/// no direct support for other buffer types.
-///
-/// For easy initialization `BlockRng` also implements [`SeedableRng`].
-///
-/// [`BlockRngCore`]: BlockRngCore.t.html
-/// [`BlockRngCore::generate`]: trait.BlockRngCore.html#tymethod.generate
-/// [`BlockRng64`]: struct.BlockRng64.html
-/// [`RngCore`]: ../RngCore.t.html
-/// [`next_u32`]: ../trait.RngCore.html#tymethod.next_u32
-/// [`next_u64`]: ../trait.RngCore.html#tymethod.next_u64
-/// [`fill_bytes`]: ../trait.RngCore.html#tymethod.fill_bytes
-/// [`try_fill_bytes`]: ../trait.RngCore.html#tymethod.try_fill_bytes
-/// [`SeedableRng`]: ../SeedableRng.t.html
-#[derive(Clone)]
-#[cfg_attr(feature="serde1", derive(Serialize, Deserialize))]
-pub struct BlockRng<R: BlockRngCore + ?Sized> {
- results: R::Results,
- index: usize,
- /// The *core* part of the RNG, implementing the `generate` function.
- pub core: R,
-}
-
-// Custom Debug implementation that does not expose the contents of `results`.
-impl<R: BlockRngCore + fmt::Debug> fmt::Debug for BlockRng<R> {
- fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
- fmt.debug_struct("BlockRng")
- .field("core", &self.core)
- .field("result_len", &self.results.as_ref().len())
- .field("index", &self.index)
- .finish()
- }
-}
-
-impl<R: BlockRngCore> BlockRng<R> {
- /// Create a new `BlockRng` from an existing RNG implementing
- /// `BlockRngCore`. Results will be generated on first use.
- pub fn new(core: R) -> BlockRng<R>{
- let results_empty = R::Results::default();
- BlockRng {
- core,
- index: results_empty.as_ref().len(),
- results: results_empty,
- }
- }
-
- /// Get the index into the result buffer.
- ///
- /// If this is equal to or larger than the size of the result buffer then
- /// the buffer is "empty" and `generate()` must be called to produce new
- /// results.
- pub fn index(&self) -> usize {
- self.index
- }
-
- /// Reset the number of available results.
- /// This will force a new set of results to be generated on next use.
- pub fn reset(&mut self) {
- self.index = self.results.as_ref().len();
- }
-
- /// Generate a new set of results immediately, setting the index to the
- /// given value.
- pub fn generate_and_set(&mut self, index: usize) {
- assert!(index < self.results.as_ref().len());
- self.core.generate(&mut self.results);
- self.index = index;
- }
-}
-
-impl<R: BlockRngCore<Item=u32>> RngCore for BlockRng<R>
-where <R as BlockRngCore>::Results: AsRef<[u32]> + AsMut<[u32]>
-{
- #[inline(always)]
- fn next_u32(&mut self) -> u32 {
- if self.index >= self.results.as_ref().len() {
- self.generate_and_set(0);
- }
-
- let value = self.results.as_ref()[self.index];
- self.index += 1;
- value
- }
-
- #[inline(always)]
- fn next_u64(&mut self) -> u64 {
- let read_u64 = |results: &[u32], index| {
- if cfg!(any(target_arch = "x86", target_arch = "x86_64")) {
- // requires little-endian CPU supporting unaligned reads:
- unsafe { *(&results[index] as *const u32 as *const u64) }
- } else {
- let x = u64::from(results[index]);
- let y = u64::from(results[index + 1]);
- (y << 32) | x
- }
- };
-
- let len = self.results.as_ref().len();
-
- let index = self.index;
- if index < len-1 {
- self.index += 2;
- // Read an u64 from the current index
- read_u64(self.results.as_ref(), index)
- } else if index >= len {
- self.generate_and_set(2);
- read_u64(self.results.as_ref(), 0)
- } else {
- let x = u64::from(self.results.as_ref()[len-1]);
- self.generate_and_set(1);
- let y = u64::from(self.results.as_ref()[0]);
- (y << 32) | x
- }
- }
-
- // As an optimization we try to write directly into the output buffer.
- // This is only enabled for little-endian platforms where unaligned writes
- // are known to be safe and fast.
- #[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
- fn fill_bytes(&mut self, dest: &mut [u8]) {
- let mut filled = 0;
-
- // Continue filling from the current set of results
- if self.index < self.results.as_ref().len() {
- let (consumed_u32, filled_u8) =
- fill_via_u32_chunks(&self.results.as_ref()[self.index..],
- dest);
-
- self.index += consumed_u32;
- filled += filled_u8;
- }
-
- let len_remainder =
- (dest.len() - filled) % (self.results.as_ref().len() * 4);
- let end_direct = dest.len() - len_remainder;
-
- while filled < end_direct {
- let dest_u32: &mut R::Results = unsafe {
- &mut *(dest[filled..].as_mut_ptr() as
- *mut <R as BlockRngCore>::Results)
- };
- self.core.generate(dest_u32);
- filled += self.results.as_ref().len() * 4;
- self.index = self.results.as_ref().len();
- }
-
- if len_remainder > 0 {
- self.core.generate(&mut self.results);
- let (consumed_u32, _) =
- fill_via_u32_chunks(self.results.as_ref(),
- &mut dest[filled..]);
-
- self.index = consumed_u32;
- }
- }
-
- #[cfg(not(any(target_arch = "x86", target_arch = "x86_64")))]
- fn fill_bytes(&mut self, dest: &mut [u8]) {
- let mut read_len = 0;
- while read_len < dest.len() {
- if self.index >= self.results.as_ref().len() {
- self.generate_and_set(0);
- }
- let (consumed_u32, filled_u8) =
- fill_via_u32_chunks(&self.results.as_ref()[self.index..],
- &mut dest[read_len..]);
-
- self.index += consumed_u32;
- read_len += filled_u8;
- }
- }
-
- fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), Error> {
- self.fill_bytes(dest);
- Ok(())
- }
-}
-
-impl<R: BlockRngCore + SeedableRng> SeedableRng for BlockRng<R> {
- type Seed = R::Seed;
-
- fn from_seed(seed: Self::Seed) -> Self {
- Self::new(R::from_seed(seed))
- }
-
- fn seed_from_u64(seed: u64) -> Self {
- Self::new(R::seed_from_u64(seed))
- }
-
- fn from_rng<S: RngCore>(rng: S) -> Result<Self, Error> {
- Ok(Self::new(R::from_rng(rng)?))
- }
-}
-
-
-
-/// A wrapper type implementing [`RngCore`] for some type implementing
-/// [`BlockRngCore`] with `u64` array buffer; i.e. this can be used to implement
-/// a full RNG from just a `generate` function.
-///
-/// This is similar to [`BlockRng`], but specialized for algorithms that operate
-/// on `u64` values.
-///
-/// No whole generated `u64` values are thrown away and all values are consumed
-/// in-order. [`next_u64`] simply takes the next available `u64` value.
-/// [`next_u32`] is however a bit special: half of a `u64` is consumed, leaving
-/// the other half in the buffer. If the next function called is [`next_u32`]
-/// then the other half is then consumed, however both [`next_u64`] and
-/// [`fill_bytes`] discard the rest of any half-consumed `u64`s when called.
-///
-/// [`fill_bytes`] and [`try_fill_bytes`] consume a whole number of `u64`
-/// values. If the requested length is not a multiple of 8, some bytes will be
-/// discarded.
-///
-/// [`BlockRngCore`]: BlockRngCore.t.html
-/// [`RngCore`]: ../RngCore.t.html
-/// [`next_u32`]: ../trait.RngCore.html#tymethod.next_u32
-/// [`next_u64`]: ../trait.RngCore.html#tymethod.next_u64
-/// [`fill_bytes`]: ../trait.RngCore.html#tymethod.fill_bytes
-/// [`try_fill_bytes`]: ../trait.RngCore.html#tymethod.try_fill_bytes
-/// [`BlockRng`]: struct.BlockRng.html
-#[derive(Clone)]
-#[cfg_attr(feature="serde1", derive(Serialize, Deserialize))]
-pub struct BlockRng64<R: BlockRngCore + ?Sized> {
- results: R::Results,
- index: usize,
- half_used: bool, // true if only half of the previous result is used
- /// The *core* part of the RNG, implementing the `generate` function.
- pub core: R,
-}
-
-// Custom Debug implementation that does not expose the contents of `results`.
-impl<R: BlockRngCore + fmt::Debug> fmt::Debug for BlockRng64<R> {
- fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
- fmt.debug_struct("BlockRng64")
- .field("core", &self.core)
- .field("result_len", &self.results.as_ref().len())
- .field("index", &self.index)
- .field("half_used", &self.half_used)
- .finish()
- }
-}
-
-impl<R: BlockRngCore> BlockRng64<R> {
- /// Create a new `BlockRng` from an existing RNG implementing
- /// `BlockRngCore`. Results will be generated on first use.
- pub fn new(core: R) -> BlockRng64<R>{
- let results_empty = R::Results::default();
- BlockRng64 {
- core,
- index: results_empty.as_ref().len(),
- half_used: false,
- results: results_empty,
- }
- }
-
- /// Get the index into the result buffer.
- ///
- /// If this is equal to or larger than the size of the result buffer then
- /// the buffer is "empty" and `generate()` must be called to produce new
- /// results.
- pub fn index(&self) -> usize {
- self.index
- }
-
- /// Reset the number of available results.
- /// This will force a new set of results to be generated on next use.
- pub fn reset(&mut self) {
- self.index = self.results.as_ref().len();
- self.half_used = false;
- }
-
- /// Generate a new set of results immediately, setting the index to the
- /// given value.
- pub fn generate_and_set(&mut self, index: usize) {
- assert!(index < self.results.as_ref().len());
- self.core.generate(&mut self.results);
- self.index = index;
- self.half_used = false;
- }
-}
-
-impl<R: BlockRngCore<Item=u64>> RngCore for BlockRng64<R>
-where <R as BlockRngCore>::Results: AsRef<[u64]> + AsMut<[u64]>
-{
- #[inline(always)]
- fn next_u32(&mut self) -> u32 {
- let mut index = self.index * 2 - self.half_used as usize;
- if index >= self.results.as_ref().len() * 2 {
- self.core.generate(&mut self.results);
- self.index = 0;
- // `self.half_used` is by definition `false`
- self.half_used = false;
- index = 0;
- }
-
- self.half_used = !self.half_used;
- self.index += self.half_used as usize;
-
- // Index as if this is a u32 slice.
- unsafe {
- let results =
- &*(self.results.as_ref() as *const [u64] as *const [u32]);
- if cfg!(target_endian = "little") {
- *results.get_unchecked(index)
- } else {
- *results.get_unchecked(index ^ 1)
- }
- }
- }
-
- #[inline(always)]
- fn next_u64(&mut self) -> u64 {
- if self.index >= self.results.as_ref().len() {
- self.core.generate(&mut self.results);
- self.index = 0;
- }
-
- let value = self.results.as_ref()[self.index];
- self.index += 1;
- self.half_used = false;
- value
- }
-
- // As an optimization we try to write directly into the output buffer.
- // This is only enabled for little-endian platforms where unaligned writes
- // are known to be safe and fast.
- #[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
- fn fill_bytes(&mut self, dest: &mut [u8]) {
- let mut filled = 0;
- self.half_used = false;
-
- // Continue filling from the current set of results
- if self.index < self.results.as_ref().len() {
- let (consumed_u64, filled_u8) =
- fill_via_u64_chunks(&self.results.as_ref()[self.index..],
- dest);
-
- self.index += consumed_u64;
- filled += filled_u8;
- }
-
- let len_remainder =
- (dest.len() - filled) % (self.results.as_ref().len() * 8);
- let end_direct = dest.len() - len_remainder;
-
- while filled < end_direct {
- let dest_u64: &mut R::Results = unsafe {
- ::core::mem::transmute(dest[filled..].as_mut_ptr())
- };
- self.core.generate(dest_u64);
- filled += self.results.as_ref().len() * 8;
- self.index = self.results.as_ref().len();
- }
-
- if len_remainder > 0 {
- self.core.generate(&mut self.results);
- let (consumed_u64, _) =
- fill_via_u64_chunks(&mut self.results.as_ref(),
- &mut dest[filled..]);
-
- self.index = consumed_u64;
- }
- }
-
- #[cfg(not(any(target_arch = "x86", target_arch = "x86_64")))]
- fn fill_bytes(&mut self, dest: &mut [u8]) {
- let mut read_len = 0;
- self.half_used = false;
- while read_len < dest.len() {
- if self.index as usize >= self.results.as_ref().len() {
- self.core.generate(&mut self.results);
- self.index = 0;
- }
-
- let (consumed_u64, filled_u8) =
- fill_via_u64_chunks(&self.results.as_ref()[self.index as usize..],
- &mut dest[read_len..]);
-
- self.index += consumed_u64;
- read_len += filled_u8;
- }
- }
-
- fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), Error> {
- Ok(self.fill_bytes(dest))
- }
-}
-
-impl<R: BlockRngCore + SeedableRng> SeedableRng for BlockRng64<R> {
- type Seed = R::Seed;
-
- fn from_seed(seed: Self::Seed) -> Self {
- Self::new(R::from_seed(seed))
- }
-
- fn seed_from_u64(seed: u64) -> Self {
- Self::new(R::seed_from_u64(seed))
- }
-
- fn from_rng<S: RngCore>(rng: S) -> Result<Self, Error> {
- Ok(Self::new(R::from_rng(rng)?))
- }
-}
-
-impl<R: BlockRngCore + CryptoRng> CryptoRng for BlockRng<R> {}
diff --git a/rand/rand_core/src/error.rs b/rand/rand_core/src/error.rs
deleted file mode 100644
index 5a8459e..0000000
--- a/rand/rand_core/src/error.rs
+++ /dev/null
@@ -1,177 +0,0 @@
-// Copyright 2018 Developers of the Rand project.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-//! Error types
-
-use core::fmt;
-
-#[cfg(feature="std")]
-use std::error::Error as stdError;
-#[cfg(feature="std")]
-use std::io;
-
-/// Error kind which can be matched over.
-#[derive(PartialEq, Eq, Debug, Copy, Clone)]
-pub enum ErrorKind {
- /// Feature is not available; not recoverable.
- ///
- /// This is the most permanent failure type and implies the error cannot be
- /// resolved simply by retrying (e.g. the feature may not exist in this
- /// build of the application or on the current platform).
- Unavailable,
- /// General failure; there may be a chance of recovery on retry.
- ///
- /// This is the catch-all kind for errors from known and unknown sources
- /// which do not have a more specific kind / handling method.
- ///
- /// It is suggested to retry a couple of times or retry later when
- /// handling; some error sources may be able to resolve themselves,
- /// although this is not likely.
- Unexpected,
- /// A transient failure which likely can be resolved or worked around.
- ///
- /// This error kind exists for a few specific cases where it is known that
- /// the error likely can be resolved internally, but is reported anyway.
- Transient,
- /// Not ready yet: recommended to try again a little later.
- ///
- /// This error kind implies the generator needs more time or needs some
- /// other part of the application to do something else first before it is
- /// ready for use; for example this may be used by external generators
- /// which require time for initialization.
- NotReady,
- #[doc(hidden)]
- __Nonexhaustive,
-}
-
-impl ErrorKind {
- /// True if this kind of error may resolve itself on retry.
- ///
- /// See also `should_wait()`.
- pub fn should_retry(self) -> bool {
- self != ErrorKind::Unavailable
- }
-
- /// True if we should retry but wait before retrying
- ///
- /// This implies `should_retry()` is true.
- pub fn should_wait(self) -> bool {
- self == ErrorKind::NotReady
- }
-
- /// A description of this error kind
- pub fn description(self) -> &'static str {
- match self {
- ErrorKind::Unavailable => "permanently unavailable",
- ErrorKind::Unexpected => "unexpected failure",
- ErrorKind::Transient => "transient failure",
- ErrorKind::NotReady => "not ready yet",
- ErrorKind::__Nonexhaustive => unreachable!(),
- }
- }
-}
-
-
-/// Error type of random number generators
-///
-/// This is a relatively simple error type, designed for compatibility with and
-/// without the Rust `std` library. It embeds a "kind" code, a message (static
-/// string only), and an optional chained cause (`std` only). The `kind` and
-/// `msg` fields can be accessed directly; cause can be accessed via
-/// `std::error::Error::cause` or `Error::take_cause`. Construction can only be
-/// done via `Error::new` or `Error::with_cause`.
-#[derive(Debug)]
-pub struct Error {
- /// The error kind
- pub kind: ErrorKind,
- /// The error message
- pub msg: &'static str,
- #[cfg(feature="std")]
- cause: Option<Box<stdError + Send + Sync>>,
-}
-
-impl Error {
- /// Create a new instance, with specified kind and a message.
- pub fn new(kind: ErrorKind, msg: &'static str) -> Self {
- #[cfg(feature="std")] {
- Error { kind, msg, cause: None }
- }
- #[cfg(not(feature="std"))] {
- Error { kind, msg }
- }
- }
-
- /// Create a new instance, with specified kind, message, and a
- /// chained cause.
- ///
- /// Note: `stdError` is an alias for `std::error::Error`.
- ///
- /// If not targetting `std` (i.e. `no_std`), this function is replaced by
- /// another with the same prototype, except that there are no bounds on the
- /// type `E` (because both `Box` and `stdError` are unavailable), and the
- /// `cause` is ignored.
- #[cfg(feature="std")]
- pub fn with_cause<E>(kind: ErrorKind, msg: &'static str, cause: E) -> Self
- where E: Into<Box<stdError + Send + Sync>>
- {
- Error { kind, msg, cause: Some(cause.into()) }
- }
-
- /// Create a new instance, with specified kind, message, and a
- /// chained cause.
- ///
- /// In `no_std` mode the *cause* is ignored.
- #[cfg(not(feature="std"))]
- pub fn with_cause<E>(kind: ErrorKind, msg: &'static str, _cause: E) -> Self {
- Error { kind, msg }
- }
-
- /// Take the cause, if any. This allows the embedded cause to be extracted.
- /// This uses `Option::take`, leaving `self` with no cause.
- #[cfg(feature="std")]
- pub fn take_cause(&mut self) -> Option<Box<stdError + Send + Sync>> {
- self.cause.take()
- }
-}
-
-impl fmt::Display for Error {
- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
- #[cfg(feature="std")] {
- if let Some(ref cause) = self.cause {
- return write!(f, "{} ({}); cause: {}",
- self.msg, self.kind.description(), cause);
- }
- }
- write!(f, "{} ({})", self.msg, self.kind.description())
- }
-}
-
-#[cfg(feature="std")]
-impl stdError for Error {
- fn description(&self) -> &str {
- self.msg
- }
-
- fn cause(&self) -> Option<&stdError> {
- self.cause.as_ref().map(|e| e.as_ref() as &stdError)
- }
-}
-
-#[cfg(feature="std")]
-impl From<Error> for io::Error {
- fn from(error: Error) -> Self {
- use std::io::ErrorKind::*;
- match error.kind {
- ErrorKind::Unavailable => io::Error::new(NotFound, error),
- ErrorKind::Unexpected |
- ErrorKind::Transient => io::Error::new(Other, error),
- ErrorKind::NotReady => io::Error::new(WouldBlock, error),
- ErrorKind::__Nonexhaustive => unreachable!(),
- }
- }
-}
diff --git a/rand/rand_core/src/impls.rs b/rand/rand_core/src/impls.rs
deleted file mode 100644
index 57bdd07..0000000
--- a/rand/rand_core/src/impls.rs
+++ /dev/null
@@ -1,165 +0,0 @@
-// Copyright 2018 Developers of the Rand project.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-//! Helper functions for implementing `RngCore` functions.
-//!
-//! For cross-platform reproducibility, these functions all use Little Endian:
-//! least-significant part first. For example, `next_u64_via_u32` takes `u32`
-//! values `x, y`, then outputs `(y << 32) | x`. To implement `next_u32`
-//! from `next_u64` in little-endian order, one should use `next_u64() as u32`.
-//!
-//! Byte-swapping (like the std `to_le` functions) is only needed to convert
-//! to/from byte sequences, and since its purpose is reproducibility,
-//! non-reproducible sources (e.g. `OsRng`) need not bother with it.
-
-use core::intrinsics::transmute;
-use core::ptr::copy_nonoverlapping;
-use core::slice;
-use core::cmp::min;
-use core::mem::size_of;
-use RngCore;
-
-
-/// Implement `next_u64` via `next_u32`, little-endian order.
-pub fn next_u64_via_u32<R: RngCore + ?Sized>(rng: &mut R) -> u64 {
- // Use LE; we explicitly generate one value before the next.
- let x = u64::from(rng.next_u32());
- let y = u64::from(rng.next_u32());
- (y << 32) | x
-}
-
-/// Implement `fill_bytes` via `next_u64` and `next_u32`, little-endian order.
-///
-/// The fastest way to fill a slice is usually to work as long as possible with
-/// integers. That is why this method mostly uses `next_u64`, and only when
-/// there are 4 or less bytes remaining at the end of the slice it uses
-/// `next_u32` once.
-pub fn fill_bytes_via_next<R: RngCore + ?Sized>(rng: &mut R, dest: &mut [u8]) {
- let mut left = dest;
- while left.len() >= 8 {
- let (l, r) = {left}.split_at_mut(8);
- left = r;
- let chunk: [u8; 8] = unsafe {
- transmute(rng.next_u64().to_le())
- };
- l.copy_from_slice(&chunk);
- }
- let n = left.len();
- if n > 4 {
- let chunk: [u8; 8] = unsafe {
- transmute(rng.next_u64().to_le())
- };
- left.copy_from_slice(&chunk[..n]);
- } else if n > 0 {
- let chunk: [u8; 4] = unsafe {
- transmute(rng.next_u32().to_le())
- };
- left.copy_from_slice(&chunk[..n]);
- }
-}
-
-macro_rules! impl_uint_from_fill {
- ($rng:expr, $ty:ty, $N:expr) => ({
- debug_assert!($N == size_of::<$ty>());
-
- let mut int: $ty = 0;
- unsafe {
- let ptr = &mut int as *mut $ty as *mut u8;
- let slice = slice::from_raw_parts_mut(ptr, $N);
- $rng.fill_bytes(slice);
- }
- int
- });
-}
-
-macro_rules! fill_via_chunks {
- ($src:expr, $dst:expr, $ty:ty, $size:expr) => ({
- let chunk_size_u8 = min($src.len() * $size, $dst.len());
- let chunk_size = (chunk_size_u8 + $size - 1) / $size;
- if cfg!(target_endian="little") {
- unsafe {
- copy_nonoverlapping(
- $src.as_ptr() as *const u8,
- $dst.as_mut_ptr(),
- chunk_size_u8);
- }
- } else {
- for (&n, chunk) in $src.iter().zip($dst.chunks_mut($size)) {
- let tmp = n.to_le();
- let src_ptr = &tmp as *const $ty as *const u8;
- unsafe {
- copy_nonoverlapping(src_ptr,
- chunk.as_mut_ptr(),
- chunk.len());
- }
- }
- }
-
- (chunk_size, chunk_size_u8)
- });
-}
-
-/// Implement `fill_bytes` by reading chunks from the output buffer of a block
-/// based RNG.
-///
-/// The return values are `(consumed_u32, filled_u8)`.
-///
-/// `filled_u8` is the number of filled bytes in `dest`, which may be less than
-/// the length of `dest`.
-/// `consumed_u32` is the number of words consumed from `src`, which is the same
-/// as `filled_u8 / 4` rounded up.
-///
-/// # Example
-/// (from `IsaacRng`)
-///
-/// ```ignore
-/// fn fill_bytes(&mut self, dest: &mut [u8]) {
-/// let mut read_len = 0;
-/// while read_len < dest.len() {
-/// if self.index >= self.rsl.len() {
-/// self.isaac();
-/// }
-///
-/// let (consumed_u32, filled_u8) =
-/// impls::fill_via_u32_chunks(&mut self.rsl[self.index..],
-/// &mut dest[read_len..]);
-///
-/// self.index += consumed_u32;
-/// read_len += filled_u8;
-/// }
-/// }
-/// ```
-pub fn fill_via_u32_chunks(src: &[u32], dest: &mut [u8]) -> (usize, usize) {
- fill_via_chunks!(src, dest, u32, 4)
-}
-
-/// Implement `fill_bytes` by reading chunks from the output buffer of a block
-/// based RNG.
-///
-/// The return values are `(consumed_u64, filled_u8)`.
-/// `filled_u8` is the number of filled bytes in `dest`, which may be less than
-/// the length of `dest`.
-/// `consumed_u64` is the number of words consumed from `src`, which is the same
-/// as `filled_u8 / 8` rounded up.
-///
-/// See `fill_via_u32_chunks` for an example.
-pub fn fill_via_u64_chunks(src: &[u64], dest: &mut [u8]) -> (usize, usize) {
- fill_via_chunks!(src, dest, u64, 8)
-}
-
-/// Implement `next_u32` via `fill_bytes`, little-endian order.
-pub fn next_u32_via_fill<R: RngCore + ?Sized>(rng: &mut R) -> u32 {
- impl_uint_from_fill!(rng, u32, 4)
-}
-
-/// Implement `next_u64` via `fill_bytes`, little-endian order.
-pub fn next_u64_via_fill<R: RngCore + ?Sized>(rng: &mut R) -> u64 {
- impl_uint_from_fill!(rng, u64, 8)
-}
-
-// TODO: implement tests for the above
diff --git a/rand/rand_core/src/le.rs b/rand/rand_core/src/le.rs
deleted file mode 100644
index 266651f..0000000
--- a/rand/rand_core/src/le.rs
+++ /dev/null
@@ -1,68 +0,0 @@
-// Copyright 2018 Developers of the Rand project.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-//! Little-Endian utilities
-//!
-//! Little-Endian order has been chosen for internal usage; this makes some
-//! useful functions available.
-
-use core::ptr;
-
-macro_rules! read_slice {
- ($src:expr, $dst:expr, $size:expr, $which:ident) => {{
- assert_eq!($src.len(), $size * $dst.len());
-
- unsafe {
- ptr::copy_nonoverlapping(
- $src.as_ptr(),
- $dst.as_mut_ptr() as *mut u8,
- $src.len());
- }
- for v in $dst.iter_mut() {
- *v = v.$which();
- }
- }};
-}
-
-/// Reads unsigned 32 bit integers from `src` into `dst`.
-/// Borrowed from the `byteorder` crate.
-#[inline]
-pub fn read_u32_into(src: &[u8], dst: &mut [u32]) {
- read_slice!(src, dst, 4, to_le);
-}
-
-/// Reads unsigned 64 bit integers from `src` into `dst`.
-/// Borrowed from the `byteorder` crate.
-#[inline]
-pub fn read_u64_into(src: &[u8], dst: &mut [u64]) {
- read_slice!(src, dst, 8, to_le);
-}
-
-#[test]
-fn test_read() {
- let bytes = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16];
-
- let mut buf = [0u32; 4];
- read_u32_into(&bytes, &mut buf);
- assert_eq!(buf[0], 0x04030201);
- assert_eq!(buf[3], 0x100F0E0D);
-
- let mut buf = [0u32; 3];
- read_u32_into(&bytes[1..13], &mut buf); // unaligned
- assert_eq!(buf[0], 0x05040302);
- assert_eq!(buf[2], 0x0D0C0B0A);
-
- let mut buf = [0u64; 2];
- read_u64_into(&bytes, &mut buf);
- assert_eq!(buf[0], 0x0807060504030201);
- assert_eq!(buf[1], 0x100F0E0D0C0B0A09);
-
- let mut buf = [0u64; 1];
- read_u64_into(&bytes[7..15], &mut buf); // unaligned
- assert_eq!(buf[0], 0x0F0E0D0C0B0A0908);
-}
diff --git a/rand/rand_core/src/lib.rs b/rand/rand_core/src/lib.rs
deleted file mode 100644
index a65db93..0000000
--- a/rand/rand_core/src/lib.rs
+++ /dev/null
@@ -1,486 +0,0 @@
-// Copyright 2018 Developers of the Rand project.
-// Copyright 2017-2018 The Rust Project Developers.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-//! Random number generation traits
-//!
-//! This crate is mainly of interest to crates publishing implementations of
-//! [`RngCore`]. Other users are encouraged to use the [rand] crate instead
-//! which re-exports the main traits and error types.
-//!
-//! [`RngCore`] is the core trait implemented by algorithmic pseudo-random number
-//! generators and external random-number sources.
-//!
-//! [`SeedableRng`] is an extension trait for construction from fixed seeds and
-//! other random number generators.
-//!
-//! [`Error`] is provided for error-handling. It is safe to use in `no_std`
-//! environments.
-//!
-//! The [`impls`] and [`le`] sub-modules include a few small functions to assist
-//! implementation of [`RngCore`].
-//!
-//! [rand]: https://crates.io/crates/rand
-//! [`RngCore`]: trait.RngCore.html
-//! [`SeedableRng`]: trait.SeedableRng.html
-//! [`Error`]: struct.Error.html
-//! [`impls`]: impls/index.html
-//! [`le`]: le/index.html
-
-#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk.png",
- html_favicon_url = "https://www.rust-lang.org/favicon.ico",
- html_root_url = "https://rust-random.github.io/rand/")]
-
-#![deny(missing_docs)]
-#![deny(missing_debug_implementations)]
-#![doc(test(attr(allow(unused_variables), deny(warnings))))]
-
-#![cfg_attr(not(feature="std"), no_std)]
-#![cfg_attr(all(feature="alloc", not(feature="std")), feature(alloc))]
-
-#[cfg(feature="std")] extern crate core;
-#[cfg(all(feature = "alloc", not(feature="std")))] extern crate alloc;
-#[cfg(feature="serde1")] extern crate serde;
-#[cfg(feature="serde1")] #[macro_use] extern crate serde_derive;
-
-
-use core::default::Default;
-use core::convert::AsMut;
-use core::ptr::copy_nonoverlapping;
-
-#[cfg(all(feature="alloc", not(feature="std")))] use alloc::boxed::Box;
-
-pub use error::{ErrorKind, Error};
-
-
-mod error;
-pub mod block;
-pub mod impls;
-pub mod le;
-
-
-/// The core of a random number generator.
-///
-/// This trait encapsulates the low-level functionality common to all
-/// generators, and is the "back end", to be implemented by generators.
-/// End users should normally use [`Rng`] from the [rand] crate, which is
-/// automatically implemented for every type implementing `RngCore`.
-///
-/// Three different methods for generating random data are provided since the
-/// optimal implementation of each is dependent on the type of generator. There
-/// is no required relationship between the output of each; e.g. many
-/// implementations of [`fill_bytes`] consume a whole number of `u32` or `u64`
-/// values and drop any remaining unused bytes.
-///
-/// The [`try_fill_bytes`] method is a variant of [`fill_bytes`] allowing error
-/// handling; it is not deemed sufficiently useful to add equivalents for
-/// [`next_u32`] or [`next_u64`] since the latter methods are almost always used
-/// with algorithmic generators (PRNGs), which are normally infallible.
-///
-/// Algorithmic generators implementing [`SeedableRng`] should normally have
-/// *portable, reproducible* output, i.e. fix Endianness when converting values
-/// to avoid platform differences, and avoid making any changes which affect
-/// output (except by communicating that the release has breaking changes).
-///
-/// Typically implementators will implement only one of the methods available
-/// in this trait directly, then use the helper functions from the
-/// [`rand_core::impls`] module to implement the other methods.
-///
-/// It is recommended that implementations also implement:
-///
-/// - `Debug` with a custom implementation which *does not* print any internal
-/// state (at least, [`CryptoRng`]s should not risk leaking state through
-/// `Debug`).
-/// - `Serialize` and `Deserialize` (from Serde), preferably making Serde
-/// support optional at the crate level in PRNG libs.
-/// - `Clone`, if possible.
-/// - *never* implement `Copy` (accidental copies may cause repeated values).
-/// - *do not* implement `Default` for pseudorandom generators, but instead
-/// implement [`SeedableRng`], to guide users towards proper seeding.
-/// External / hardware RNGs can choose to implement `Default`.
-/// - `Eq` and `PartialEq` could be implemented, but are probably not useful.
-///
-/// # Example
-///
-/// A simple example, obviously not generating very *random* output:
-///
-/// ```
-/// #![allow(dead_code)]
-/// use rand_core::{RngCore, Error, impls};
-///
-/// struct CountingRng(u64);
-///
-/// impl RngCore for CountingRng {
-/// fn next_u32(&mut self) -> u32 {
-/// self.next_u64() as u32
-/// }
-///
-/// fn next_u64(&mut self) -> u64 {
-/// self.0 += 1;
-/// self.0
-/// }
-///
-/// fn fill_bytes(&mut self, dest: &mut [u8]) {
-/// impls::fill_bytes_via_next(self, dest)
-/// }
-///
-/// fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), Error> {
-/// Ok(self.fill_bytes(dest))
-/// }
-/// }
-/// ```
-///
-/// [rand]: https://crates.io/crates/rand
-/// [`Rng`]: ../rand/trait.Rng.html
-/// [`SeedableRng`]: trait.SeedableRng.html
-/// [`rand_core::impls`]: ../rand_core/impls/index.html
-/// [`try_fill_bytes`]: trait.RngCore.html#tymethod.try_fill_bytes
-/// [`fill_bytes`]: trait.RngCore.html#tymethod.fill_bytes
-/// [`next_u32`]: trait.RngCore.html#tymethod.next_u32
-/// [`next_u64`]: trait.RngCore.html#tymethod.next_u64
-/// [`CryptoRng`]: trait.CryptoRng.html
-pub trait RngCore {
- /// Return the next random `u32`.
- ///
- /// RNGs must implement at least one method from this trait directly. In
- /// the case this method is not implemented directly, it can be implemented
- /// using `self.next_u64() as u32` or
- /// [via `fill_bytes`](../rand_core/impls/fn.next_u32_via_fill.html).
- fn next_u32(&mut self) -> u32;
-
- /// Return the next random `u64`.
- ///
- /// RNGs must implement at least one method from this trait directly. In
- /// the case this method is not implemented directly, it can be implemented
- /// [via `next_u32`](../rand_core/impls/fn.next_u64_via_u32.html) or
- /// [via `fill_bytes`](../rand_core/impls/fn.next_u64_via_fill.html).
- fn next_u64(&mut self) -> u64;
-
- /// Fill `dest` with random data.
- ///
- /// RNGs must implement at least one method from this trait directly. In
- /// the case this method is not implemented directly, it can be implemented
- /// [via `next_u*`](../rand_core/impls/fn.fill_bytes_via_next.html) or
- /// via `try_fill_bytes`; if this generator can fail the implementation
- /// must choose how best to handle errors here (e.g. panic with a
- /// descriptive message or log a warning and retry a few times).
- ///
- /// This method should guarantee that `dest` is entirely filled
- /// with new data, and may panic if this is impossible
- /// (e.g. reading past the end of a file that is being used as the
- /// source of randomness).
- fn fill_bytes(&mut self, dest: &mut [u8]);
-
- /// Fill `dest` entirely with random data.
- ///
- /// This is the only method which allows an RNG to report errors while
- /// generating random data thus making this the primary method implemented
- /// by external (true) RNGs (e.g. `OsRng`) which can fail. It may be used
- /// directly to generate keys and to seed (infallible) PRNGs.
- ///
- /// Other than error handling, this method is identical to [`fill_bytes`];
- /// thus this may be implemented using `Ok(self.fill_bytes(dest))` or
- /// `fill_bytes` may be implemented with
- /// `self.try_fill_bytes(dest).unwrap()` or more specific error handling.
- ///
- /// [`fill_bytes`]: trait.RngCore.html#method.fill_bytes
- fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), Error>;
-}
-
-/// A marker trait used to indicate that an [`RngCore`] or [`BlockRngCore`]
-/// implementation is supposed to be cryptographically secure.
-///
-/// *Cryptographically secure generators*, also known as *CSPRNGs*, should
-/// satisfy an additional properties over other generators: given the first
-/// *k* bits of an algorithm's output
-/// sequence, it should not be possible using polynomial-time algorithms to
-/// predict the next bit with probability significantly greater than 50%.
-///
-/// Some generators may satisfy an additional property, however this is not
-/// required by this trait: if the CSPRNG's state is revealed, it should not be
-/// computationally-feasible to reconstruct output prior to this. Some other
-/// generators allow backwards-computation and are consided *reversible*.
-///
-/// Note that this trait is provided for guidance only and cannot guarantee
-/// suitability for cryptographic applications. In general it should only be
-/// implemented for well-reviewed code implementing well-regarded algorithms.
-///
-/// Note also that use of a `CryptoRng` does not protect against other
-/// weaknesses such as seeding from a weak entropy source or leaking state.
-///
-/// [`RngCore`]: trait.RngCore.html
-/// [`BlockRngCore`]: ../rand_core/block/trait.BlockRngCore.html
-pub trait CryptoRng {}
-
-/// A random number generator that can be explicitly seeded.
-///
-/// This trait encapsulates the low-level functionality common to all
-/// pseudo-random number generators (PRNGs, or algorithmic generators).
-///
-/// The [`rand::FromEntropy`] trait is automatically implemented for every type
-/// implementing `SeedableRng`, providing a convenient `from_entropy()`
-/// constructor.
-///
-/// [`rand::FromEntropy`]: ../rand/trait.FromEntropy.html
-pub trait SeedableRng: Sized {
- /// Seed type, which is restricted to types mutably-dereferencable as `u8`
- /// arrays (we recommend `[u8; N]` for some `N`).
- ///
- /// It is recommended to seed PRNGs with a seed of at least circa 100 bits,
- /// which means an array of `[u8; 12]` or greater to avoid picking RNGs with
- /// partially overlapping periods.
- ///
- /// For cryptographic RNG's a seed of 256 bits is recommended, `[u8; 32]`.
- ///
- ///
- /// # Implementing `SeedableRng` for RNGs with large seeds
- ///
- /// Note that the required traits `core::default::Default` and
- /// `core::convert::AsMut<u8>` are not implemented for large arrays
- /// `[u8; N]` with `N` > 32. To be able to implement the traits required by
- /// `SeedableRng` for RNGs with such large seeds, the newtype pattern can be
- /// used:
- ///
- /// ```
- /// use rand_core::SeedableRng;
- ///
- /// const N: usize = 64;
- /// pub struct MyRngSeed(pub [u8; N]);
- /// pub struct MyRng(MyRngSeed);
- ///
- /// impl Default for MyRngSeed {
- /// fn default() -> MyRngSeed {
- /// MyRngSeed([0; N])
- /// }
- /// }
- ///
- /// impl AsMut<[u8]> for MyRngSeed {
- /// fn as_mut(&mut self) -> &mut [u8] {
- /// &mut self.0
- /// }
- /// }
- ///
- /// impl SeedableRng for MyRng {
- /// type Seed = MyRngSeed;
- ///
- /// fn from_seed(seed: MyRngSeed) -> MyRng {
- /// MyRng(seed)
- /// }
- /// }
- /// ```
- type Seed: Sized + Default + AsMut<[u8]>;
-
- /// Create a new PRNG using the given seed.
- ///
- /// PRNG implementations are allowed to assume that bits in the seed are
- /// well distributed. That means usually that the number of one and zero
- /// bits are about equal, and values like 0, 1 and (size - 1) are unlikely.
- ///
- /// PRNG implementations are recommended to be reproducible. A PRNG seeded
- /// using this function with a fixed seed should produce the same sequence
- /// of output in the future and on different architectures (with for example
- /// different endianness).
- ///
- /// It is however not required that this function yield the same state as a
- /// reference implementation of the PRNG given equivalent seed; if necessary
- /// another constructor replicating behaviour from a reference
- /// implementation can be added.
- ///
- /// PRNG implementations should make sure `from_seed` never panics. In the
- /// case that some special values (like an all zero seed) are not viable
- /// seeds it is preferable to map these to alternative constant value(s),
- /// for example `0xBAD5EEDu32` or `0x0DDB1A5E5BAD5EEDu64` ("odd biases? bad
- /// seed"). This is assuming only a small number of values must be rejected.
- fn from_seed(seed: Self::Seed) -> Self;
-
- /// Create a new PRNG using a `u64` seed.
- ///
- /// This is a convenience-wrapper around `from_seed` to allow construction
- /// of any `SeedableRng` from a simple `u64` value. It is designed such that
- /// low Hamming Weight numbers like 0 and 1 can be used and should still
- /// result in good, independent seeds to the PRNG which is returned.
- ///
- /// This **is not suitable for cryptography**, as should be clear given that
- /// the input size is only 64 bits.
- ///
- /// Implementations for PRNGs *may* provide their own implementations of
- /// this function, but the default implementation should be good enough for
- /// all purposes. *Changing* the implementation of this function should be
- /// considered a value-breaking change.
- fn seed_from_u64(mut state: u64) -> Self {
- // We use PCG32 to generate a u32 sequence, and copy to the seed
- const MUL: u64 = 6364136223846793005;
- const INC: u64 = 11634580027462260723;
-
- let mut seed = Self::Seed::default();
- for chunk in seed.as_mut().chunks_mut(4) {
- // We advance the state first (to get away from the input value,
- // in case it has low Hamming Weight).
- state = state.wrapping_mul(MUL).wrapping_add(INC);
-
- // Use PCG output function with to_le to generate x:
- let xorshifted = (((state >> 18) ^ state) >> 27) as u32;
- let rot = (state >> 59) as u32;
- let x = xorshifted.rotate_right(rot).to_le();
-
- unsafe {
- let p = &x as *const u32 as *const u8;
- copy_nonoverlapping(p, chunk.as_mut_ptr(), chunk.len());
- }
- }
-
- Self::from_seed(seed)
- }
-
- /// Create a new PRNG seeded from another `Rng`.
- ///
- /// This is the recommended way to initialize PRNGs with fresh entropy. The
- /// [`FromEntropy`] trait provides a convenient `from_entropy` method
- /// based on `from_rng`.
- ///
- /// Usage of this method is not recommended when reproducibility is required
- /// since implementing PRNGs are not required to fix Endianness and are
- /// allowed to modify implementations in new releases.
- ///
- /// It is important to use a good source of randomness to initialize the
- /// PRNG. Cryptographic PRNG may be rendered insecure when seeded from a
- /// non-cryptographic PRNG or with insufficient entropy.
- /// Many non-cryptographic PRNGs will show statistical bias in their first
- /// results if their seed numbers are small or if there is a simple pattern
- /// between them.
- ///
- /// Prefer to seed from a strong external entropy source like [`OsRng`] or
- /// from a cryptographic PRNG; if creating a new generator for cryptographic
- /// uses you *must* seed from a strong source.
- ///
- /// Seeding a small PRNG from another small PRNG is possible, but
- /// something to be careful with. An extreme example of how this can go
- /// wrong is seeding an Xorshift RNG from another Xorshift RNG, which
- /// will effectively clone the generator. In general seeding from a
- /// generator which is hard to predict is probably okay.
- ///
- /// PRNG implementations are allowed to assume that a good RNG is provided
- /// for seeding, and that it is cryptographically secure when appropriate.
- ///
- /// [`FromEntropy`]: ../rand/trait.FromEntropy.html
- /// [`OsRng`]: ../rand/rngs/struct.OsRng.html
- fn from_rng<R: RngCore>(mut rng: R) -> Result<Self, Error> {
- let mut seed = Self::Seed::default();
- rng.try_fill_bytes(seed.as_mut())?;
- Ok(Self::from_seed(seed))
- }
-}
-
-// Implement `RngCore` for references to an `RngCore`.
-// Force inlining all functions, so that it is up to the `RngCore`
-// implementation and the optimizer to decide on inlining.
-impl<'a, R: RngCore + ?Sized> RngCore for &'a mut R {
- #[inline(always)]
- fn next_u32(&mut self) -> u32 {
- (**self).next_u32()
- }
-
- #[inline(always)]
- fn next_u64(&mut self) -> u64 {
- (**self).next_u64()
- }
-
- #[inline(always)]
- fn fill_bytes(&mut self, dest: &mut [u8]) {
- (**self).fill_bytes(dest)
- }
-
- #[inline(always)]
- fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), Error> {
- (**self).try_fill_bytes(dest)
- }
-}
-
-// Implement `RngCore` for boxed references to an `RngCore`.
-// Force inlining all functions, so that it is up to the `RngCore`
-// implementation and the optimizer to decide on inlining.
-#[cfg(feature="alloc")]
-impl<R: RngCore + ?Sized> RngCore for Box<R> {
- #[inline(always)]
- fn next_u32(&mut self) -> u32 {
- (**self).next_u32()
- }
-
- #[inline(always)]
- fn next_u64(&mut self) -> u64 {
- (**self).next_u64()
- }
-
- #[inline(always)]
- fn fill_bytes(&mut self, dest: &mut [u8]) {
- (**self).fill_bytes(dest)
- }
-
- #[inline(always)]
- fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), Error> {
- (**self).try_fill_bytes(dest)
- }
-}
-
-#[cfg(feature="std")]
-impl std::io::Read for RngCore {
- fn read(&mut self, buf: &mut [u8]) -> Result<usize, std::io::Error> {
- self.try_fill_bytes(buf)?;
- Ok(buf.len())
- }
-}
-
-// Implement `CryptoRng` for references to an `CryptoRng`.
-impl<'a, R: CryptoRng + ?Sized> CryptoRng for &'a mut R {}
-
-// Implement `CryptoRng` for boxed references to an `CryptoRng`.
-#[cfg(feature="alloc")]
-impl<R: CryptoRng + ?Sized> CryptoRng for Box<R> {}
-
-#[cfg(test)]
-mod test {
- use super::*;
-
- #[test]
- fn test_seed_from_u64() {
- struct SeedableNum(u64);
- impl SeedableRng for SeedableNum {
- type Seed = [u8; 8];
- fn from_seed(seed: Self::Seed) -> Self {
- let mut x = [0u64; 1];
- le::read_u64_into(&seed, &mut x);
- SeedableNum(x[0])
- }
- }
-
- const N: usize = 8;
- const SEEDS: [u64; N] = [0u64, 1, 2, 3, 4, 8, 16, -1i64 as u64];
- let mut results = [0u64; N];
- for (i, seed) in SEEDS.iter().enumerate() {
- let SeedableNum(x) = SeedableNum::seed_from_u64(*seed);
- results[i] = x;
- }
-
- for (i1, r1) in results.iter().enumerate() {
- let weight = r1.count_ones();
- // This is the binomial distribution B(64, 0.5), so chance of
- // weight < 20 is binocdf(19, 64, 0.5) = 7.8e-4, and same for
- // weight > 44.
- assert!(weight >= 20 && weight <= 44);
-
- for (i2, r2) in results.iter().enumerate() {
- if i1 == i2 { continue; }
- let diff_weight = (r1 ^ r2).count_ones();
- assert!(diff_weight >= 20);
- }
- }
-
- // value-breakage test:
- assert_eq!(results[0], 5029875928683246316);
- }
-}
diff --git a/rand/rand_hc/CHANGELOG.md b/rand/rand_hc/CHANGELOG.md
deleted file mode 100644
index d0c4a2f..0000000
--- a/rand/rand_hc/CHANGELOG.md
+++ /dev/null
@@ -1,8 +0,0 @@
-# Changelog
-All notable changes to this project will be documented in this file.
-
-The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
-and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
-
-## [0.1.0] - 2018-10-17
-- Pulled out of the Rand crate
diff --git a/rand/rand_hc/COPYRIGHT b/rand/rand_hc/COPYRIGHT
deleted file mode 100644
index 468d907..0000000
--- a/rand/rand_hc/COPYRIGHT
+++ /dev/null
@@ -1,12 +0,0 @@
-Copyrights in the Rand project are retained by their contributors. No
-copyright assignment is required to contribute to the Rand project.
-
-For full authorship information, see the version control history.
-
-Except as otherwise noted (below and/or in individual files), Rand is
-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.
-
-The Rand project includes code from the Rust project
-published under these same licenses.
diff --git a/rand/rand_hc/Cargo.toml b/rand/rand_hc/Cargo.toml
deleted file mode 100644
index ed5dd5b..0000000
--- a/rand/rand_hc/Cargo.toml
+++ /dev/null
@@ -1,21 +0,0 @@
-[package]
-name = "rand_hc"
-version = "0.1.0"
-authors = ["The Rand Project Developers"]
-license = "MIT/Apache-2.0"
-readme = "README.md"
-repository = "https://github.com/rust-random/rand"
-documentation = "https://rust-random.github.io/rand/rand_hc"
-homepage = "https://crates.io/crates/rand_hc"
-description = """
-HC128 random number generator
-"""
-keywords = ["random", "rng", "hc128"]
-categories = ["algorithms", "no-std"]
-
-[badges]
-travis-ci = { repository = "rust-random/rand" }
-appveyor = { repository = "rust-random/rand" }
-
-[dependencies]
-rand_core = { path = "../rand_core", version = ">=0.2, <0.4", default-features=false }
diff --git a/rand/rand_hc/LICENSE-APACHE b/rand/rand_hc/LICENSE-APACHE
deleted file mode 100644
index 17d7468..0000000
--- a/rand/rand_hc/LICENSE-APACHE
+++ /dev/null
@@ -1,201 +0,0 @@
- Apache License
- Version 2.0, January 2004
- https://www.apache.org/licenses/
-
-TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
-1. Definitions.
-
- "License" shall mean the terms and conditions for use, reproduction,
- and distribution as defined by Sections 1 through 9 of this document.
-
- "Licensor" shall mean the copyright owner or entity authorized by
- the copyright owner that is granting the License.
-
- "Legal Entity" shall mean the union of the acting entity and all
- other entities that control, are controlled by, or are under common
- control with that entity. For the purposes of this definition,
- "control" means (i) the power, direct or indirect, to cause the
- direction or management of such entity, whether by contract or
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
- outstanding shares, or (iii) beneficial ownership of such entity.
-
- "You" (or "Your") shall mean an individual or Legal Entity
- exercising permissions granted by this License.
-
- "Source" form shall mean the preferred form for making modifications,
- including but not limited to software source code, documentation
- source, and configuration files.
-
- "Object" form shall mean any form resulting from mechanical
- transformation or translation of a Source form, including but
- not limited to compiled object code, generated documentation,
- and conversions to other media types.
-
- "Work" shall mean the work of authorship, whether in Source or
- Object form, made available under the License, as indicated by a
- copyright notice that is included in or attached to the work
- (an example is provided in the Appendix below).
-
- "Derivative Works" shall mean any work, whether in Source or Object
- form, that is based on (or derived from) the Work and for which the
- editorial revisions, annotations, elaborations, or other modifications
- represent, as a whole, an original work of authorship. For the purposes
- of this License, Derivative Works shall not include works that remain
- separable from, or merely link (or bind by name) to the interfaces of,
- the Work and Derivative Works thereof.
-
- "Contribution" shall mean any work of authorship, including
- the original version of the Work and any modifications or additions
- to that Work or Derivative Works thereof, that is intentionally
- submitted to Licensor for inclusion in the Work by the copyright owner
- or by an individual or Legal Entity authorized to submit on behalf of
- the copyright owner. For the purposes of this definition, "submitted"
- means any form of electronic, verbal, or written communication sent
- to the Licensor or its representatives, including but not limited to
- communication on electronic mailing lists, source code control systems,
- and issue tracking systems that are managed by, or on behalf of, the
- Licensor for the purpose of discussing and improving the Work, but
- excluding communication that is conspicuously marked or otherwise
- designated in writing by the copyright owner as "Not a Contribution."
-
- "Contributor" shall mean Licensor and any individual or Legal Entity
- on behalf of whom a Contribution has been received by Licensor and
- subsequently incorporated within the Work.
-
-2. Grant of Copyright License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- copyright license to reproduce, prepare Derivative Works of,
- publicly display, publicly perform, sublicense, and distribute the
- Work and such Derivative Works in Source or Object form.
-
-3. Grant of Patent License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- (except as stated in this section) patent license to make, have made,
- use, offer to sell, sell, import, and otherwise transfer the Work,
- where such license applies only to those patent claims licensable
- by such Contributor that are necessarily infringed by their
- Contribution(s) alone or by combination of their Contribution(s)
- with the Work to which such Contribution(s) was submitted. If You
- institute patent litigation against any entity (including a
- cross-claim or counterclaim in a lawsuit) alleging that the Work
- or a Contribution incorporated within the Work constitutes direct
- or contributory patent infringement, then any patent licenses
- granted to You under this License for that Work shall terminate
- as of the date such litigation is filed.
-
-4. Redistribution. You may reproduce and distribute copies of the
- Work or Derivative Works thereof in any medium, with or without
- modifications, and in Source or Object form, provided that You
- meet the following conditions:
-
- (a) You must give any other recipients of the Work or
- Derivative Works a copy of this License; and
-
- (b) You must cause any modified files to carry prominent notices
- stating that You changed the files; and
-
- (c) You must retain, in the Source form of any Derivative Works
- that You distribute, all copyright, patent, trademark, and
- attribution notices from the Source form of the Work,
- excluding those notices that do not pertain to any part of
- the Derivative Works; and
-
- (d) If the Work includes a "NOTICE" text file as part of its
- distribution, then any Derivative Works that You distribute must
- include a readable copy of the attribution notices contained
- within such NOTICE file, excluding those notices that do not
- pertain to any part of the Derivative Works, in at least one
- of the following places: within a NOTICE text file distributed
- as part of the Derivative Works; within the Source form or
- documentation, if provided along with the Derivative Works; or,
- within a display generated by the Derivative Works, if and
- wherever such third-party notices normally appear. The contents
- of the NOTICE file are for informational purposes only and
- do not modify the License. You may add Your own attribution
- notices within Derivative Works that You distribute, alongside
- or as an addendum to the NOTICE text from the Work, provided
- that such additional attribution notices cannot be construed
- as modifying the License.
-
- You may add Your own copyright statement to Your modifications and
- may provide additional or different license terms and conditions
- for use, reproduction, or distribution of Your modifications, or
- for any such Derivative Works as a whole, provided Your use,
- reproduction, and distribution of the Work otherwise complies with
- the conditions stated in this License.
-
-5. Submission of Contributions. Unless You explicitly state otherwise,
- any Contribution intentionally submitted for inclusion in the Work
- by You to the Licensor shall be under the terms and conditions of
- this License, without any additional terms or conditions.
- Notwithstanding the above, nothing herein shall supersede or modify
- the terms of any separate license agreement you may have executed
- with Licensor regarding such Contributions.
-
-6. Trademarks. This License does not grant permission to use the trade
- names, trademarks, service marks, or product names of the Licensor,
- except as required for reasonable and customary use in describing the
- origin of the Work and reproducing the content of the NOTICE file.
-
-7. Disclaimer of Warranty. Unless required by applicable law or
- agreed to in writing, Licensor provides the Work (and each
- Contributor provides its Contributions) on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- implied, including, without limitation, any warranties or conditions
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
- PARTICULAR PURPOSE. You are solely responsible for determining the
- appropriateness of using or redistributing the Work and assume any
- risks associated with Your exercise of permissions under this License.
-
-8. Limitation of Liability. In no event and under no legal theory,
- whether in tort (including negligence), contract, or otherwise,
- unless required by applicable law (such as deliberate and grossly
- negligent acts) or agreed to in writing, shall any Contributor be
- liable to You for damages, including any direct, indirect, special,
- incidental, or consequential damages of any character arising as a
- result of this License or out of the use or inability to use the
- Work (including but not limited to damages for loss of goodwill,
- work stoppage, computer failure or malfunction, or any and all
- other commercial damages or losses), even if such Contributor
- has been advised of the possibility of such damages.
-
-9. Accepting Warranty or Additional Liability. While redistributing
- the Work or Derivative Works thereof, You may choose to offer,
- and charge a fee for, acceptance of support, warranty, indemnity,
- or other liability obligations and/or rights consistent with this
- License. However, in accepting such obligations, You may act only
- on Your own behalf and on Your sole responsibility, not on behalf
- of any other Contributor, and only if You agree to indemnify,
- defend, and hold each Contributor harmless for any liability
- incurred by, or claims asserted against, such Contributor by reason
- of your accepting any such warranty or additional liability.
-
-END OF TERMS AND CONDITIONS
-
-APPENDIX: How to apply the Apache License to your work.
-
- To apply the Apache License to your work, attach the following
- boilerplate notice, with the fields enclosed by brackets "[]"
- replaced with your own identifying information. (Don't include
- the brackets!) The text should be enclosed in the appropriate
- comment syntax for the file format. We also recommend that a
- file or class name and description of purpose be included on the
- same "printed page" as the copyright notice for easier
- identification within third-party archives.
-
-Copyright [yyyy] [name of copyright owner]
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
- https://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
diff --git a/rand/rand_hc/LICENSE-MIT b/rand/rand_hc/LICENSE-MIT
deleted file mode 100644
index cf65607..0000000
--- a/rand/rand_hc/LICENSE-MIT
+++ /dev/null
@@ -1,25 +0,0 @@
-Copyright 2018 Developers of the Rand project
-
-Permission is hereby granted, free of charge, to any
-person obtaining a copy of this software and associated
-documentation files (the "Software"), to deal in the
-Software without restriction, including without
-limitation the rights to use, copy, modify, merge,
-publish, distribute, sublicense, and/or sell copies of
-the Software, and to permit persons to whom the Software
-is furnished to do so, subject to the following
-conditions:
-
-The above copyright notice and this permission notice
-shall be included in all copies or substantial portions
-of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
-ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
-TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
-PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
-SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
-CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
-IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
-DEALINGS IN THE SOFTWARE.
diff --git a/rand/rand_hc/README.md b/rand/rand_hc/README.md
deleted file mode 100644
index 178548a..0000000
--- a/rand/rand_hc/README.md
+++ /dev/null
@@ -1,45 +0,0 @@
-# rand_hc
-
-[![Build Status](https://travis-ci.org/rust-random/rand.svg)](https://travis-ci.org/rust-random/rand)
-[![Build Status](https://ci.appveyor.com/api/projects/status/github/rust-random/rand?svg=true)](https://ci.appveyor.com/project/rust-random/rand)
-[![Latest version](https://img.shields.io/crates/v/rand_hc.svg)](https://crates.io/crates/rand_hc)
-[[![Book](https://img.shields.io/badge/book-master-yellow.svg)](https://rust-random.github.io/book/)
-[![API](https://img.shields.io/badge/api-master-yellow.svg)](https://rust-random.github.io/rand/rand_hc)
-[![API](https://docs.rs/rand_hc/badge.svg)](https://docs.rs/rand_hc)
-[![Minimum rustc version](https://img.shields.io/badge/rustc-1.22+-lightgray.svg)](https://github.com/rust-random/rand#rust-version-requirements)
-
-A cryptographically secure random number generator that uses the HC-128
-algorithm.
-
-HC-128 is a stream cipher designed by Hongjun Wu[^1], that we use as an
-RNG. It is selected as one of the "stream ciphers suitable for widespread
-adoption" by eSTREAM[^2].
-
-Links:
-
-- [API documentation (master)](https://rust-random.github.io/rand/rand_hc)
-- [API documentation (docs.rs)](https://docs.rs/rand_hc)
-- [Changelog](CHANGELOG.md)
-
-[rand]: https://crates.io/crates/rand
-[^1]: Hongjun Wu (2008). ["The Stream Cipher HC-128"](
- http://www.ecrypt.eu.org/stream/p3ciphers/hc/hc128_p3.pdf).
- *The eSTREAM Finalists*, LNCS 4986, pp. 39–47, Springer-Verlag.
-
-[^2]: [eSTREAM: the ECRYPT Stream Cipher Project](
- http://www.ecrypt.eu.org/stream/)
-
-
-## Crate Features
-
-`rand_hc` is `no_std` compatible. It does not require any functionality
-outside of the `core` lib, thus there are no features to configure.
-
-
-# License
-
-`rand_hc` is distributed under the terms of both the MIT license and the
-Apache License (Version 2.0).
-
-See [LICENSE-APACHE](LICENSE-APACHE) and [LICENSE-MIT](LICENSE-MIT), and
-[COPYRIGHT](COPYRIGHT) for details.
diff --git a/rand/rand_hc/src/hc128.rs b/rand/rand_hc/src/hc128.rs
deleted file mode 100644
index d1dadcc..0000000
--- a/rand/rand_hc/src/hc128.rs
+++ /dev/null
@@ -1,462 +0,0 @@
-// Copyright 2018 Developers of the Rand project.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-//! The HC-128 random number generator.
-
-use core::fmt;
-use rand_core::{CryptoRng, RngCore, SeedableRng, Error, le};
-use rand_core::block::{BlockRngCore, BlockRng};
-
-const SEED_WORDS: usize = 8; // 128 bit key followed by 128 bit iv
-
-/// A cryptographically secure random number generator that uses the HC-128
-/// algorithm.
-///
-/// HC-128 is a stream cipher designed by Hongjun Wu[^1], that we use as an
-/// RNG. It is selected as one of the "stream ciphers suitable for widespread
-/// adoption" by eSTREAM[^2].
-///
-/// HC-128 is an array based RNG. In this it is similar to RC-4 and ISAAC before
-/// it, but those have never been proven cryptographically secure (or have even
-/// been significantly compromised, as in the case of RC-4[^5]).
-///
-/// Because HC-128 works with simple indexing into a large array and with a few
-/// operations that parallelize well, it has very good performance. The size of
-/// the array it needs, 4kb, can however be a disadvantage.
-///
-/// This implementation is not based on the version of HC-128 submitted to the
-/// eSTREAM contest, but on a later version by the author with a few small
-/// improvements from December 15, 2009[^3].
-///
-/// HC-128 has no known weaknesses that are easier to exploit than doing a
-/// brute-force search of 2<sup>128</sup>. A very comprehensive analysis of the
-/// current state of known attacks / weaknesses of HC-128 is given in *Some
-/// Results On Analysis And Implementation Of HC-128 Stream Cipher*[^4].
-///
-/// The average cycle length is expected to be
-/// 2<sup>1024*32+10-1</sup> = 2<sup>32777</sup>.
-/// We support seeding with a 256-bit array, which matches the 128-bit key
-/// concatenated with a 128-bit IV from the stream cipher.
-///
-/// This implementation uses an output buffer of sixteen `u32` words, and uses
-/// [`BlockRng`] to implement the [`RngCore`] methods.
-///
-/// ## References
-/// [^1]: Hongjun Wu (2008). ["The Stream Cipher HC-128"](
-/// http://www.ecrypt.eu.org/stream/p3ciphers/hc/hc128_p3.pdf).
-/// *The eSTREAM Finalists*, LNCS 4986, pp. 39–47, Springer-Verlag.
-///
-/// [^2]: [eSTREAM: the ECRYPT Stream Cipher Project](
-/// http://www.ecrypt.eu.org/stream/)
-///
-/// [^3]: Hongjun Wu, [Stream Ciphers HC-128 and HC-256](
-/// https://www.ntu.edu.sg/home/wuhj/research/hc/index.html)
-///
-/// [^4]: Shashwat Raizada (January 2015),["Some Results On Analysis And
-/// Implementation Of HC-128 Stream Cipher"](
-/// http://library.isical.ac.in:8080/jspui/bitstream/123456789/6636/1/TH431.pdf).
-///
-/// [^5]: Internet Engineering Task Force (February 2015),
-/// ["Prohibiting RC4 Cipher Suites"](https://tools.ietf.org/html/rfc7465).
-///
-/// [`BlockRng`]: ../rand_core/block/struct.BlockRng.html
-/// [`RngCore`]: ../rand_core/trait.RngCore.html
-#[derive(Clone, Debug)]
-pub struct Hc128Rng(BlockRng<Hc128Core>);
-
-impl RngCore for Hc128Rng {
- #[inline(always)]
- fn next_u32(&mut self) -> u32 {
- self.0.next_u32()
- }
-
- #[inline(always)]
- fn next_u64(&mut self) -> u64 {
- self.0.next_u64()
- }
-
- fn fill_bytes(&mut self, dest: &mut [u8]) {
- self.0.fill_bytes(dest)
- }
-
- fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), Error> {
- self.0.try_fill_bytes(dest)
- }
-}
-
-impl SeedableRng for Hc128Rng {
- type Seed = <Hc128Core as SeedableRng>::Seed;
-
- fn from_seed(seed: Self::Seed) -> Self {
- Hc128Rng(BlockRng::<Hc128Core>::from_seed(seed))
- }
-
- fn from_rng<R: RngCore>(rng: R) -> Result<Self, Error> {
- BlockRng::<Hc128Core>::from_rng(rng).map(Hc128Rng)
- }
-}
-
-impl CryptoRng for Hc128Rng {}
-
-/// The core of `Hc128Rng`, used with `BlockRng`.
-#[derive(Clone)]
-pub struct Hc128Core {
- t: [u32; 1024],
- counter1024: usize,
-}
-
-// Custom Debug implementation that does not expose the internal state
-impl fmt::Debug for Hc128Core {
- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
- write!(f, "Hc128Core {{}}")
- }
-}
-
-impl BlockRngCore for Hc128Core {
- type Item = u32;
- type Results = [u32; 16];
-
- fn generate(&mut self, results: &mut Self::Results) {
- assert!(self.counter1024 % 16 == 0);
-
- let cc = self.counter1024 % 512;
- let dd = (cc + 16) % 512;
- let ee = cc.wrapping_sub(16) % 512;
-
- if self.counter1024 & 512 == 0 {
- // P block
- results[0] = self.step_p(cc+0, cc+1, ee+13, ee+6, ee+4);
- results[1] = self.step_p(cc+1, cc+2, ee+14, ee+7, ee+5);
- results[2] = self.step_p(cc+2, cc+3, ee+15, ee+8, ee+6);
- results[3] = self.step_p(cc+3, cc+4, cc+0, ee+9, ee+7);
- results[4] = self.step_p(cc+4, cc+5, cc+1, ee+10, ee+8);
- results[5] = self.step_p(cc+5, cc+6, cc+2, ee+11, ee+9);
- results[6] = self.step_p(cc+6, cc+7, cc+3, ee+12, ee+10);
- results[7] = self.step_p(cc+7, cc+8, cc+4, ee+13, ee+11);
- results[8] = self.step_p(cc+8, cc+9, cc+5, ee+14, ee+12);
- results[9] = self.step_p(cc+9, cc+10, cc+6, ee+15, ee+13);
- results[10] = self.step_p(cc+10, cc+11, cc+7, cc+0, ee+14);
- results[11] = self.step_p(cc+11, cc+12, cc+8, cc+1, ee+15);
- results[12] = self.step_p(cc+12, cc+13, cc+9, cc+2, cc+0);
- results[13] = self.step_p(cc+13, cc+14, cc+10, cc+3, cc+1);
- results[14] = self.step_p(cc+14, cc+15, cc+11, cc+4, cc+2);
- results[15] = self.step_p(cc+15, dd+0, cc+12, cc+5, cc+3);
- } else {
- // Q block
- results[0] = self.step_q(cc+0, cc+1, ee+13, ee+6, ee+4);
- results[1] = self.step_q(cc+1, cc+2, ee+14, ee+7, ee+5);
- results[2] = self.step_q(cc+2, cc+3, ee+15, ee+8, ee+6);
- results[3] = self.step_q(cc+3, cc+4, cc+0, ee+9, ee+7);
- results[4] = self.step_q(cc+4, cc+5, cc+1, ee+10, ee+8);
- results[5] = self.step_q(cc+5, cc+6, cc+2, ee+11, ee+9);
- results[6] = self.step_q(cc+6, cc+7, cc+3, ee+12, ee+10);
- results[7] = self.step_q(cc+7, cc+8, cc+4, ee+13, ee+11);
- results[8] = self.step_q(cc+8, cc+9, cc+5, ee+14, ee+12);
- results[9] = self.step_q(cc+9, cc+10, cc+6, ee+15, ee+13);
- results[10] = self.step_q(cc+10, cc+11, cc+7, cc+0, ee+14);
- results[11] = self.step_q(cc+11, cc+12, cc+8, cc+1, ee+15);
- results[12] = self.step_q(cc+12, cc+13, cc+9, cc+2, cc+0);
- results[13] = self.step_q(cc+13, cc+14, cc+10, cc+3, cc+1);
- results[14] = self.step_q(cc+14, cc+15, cc+11, cc+4, cc+2);
- results[15] = self.step_q(cc+15, dd+0, cc+12, cc+5, cc+3);
- }
- self.counter1024 = self.counter1024.wrapping_add(16);
- }
-}
-
-impl Hc128Core {
- // One step of HC-128, update P and generate 32 bits keystream
- #[inline(always)]
- fn step_p(&mut self, i: usize, i511: usize, i3: usize, i10: usize, i12: usize)
- -> u32
- {
- let (p, q) = self.t.split_at_mut(512);
- // FIXME: it would be great if we the bounds checks here could be
- // optimized out, and we would not need unsafe.
- // This improves performance by about 7%.
- unsafe {
- let temp0 = p.get_unchecked(i511).rotate_right(23);
- let temp1 = p.get_unchecked(i3).rotate_right(10);
- let temp2 = p.get_unchecked(i10).rotate_right(8);
- *p.get_unchecked_mut(i) = p.get_unchecked(i)
- .wrapping_add(temp2)
- .wrapping_add(temp0 ^ temp1);
- let temp3 = {
- // The h1 function in HC-128
- let a = *p.get_unchecked(i12) as u8;
- let c = (p.get_unchecked(i12) >> 16) as u8;
- q[a as usize].wrapping_add(q[256 + c as usize])
- };
- temp3 ^ p.get_unchecked(i)
- }
- }
-
- // One step of HC-128, update Q and generate 32 bits keystream
- // Similar to `step_p`, but `p` and `q` are swapped, and the rotates are to
- // the left instead of to the right.
- #[inline(always)]
- fn step_q(&mut self, i: usize, i511: usize, i3: usize, i10: usize, i12: usize)
- -> u32
- {
- let (p, q) = self.t.split_at_mut(512);
- unsafe {
- let temp0 = q.get_unchecked(i511).rotate_left(23);
- let temp1 = q.get_unchecked(i3).rotate_left(10);
- let temp2 = q.get_unchecked(i10).rotate_left(8);
- *q.get_unchecked_mut(i) = q.get_unchecked(i)
- .wrapping_add(temp2)
- .wrapping_add(temp0 ^ temp1);
- let temp3 = {
- // The h2 function in HC-128
- let a = *q.get_unchecked(i12) as u8;
- let c = (q.get_unchecked(i12) >> 16) as u8;
- p[a as usize].wrapping_add(p[256 + c as usize])
- };
- temp3 ^ q.get_unchecked(i)
- }
- }
-
- fn sixteen_steps(&mut self) {
- assert!(self.counter1024 % 16 == 0);
-
- let cc = self.counter1024 % 512;
- let dd = (cc + 16) % 512;
- let ee = cc.wrapping_sub(16) % 512;
-
- if self.counter1024 < 512 {
- // P block
- self.t[cc+0] = self.step_p(cc+0, cc+1, ee+13, ee+6, ee+4);
- self.t[cc+1] = self.step_p(cc+1, cc+2, ee+14, ee+7, ee+5);
- self.t[cc+2] = self.step_p(cc+2, cc+3, ee+15, ee+8, ee+6);
- self.t[cc+3] = self.step_p(cc+3, cc+4, cc+0, ee+9, ee+7);
- self.t[cc+4] = self.step_p(cc+4, cc+5, cc+1, ee+10, ee+8);
- self.t[cc+5] = self.step_p(cc+5, cc+6, cc+2, ee+11, ee+9);
- self.t[cc+6] = self.step_p(cc+6, cc+7, cc+3, ee+12, ee+10);
- self.t[cc+7] = self.step_p(cc+7, cc+8, cc+4, ee+13, ee+11);
- self.t[cc+8] = self.step_p(cc+8, cc+9, cc+5, ee+14, ee+12);
- self.t[cc+9] = self.step_p(cc+9, cc+10, cc+6, ee+15, ee+13);
- self.t[cc+10] = self.step_p(cc+10, cc+11, cc+7, cc+0, ee+14);
- self.t[cc+11] = self.step_p(cc+11, cc+12, cc+8, cc+1, ee+15);
- self.t[cc+12] = self.step_p(cc+12, cc+13, cc+9, cc+2, cc+0);
- self.t[cc+13] = self.step_p(cc+13, cc+14, cc+10, cc+3, cc+1);
- self.t[cc+14] = self.step_p(cc+14, cc+15, cc+11, cc+4, cc+2);
- self.t[cc+15] = self.step_p(cc+15, dd+0, cc+12, cc+5, cc+3);
- } else {
- // Q block
- self.t[cc+512+0] = self.step_q(cc+0, cc+1, ee+13, ee+6, ee+4);
- self.t[cc+512+1] = self.step_q(cc+1, cc+2, ee+14, ee+7, ee+5);
- self.t[cc+512+2] = self.step_q(cc+2, cc+3, ee+15, ee+8, ee+6);
- self.t[cc+512+3] = self.step_q(cc+3, cc+4, cc+0, ee+9, ee+7);
- self.t[cc+512+4] = self.step_q(cc+4, cc+5, cc+1, ee+10, ee+8);
- self.t[cc+512+5] = self.step_q(cc+5, cc+6, cc+2, ee+11, ee+9);
- self.t[cc+512+6] = self.step_q(cc+6, cc+7, cc+3, ee+12, ee+10);
- self.t[cc+512+7] = self.step_q(cc+7, cc+8, cc+4, ee+13, ee+11);
- self.t[cc+512+8] = self.step_q(cc+8, cc+9, cc+5, ee+14, ee+12);
- self.t[cc+512+9] = self.step_q(cc+9, cc+10, cc+6, ee+15, ee+13);
- self.t[cc+512+10] = self.step_q(cc+10, cc+11, cc+7, cc+0, ee+14);
- self.t[cc+512+11] = self.step_q(cc+11, cc+12, cc+8, cc+1, ee+15);
- self.t[cc+512+12] = self.step_q(cc+12, cc+13, cc+9, cc+2, cc+0);
- self.t[cc+512+13] = self.step_q(cc+13, cc+14, cc+10, cc+3, cc+1);
- self.t[cc+512+14] = self.step_q(cc+14, cc+15, cc+11, cc+4, cc+2);
- self.t[cc+512+15] = self.step_q(cc+15, dd+0, cc+12, cc+5, cc+3);
- }
- self.counter1024 += 16;
- }
-
- // Initialize an HC-128 random number generator. The seed has to be
- // 256 bits in length (`[u32; 8]`), matching the 128 bit `key` followed by
- // 128 bit `iv` when HC-128 where to be used as a stream cipher.
- fn init(seed: [u32; SEED_WORDS]) -> Self {
- #[inline]
- fn f1(x: u32) -> u32 {
- x.rotate_right(7) ^ x.rotate_right(18) ^ (x >> 3)
- }
-
- #[inline]
- fn f2(x: u32) -> u32 {
- x.rotate_right(17) ^ x.rotate_right(19) ^ (x >> 10)
- }
-
- let mut t = [0u32; 1024];
-
- // Expand the key and iv into P and Q
- let (key, iv) = seed.split_at(4);
- t[..4].copy_from_slice(key);
- t[4..8].copy_from_slice(key);
- t[8..12].copy_from_slice(iv);
- t[12..16].copy_from_slice(iv);
-
- // Generate the 256 intermediate values W[16] ... W[256+16-1], and
- // copy the last 16 generated values to the start op P.
- for i in 16..256+16 {
- t[i] = f2(t[i-2]).wrapping_add(t[i-7]).wrapping_add(f1(t[i-15]))
- .wrapping_add(t[i-16]).wrapping_add(i as u32);
- }
- {
- let (p1, p2) = t.split_at_mut(256);
- p1[0..16].copy_from_slice(&p2[0..16]);
- }
-
- // Generate both the P and Q tables
- for i in 16..1024 {
- t[i] = f2(t[i-2]).wrapping_add(t[i-7]).wrapping_add(f1(t[i-15]))
- .wrapping_add(t[i-16]).wrapping_add(256 + i as u32);
- }
-
- let mut core = Self { t, counter1024: 0 };
-
- // run the cipher 1024 steps
- for _ in 0..64 { core.sixteen_steps() };
- core.counter1024 = 0;
- core
- }
-}
-
-impl SeedableRng for Hc128Core {
- type Seed = [u8; SEED_WORDS*4];
-
- /// Create an HC-128 random number generator with a seed. The seed has to be
- /// 256 bits in length, matching the 128 bit `key` followed by 128 bit `iv`
- /// when HC-128 where to be used as a stream cipher.
- fn from_seed(seed: Self::Seed) -> Self {
- let mut seed_u32 = [0u32; SEED_WORDS];
- le::read_u32_into(&seed, &mut seed_u32);
- Self::init(seed_u32)
- }
-}
-
-impl CryptoRng for Hc128Core {}
-
-#[cfg(test)]
-mod test {
- use ::rand_core::{RngCore, SeedableRng};
- use super::Hc128Rng;
-
- #[test]
- // Test vector 1 from the paper "The Stream Cipher HC-128"
- fn test_hc128_true_values_a() {
- let seed = [0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, // key
- 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0]; // iv
- let mut rng = Hc128Rng::from_seed(seed);
-
- let mut results = [0u32; 16];
- for i in results.iter_mut() { *i = rng.next_u32(); }
- let expected = [0x73150082, 0x3bfd03a0, 0xfb2fd77f, 0xaa63af0e,
- 0xde122fc6, 0xa7dc29b6, 0x62a68527, 0x8b75ec68,
- 0x9036db1e, 0x81896005, 0x00ade078, 0x491fbf9a,
- 0x1cdc3013, 0x6c3d6e24, 0x90f664b2, 0x9cd57102];
- assert_eq!(results, expected);
- }
-
- #[test]
- // Test vector 2 from the paper "The Stream Cipher HC-128"
- fn test_hc128_true_values_b() {
- let seed = [0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, // key
- 1,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0]; // iv
- let mut rng = Hc128Rng::from_seed(seed);
-
- let mut results = [0u32; 16];
- for i in results.iter_mut() { *i = rng.next_u32(); }
- let expected = [0xc01893d5, 0xb7dbe958, 0x8f65ec98, 0x64176604,
- 0x36fc6724, 0xc82c6eec, 0x1b1c38a7, 0xc9b42a95,
- 0x323ef123, 0x0a6a908b, 0xce757b68, 0x9f14f7bb,
- 0xe4cde011, 0xaeb5173f, 0x89608c94, 0xb5cf46ca];
- assert_eq!(results, expected);
- }
-
- #[test]
- // Test vector 3 from the paper "The Stream Cipher HC-128"
- fn test_hc128_true_values_c() {
- let seed = [0x55,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, // key
- 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0]; // iv
- let mut rng = Hc128Rng::from_seed(seed);
-
- let mut results = [0u32; 16];
- for i in results.iter_mut() { *i = rng.next_u32(); }
- let expected = [0x518251a4, 0x04b4930a, 0xb02af931, 0x0639f032,
- 0xbcb4a47a, 0x5722480b, 0x2bf99f72, 0xcdc0e566,
- 0x310f0c56, 0xd3cc83e8, 0x663db8ef, 0x62dfe07f,
- 0x593e1790, 0xc5ceaa9c, 0xab03806f, 0xc9a6e5a0];
- assert_eq!(results, expected);
- }
-
- #[test]
- fn test_hc128_true_values_u64() {
- let seed = [0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, // key
- 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0]; // iv
- let mut rng = Hc128Rng::from_seed(seed);
-
- let mut results = [0u64; 8];
- for i in results.iter_mut() { *i = rng.next_u64(); }
- let expected = [0x3bfd03a073150082, 0xaa63af0efb2fd77f,
- 0xa7dc29b6de122fc6, 0x8b75ec6862a68527,
- 0x818960059036db1e, 0x491fbf9a00ade078,
- 0x6c3d6e241cdc3013, 0x9cd5710290f664b2];
- assert_eq!(results, expected);
-
- // The RNG operates in a P block of 512 results and next a Q block.
- // After skipping 2*800 u32 results we end up somewhere in the Q block
- // of the second round
- for _ in 0..800 { rng.next_u64(); }
-
- for i in results.iter_mut() { *i = rng.next_u64(); }
- let expected = [0xd8c4d6ca84d0fc10, 0xf16a5d91dc66e8e7,
- 0xd800de5bc37a8653, 0x7bae1f88c0dfbb4c,
- 0x3bfe1f374e6d4d14, 0x424b55676be3fa06,
- 0xe3a1e8758cbff579, 0x417f7198c5652bcd];
- assert_eq!(results, expected);
- }
-
- #[test]
- fn test_hc128_true_values_bytes() {
- let seed = [0x55,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, // key
- 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0]; // iv
- let mut rng = Hc128Rng::from_seed(seed);
- let expected = [0x31, 0xf9, 0x2a, 0xb0, 0x32, 0xf0, 0x39, 0x06,
- 0x7a, 0xa4, 0xb4, 0xbc, 0x0b, 0x48, 0x22, 0x57,
- 0x72, 0x9f, 0xf9, 0x2b, 0x66, 0xe5, 0xc0, 0xcd,
- 0x56, 0x0c, 0x0f, 0x31, 0xe8, 0x83, 0xcc, 0xd3,
- 0xef, 0xb8, 0x3d, 0x66, 0x7f, 0xe0, 0xdf, 0x62,
- 0x90, 0x17, 0x3e, 0x59, 0x9c, 0xaa, 0xce, 0xc5,
- 0x6f, 0x80, 0x03, 0xab, 0xa0, 0xe5, 0xa6, 0xc9,
- 0x60, 0x95, 0x84, 0x7a, 0xa5, 0x68, 0x5a, 0x84,
- 0xea, 0xd5, 0xf3, 0xea, 0x73, 0xa9, 0xad, 0x01,
- 0x79, 0x7d, 0xbe, 0x9f, 0xea, 0xe3, 0xf9, 0x74,
- 0x0e, 0xda, 0x2f, 0xa0, 0xe4, 0x7b, 0x4b, 0x1b,
- 0xdd, 0x17, 0x69, 0x4a, 0xfe, 0x9f, 0x56, 0x95,
- 0xad, 0x83, 0x6b, 0x9d, 0x60, 0xa1, 0x99, 0x96,
- 0x90, 0x00, 0x66, 0x7f, 0xfa, 0x7e, 0x65, 0xe9,
- 0xac, 0x8b, 0x92, 0x34, 0x77, 0xb4, 0x23, 0xd0,
- 0xb9, 0xab, 0xb1, 0x47, 0x7d, 0x4a, 0x13, 0x0a];
-
- // Pick a somewhat large buffer so we can test filling with the
- // remainder from `state.results`, directly filling the buffer, and
- // filling the remainder of the buffer.
- let mut buffer = [0u8; 16*4*2];
- // Consume a value so that we have a remainder.
- assert!(rng.next_u64() == 0x04b4930a518251a4);
- rng.fill_bytes(&mut buffer);
-
- // [u8; 128] doesn't implement PartialEq
- assert_eq!(buffer.len(), expected.len());
- for (b, e) in buffer.iter().zip(expected.iter()) {
- assert_eq!(b, e);
- }
- }
-
- #[test]
- fn test_hc128_clone() {
- let seed = [0x55,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, // key
- 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0]; // iv
- let mut rng1 = Hc128Rng::from_seed(seed);
- let mut rng2 = rng1.clone();
- for _ in 0..16 {
- assert_eq!(rng1.next_u32(), rng2.next_u32());
- }
- }
-}
diff --git a/rand/rand_hc/src/lib.rs b/rand/rand_hc/src/lib.rs
deleted file mode 100644
index 10466cf..0000000
--- a/rand/rand_hc/src/lib.rs
+++ /dev/null
@@ -1,25 +0,0 @@
-// Copyright 2018 Developers of the Rand project.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-//! The HC128 random number generator.
-
-#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk.png",
- html_favicon_url = "https://www.rust-lang.org/favicon.ico",
- html_root_url = "https://rust-random.github.io/rand/")]
-
-#![deny(missing_docs)]
-#![deny(missing_debug_implementations)]
-#![doc(test(attr(allow(unused_variables), deny(warnings))))]
-
-#![no_std]
-
-pub extern crate rand_core;
-
-mod hc128;
-
-pub use hc128::{Hc128Rng, Hc128Core};
diff --git a/rand/rand_isaac/CHANGELOG.md b/rand/rand_isaac/CHANGELOG.md
deleted file mode 100644
index fb1ab3f..0000000
--- a/rand/rand_isaac/CHANGELOG.md
+++ /dev/null
@@ -1,12 +0,0 @@
-# Changelog
-All notable changes to this project will be documented in this file.
-
-The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
-and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
-
-## [0.1.1] - 2018-11-26
-- Fix `rand_core` version requirement
-- Fix doc links
-
-## [0.1.0] - 2018-10-17
-- Pulled out of the Rand crate
diff --git a/rand/rand_isaac/COPYRIGHT b/rand/rand_isaac/COPYRIGHT
deleted file mode 100644
index 468d907..0000000
--- a/rand/rand_isaac/COPYRIGHT
+++ /dev/null
@@ -1,12 +0,0 @@
-Copyrights in the Rand project are retained by their contributors. No
-copyright assignment is required to contribute to the Rand project.
-
-For full authorship information, see the version control history.
-
-Except as otherwise noted (below and/or in individual files), Rand is
-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.
-
-The Rand project includes code from the Rust project
-published under these same licenses.
diff --git a/rand/rand_isaac/Cargo.toml b/rand/rand_isaac/Cargo.toml
deleted file mode 100644
index b35d0ab..0000000
--- a/rand/rand_isaac/Cargo.toml
+++ /dev/null
@@ -1,31 +0,0 @@
-[package]
-name = "rand_isaac"
-version = "0.1.1"
-authors = ["The Rand Project Developers", "The Rust Project Developers"]
-license = "MIT/Apache-2.0"
-readme = "README.md"
-repository = "https://github.com/rust-random/rand"
-documentation = "https://rust-random.github.io/rand/rand_isaac"
-homepage = "https://crates.io/crates/rand_isaac"
-description = """
-ISAAC random number generator
-"""
-keywords = ["random", "rng", "isaac"]
-categories = ["algorithms", "no-std"]
-
-[badges]
-travis-ci = { repository = "rust-random/rand" }
-appveyor = { repository = "rust-random/rand" }
-
-[features]
-serde1 = ["serde", "serde_derive", "rand_core/serde1"]
-
-[dependencies]
-rand_core = { path = "../rand_core", version = "0.3", default-features=false }
-serde = { version = "1", optional = true }
-serde_derive = { version = "^1.0.38", optional = true }
-
-[dev-dependencies]
-# This is for testing serde, unfortunately we can't specify feature-gated dev
-# deps yet, see: https://github.com/rust-lang/cargo/issues/1596
-bincode = "1"
diff --git a/rand/rand_isaac/LICENSE-APACHE b/rand/rand_isaac/LICENSE-APACHE
deleted file mode 100644
index 17d7468..0000000
--- a/rand/rand_isaac/LICENSE-APACHE
+++ /dev/null
@@ -1,201 +0,0 @@
- Apache License
- Version 2.0, January 2004
- https://www.apache.org/licenses/
-
-TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
-1. Definitions.
-
- "License" shall mean the terms and conditions for use, reproduction,
- and distribution as defined by Sections 1 through 9 of this document.
-
- "Licensor" shall mean the copyright owner or entity authorized by
- the copyright owner that is granting the License.
-
- "Legal Entity" shall mean the union of the acting entity and all
- other entities that control, are controlled by, or are under common
- control with that entity. For the purposes of this definition,
- "control" means (i) the power, direct or indirect, to cause the
- direction or management of such entity, whether by contract or
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
- outstanding shares, or (iii) beneficial ownership of such entity.
-
- "You" (or "Your") shall mean an individual or Legal Entity
- exercising permissions granted by this License.
-
- "Source" form shall mean the preferred form for making modifications,
- including but not limited to software source code, documentation
- source, and configuration files.
-
- "Object" form shall mean any form resulting from mechanical
- transformation or translation of a Source form, including but
- not limited to compiled object code, generated documentation,
- and conversions to other media types.
-
- "Work" shall mean the work of authorship, whether in Source or
- Object form, made available under the License, as indicated by a
- copyright notice that is included in or attached to the work
- (an example is provided in the Appendix below).
-
- "Derivative Works" shall mean any work, whether in Source or Object
- form, that is based on (or derived from) the Work and for which the
- editorial revisions, annotations, elaborations, or other modifications
- represent, as a whole, an original work of authorship. For the purposes
- of this License, Derivative Works shall not include works that remain
- separable from, or merely link (or bind by name) to the interfaces of,
- the Work and Derivative Works thereof.
-
- "Contribution" shall mean any work of authorship, including
- the original version of the Work and any modifications or additions
- to that Work or Derivative Works thereof, that is intentionally
- submitted to Licensor for inclusion in the Work by the copyright owner
- or by an individual or Legal Entity authorized to submit on behalf of
- the copyright owner. For the purposes of this definition, "submitted"
- means any form of electronic, verbal, or written communication sent
- to the Licensor or its representatives, including but not limited to
- communication on electronic mailing lists, source code control systems,
- and issue tracking systems that are managed by, or on behalf of, the
- Licensor for the purpose of discussing and improving the Work, but
- excluding communication that is conspicuously marked or otherwise
- designated in writing by the copyright owner as "Not a Contribution."
-
- "Contributor" shall mean Licensor and any individual or Legal Entity
- on behalf of whom a Contribution has been received by Licensor and
- subsequently incorporated within the Work.
-
-2. Grant of Copyright License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- copyright license to reproduce, prepare Derivative Works of,
- publicly display, publicly perform, sublicense, and distribute the
- Work and such Derivative Works in Source or Object form.
-
-3. Grant of Patent License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- (except as stated in this section) patent license to make, have made,
- use, offer to sell, sell, import, and otherwise transfer the Work,
- where such license applies only to those patent claims licensable
- by such Contributor that are necessarily infringed by their
- Contribution(s) alone or by combination of their Contribution(s)
- with the Work to which such Contribution(s) was submitted. If You
- institute patent litigation against any entity (including a
- cross-claim or counterclaim in a lawsuit) alleging that the Work
- or a Contribution incorporated within the Work constitutes direct
- or contributory patent infringement, then any patent licenses
- granted to You under this License for that Work shall terminate
- as of the date such litigation is filed.
-
-4. Redistribution. You may reproduce and distribute copies of the
- Work or Derivative Works thereof in any medium, with or without
- modifications, and in Source or Object form, provided that You
- meet the following conditions:
-
- (a) You must give any other recipients of the Work or
- Derivative Works a copy of this License; and
-
- (b) You must cause any modified files to carry prominent notices
- stating that You changed the files; and
-
- (c) You must retain, in the Source form of any Derivative Works
- that You distribute, all copyright, patent, trademark, and
- attribution notices from the Source form of the Work,
- excluding those notices that do not pertain to any part of
- the Derivative Works; and
-
- (d) If the Work includes a "NOTICE" text file as part of its
- distribution, then any Derivative Works that You distribute must
- include a readable copy of the attribution notices contained
- within such NOTICE file, excluding those notices that do not
- pertain to any part of the Derivative Works, in at least one
- of the following places: within a NOTICE text file distributed
- as part of the Derivative Works; within the Source form or
- documentation, if provided along with the Derivative Works; or,
- within a display generated by the Derivative Works, if and
- wherever such third-party notices normally appear. The contents
- of the NOTICE file are for informational purposes only and
- do not modify the License. You may add Your own attribution
- notices within Derivative Works that You distribute, alongside
- or as an addendum to the NOTICE text from the Work, provided
- that such additional attribution notices cannot be construed
- as modifying the License.
-
- You may add Your own copyright statement to Your modifications and
- may provide additional or different license terms and conditions
- for use, reproduction, or distribution of Your modifications, or
- for any such Derivative Works as a whole, provided Your use,
- reproduction, and distribution of the Work otherwise complies with
- the conditions stated in this License.
-
-5. Submission of Contributions. Unless You explicitly state otherwise,
- any Contribution intentionally submitted for inclusion in the Work
- by You to the Licensor shall be under the terms and conditions of
- this License, without any additional terms or conditions.
- Notwithstanding the above, nothing herein shall supersede or modify
- the terms of any separate license agreement you may have executed
- with Licensor regarding such Contributions.
-
-6. Trademarks. This License does not grant permission to use the trade
- names, trademarks, service marks, or product names of the Licensor,
- except as required for reasonable and customary use in describing the
- origin of the Work and reproducing the content of the NOTICE file.
-
-7. Disclaimer of Warranty. Unless required by applicable law or
- agreed to in writing, Licensor provides the Work (and each
- Contributor provides its Contributions) on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- implied, including, without limitation, any warranties or conditions
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
- PARTICULAR PURPOSE. You are solely responsible for determining the
- appropriateness of using or redistributing the Work and assume any
- risks associated with Your exercise of permissions under this License.
-
-8. Limitation of Liability. In no event and under no legal theory,
- whether in tort (including negligence), contract, or otherwise,
- unless required by applicable law (such as deliberate and grossly
- negligent acts) or agreed to in writing, shall any Contributor be
- liable to You for damages, including any direct, indirect, special,
- incidental, or consequential damages of any character arising as a
- result of this License or out of the use or inability to use the
- Work (including but not limited to damages for loss of goodwill,
- work stoppage, computer failure or malfunction, or any and all
- other commercial damages or losses), even if such Contributor
- has been advised of the possibility of such damages.
-
-9. Accepting Warranty or Additional Liability. While redistributing
- the Work or Derivative Works thereof, You may choose to offer,
- and charge a fee for, acceptance of support, warranty, indemnity,
- or other liability obligations and/or rights consistent with this
- License. However, in accepting such obligations, You may act only
- on Your own behalf and on Your sole responsibility, not on behalf
- of any other Contributor, and only if You agree to indemnify,
- defend, and hold each Contributor harmless for any liability
- incurred by, or claims asserted against, such Contributor by reason
- of your accepting any such warranty or additional liability.
-
-END OF TERMS AND CONDITIONS
-
-APPENDIX: How to apply the Apache License to your work.
-
- To apply the Apache License to your work, attach the following
- boilerplate notice, with the fields enclosed by brackets "[]"
- replaced with your own identifying information. (Don't include
- the brackets!) The text should be enclosed in the appropriate
- comment syntax for the file format. We also recommend that a
- file or class name and description of purpose be included on the
- same "printed page" as the copyright notice for easier
- identification within third-party archives.
-
-Copyright [yyyy] [name of copyright owner]
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
- https://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
diff --git a/rand/rand_isaac/LICENSE-MIT b/rand/rand_isaac/LICENSE-MIT
deleted file mode 100644
index d93b5ba..0000000
--- a/rand/rand_isaac/LICENSE-MIT
+++ /dev/null
@@ -1,26 +0,0 @@
-Copyright 2018 Developers of the Rand project
-Copyright (c) 2014 The Rust Project Developers
-
-Permission is hereby granted, free of charge, to any
-person obtaining a copy of this software and associated
-documentation files (the "Software"), to deal in the
-Software without restriction, including without
-limitation the rights to use, copy, modify, merge,
-publish, distribute, sublicense, and/or sell copies of
-the Software, and to permit persons to whom the Software
-is furnished to do so, subject to the following
-conditions:
-
-The above copyright notice and this permission notice
-shall be included in all copies or substantial portions
-of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
-ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
-TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
-PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
-SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
-CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
-IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
-DEALINGS IN THE SOFTWARE.
diff --git a/rand/rand_isaac/README.md b/rand/rand_isaac/README.md
deleted file mode 100644
index 02d1230..0000000
--- a/rand/rand_isaac/README.md
+++ /dev/null
@@ -1,47 +0,0 @@
-# rand_isaac
-
-[![Build Status](https://travis-ci.org/rust-random/rand.svg)](https://travis-ci.org/rust-random/rand)
-[![Build Status](https://ci.appveyor.com/api/projects/status/github/rust-random/rand?svg=true)](https://ci.appveyor.com/project/rust-random/rand)
-[![Latest version](https://img.shields.io/crates/v/rand_isaac.svg)](https://crates.io/crates/rand_isaac)
-[![Book](https://img.shields.io/badge/book-master-yellow.svg)](https://rust-random.github.io/book/)
-[![API](https://img.shields.io/badge/api-master-yellow.svg)](https://rust-random.github.io/rand/rand_isaac)
-[![API](https://docs.rs/rand_isaac/badge.svg)](https://docs.rs/rand_isaac)
-[![Minimum rustc version](https://img.shields.io/badge/rustc-1.22+-lightgray.svg)](https://github.com/rust-random/rand#rust-version-requirements)
-
-Implements the ISAAC and ISAAC-64 random number generators.
-
-ISAAC stands for "Indirection, Shift, Accumulate, Add, and Count" which are
-the principal bitwise operations employed. It is the most advanced of a
-series of array based random number generator designed by Robert Jenkins
-in 1996[^1][^2].
-
-ISAAC is notably fast and produces excellent quality random numbers for
-non-cryptographic applications.
-
-Links:
-
-- [API documentation (master)](https://rust-random.github.io/rand/rand_isaac)
-- [API documentation (docs.rs)](https://docs.rs/rand_isaac)
-- [Changelog](CHANGELOG.md)
-
-[rand]: https://crates.io/crates/rand
-[^1]: Bob Jenkins, [*ISAAC: A fast cryptographic random number generator*](http://burtleburtle.net/bob/rand/isaacafa.html)
-[^2]: Bob Jenkins, [*ISAAC and RC4*](http://burtleburtle.net/bob/rand/isaac.html)
-
-
-## Crate Features
-
-`rand_isaac` is `no_std` compatible. It does not require any functionality
-outside of the `core` lib, thus there are no features to configure.
-
-The `serde1` feature includes implementations of `Serialize` and `Deserialize`
-for the included RNGs.
-
-
-# License
-
-`rand_isaac` is distributed under the terms of both the MIT license and the
-Apache License (Version 2.0).
-
-See [LICENSE-APACHE](LICENSE-APACHE) and [LICENSE-MIT](LICENSE-MIT), and
-[COPYRIGHT](COPYRIGHT) for details.
diff --git a/rand/rand_isaac/src/isaac.rs b/rand/rand_isaac/src/isaac.rs
deleted file mode 100644
index 2bfdd94..0000000
--- a/rand/rand_isaac/src/isaac.rs
+++ /dev/null
@@ -1,484 +0,0 @@
-// Copyright 2018 Developers of the Rand project.
-// Copyright 2013-2018 The Rust Project Developers.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-//! The ISAAC random number generator.
-
-use core::{fmt, slice};
-use core::num::Wrapping as w;
-use rand_core::{RngCore, SeedableRng, Error, le};
-use rand_core::block::{BlockRngCore, BlockRng};
-use isaac_array::IsaacArray;
-
-#[allow(non_camel_case_types)]
-type w32 = w<u32>;
-
-const RAND_SIZE_LEN: usize = 8;
-const RAND_SIZE: usize = 1 << RAND_SIZE_LEN;
-
-/// A random number generator that uses the ISAAC algorithm.
-///
-/// ISAAC stands for "Indirection, Shift, Accumulate, Add, and Count" which are
-/// the principal bitwise operations employed. It is the most advanced of a
-/// series of array based random number generator designed by Robert Jenkins
-/// in 1996[^1][^2].
-///
-/// ISAAC is notably fast and produces excellent quality random numbers for
-/// non-cryptographic applications.
-///
-/// In spite of being designed with cryptographic security in mind, ISAAC hasn't
-/// been stringently cryptanalyzed and thus cryptographers do not not
-/// consensually trust it to be secure. When looking for a secure RNG, prefer
-/// [`Hc128Rng`] instead, which, like ISAAC, is an array-based RNG and one of
-/// the stream-ciphers selected the by eSTREAM contest.
-///
-/// In 2006 an improvement to ISAAC was suggested by Jean-Philippe Aumasson,
-/// named ISAAC+[^3]. But because the specification is not complete, because
-/// there is no good implementation, and because the suggested bias may not
-/// exist, it is not implemented here.
-///
-/// ## Overview of the ISAAC algorithm:
-/// (in pseudo-code)
-///
-/// ```text
-/// Input: a, b, c, s[256] // state
-/// Output: r[256] // results
-///
-/// mix(a,i) = a ^ a << 13 if i = 0 mod 4
-/// a ^ a >> 6 if i = 1 mod 4
-/// a ^ a << 2 if i = 2 mod 4
-/// a ^ a >> 16 if i = 3 mod 4
-///
-/// c = c + 1
-/// b = b + c
-///
-/// for i in 0..256 {
-/// x = s_[i]
-/// a = f(a,i) + s[i+128 mod 256]
-/// y = a + b + s[x>>2 mod 256]
-/// s[i] = y
-/// b = x + s[y>>10 mod 256]
-/// r[i] = b
-/// }
-/// ```
-///
-/// Numbers are generated in blocks of 256. This means the function above only
-/// runs once every 256 times you ask for a next random number. In all other
-/// circumstances the last element of the results array is returned.
-///
-/// ISAAC therefore needs a lot of memory, relative to other non-crypto RNGs.
-/// 2 * 256 * 4 = 2 kb to hold the state and results.
-///
-/// This implementation uses [`BlockRng`] to implement the [`RngCore`] methods.
-///
-/// ## References
-/// [^1]: Bob Jenkins, [*ISAAC: A fast cryptographic random number generator*](
-/// http://burtleburtle.net/bob/rand/isaacafa.html)
-///
-/// [^2]: Bob Jenkins, [*ISAAC and RC4*](
-/// http://burtleburtle.net/bob/rand/isaac.html)
-///
-/// [^3]: Jean-Philippe Aumasson, [*On the pseudo-random generator ISAAC*](
-/// https://eprint.iacr.org/2006/438)
-///
-/// [`Hc128Rng`]: ../../rand_hc/struct.Hc128Rng.html
-/// [`BlockRng`]: ../../rand_core/block/struct.BlockRng.html
-/// [`RngCore`]: ../../rand_core/trait.RngCore.html
-#[derive(Clone, Debug)]
-#[cfg_attr(feature="serde1", derive(Serialize, Deserialize))]
-pub struct IsaacRng(BlockRng<IsaacCore>);
-
-impl RngCore for IsaacRng {
- #[inline(always)]
- fn next_u32(&mut self) -> u32 {
- self.0.next_u32()
- }
-
- #[inline(always)]
- fn next_u64(&mut self) -> u64 {
- self.0.next_u64()
- }
-
- fn fill_bytes(&mut self, dest: &mut [u8]) {
- self.0.fill_bytes(dest)
- }
-
- fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), Error> {
- self.0.try_fill_bytes(dest)
- }
-}
-
-impl SeedableRng for IsaacRng {
- type Seed = <IsaacCore as SeedableRng>::Seed;
-
- fn from_seed(seed: Self::Seed) -> Self {
- IsaacRng(BlockRng::<IsaacCore>::from_seed(seed))
- }
-
- /// Create an ISAAC random number generator using an `u64` as seed.
- /// If `seed == 0` this will produce the same stream of random numbers as
- /// the reference implementation when used unseeded.
- fn seed_from_u64(seed: u64) -> Self {
- IsaacRng(BlockRng::<IsaacCore>::seed_from_u64(seed))
- }
-
- fn from_rng<S: RngCore>(rng: S) -> Result<Self, Error> {
- BlockRng::<IsaacCore>::from_rng(rng).map(|rng| IsaacRng(rng))
- }
-}
-
-impl IsaacRng {
- /// Create an ISAAC random number generator using an `u64` as seed.
- /// If `seed == 0` this will produce the same stream of random numbers as
- /// the reference implementation when used unseeded.
- #[deprecated(since="0.6.0", note="use SeedableRng::seed_from_u64 instead")]
- pub fn new_from_u64(seed: u64) -> Self {
- Self::seed_from_u64(seed)
- }
-}
-
-/// The core of `IsaacRng`, used with `BlockRng`.
-#[derive(Clone)]
-#[cfg_attr(feature="serde1", derive(Serialize, Deserialize))]
-pub struct IsaacCore {
- #[cfg_attr(feature="serde1",serde(with="super::isaac_array::isaac_array_serde"))]
- mem: [w32; RAND_SIZE],
- a: w32,
- b: w32,
- c: w32,
-}
-
-// Custom Debug implementation that does not expose the internal state
-impl fmt::Debug for IsaacCore {
- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
- write!(f, "IsaacCore {{}}")
- }
-}
-
-impl BlockRngCore for IsaacCore {
- type Item = u32;
- type Results = IsaacArray<Self::Item>;
-
- /// Refills the output buffer, `results`. See also the pseudocode desciption
- /// of the algorithm in the [`IsaacRng`] documentation.
- ///
- /// Optimisations used (similar to the reference implementation):
- ///
- /// - The loop is unrolled 4 times, once for every constant of mix().
- /// - The contents of the main loop are moved to a function `rngstep`, to
- /// reduce code duplication.
- /// - We use local variables for a and b, which helps with optimisations.
- /// - We split the main loop in two, one that operates over 0..128 and one
- /// over 128..256. This way we can optimise out the addition and modulus
- /// from `s[i+128 mod 256]`.
- /// - We maintain one index `i` and add `m` or `m2` as base (m2 for the
- /// `s[i+128 mod 256]`), relying on the optimizer to turn it into pointer
- /// arithmetic.
- /// - We fill `results` backwards. The reference implementation reads values
- /// from `results` in reverse. We read them in the normal direction, to
- /// make `fill_bytes` a memcopy. To maintain compatibility we fill in
- /// reverse.
- ///
- /// [`IsaacRng`]: struct.IsaacRng.html
- fn generate(&mut self, results: &mut IsaacArray<Self::Item>) {
- self.c += w(1);
- // abbreviations
- let mut a = self.a;
- let mut b = self.b + self.c;
- const MIDPOINT: usize = RAND_SIZE / 2;
-
- #[inline]
- fn ind(mem:&[w32; RAND_SIZE], v: w32, amount: usize) -> w32 {
- let index = (v >> amount).0 as usize % RAND_SIZE;
- mem[index]
- }
-
- #[inline]
- fn rngstep(mem: &mut [w32; RAND_SIZE],
- results: &mut [u32; RAND_SIZE],
- mix: w32,
- a: &mut w32,
- b: &mut w32,
- base: usize,
- m: usize,
- m2: usize) {
- let x = mem[base + m];
- *a = mix + mem[base + m2];
- let y = *a + *b + ind(&mem, x, 2);
- mem[base + m] = y;
- *b = x + ind(&mem, y, 2 + RAND_SIZE_LEN);
- results[RAND_SIZE - 1 - base - m] = (*b).0;
- }
-
- let mut m = 0;
- let mut m2 = MIDPOINT;
- for i in (0..MIDPOINT/4).map(|i| i * 4) {
- rngstep(&mut self.mem, results, a ^ (a << 13), &mut a, &mut b, i + 0, m, m2);
- rngstep(&mut self.mem, results, a ^ (a >> 6 ), &mut a, &mut b, i + 1, m, m2);
- rngstep(&mut self.mem, results, a ^ (a << 2 ), &mut a, &mut b, i + 2, m, m2);
- rngstep(&mut self.mem, results, a ^ (a >> 16), &mut a, &mut b, i + 3, m, m2);
- }
-
- m = MIDPOINT;
- m2 = 0;
- for i in (0..MIDPOINT/4).map(|i| i * 4) {
- rngstep(&mut self.mem, results, a ^ (a << 13), &mut a, &mut b, i + 0, m, m2);
- rngstep(&mut self.mem, results, a ^ (a >> 6 ), &mut a, &mut b, i + 1, m, m2);
- rngstep(&mut self.mem, results, a ^ (a << 2 ), &mut a, &mut b, i + 2, m, m2);
- rngstep(&mut self.mem, results, a ^ (a >> 16), &mut a, &mut b, i + 3, m, m2);
- }
-
- self.a = a;
- self.b = b;
- }
-}
-
-impl IsaacCore {
- /// Create a new ISAAC random number generator.
- ///
- /// The author Bob Jenkins describes how to best initialize ISAAC here:
- /// <https://rt.cpan.org/Public/Bug/Display.html?id=64324>
- /// The answer is included here just in case:
- ///
- /// "No, you don't need a full 8192 bits of seed data. Normal key sizes will
- /// do fine, and they should have their expected strength (eg a 40-bit key
- /// will take as much time to brute force as 40-bit keys usually will). You
- /// could fill the remainder with 0, but set the last array element to the
- /// length of the key provided (to distinguish keys that differ only by
- /// different amounts of 0 padding). You do still need to call `randinit()`
- /// to make sure the initial state isn't uniform-looking."
- /// "After publishing ISAAC, I wanted to limit the key to half the size of
- /// `r[]`, and repeat it twice. That would have made it hard to provide a
- /// key that sets the whole internal state to anything convenient. But I'd
- /// already published it."
- ///
- /// And his answer to the question "For my code, would repeating the key
- /// over and over to fill 256 integers be a better solution than
- /// zero-filling, or would they essentially be the same?":
- /// "If the seed is under 32 bytes, they're essentially the same, otherwise
- /// repeating the seed would be stronger. randinit() takes a chunk of 32
- /// bytes, mixes it, and combines that with the next 32 bytes, et cetera.
- /// Then loops over all the elements the same way a second time."
- #[inline]
- fn init(mut mem: [w32; RAND_SIZE], rounds: u32) -> Self {
- fn mix(a: &mut w32, b: &mut w32, c: &mut w32, d: &mut w32,
- e: &mut w32, f: &mut w32, g: &mut w32, h: &mut w32) {
- *a ^= *b << 11; *d += *a; *b += *c;
- *b ^= *c >> 2; *e += *b; *c += *d;
- *c ^= *d << 8; *f += *c; *d += *e;
- *d ^= *e >> 16; *g += *d; *e += *f;
- *e ^= *f << 10; *h += *e; *f += *g;
- *f ^= *g >> 4; *a += *f; *g += *h;
- *g ^= *h << 8; *b += *g; *h += *a;
- *h ^= *a >> 9; *c += *h; *a += *b;
- }
-
- // These numbers are the result of initializing a...h with the
- // fractional part of the golden ratio in binary (0x9e3779b9)
- // and applying mix() 4 times.
- let mut a = w(0x1367df5a);
- let mut b = w(0x95d90059);
- let mut c = w(0xc3163e4b);
- let mut d = w(0x0f421ad8);
- let mut e = w(0xd92a4a78);
- let mut f = w(0xa51a3c49);
- let mut g = w(0xc4efea1b);
- let mut h = w(0x30609119);
-
- // Normally this should do two passes, to make all of the seed effect
- // all of `mem`
- for _ in 0..rounds {
- for i in (0..RAND_SIZE/8).map(|i| i * 8) {
- a += mem[i ]; b += mem[i+1];
- c += mem[i+2]; d += mem[i+3];
- e += mem[i+4]; f += mem[i+5];
- g += mem[i+6]; h += mem[i+7];
- mix(&mut a, &mut b, &mut c, &mut d,
- &mut e, &mut f, &mut g, &mut h);
- mem[i ] = a; mem[i+1] = b;
- mem[i+2] = c; mem[i+3] = d;
- mem[i+4] = e; mem[i+5] = f;
- mem[i+6] = g; mem[i+7] = h;
- }
- }
-
- Self { mem, a: w(0), b: w(0), c: w(0) }
- }
-}
-
-impl SeedableRng for IsaacCore {
- type Seed = [u8; 32];
-
- fn from_seed(seed: Self::Seed) -> Self {
- let mut seed_u32 = [0u32; 8];
- le::read_u32_into(&seed, &mut seed_u32);
- // Convert the seed to `Wrapping<u32>` and zero-extend to `RAND_SIZE`.
- let mut seed_extended = [w(0); RAND_SIZE];
- for (x, y) in seed_extended.iter_mut().zip(seed_u32.iter()) {
- *x = w(*y);
- }
- Self::init(seed_extended, 2)
- }
-
- /// Create an ISAAC random number generator using an `u64` as seed.
- /// If `seed == 0` this will produce the same stream of random numbers as
- /// the reference implementation when used unseeded.
- fn seed_from_u64(seed: u64) -> Self {
- let mut key = [w(0); RAND_SIZE];
- key[0] = w(seed as u32);
- key[1] = w((seed >> 32) as u32);
- // Initialize with only one pass.
- // A second pass does not improve the quality here, because all of the
- // seed was already available in the first round.
- // Not doing the second pass has the small advantage that if
- // `seed == 0` this method produces exactly the same state as the
- // reference implementation when used unseeded.
- Self::init(key, 1)
- }
-
- fn from_rng<R: RngCore>(mut rng: R) -> Result<Self, Error> {
- // Custom `from_rng` implementation that fills a seed with the same size
- // as the entire state.
- let mut seed = [w(0u32); RAND_SIZE];
- unsafe {
- let ptr = seed.as_mut_ptr() as *mut u8;
-
- let slice = slice::from_raw_parts_mut(ptr, RAND_SIZE * 4);
- rng.try_fill_bytes(slice)?;
- }
- for i in seed.iter_mut() {
- *i = w(i.0.to_le());
- }
-
- Ok(Self::init(seed, 2))
- }
-}
-
-#[cfg(test)]
-mod test {
- use rand_core::{RngCore, SeedableRng};
- use super::IsaacRng;
-
- #[test]
- fn test_isaac_construction() {
- // Test that various construction techniques produce a working RNG.
- let seed = [1,0,0,0, 23,0,0,0, 200,1,0,0, 210,30,0,0,
- 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0];
- let mut rng1 = IsaacRng::from_seed(seed);
- assert_eq!(rng1.next_u32(), 2869442790);
-
- let mut rng2 = IsaacRng::from_rng(rng1).unwrap();
- assert_eq!(rng2.next_u32(), 3094074039);
- }
-
- #[test]
- fn test_isaac_true_values_32() {
- let seed = [1,0,0,0, 23,0,0,0, 200,1,0,0, 210,30,0,0,
- 57,48,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0];
- let mut rng1 = IsaacRng::from_seed(seed);
- let mut results = [0u32; 10];
- for i in results.iter_mut() { *i = rng1.next_u32(); }
- let expected = [
- 2558573138, 873787463, 263499565, 2103644246, 3595684709,
- 4203127393, 264982119, 2765226902, 2737944514, 3900253796];
- assert_eq!(results, expected);
-
- let seed = [57,48,0,0, 50,9,1,0, 49,212,0,0, 148,38,0,0,
- 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0];
- let mut rng2 = IsaacRng::from_seed(seed);
- // skip forward to the 10000th number
- for _ in 0..10000 { rng2.next_u32(); }
-
- for i in results.iter_mut() { *i = rng2.next_u32(); }
- let expected = [
- 3676831399, 3183332890, 2834741178, 3854698763, 2717568474,
- 1576568959, 3507990155, 179069555, 141456972, 2478885421];
- assert_eq!(results, expected);
- }
-
- #[test]
- fn test_isaac_true_values_64() {
- // As above, using little-endian versions of above values
- let seed = [1,0,0,0, 23,0,0,0, 200,1,0,0, 210,30,0,0,
- 57,48,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0];
- let mut rng = IsaacRng::from_seed(seed);
- let mut results = [0u64; 5];
- for i in results.iter_mut() { *i = rng.next_u64(); }
- let expected = [
- 3752888579798383186, 9035083239252078381,18052294697452424037,
- 11876559110374379111, 16751462502657800130];
- assert_eq!(results, expected);
- }
-
- #[test]
- fn test_isaac_true_bytes() {
- let seed = [1,0,0,0, 23,0,0,0, 200,1,0,0, 210,30,0,0,
- 57,48,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0];
- let mut rng = IsaacRng::from_seed(seed);
- let mut results = [0u8; 32];
- rng.fill_bytes(&mut results);
- // Same as first values in test_isaac_true_values as bytes in LE order
- let expected = [82, 186, 128, 152, 71, 240, 20, 52,
- 45, 175, 180, 15, 86, 16, 99, 125,
- 101, 203, 81, 214, 97, 162, 134, 250,
- 103, 78, 203, 15, 150, 3, 210, 164];
- assert_eq!(results, expected);
- }
-
- #[test]
- fn test_isaac_new_uninitialized() {
- // Compare the results from initializing `IsaacRng` with
- // `seed_from_u64(0)`, to make sure it is the same as the reference
- // implementation when used uninitialized.
- // Note: We only test the first 16 integers, not the full 256 of the
- // first block.
- let mut rng = IsaacRng::seed_from_u64(0);
- let mut results = [0u32; 16];
- for i in results.iter_mut() { *i = rng.next_u32(); }
- let expected: [u32; 16] = [
- 0x71D71FD2, 0xB54ADAE7, 0xD4788559, 0xC36129FA,
- 0x21DC1EA9, 0x3CB879CA, 0xD83B237F, 0xFA3CE5BD,
- 0x8D048509, 0xD82E9489, 0xDB452848, 0xCA20E846,
- 0x500F972E, 0x0EEFF940, 0x00D6B993, 0xBC12C17F];
- assert_eq!(results, expected);
- }
-
- #[test]
- fn test_isaac_clone() {
- let seed = [1,0,0,0, 23,0,0,0, 200,1,0,0, 210,30,0,0,
- 57,48,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0];
- let mut rng1 = IsaacRng::from_seed(seed);
- let mut rng2 = rng1.clone();
- for _ in 0..16 {
- assert_eq!(rng1.next_u32(), rng2.next_u32());
- }
- }
-
- #[test]
- #[cfg(feature="serde1")]
- fn test_isaac_serde() {
- use bincode;
- use std::io::{BufWriter, BufReader};
-
- let seed = [1,0,0,0, 23,0,0,0, 200,1,0,0, 210,30,0,0,
- 57,48,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0];
- let mut rng = IsaacRng::from_seed(seed);
-
- let buf: Vec<u8> = Vec::new();
- let mut buf = BufWriter::new(buf);
- bincode::serialize_into(&mut buf, &rng).expect("Could not serialize");
-
- let buf = buf.into_inner().unwrap();
- let mut read = BufReader::new(&buf[..]);
- let mut deserialized: IsaacRng = bincode::deserialize_from(&mut read).expect("Could not deserialize");
-
- for _ in 0..300 { // more than the 256 buffered results
- assert_eq!(rng.next_u32(), deserialized.next_u32());
- }
- }
-}
diff --git a/rand/rand_isaac/src/isaac64.rs b/rand/rand_isaac/src/isaac64.rs
deleted file mode 100644
index 2712762..0000000
--- a/rand/rand_isaac/src/isaac64.rs
+++ /dev/null
@@ -1,481 +0,0 @@
-// Copyright 2018 Developers of the Rand project.
-// Copyright 2013-2018 The Rust Project Developers.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-//! The ISAAC-64 random number generator.
-
-use core::{fmt, slice};
-use core::num::Wrapping as w;
-use rand_core::{RngCore, SeedableRng, Error, le};
-use rand_core::block::{BlockRngCore, BlockRng64};
-use isaac_array::IsaacArray;
-
-#[allow(non_camel_case_types)]
-type w64 = w<u64>;
-
-const RAND_SIZE_LEN: usize = 8;
-const RAND_SIZE: usize = 1 << RAND_SIZE_LEN;
-
-/// A random number generator that uses ISAAC-64, the 64-bit variant of the
-/// ISAAC algorithm.
-///
-/// ISAAC stands for "Indirection, Shift, Accumulate, Add, and Count" which are
-/// the principal bitwise operations employed. It is the most advanced of a
-/// series of array based random number generator designed by Robert Jenkins
-/// in 1996[^1].
-///
-/// ISAAC-64 is mostly similar to ISAAC. Because it operates on 64-bit integers
-/// instead of 32-bit, it uses twice as much memory to hold its state and
-/// results. Also it uses different constants for shifts and indirect indexing,
-/// optimized to give good results for 64bit arithmetic.
-///
-/// ISAAC-64 is notably fast and produces excellent quality random numbers for
-/// non-cryptographic applications.
-///
-/// In spite of being designed with cryptographic security in mind, ISAAC hasn't
-/// been stringently cryptanalyzed and thus cryptographers do not not
-/// consensually trust it to be secure. When looking for a secure RNG, prefer
-/// [`Hc128Rng`] instead, which, like ISAAC, is an array-based RNG and one of
-/// the stream-ciphers selected the by eSTREAM contest.
-///
-/// ## Overview of the ISAAC-64 algorithm:
-/// (in pseudo-code)
-///
-/// ```text
-/// Input: a, b, c, s[256] // state
-/// Output: r[256] // results
-///
-/// mix(a,i) = !(a ^ a << 21) if i = 0 mod 4
-/// a ^ a >> 5 if i = 1 mod 4
-/// a ^ a << 12 if i = 2 mod 4
-/// a ^ a >> 33 if i = 3 mod 4
-///
-/// c = c + 1
-/// b = b + c
-///
-/// for i in 0..256 {
-/// x = s_[i]
-/// a = mix(a,i) + s[i+128 mod 256]
-/// y = a + b + s[x>>3 mod 256]
-/// s[i] = y
-/// b = x + s[y>>11 mod 256]
-/// r[i] = b
-/// }
-/// ```
-///
-/// This implementation uses [`BlockRng64`] to implement the [`RngCore`] methods.
-///
-/// See for more information the documentation of [`IsaacRng`].
-///
-/// [^1]: Bob Jenkins, [*ISAAC and RC4*](
-/// http://burtleburtle.net/bob/rand/isaac.html)
-///
-/// [`IsaacRng`]: ../isaac/struct.IsaacRng.html
-/// [`Hc128Rng`]: ../../rand_hc/struct.Hc128Rng.html
-/// [`BlockRng64`]: ../../rand_core/block/struct.BlockRng64.html
-/// [`RngCore`]: ../../rand_core/trait.RngCore.html
-#[derive(Clone, Debug)]
-#[cfg_attr(feature="serde1", derive(Serialize, Deserialize))]
-pub struct Isaac64Rng(BlockRng64<Isaac64Core>);
-
-impl RngCore for Isaac64Rng {
- #[inline(always)]
- fn next_u32(&mut self) -> u32 {
- self.0.next_u32()
- }
-
- #[inline(always)]
- fn next_u64(&mut self) -> u64 {
- self.0.next_u64()
- }
-
- fn fill_bytes(&mut self, dest: &mut [u8]) {
- self.0.fill_bytes(dest)
- }
-
- fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), Error> {
- self.0.try_fill_bytes(dest)
- }
-}
-
-impl SeedableRng for Isaac64Rng {
- type Seed = <Isaac64Core as SeedableRng>::Seed;
-
- fn from_seed(seed: Self::Seed) -> Self {
- Isaac64Rng(BlockRng64::<Isaac64Core>::from_seed(seed))
- }
-
- /// Create an ISAAC random number generator using an `u64` as seed.
- /// If `seed == 0` this will produce the same stream of random numbers as
- /// the reference implementation when used unseeded.
- fn seed_from_u64(seed: u64) -> Self {
- Isaac64Rng(BlockRng64::<Isaac64Core>::seed_from_u64(seed))
- }
-
- fn from_rng<S: RngCore>(rng: S) -> Result<Self, Error> {
- BlockRng64::<Isaac64Core>::from_rng(rng).map(|rng| Isaac64Rng(rng))
- }
-}
-
-impl Isaac64Rng {
- /// Create an ISAAC-64 random number generator using an `u64` as seed.
- /// If `seed == 0` this will produce the same stream of random numbers as
- /// the reference implementation when used unseeded.
- #[deprecated(since="0.6.0", note="use SeedableRng::seed_from_u64 instead")]
- pub fn new_from_u64(seed: u64) -> Self {
- Self::seed_from_u64(seed)
- }
-}
-
-/// The core of `Isaac64Rng`, used with `BlockRng`.
-#[derive(Clone)]
-#[cfg_attr(feature="serde1", derive(Serialize, Deserialize))]
-pub struct Isaac64Core {
- #[cfg_attr(feature="serde1",serde(with="super::isaac_array::isaac_array_serde"))]
- mem: [w64; RAND_SIZE],
- a: w64,
- b: w64,
- c: w64,
-}
-
-// Custom Debug implementation that does not expose the internal state
-impl fmt::Debug for Isaac64Core {
- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
- write!(f, "Isaac64Core {{}}")
- }
-}
-
-impl BlockRngCore for Isaac64Core {
- type Item = u64;
- type Results = IsaacArray<Self::Item>;
-
- /// Refills the output buffer, `results`. See also the pseudocode desciption
- /// of the algorithm in the [`Isaac64Rng`] documentation.
- ///
- /// Optimisations used (similar to the reference implementation):
- ///
- /// - The loop is unrolled 4 times, once for every constant of mix().
- /// - The contents of the main loop are moved to a function `rngstep`, to
- /// reduce code duplication.
- /// - We use local variables for a and b, which helps with optimisations.
- /// - We split the main loop in two, one that operates over 0..128 and one
- /// over 128..256. This way we can optimise out the addition and modulus
- /// from `s[i+128 mod 256]`.
- /// - We maintain one index `i` and add `m` or `m2` as base (m2 for the
- /// `s[i+128 mod 256]`), relying on the optimizer to turn it into pointer
- /// arithmetic.
- /// - We fill `results` backwards. The reference implementation reads values
- /// from `results` in reverse. We read them in the normal direction, to
- /// make `fill_bytes` a memcopy. To maintain compatibility we fill in
- /// reverse.
- ///
- /// [`Isaac64Rng`]: struct.Isaac64Rng.html
- fn generate(&mut self, results: &mut IsaacArray<Self::Item>) {
- self.c += w(1);
- // abbreviations
- let mut a = self.a;
- let mut b = self.b + self.c;
- const MIDPOINT: usize = RAND_SIZE / 2;
-
- #[inline]
- fn ind(mem:&[w64; RAND_SIZE], v: w64, amount: usize) -> w64 {
- let index = (v >> amount).0 as usize % RAND_SIZE;
- mem[index]
- }
-
- #[inline]
- fn rngstep(mem: &mut [w64; RAND_SIZE],
- results: &mut [u64; RAND_SIZE],
- mix: w64,
- a: &mut w64,
- b: &mut w64,
- base: usize,
- m: usize,
- m2: usize) {
- let x = mem[base + m];
- *a = mix + mem[base + m2];
- let y = *a + *b + ind(&mem, x, 3);
- mem[base + m] = y;
- *b = x + ind(&mem, y, 3 + RAND_SIZE_LEN);
- results[RAND_SIZE - 1 - base - m] = (*b).0;
- }
-
- let mut m = 0;
- let mut m2 = MIDPOINT;
- for i in (0..MIDPOINT/4).map(|i| i * 4) {
- rngstep(&mut self.mem, results, !(a ^ (a << 21)), &mut a, &mut b, i + 0, m, m2);
- rngstep(&mut self.mem, results, a ^ (a >> 5 ), &mut a, &mut b, i + 1, m, m2);
- rngstep(&mut self.mem, results, a ^ (a << 12), &mut a, &mut b, i + 2, m, m2);
- rngstep(&mut self.mem, results, a ^ (a >> 33), &mut a, &mut b, i + 3, m, m2);
- }
-
- m = MIDPOINT;
- m2 = 0;
- for i in (0..MIDPOINT/4).map(|i| i * 4) {
- rngstep(&mut self.mem, results, !(a ^ (a << 21)), &mut a, &mut b, i + 0, m, m2);
- rngstep(&mut self.mem, results, a ^ (a >> 5 ), &mut a, &mut b, i + 1, m, m2);
- rngstep(&mut self.mem, results, a ^ (a << 12), &mut a, &mut b, i + 2, m, m2);
- rngstep(&mut self.mem, results, a ^ (a >> 33), &mut a, &mut b, i + 3, m, m2);
- }
-
- self.a = a;
- self.b = b;
- }
-}
-
-impl Isaac64Core {
- /// Create a new ISAAC-64 random number generator.
- fn init(mut mem: [w64; RAND_SIZE], rounds: u32) -> Self {
- fn mix(a: &mut w64, b: &mut w64, c: &mut w64, d: &mut w64,
- e: &mut w64, f: &mut w64, g: &mut w64, h: &mut w64) {
- *a -= *e; *f ^= *h >> 9; *h += *a;
- *b -= *f; *g ^= *a << 9; *a += *b;
- *c -= *g; *h ^= *b >> 23; *b += *c;
- *d -= *h; *a ^= *c << 15; *c += *d;
- *e -= *a; *b ^= *d >> 14; *d += *e;
- *f -= *b; *c ^= *e << 20; *e += *f;
- *g -= *c; *d ^= *f >> 17; *f += *g;
- *h -= *d; *e ^= *g << 14; *g += *h;
- }
-
- // These numbers are the result of initializing a...h with the
- // fractional part of the golden ratio in binary (0x9e3779b97f4a7c13)
- // and applying mix() 4 times.
- let mut a = w(0x647c4677a2884b7c);
- let mut b = w(0xb9f8b322c73ac862);
- let mut c = w(0x8c0ea5053d4712a0);
- let mut d = w(0xb29b2e824a595524);
- let mut e = w(0x82f053db8355e0ce);
- let mut f = w(0x48fe4a0fa5a09315);
- let mut g = w(0xae985bf2cbfc89ed);
- let mut h = w(0x98f5704f6c44c0ab);
-
- // Normally this should do two passes, to make all of the seed effect
- // all of `mem`
- for _ in 0..rounds {
- for i in (0..RAND_SIZE/8).map(|i| i * 8) {
- a += mem[i ]; b += mem[i+1];
- c += mem[i+2]; d += mem[i+3];
- e += mem[i+4]; f += mem[i+5];
- g += mem[i+6]; h += mem[i+7];
- mix(&mut a, &mut b, &mut c, &mut d,
- &mut e, &mut f, &mut g, &mut h);
- mem[i ] = a; mem[i+1] = b;
- mem[i+2] = c; mem[i+3] = d;
- mem[i+4] = e; mem[i+5] = f;
- mem[i+6] = g; mem[i+7] = h;
- }
- }
-
- Self { mem, a: w(0), b: w(0), c: w(0) }
- }
-
- /// Create an ISAAC-64 random number generator using an `u64` as seed.
- /// If `seed == 0` this will produce the same stream of random numbers as
- /// the reference implementation when used unseeded.
- #[deprecated(since="0.6.0", note="use SeedableRng::seed_from_u64 instead")]
- pub fn new_from_u64(seed: u64) -> Self {
- Self::seed_from_u64(seed)
- }
-}
-
-impl SeedableRng for Isaac64Core {
- type Seed = [u8; 32];
-
- fn from_seed(seed: Self::Seed) -> Self {
- let mut seed_u64 = [0u64; 4];
- le::read_u64_into(&seed, &mut seed_u64);
- // Convert the seed to `Wrapping<u64>` and zero-extend to `RAND_SIZE`.
- let mut seed_extended = [w(0); RAND_SIZE];
- for (x, y) in seed_extended.iter_mut().zip(seed_u64.iter()) {
- *x = w(*y);
- }
- Self::init(seed_extended, 2)
- }
-
- fn seed_from_u64(seed: u64) -> Self {
- let mut key = [w(0); RAND_SIZE];
- key[0] = w(seed);
- // Initialize with only one pass.
- // A second pass does not improve the quality here, because all of the
- // seed was already available in the first round.
- // Not doing the second pass has the small advantage that if
- // `seed == 0` this method produces exactly the same state as the
- // reference implementation when used unseeded.
- Self::init(key, 1)
- }
-
- fn from_rng<R: RngCore>(mut rng: R) -> Result<Self, Error> {
- // Custom `from_rng` implementation that fills a seed with the same size
- // as the entire state.
- let mut seed = [w(0u64); RAND_SIZE];
- unsafe {
- let ptr = seed.as_mut_ptr() as *mut u8;
- let slice = slice::from_raw_parts_mut(ptr, RAND_SIZE * 8);
- rng.try_fill_bytes(slice)?;
- }
- for i in seed.iter_mut() {
- *i = w(i.0.to_le());
- }
-
- Ok(Self::init(seed, 2))
- }
-}
-
-#[cfg(test)]
-mod test {
- use rand_core::{RngCore, SeedableRng};
- use super::Isaac64Rng;
-
- #[test]
- fn test_isaac64_construction() {
- // Test that various construction techniques produce a working RNG.
- let seed = [1,0,0,0, 23,0,0,0, 200,1,0,0, 210,30,0,0,
- 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0];
- let mut rng1 = Isaac64Rng::from_seed(seed);
- assert_eq!(rng1.next_u64(), 14964555543728284049);
-
- let mut rng2 = Isaac64Rng::from_rng(rng1).unwrap();
- assert_eq!(rng2.next_u64(), 919595328260451758);
- }
-
- #[test]
- fn test_isaac64_true_values_64() {
- let seed = [1,0,0,0, 0,0,0,0, 23,0,0,0, 0,0,0,0,
- 200,1,0,0, 0,0,0,0, 210,30,0,0, 0,0,0,0];
- let mut rng1 = Isaac64Rng::from_seed(seed);
- let mut results = [0u64; 10];
- for i in results.iter_mut() { *i = rng1.next_u64(); }
- let expected = [
- 15071495833797886820, 7720185633435529318,
- 10836773366498097981, 5414053799617603544,
- 12890513357046278984, 17001051845652595546,
- 9240803642279356310, 12558996012687158051,
- 14673053937227185542, 1677046725350116783];
- assert_eq!(results, expected);
-
- let seed = [57,48,0,0, 0,0,0,0, 50,9,1,0, 0,0,0,0,
- 49,212,0,0, 0,0,0,0, 148,38,0,0, 0,0,0,0];
- let mut rng2 = Isaac64Rng::from_seed(seed);
- // skip forward to the 10000th number
- for _ in 0..10000 { rng2.next_u64(); }
-
- for i in results.iter_mut() { *i = rng2.next_u64(); }
- let expected = [
- 18143823860592706164, 8491801882678285927, 2699425367717515619,
- 17196852593171130876, 2606123525235546165, 15790932315217671084,
- 596345674630742204, 9947027391921273664, 11788097613744130851,
- 10391409374914919106];
- assert_eq!(results, expected);
- }
-
- #[test]
- fn test_isaac64_true_values_32() {
- let seed = [1,0,0,0, 0,0,0,0, 23,0,0,0, 0,0,0,0,
- 200,1,0,0, 0,0,0,0, 210,30,0,0, 0,0,0,0];
- let mut rng = Isaac64Rng::from_seed(seed);
- let mut results = [0u32; 12];
- for i in results.iter_mut() { *i = rng.next_u32(); }
- // Subset of above values, as an LE u32 sequence
- let expected = [
- 3477963620, 3509106075,
- 687845478, 1797495790,
- 227048253, 2523132918,
- 4044335064, 1260557630,
- 4079741768, 3001306521,
- 69157722, 3958365844];
- assert_eq!(results, expected);
- }
-
- #[test]
- fn test_isaac64_true_values_mixed() {
- let seed = [1,0,0,0, 0,0,0,0, 23,0,0,0, 0,0,0,0,
- 200,1,0,0, 0,0,0,0, 210,30,0,0, 0,0,0,0];
- let mut rng = Isaac64Rng::from_seed(seed);
- // Test alternating between `next_u64` and `next_u32` works as expected.
- // Values are the same as `test_isaac64_true_values` and
- // `test_isaac64_true_values_32`.
- assert_eq!(rng.next_u64(), 15071495833797886820);
- assert_eq!(rng.next_u32(), 687845478);
- assert_eq!(rng.next_u32(), 1797495790);
- assert_eq!(rng.next_u64(), 10836773366498097981);
- assert_eq!(rng.next_u32(), 4044335064);
- // Skip one u32
- assert_eq!(rng.next_u64(), 12890513357046278984);
- assert_eq!(rng.next_u32(), 69157722);
- }
-
- #[test]
- fn test_isaac64_true_bytes() {
- let seed = [1,0,0,0, 0,0,0,0, 23,0,0,0, 0,0,0,0,
- 200,1,0,0, 0,0,0,0, 210,30,0,0, 0,0,0,0];
- let mut rng = Isaac64Rng::from_seed(seed);
- let mut results = [0u8; 32];
- rng.fill_bytes(&mut results);
- // Same as first values in test_isaac64_true_values as bytes in LE order
- let expected = [100, 131, 77, 207, 155, 181, 40, 209,
- 102, 176, 255, 40, 238, 155, 35, 107,
- 61, 123, 136, 13, 246, 243, 99, 150,
- 216, 167, 15, 241, 62, 149, 34, 75];
- assert_eq!(results, expected);
- }
-
- #[test]
- fn test_isaac64_new_uninitialized() {
- // Compare the results from initializing `IsaacRng` with
- // `seed_from_u64(0)`, to make sure it is the same as the reference
- // implementation when used uninitialized.
- // Note: We only test the first 16 integers, not the full 256 of the
- // first block.
- let mut rng = Isaac64Rng::seed_from_u64(0);
- let mut results = [0u64; 16];
- for i in results.iter_mut() { *i = rng.next_u64(); }
- let expected: [u64; 16] = [
- 0xF67DFBA498E4937C, 0x84A5066A9204F380, 0xFEE34BD5F5514DBB,
- 0x4D1664739B8F80D6, 0x8607459AB52A14AA, 0x0E78BC5A98529E49,
- 0xFE5332822AD13777, 0x556C27525E33D01A, 0x08643CA615F3149F,
- 0xD0771FAF3CB04714, 0x30E86F68A37B008D, 0x3074EBC0488A3ADF,
- 0x270645EA7A2790BC, 0x5601A0A8D3763C6A, 0x2F83071F53F325DD,
- 0xB9090F3D42D2D2EA];
- assert_eq!(results, expected);
- }
-
- #[test]
- fn test_isaac64_clone() {
- let seed = [1,0,0,0, 0,0,0,0, 23,0,0,0, 0,0,0,0,
- 200,1,0,0, 0,0,0,0, 210,30,0,0, 0,0,0,0];
- let mut rng1 = Isaac64Rng::from_seed(seed);
- let mut rng2 = rng1.clone();
- for _ in 0..16 {
- assert_eq!(rng1.next_u64(), rng2.next_u64());
- }
- }
-
- #[test]
- #[cfg(feature="serde1")]
- fn test_isaac64_serde() {
- use bincode;
- use std::io::{BufWriter, BufReader};
-
- let seed = [1,0,0,0, 23,0,0,0, 200,1,0,0, 210,30,0,0,
- 57,48,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0];
- let mut rng = Isaac64Rng::from_seed(seed);
-
- let buf: Vec<u8> = Vec::new();
- let mut buf = BufWriter::new(buf);
- bincode::serialize_into(&mut buf, &rng).expect("Could not serialize");
-
- let buf = buf.into_inner().unwrap();
- let mut read = BufReader::new(&buf[..]);
- let mut deserialized: Isaac64Rng = bincode::deserialize_from(&mut read).expect("Could not deserialize");
-
- for _ in 0..300 { // more than the 256 buffered results
- assert_eq!(rng.next_u64(), deserialized.next_u64());
- }
- }
-}
diff --git a/rand/rand_isaac/src/isaac_array.rs b/rand/rand_isaac/src/isaac_array.rs
deleted file mode 100644
index 0fa6147..0000000
--- a/rand/rand_isaac/src/isaac_array.rs
+++ /dev/null
@@ -1,136 +0,0 @@
-// Copyright 2018 Developers of the Rand project.
-// Copyright 2017-2018 The Rust Project Developers.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-//! ISAAC helper functions for 256-element arrays.
-
-// Terrible workaround because arrays with more than 32 elements do not
-// implement `AsRef`, `Default`, `Serialize`, `Deserialize`, or any other
-// traits for that matter.
-
-#[cfg(feature="serde1")] use serde::{Serialize, Deserialize};
-
-const RAND_SIZE_LEN: usize = 8;
-const RAND_SIZE: usize = 1 << RAND_SIZE_LEN;
-
-
-#[derive(Copy, Clone)]
-#[allow(missing_debug_implementations)]
-#[cfg_attr(feature="serde1", derive(Serialize, Deserialize))]
-pub struct IsaacArray<T> {
- #[cfg_attr(feature="serde1",serde(with="isaac_array_serde"))]
- #[cfg_attr(feature="serde1", serde(bound(
- serialize = "T: Serialize",
- deserialize = "T: Deserialize<'de> + Copy + Default")))]
- inner: [T; RAND_SIZE]
-}
-
-impl<T> ::core::convert::AsRef<[T]> for IsaacArray<T> {
- #[inline(always)]
- fn as_ref(&self) -> &[T] {
- &self.inner[..]
- }
-}
-
-impl<T> ::core::convert::AsMut<[T]> for IsaacArray<T> {
- #[inline(always)]
- fn as_mut(&mut self) -> &mut [T] {
- &mut self.inner[..]
- }
-}
-
-impl<T> ::core::ops::Deref for IsaacArray<T> {
- type Target = [T; RAND_SIZE];
- #[inline(always)]
- fn deref(&self) -> &Self::Target {
- &self.inner
- }
-}
-
-impl<T> ::core::ops::DerefMut for IsaacArray<T> {
- #[inline(always)]
- fn deref_mut(&mut self) -> &mut [T; RAND_SIZE] {
- &mut self.inner
- }
-}
-
-impl<T> ::core::default::Default for IsaacArray<T> where T: Copy + Default {
- fn default() -> IsaacArray<T> {
- IsaacArray { inner: [T::default(); RAND_SIZE] }
- }
-}
-
-
-#[cfg(feature="serde1")]
-pub(super) mod isaac_array_serde {
- const RAND_SIZE_LEN: usize = 8;
- const RAND_SIZE: usize = 1 << RAND_SIZE_LEN;
-
- use serde::{Deserialize, Deserializer, Serialize, Serializer};
- use serde::de::{Visitor,SeqAccess};
- use serde::de;
-
- use core::fmt;
-
- pub fn serialize<T, S>(arr: &[T;RAND_SIZE], ser: S) -> Result<S::Ok, S::Error>
- where
- T: Serialize,
- S: Serializer
- {
- use serde::ser::SerializeTuple;
-
- let mut seq = ser.serialize_tuple(RAND_SIZE)?;
-
- for e in arr.iter() {
- seq.serialize_element(&e)?;
- }
-
- seq.end()
- }
-
- #[inline]
- pub fn deserialize<'de, T, D>(de: D) -> Result<[T;RAND_SIZE], D::Error>
- where
- T: Deserialize<'de>+Default+Copy,
- D: Deserializer<'de>,
- {
- use core::marker::PhantomData;
- struct ArrayVisitor<T> {
- _pd: PhantomData<T>,
- };
- impl<'de,T> Visitor<'de> for ArrayVisitor<T>
- where
- T: Deserialize<'de>+Default+Copy
- {
- type Value = [T; RAND_SIZE];
-
- fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- formatter.write_str("Isaac state array")
- }
-
- #[inline]
- fn visit_seq<A>(self, mut seq: A) -> Result<[T; RAND_SIZE], A::Error>
- where
- A: SeqAccess<'de>,
- {
- let mut out = [Default::default();RAND_SIZE];
-
- for i in 0..RAND_SIZE {
- match seq.next_element()? {
- Some(val) => out[i] = val,
- None => return Err(de::Error::invalid_length(i, &self)),
- };
- }
-
- Ok(out)
- }
- }
-
- de.deserialize_tuple(RAND_SIZE, ArrayVisitor{_pd: PhantomData})
- }
-}
diff --git a/rand/rand_isaac/src/lib.rs b/rand/rand_isaac/src/lib.rs
deleted file mode 100644
index 285d631..0000000
--- a/rand/rand_isaac/src/lib.rs
+++ /dev/null
@@ -1,36 +0,0 @@
-// Copyright 2018 Developers of the Rand project.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-//! The ISAAC and ISAAC-64 random number generators.
-
-#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk.png",
- html_favicon_url = "https://www.rust-lang.org/favicon.ico",
- html_root_url = "https://rust-random.github.io/rand/")]
-
-#![deny(missing_docs)]
-#![deny(missing_debug_implementations)]
-#![doc(test(attr(allow(unused_variables), deny(warnings))))]
-
-#![cfg_attr(not(all(feature="serde1", test)), no_std)]
-
-pub extern crate rand_core;
-
-#[cfg(feature="serde1")] extern crate serde;
-#[cfg(feature="serde1")] #[macro_use] extern crate serde_derive;
-
-// To test serialization we need bincode and the standard library
-#[cfg(all(feature="serde1", test))] extern crate bincode;
-#[cfg(all(feature="serde1", test))] extern crate std as core;
-
-pub mod isaac;
-pub mod isaac64;
-
-mod isaac_array;
-
-pub use self::isaac::IsaacRng;
-pub use self::isaac64::Isaac64Rng;
diff --git a/rand/rand_os/CHANGELOG.md b/rand/rand_os/CHANGELOG.md
deleted file mode 100644
index 459f7bd..0000000
--- a/rand/rand_os/CHANGELOG.md
+++ /dev/null
@@ -1,13 +0,0 @@
-# Changelog
-All notable changes to this project will be documented in this file.
-
-The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
-and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
-
-
-## [0.1.1] - 2019-01-08
-### Additions
-- Add support for x86_64-fortanix-unknown-sgx target (#670)
-
-## [0.1.0] - 2019-01-04
-Initial release.
diff --git a/rand/rand_os/COPYRIGHT b/rand/rand_os/COPYRIGHT
deleted file mode 100644
index 468d907..0000000
--- a/rand/rand_os/COPYRIGHT
+++ /dev/null
@@ -1,12 +0,0 @@
-Copyrights in the Rand project are retained by their contributors. No
-copyright assignment is required to contribute to the Rand project.
-
-For full authorship information, see the version control history.
-
-Except as otherwise noted (below and/or in individual files), Rand is
-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.
-
-The Rand project includes code from the Rust project
-published under these same licenses.
diff --git a/rand/rand_os/Cargo.toml b/rand/rand_os/Cargo.toml
deleted file mode 100644
index 2f9224a..0000000
--- a/rand/rand_os/Cargo.toml
+++ /dev/null
@@ -1,38 +0,0 @@
-[package]
-name = "rand_os"
-version = "0.1.1"
-authors = ["The Rand Project Developers"]
-license = "MIT/Apache-2.0"
-readme = "README.md"
-repository = "https://github.com/rust-random/rand"
-documentation = "https://docs.rs/rand_os"
-homepage = "https://crates.io/crates/rand_os"
-description = "OS backed Random Number Generator"
-keywords = ["random", "rng", "os"]
-
-[badges]
-travis-ci = { repository = "rust-random/rand" }
-appveyor = { repository = "rust-random/rand" }
-
-[dependencies]
-rand_core = { path = "../rand_core", version = "0.3", default-features = false }
-log = { version = "0.4", optional = true }
-
-[target.'cfg(unix)'.dependencies]
-libc = "0.2"
-
-[target.'cfg(windows)'.dependencies]
-winapi = { version = "0.3", features = ["minwindef", "ntsecapi", "winnt"] }
-
-[target.'cfg(target_os = "cloudabi")'.dependencies]
-cloudabi = "0.0.3"
-
-[target.'cfg(target_os = "fuchsia")'.dependencies]
-fuchsia-zircon = "0.3.2"
-
-[target.wasm32-unknown-unknown.dependencies]
-wasm-bindgen = { version = "0.2.12", optional = true }
-stdweb = { version = "0.4", optional = true }
-
-[target.'cfg(target_env = "sgx")'.dependencies]
-rdrand = "0.4.0"
diff --git a/rand/rand_os/LICENSE-APACHE b/rand/rand_os/LICENSE-APACHE
deleted file mode 100644
index 17d7468..0000000
--- a/rand/rand_os/LICENSE-APACHE
+++ /dev/null
@@ -1,201 +0,0 @@
- Apache License
- Version 2.0, January 2004
- https://www.apache.org/licenses/
-
-TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
-1. Definitions.
-
- "License" shall mean the terms and conditions for use, reproduction,
- and distribution as defined by Sections 1 through 9 of this document.
-
- "Licensor" shall mean the copyright owner or entity authorized by
- the copyright owner that is granting the License.
-
- "Legal Entity" shall mean the union of the acting entity and all
- other entities that control, are controlled by, or are under common
- control with that entity. For the purposes of this definition,
- "control" means (i) the power, direct or indirect, to cause the
- direction or management of such entity, whether by contract or
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
- outstanding shares, or (iii) beneficial ownership of such entity.
-
- "You" (or "Your") shall mean an individual or Legal Entity
- exercising permissions granted by this License.
-
- "Source" form shall mean the preferred form for making modifications,
- including but not limited to software source code, documentation
- source, and configuration files.
-
- "Object" form shall mean any form resulting from mechanical
- transformation or translation of a Source form, including but
- not limited to compiled object code, generated documentation,
- and conversions to other media types.
-
- "Work" shall mean the work of authorship, whether in Source or
- Object form, made available under the License, as indicated by a
- copyright notice that is included in or attached to the work
- (an example is provided in the Appendix below).
-
- "Derivative Works" shall mean any work, whether in Source or Object
- form, that is based on (or derived from) the Work and for which the
- editorial revisions, annotations, elaborations, or other modifications
- represent, as a whole, an original work of authorship. For the purposes
- of this License, Derivative Works shall not include works that remain
- separable from, or merely link (or bind by name) to the interfaces of,
- the Work and Derivative Works thereof.
-
- "Contribution" shall mean any work of authorship, including
- the original version of the Work and any modifications or additions
- to that Work or Derivative Works thereof, that is intentionally
- submitted to Licensor for inclusion in the Work by the copyright owner
- or by an individual or Legal Entity authorized to submit on behalf of
- the copyright owner. For the purposes of this definition, "submitted"
- means any form of electronic, verbal, or written communication sent
- to the Licensor or its representatives, including but not limited to
- communication on electronic mailing lists, source code control systems,
- and issue tracking systems that are managed by, or on behalf of, the
- Licensor for the purpose of discussing and improving the Work, but
- excluding communication that is conspicuously marked or otherwise
- designated in writing by the copyright owner as "Not a Contribution."
-
- "Contributor" shall mean Licensor and any individual or Legal Entity
- on behalf of whom a Contribution has been received by Licensor and
- subsequently incorporated within the Work.
-
-2. Grant of Copyright License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- copyright license to reproduce, prepare Derivative Works of,
- publicly display, publicly perform, sublicense, and distribute the
- Work and such Derivative Works in Source or Object form.
-
-3. Grant of Patent License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- (except as stated in this section) patent license to make, have made,
- use, offer to sell, sell, import, and otherwise transfer the Work,
- where such license applies only to those patent claims licensable
- by such Contributor that are necessarily infringed by their
- Contribution(s) alone or by combination of their Contribution(s)
- with the Work to which such Contribution(s) was submitted. If You
- institute patent litigation against any entity (including a
- cross-claim or counterclaim in a lawsuit) alleging that the Work
- or a Contribution incorporated within the Work constitutes direct
- or contributory patent infringement, then any patent licenses
- granted to You under this License for that Work shall terminate
- as of the date such litigation is filed.
-
-4. Redistribution. You may reproduce and distribute copies of the
- Work or Derivative Works thereof in any medium, with or without
- modifications, and in Source or Object form, provided that You
- meet the following conditions:
-
- (a) You must give any other recipients of the Work or
- Derivative Works a copy of this License; and
-
- (b) You must cause any modified files to carry prominent notices
- stating that You changed the files; and
-
- (c) You must retain, in the Source form of any Derivative Works
- that You distribute, all copyright, patent, trademark, and
- attribution notices from the Source form of the Work,
- excluding those notices that do not pertain to any part of
- the Derivative Works; and
-
- (d) If the Work includes a "NOTICE" text file as part of its
- distribution, then any Derivative Works that You distribute must
- include a readable copy of the attribution notices contained
- within such NOTICE file, excluding those notices that do not
- pertain to any part of the Derivative Works, in at least one
- of the following places: within a NOTICE text file distributed
- as part of the Derivative Works; within the Source form or
- documentation, if provided along with the Derivative Works; or,
- within a display generated by the Derivative Works, if and
- wherever such third-party notices normally appear. The contents
- of the NOTICE file are for informational purposes only and
- do not modify the License. You may add Your own attribution
- notices within Derivative Works that You distribute, alongside
- or as an addendum to the NOTICE text from the Work, provided
- that such additional attribution notices cannot be construed
- as modifying the License.
-
- You may add Your own copyright statement to Your modifications and
- may provide additional or different license terms and conditions
- for use, reproduction, or distribution of Your modifications, or
- for any such Derivative Works as a whole, provided Your use,
- reproduction, and distribution of the Work otherwise complies with
- the conditions stated in this License.
-
-5. Submission of Contributions. Unless You explicitly state otherwise,
- any Contribution intentionally submitted for inclusion in the Work
- by You to the Licensor shall be under the terms and conditions of
- this License, without any additional terms or conditions.
- Notwithstanding the above, nothing herein shall supersede or modify
- the terms of any separate license agreement you may have executed
- with Licensor regarding such Contributions.
-
-6. Trademarks. This License does not grant permission to use the trade
- names, trademarks, service marks, or product names of the Licensor,
- except as required for reasonable and customary use in describing the
- origin of the Work and reproducing the content of the NOTICE file.
-
-7. Disclaimer of Warranty. Unless required by applicable law or
- agreed to in writing, Licensor provides the Work (and each
- Contributor provides its Contributions) on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- implied, including, without limitation, any warranties or conditions
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
- PARTICULAR PURPOSE. You are solely responsible for determining the
- appropriateness of using or redistributing the Work and assume any
- risks associated with Your exercise of permissions under this License.
-
-8. Limitation of Liability. In no event and under no legal theory,
- whether in tort (including negligence), contract, or otherwise,
- unless required by applicable law (such as deliberate and grossly
- negligent acts) or agreed to in writing, shall any Contributor be
- liable to You for damages, including any direct, indirect, special,
- incidental, or consequential damages of any character arising as a
- result of this License or out of the use or inability to use the
- Work (including but not limited to damages for loss of goodwill,
- work stoppage, computer failure or malfunction, or any and all
- other commercial damages or losses), even if such Contributor
- has been advised of the possibility of such damages.
-
-9. Accepting Warranty or Additional Liability. While redistributing
- the Work or Derivative Works thereof, You may choose to offer,
- and charge a fee for, acceptance of support, warranty, indemnity,
- or other liability obligations and/or rights consistent with this
- License. However, in accepting such obligations, You may act only
- on Your own behalf and on Your sole responsibility, not on behalf
- of any other Contributor, and only if You agree to indemnify,
- defend, and hold each Contributor harmless for any liability
- incurred by, or claims asserted against, such Contributor by reason
- of your accepting any such warranty or additional liability.
-
-END OF TERMS AND CONDITIONS
-
-APPENDIX: How to apply the Apache License to your work.
-
- To apply the Apache License to your work, attach the following
- boilerplate notice, with the fields enclosed by brackets "[]"
- replaced with your own identifying information. (Don't include
- the brackets!) The text should be enclosed in the appropriate
- comment syntax for the file format. We also recommend that a
- file or class name and description of purpose be included on the
- same "printed page" as the copyright notice for easier
- identification within third-party archives.
-
-Copyright [yyyy] [name of copyright owner]
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
- https://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
diff --git a/rand/rand_os/LICENSE-MIT b/rand/rand_os/LICENSE-MIT
deleted file mode 100644
index d93b5ba..0000000
--- a/rand/rand_os/LICENSE-MIT
+++ /dev/null
@@ -1,26 +0,0 @@
-Copyright 2018 Developers of the Rand project
-Copyright (c) 2014 The Rust Project Developers
-
-Permission is hereby granted, free of charge, to any
-person obtaining a copy of this software and associated
-documentation files (the "Software"), to deal in the
-Software without restriction, including without
-limitation the rights to use, copy, modify, merge,
-publish, distribute, sublicense, and/or sell copies of
-the Software, and to permit persons to whom the Software
-is furnished to do so, subject to the following
-conditions:
-
-The above copyright notice and this permission notice
-shall be included in all copies or substantial portions
-of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
-ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
-TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
-PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
-SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
-CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
-IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
-DEALINGS IN THE SOFTWARE.
diff --git a/rand/rand_os/README.md b/rand/rand_os/README.md
deleted file mode 100644
index 4f48b63..0000000
--- a/rand/rand_os/README.md
+++ /dev/null
@@ -1,33 +0,0 @@
-# rand_os
-
-[![Build Status](https://travis-ci.org/rust-random/rand.svg?branch=master)](https://travis-ci.org/rust-random/rand)
-[![Build Status](https://ci.appveyor.com/api/projects/status/github/rust-random/rand?svg=true)](https://ci.appveyor.com/project/rust-random/rand)
-[![Latest version](https://img.shields.io/crates/v/rand_os.svg)](https://crates.io/crates/rand_os)
-[![Book](https://img.shields.io/badge/book-master-yellow.svg)](https://rust-random.github.io/book/)
-[![API](https://img.shields.io/badge/api-master-yellow.svg)](https://rust-random.github.io/rand/rand_os)
-[![API](https://docs.rs/rand_os/badge.svg)](https://docs.rs/rand_os)
-[![Minimum rustc version](https://img.shields.io/badge/rustc-1.22+-lightgray.svg)](https://github.com/rust-random/rand#rust-version-requirements)
-
-A random number generator that retrieves randomness straight from the
-operating system.
-
-This crate depends on [rand_core](https://crates.io/crates/rand_core) and is
-part of the [Rand project](https://github.com/rust-random/rand).
-
-This crate aims to support all of Rust's `std` platforms with a system-provided
-entropy source. Unlike other Rand crates, this crate does not support `no_std`
-(handling this gracefully is a current discussion topic).
-
-Links:
-
-- [API documentation (master)](https://rust-random.github.io/rand/rand_os)
-- [API documentation (docs.rs)](https://docs.rs/rand_os)
-- [Changelog](CHANGELOG.md)
-
-## License
-
-`rand_os` is distributed under the terms of both the MIT license and the
-Apache License (Version 2.0).
-
-See [LICENSE-APACHE](LICENSE-APACHE) and [LICENSE-MIT](LICENSE-MIT), and
-[COPYRIGHT](COPYRIGHT) for details.
diff --git a/rand/rand_os/src/cloudabi.rs b/rand/rand_os/src/cloudabi.rs
deleted file mode 100644
index 8b96a2b..0000000
--- a/rand/rand_os/src/cloudabi.rs
+++ /dev/null
@@ -1,39 +0,0 @@
-// Copyright 2018 Developers of the Rand project.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-//! Implementation for CloudABI
-
-extern crate cloudabi;
-
-use std::io;
-use rand_core::{Error, ErrorKind};
-use super::OsRngImpl;
-
-#[derive(Clone, Debug)]
-pub struct OsRng;
-
-impl OsRngImpl for OsRng {
- fn new() -> Result<OsRng, Error> { Ok(OsRng) }
-
- fn fill_chunk(&mut self, dest: &mut [u8]) -> Result<(), Error> {
- let errno = unsafe { cloudabi::random_get(dest) };
- if errno == cloudabi::errno::SUCCESS {
- Ok(())
- } else {
- // Cloudlibc provides its own `strerror` implementation so we
- // can use `from_raw_os_error` here.
- Err(Error::with_cause(
- ErrorKind::Unavailable,
- "random_get() system call failed",
- io::Error::from_raw_os_error(errno as i32),
- ))
- }
- }
-
- fn method_str(&self) -> &'static str { "cloudabi::random_get" }
-}
diff --git a/rand/rand_os/src/dragonfly_haiku_emscripten.rs b/rand/rand_os/src/dragonfly_haiku_emscripten.rs
deleted file mode 100644
index 6132d7a..0000000
--- a/rand/rand_os/src/dragonfly_haiku_emscripten.rs
+++ /dev/null
@@ -1,39 +0,0 @@
-// Copyright 2018 Developers of the Rand project.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-//! Implementation for DragonFly / Haiku / Emscripten
-
-use rand_core::Error;
-use super::random_device;
-use super::OsRngImpl;
-use std::fs::File;
-
-#[derive(Clone, Debug)]
-pub struct OsRng();
-
-impl OsRngImpl for OsRng {
- fn new() -> Result<OsRng, Error> {
- random_device::open("/dev/random", &|p| File::open(p))?;
- Ok(OsRng())
- }
-
- fn fill_chunk(&mut self, dest: &mut [u8]) -> Result<(), Error> {
- random_device::read(dest)
- }
-
- #[cfg(target_os = "emscripten")]
- fn max_chunk_size(&self) -> usize {
- // `Crypto.getRandomValues` documents `dest` should be at most 65536
- // bytes. `crypto.randomBytes` documents: "To minimize threadpool
- // task length variation, partition large randomBytes requests when
- // doing so as part of fulfilling a client request.
- 65536
- }
-
- fn method_str(&self) -> &'static str { "/dev/random" }
-}
diff --git a/rand/rand_os/src/dummy_log.rs b/rand/rand_os/src/dummy_log.rs
deleted file mode 100644
index ccfe4ba..0000000
--- a/rand/rand_os/src/dummy_log.rs
+++ /dev/null
@@ -1,10 +0,0 @@
-#[allow(unused)]
-macro_rules! trace { ($($x:tt)*) => () }
-#[allow(unused)]
-macro_rules! debug { ($($x:tt)*) => () }
-#[allow(unused)]
-macro_rules! info { ($($x:tt)*) => () }
-#[allow(unused)]
-macro_rules! warn { ($($x:tt)*) => () }
-#[allow(unused)]
-macro_rules! error { ($($x:tt)*) => () }
diff --git a/rand/rand_os/src/freebsd.rs b/rand/rand_os/src/freebsd.rs
deleted file mode 100644
index 6b8e672..0000000
--- a/rand/rand_os/src/freebsd.rs
+++ /dev/null
@@ -1,45 +0,0 @@
-// Copyright 2018 Developers of the Rand project.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-//! Implementation for FreeBSD
-
-extern crate libc;
-
-use rand_core::{Error, ErrorKind};
-use super::OsRngImpl;
-
-use std::ptr;
-use std::io;
-
-#[derive(Clone, Debug)]
-pub struct OsRng;
-
-impl OsRngImpl for OsRng {
- fn new() -> Result<OsRng, Error> { Ok(OsRng) }
-
- fn fill_chunk(&mut self, dest: &mut [u8]) -> Result<(), Error> {
- let mib = [libc::CTL_KERN, libc::KERN_ARND];
- let mut len = dest.len();
- let ret = unsafe {
- libc::sysctl(mib.as_ptr(), mib.len() as libc::c_uint,
- dest.as_mut_ptr() as *mut _, &mut len,
- ptr::null(), 0)
- };
- if ret == -1 || len != dest.len() {
- return Err(Error::with_cause(
- ErrorKind::Unavailable,
- "kern.arandom sysctl failed",
- io::Error::last_os_error()));
- }
- Ok(())
- }
-
- fn max_chunk_size(&self) -> usize { 256 }
-
- fn method_str(&self) -> &'static str { "kern.arandom" }
-}
diff --git a/rand/rand_os/src/fuchsia.rs b/rand/rand_os/src/fuchsia.rs
deleted file mode 100644
index 7063ff6..0000000
--- a/rand/rand_os/src/fuchsia.rs
+++ /dev/null
@@ -1,43 +0,0 @@
-// Copyright 2018 Developers of the Rand project.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-//! Implementation for Fuchsia Zircon
-
-extern crate fuchsia_zircon;
-
-use rand_core::{Error, ErrorKind};
-use super::OsRngImpl;
-
-#[derive(Clone, Debug)]
-pub struct OsRng;
-
-impl OsRngImpl for OsRng {
- fn new() -> Result<OsRng, Error> { Ok(OsRng) }
-
- fn fill_chunk(&mut self, dest: &mut [u8]) -> Result<(), Error> {
- let mut read = 0;
- while read < dest.len() {
- match fuchsia_zircon::cprng_draw(&mut dest[read..]) {
- Ok(actual) => read += actual,
- Err(e) => {
- return Err(Error::with_cause(
- ErrorKind::Unavailable,
- "cprng_draw failed",
- e.into_io_error()));
- }
- };
- }
- Ok(())
- }
-
- fn max_chunk_size(&self) -> usize {
- fuchsia_zircon::sys::ZX_CPRNG_DRAW_MAX_LEN
- }
-
- fn method_str(&self) -> &'static str { "cprng_draw" }
-}
diff --git a/rand/rand_os/src/lib.rs b/rand/rand_os/src/lib.rs
deleted file mode 100644
index 67b0dfe..0000000
--- a/rand/rand_os/src/lib.rs
+++ /dev/null
@@ -1,439 +0,0 @@
-// Copyright 2018 Developers of the Rand project.
-// Copyright 2013-2015 The Rust Project Developers.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-//! Interface to the random number generator of the operating system.
-//!
-//! `OsRng` is the preferred external source of entropy for most applications.
-//! Commonly it is used to initialize a user-space RNG, which can then be used
-//! to generate random values with much less overhead than `OsRng`.
-//!
-//! You may prefer to use [`EntropyRng`] instead of `OsRng`. It is unlikely, but
-//! not entirely theoretical, for `OsRng` to fail. In such cases [`EntropyRng`]
-//! falls back on a good alternative entropy source.
-//!
-//! `OsRng::new()` is guaranteed to be very cheap (after the first successful
-//! call), and will never consume more than one file handle per process.
-//!
-//! # Usage example
-//! ```
-//! use rand_os::OsRng;
-//! use rand_os::rand_core::RngCore;
-//!
-//! let mut os_rng = OsRng::new().unwrap();
-//! let mut key = [0u8; 16];
-//! os_rng.fill_bytes(&mut key);
-//! let random_u64 = os_rng.next_u64();
-//! ```
-//!
-//! # Platform sources
-//!
-//! | OS | interface
-//! |------------------|---------------------------------------------------------
-//! | Linux, Android | [`getrandom`][1] system call if available, otherwise [`/dev/urandom`][2] after reading from `/dev/random` once
-//! | Windows | [`RtlGenRandom`][3]
-//! | macOS, iOS | [`SecRandomCopyBytes`][4]
-//! | FreeBSD | [`kern.arandom`][5]
-//! | OpenBSD, Bitrig | [`getentropy`][6]
-//! | NetBSD | [`/dev/urandom`][7] after reading from `/dev/random` once
-//! | Dragonfly BSD | [`/dev/random`][8]
-//! | Solaris, illumos | [`getrandom`][9] system call if available, otherwise [`/dev/random`][10]
-//! | Fuchsia OS | [`cprng_draw`][11]
-//! | Redox | [`rand:`][12]
-//! | CloudABI | [`random_get`][13]
-//! | Haiku | `/dev/random` (identical to `/dev/urandom`)
-//! | Web browsers | [`Crypto.getRandomValues`][14] (see [Support for WebAssembly and ams.js][14])
-//! | Node.js | [`crypto.randomBytes`][15] (see [Support for WebAssembly and ams.js][16])
-//!
-//! Rand doesn't have a blanket implementation for all Unix-like operating
-//! systems that reads from `/dev/urandom`. This ensures all supported operating
-//! systems are using the recommended interface and respect maximum buffer
-//! sizes.
-//!
-//! ## Support for WebAssembly and ams.js
-//!
-//! The three Emscripten targets `asmjs-unknown-emscripten`,
-//! `wasm32-unknown-emscripten` and `wasm32-experimental-emscripten` use
-//! Emscripten's emulation of `/dev/random` on web browsers and Node.js.
-//!
-//! The bare WASM target `wasm32-unknown-unknown` tries to call the javascript
-//! methods directly, using either `stdweb` or `wasm-bindgen` depending on what
-//! features are activated for this crate. Note that if both features are
-//! enabled `wasm-bindgen` will be used.
-//!
-//! ## Early boot
-//!
-//! It is possible that early in the boot process the OS hasn't had enough time
-//! yet to collect entropy to securely seed its RNG, especially on virtual
-//! machines.
-//!
-//! Some operating systems always block the thread until the RNG is securely
-//! seeded. This can take anywhere from a few seconds to more than a minute.
-//! Others make a best effort to use a seed from before the shutdown and don't
-//! document much.
-//!
-//! A few, Linux, NetBSD and Solaris, offer a choice between blocking, and
-//! getting an error. With `try_fill_bytes` we choose to get the error
-//! ([`ErrorKind::NotReady`]), while the other methods use a blocking interface.
-//!
-//! On Linux (when the `genrandom` system call is not available) and on NetBSD
-//! reading from `/dev/urandom` never blocks, even when the OS hasn't collected
-//! enough entropy yet. As a countermeasure we try to do a single read from
-//! `/dev/random` until we know the OS RNG is initialized (and store this in a
-//! global static).
-//!
-//! # Panics and error handling
-//!
-//! We cannot guarantee that `OsRng` will fail, but if it does, it will likely
-//! be either when `OsRng::new()` is first called or when data is first read.
-//! If you wish to catch errors early, then test reading of at least one byte
-//! from `OsRng` via [`try_fill_bytes`]. If this succeeds, it is extremely
-//! unlikely that any further errors will occur.
-//!
-//! Only [`try_fill_bytes`] is able to report the cause of an error; the other
-//! [`RngCore`] methods may (depending on the error kind) retry several times,
-//! but must eventually panic if the error persists.
-//!
-//! [`EntropyRng`]: ../rand/rngs/struct.EntropyRng.html
-//! [`RngCore`]: ../rand_core/trait.RngCore.html
-//! [`try_fill_bytes`]: ../rand_core/trait.RngCore.html#method.tymethod.try_fill_bytes
-//! [`ErrorKind::NotReady`]: ../rand_core/enum.ErrorKind.html#variant.NotReady
-//!
-//! [1]: http://man7.org/linux/man-pages/man2/getrandom.2.html
-//! [2]: http://man7.org/linux/man-pages/man4/urandom.4.html
-//! [3]: https://msdn.microsoft.com/en-us/library/windows/desktop/aa387694.aspx
-//! [4]: https://developer.apple.com/documentation/security/1399291-secrandomcopybytes?language=objc
-//! [5]: https://www.freebsd.org/cgi/man.cgi?query=random&sektion=4
-//! [6]: https://man.openbsd.org/getentropy.2
-//! [7]: http://netbsd.gw.com/cgi-bin/man-cgi?random+4+NetBSD-current
-//! [8]: https://leaf.dragonflybsd.org/cgi/web-man?command=random&section=4
-//! [9]: https://docs.oracle.com/cd/E88353_01/html/E37841/getrandom-2.html
-//! [10]: https://docs.oracle.com/cd/E86824_01/html/E54777/random-7d.html
-//! [11]: https://fuchsia.googlesource.com/zircon/+/HEAD/docs/syscalls/cprng_draw.md
-//! [12]: https://github.com/redox-os/randd/blob/master/src/main.rs
-//! [13]: https://github.com/NuxiNL/cloudabi/blob/v0.20/cloudabi.txt#L1826
-//! [14]: https://www.w3.org/TR/WebCryptoAPI/#Crypto-method-getRandomValues
-//! [15]: https://nodejs.org/api/crypto.html#crypto_crypto_randombytes_size_callback
-//! [16]: #support-for-webassembly-and-amsjs
-#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk.png",
- html_favicon_url = "https://www.rust-lang.org/favicon.ico",
- html_root_url = "https://rust-random.github.io/rand/")]
-#![deny(missing_docs)]
-#![deny(missing_debug_implementations)]
-#![doc(test(attr(allow(unused_variables), deny(warnings))))]
-
-#![cfg_attr(feature = "stdweb", recursion_limit="128")]
-
-pub extern crate rand_core;
-#[cfg(feature = "log")]
-#[macro_use] extern crate log;
-
-// We have to do it here because we load macros
-#[cfg(all(target_arch = "wasm32", not(target_os = "emscripten"),
- feature = "wasm-bindgen"))]
-extern crate wasm_bindgen;
-#[cfg(all(target_arch = "wasm32", not(target_os = "emscripten"),
- not(feature = "wasm-bindgen"),
- feature = "stdweb"))]
-#[macro_use] extern crate stdweb;
-
-#[cfg(target_env = "sgx")]
-extern crate rdrand;
-
-#[cfg(not(feature = "log"))]
-#[macro_use]
-mod dummy_log;
-
-use std::fmt;
-use rand_core::{CryptoRng, RngCore, Error, impls};
-
-/// A random number generator that retrieves randomness straight from the
-/// operating system.
-#[derive(Clone)]
-pub struct OsRng(imp::OsRng);
-
-impl fmt::Debug for OsRng {
- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
- self.0.fmt(f)
- }
-}
-
-impl OsRng {
- /// Create a new `OsRng`.
- pub fn new() -> Result<OsRng, Error> {
- imp::OsRng::new().map(OsRng)
- }
-}
-
-impl CryptoRng for OsRng {}
-
-impl RngCore for OsRng {
- fn next_u32(&mut self) -> u32 {
- impls::next_u32_via_fill(self)
- }
-
- fn next_u64(&mut self) -> u64 {
- impls::next_u64_via_fill(self)
- }
-
- fn fill_bytes(&mut self, dest: &mut [u8]) {
- use std::{time, thread};
-
- // We cannot return Err(..), so we try to handle before panicking.
- const MAX_RETRY_PERIOD: u32 = 10; // max 10s
- const WAIT_DUR_MS: u32 = 100; // retry every 100ms
- let wait_dur = time::Duration::from_millis(WAIT_DUR_MS as u64);
- const RETRY_LIMIT: u32 = (MAX_RETRY_PERIOD * 1000) / WAIT_DUR_MS;
- const TRANSIENT_RETRIES: u32 = 8;
- let mut err_count = 0;
- let mut error_logged = false;
-
- // Maybe block until the OS RNG is initialized
- let mut read = 0;
- if let Ok(n) = self.0.test_initialized(dest, true) { read = n };
- let dest = &mut dest[read..];
-
- loop {
- if let Err(e) = self.try_fill_bytes(dest) {
- if err_count >= RETRY_LIMIT {
- error!("OsRng failed too many times; last error: {}", e);
- panic!("OsRng failed too many times; last error: {}", e);
- }
-
- if e.kind.should_wait() {
- if !error_logged {
- warn!("OsRng failed; waiting up to {}s and retrying. Error: {}",
- MAX_RETRY_PERIOD, e);
- error_logged = true;
- }
- err_count += 1;
- thread::sleep(wait_dur);
- continue;
- } else if e.kind.should_retry() {
- if !error_logged {
- warn!("OsRng failed; retrying up to {} times. Error: {}",
- TRANSIENT_RETRIES, e);
- error_logged = true;
- }
- err_count += (RETRY_LIMIT + TRANSIENT_RETRIES - 1)
- / TRANSIENT_RETRIES; // round up
- continue;
- } else {
- error!("OsRng failed: {}", e);
- panic!("OsRng fatal error: {}", e);
- }
- }
-
- break;
- }
- }
-
- fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), Error> {
- // Some systems do not support reading 0 random bytes.
- // (And why waste a system call?)
- if dest.len() == 0 { return Ok(()); }
-
- let read = self.0.test_initialized(dest, false)?;
- let dest = &mut dest[read..];
-
- let max = self.0.max_chunk_size();
- if dest.len() <= max {
- trace!("OsRng: reading {} bytes via {}",
- dest.len(), self.0.method_str());
- } else {
- trace!("OsRng: reading {} bytes via {} in {} chunks of {} bytes",
- dest.len(), self.0.method_str(), (dest.len() + max) / max, max);
- }
- for slice in dest.chunks_mut(max) {
- self.0.fill_chunk(slice)?;
- }
- Ok(())
- }
-}
-
-trait OsRngImpl where Self: Sized {
- // Create a new `OsRng` platform interface.
- fn new() -> Result<Self, Error>;
-
- // Fill a chunk with random bytes.
- fn fill_chunk(&mut self, dest: &mut [u8]) -> Result<(), Error>;
-
- // Test whether the OS RNG is initialized. This method may not be possible
- // to support cheaply (or at all) on all operating systems.
- //
- // If `blocking` is set, this will cause the OS the block execution until
- // its RNG is initialized.
- //
- // Random values that are read while this are stored in `dest`, the amount
- // of read bytes is returned.
- fn test_initialized(&mut self, _dest: &mut [u8], _blocking: bool)
- -> Result<usize, Error> { Ok(0) }
-
- // Maximum chunk size supported.
- fn max_chunk_size(&self) -> usize { ::std::usize::MAX }
-
- // Name of the OS interface (used for logging).
- fn method_str(&self) -> &'static str;
-}
-
-#[cfg(any(target_os = "linux", target_os = "android",
- target_os = "netbsd", target_os = "dragonfly",
- target_os = "solaris", target_os = "redox",
- target_os = "haiku", target_os = "emscripten"))]
-mod random_device;
-
-macro_rules! mod_use {
- ($cond:meta, $module:ident) => {
- #[$cond]
- mod $module;
- #[$cond]
- use $module as imp;
- }
-}
-
-mod_use!(cfg(target_os = "android"), linux_android);
-mod_use!(cfg(target_os = "bitrig"), openbsd_bitrig);
-mod_use!(cfg(target_os = "cloudabi"), cloudabi);
-mod_use!(cfg(target_os = "dragonfly"), dragonfly_haiku_emscripten);
-mod_use!(cfg(target_os = "emscripten"), dragonfly_haiku_emscripten);
-mod_use!(cfg(target_os = "freebsd"), freebsd);
-mod_use!(cfg(target_os = "fuchsia"), fuchsia);
-mod_use!(cfg(target_os = "haiku"), dragonfly_haiku_emscripten);
-mod_use!(cfg(target_os = "ios"), macos);
-mod_use!(cfg(target_os = "linux"), linux_android);
-mod_use!(cfg(target_os = "macos"), macos);
-mod_use!(cfg(target_os = "netbsd"), netbsd);
-mod_use!(cfg(target_os = "openbsd"), openbsd_bitrig);
-mod_use!(cfg(target_os = "redox"), redox);
-mod_use!(cfg(target_os = "solaris"), solaris);
-mod_use!(cfg(windows), windows);
-mod_use!(cfg(target_env = "sgx"), sgx);
-
-mod_use!(
- cfg(all(
- target_arch = "wasm32",
- not(target_os = "emscripten"),
- feature = "wasm-bindgen"
- )),
- wasm32_bindgen
-);
-
-mod_use!(
- cfg(all(
- target_arch = "wasm32",
- not(target_os = "emscripten"),
- not(feature = "wasm-bindgen"),
- feature = "stdweb",
- )),
- wasm32_stdweb
-);
-
-/// Per #678 we use run-time failure where WASM bindings are missing
-#[cfg(all(
- target_arch = "wasm32",
- not(target_os = "emscripten"),
- not(feature = "wasm-bindgen"),
- not(feature = "stdweb"),
-))]
-mod imp {
- use rand_core::{Error, ErrorKind};
- use super::OsRngImpl;
-
- #[derive(Clone, Debug)]
- pub struct OsRng;
-
- impl OsRngImpl for OsRng {
- fn new() -> Result<OsRng, Error> {
- Err(Error::new(ErrorKind::Unavailable,
- "OsRng: support for wasm32 requires emscripten, stdweb or wasm-bindgen"))
- }
-
- fn fill_chunk(&mut self, _dest: &mut [u8]) -> Result<(), Error> {
- unimplemented!()
- }
-
- fn method_str(&self) -> &'static str { unimplemented!() }
- }
-}
-
-#[cfg(not(any(
- target_os = "android",
- target_os = "bitrig",
- target_os = "cloudabi",
- target_os = "dragonfly",
- target_os = "emscripten",
- target_os = "freebsd",
- target_os = "fuchsia",
- target_os = "haiku",
- target_os = "ios",
- target_os = "linux",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
- target_os = "redox",
- target_os = "solaris",
- windows,
- target_arch = "wasm32",
- target_env = "sgx"
-)))]
-compile_error!("OS RNG support is not available for this platform");
-
-// Due to rustwasm/wasm-bindgen#201 this can't be defined in the inner os
-// modules, so hack around it for now and place it at the root.
-#[cfg(all(feature = "wasm-bindgen", target_arch = "wasm32"))]
-#[doc(hidden)]
-#[allow(missing_debug_implementations)]
-pub mod __wbg_shims {
-
- // `extern { type Foo; }` isn't supported on 1.22 syntactically, so use a
- // macro to work around that.
- macro_rules! rust_122_compat {
- ($($t:tt)*) => ($($t)*)
- }
-
- rust_122_compat! {
- extern crate wasm_bindgen;
-
- pub use wasm_bindgen::prelude::*;
-
- #[wasm_bindgen]
- extern "C" {
- pub type Function;
- #[wasm_bindgen(constructor)]
- pub fn new(s: &str) -> Function;
- #[wasm_bindgen(method)]
- pub fn call(this: &Function, self_: &JsValue) -> JsValue;
-
- pub type This;
- #[wasm_bindgen(method, getter, structural, js_name = self)]
- pub fn self_(me: &This) -> JsValue;
- #[wasm_bindgen(method, getter, structural)]
- pub fn crypto(me: &This) -> JsValue;
-
- #[derive(Clone, Debug)]
- pub type BrowserCrypto;
-
- // TODO: these `structural` annotations here ideally wouldn't be here to
- // avoid a JS shim, but for now with feature detection they're
- // unavoidable.
- #[wasm_bindgen(method, js_name = getRandomValues, structural, getter)]
- pub fn get_random_values_fn(me: &BrowserCrypto) -> JsValue;
- #[wasm_bindgen(method, js_name = getRandomValues, structural)]
- pub fn get_random_values(me: &BrowserCrypto, buf: &mut [u8]);
-
- #[wasm_bindgen(js_name = require)]
- pub fn node_require(s: &str) -> NodeCrypto;
-
- #[derive(Clone, Debug)]
- pub type NodeCrypto;
-
- #[wasm_bindgen(method, js_name = randomFillSync, structural)]
- pub fn random_fill_sync(me: &NodeCrypto, buf: &mut [u8]);
- }
- }
-}
diff --git a/rand/rand_os/src/linux_android.rs b/rand/rand_os/src/linux_android.rs
deleted file mode 100644
index 9622f93..0000000
--- a/rand/rand_os/src/linux_android.rs
+++ /dev/null
@@ -1,182 +0,0 @@
-// Copyright 2018 Developers of the Rand project.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-//! Implementation for Linux / Android
-
-extern crate libc;
-
-use rand_core::{Error, ErrorKind};
-use super::random_device;
-use super::OsRngImpl;
-
-use std::io;
-use std::io::Read;
-use std::fs::{File, OpenOptions};
-use std::os::unix::fs::OpenOptionsExt;
-use std::sync::atomic::{AtomicBool, ATOMIC_BOOL_INIT, Ordering};
-use std::sync::{Once, ONCE_INIT};
-
-#[derive(Clone, Debug)]
-pub struct OsRng {
- method: OsRngMethod,
- initialized: bool,
-}
-
-#[derive(Clone, Debug)]
-enum OsRngMethod {
- GetRandom,
- RandomDevice,
-}
-
-impl OsRngImpl for OsRng {
- fn new() -> Result<OsRng, Error> {
- if is_getrandom_available() {
- return Ok(OsRng { method: OsRngMethod::GetRandom,
- initialized: false });
- }
- random_device::open("/dev/urandom", &|p| File::open(p))?;
- Ok(OsRng { method: OsRngMethod::RandomDevice, initialized: false })
- }
-
- fn fill_chunk(&mut self, dest: &mut [u8]) -> Result<(), Error> {
- match self.method {
- OsRngMethod::GetRandom => getrandom_try_fill(dest, false),
- OsRngMethod::RandomDevice => random_device::read(dest),
- }
- }
-
- fn test_initialized(&mut self, dest: &mut [u8], blocking: bool)
- -> Result<usize, Error>
- {
- static OS_RNG_INITIALIZED: AtomicBool = ATOMIC_BOOL_INIT;
- if !self.initialized {
- self.initialized = OS_RNG_INITIALIZED.load(Ordering::Relaxed);
- }
- if self.initialized { return Ok(0); }
-
- let result = match self.method {
- OsRngMethod::GetRandom => {
- getrandom_try_fill(dest, blocking)?;
- Ok(dest.len())
- }
- OsRngMethod::RandomDevice => {
- info!("OsRng: testing random device /dev/random");
- let mut file = OpenOptions::new()
- .read(true)
- .custom_flags(if blocking { 0 } else { libc::O_NONBLOCK })
- .open("/dev/random")
- .map_err(random_device::map_err)?;
- file.read(&mut dest[..1]).map_err(random_device::map_err)?;
- Ok(1)
- }
- };
- OS_RNG_INITIALIZED.store(true, Ordering::Relaxed);
- self.initialized = true;
- result
- }
-
- fn method_str(&self) -> &'static str {
- match self.method {
- OsRngMethod::GetRandom => "getrandom",
- OsRngMethod::RandomDevice => "/dev/urandom",
- }
- }
-}
-
-#[cfg(target_arch = "x86_64")]
-const NR_GETRANDOM: libc::c_long = 318;
-#[cfg(target_arch = "x86")]
-const NR_GETRANDOM: libc::c_long = 355;
-#[cfg(target_arch = "arm")]
-const NR_GETRANDOM: libc::c_long = 384;
-#[cfg(target_arch = "aarch64")]
-const NR_GETRANDOM: libc::c_long = 278;
- #[cfg(target_arch = "s390x")]
-const NR_GETRANDOM: libc::c_long = 349;
-#[cfg(target_arch = "powerpc")]
-const NR_GETRANDOM: libc::c_long = 359;
-#[cfg(target_arch = "powerpc64")]
-const NR_GETRANDOM: libc::c_long = 359;
-#[cfg(target_arch = "mips")] // old ABI
-const NR_GETRANDOM: libc::c_long = 4353;
-#[cfg(target_arch = "mips64")]
-const NR_GETRANDOM: libc::c_long = 5313;
-#[cfg(target_arch = "sparc")]
-const NR_GETRANDOM: libc::c_long = 347;
-#[cfg(target_arch = "sparc64")]
-const NR_GETRANDOM: libc::c_long = 347;
-#[cfg(not(any(target_arch = "x86_64", target_arch = "x86",
- target_arch = "arm", target_arch = "aarch64",
- target_arch = "s390x", target_arch = "powerpc",
- target_arch = "powerpc64", target_arch = "mips",
- target_arch = "mips64", target_arch = "sparc",
- target_arch = "sparc64")))]
-const NR_GETRANDOM: libc::c_long = 0;
-
-fn getrandom(buf: &mut [u8], blocking: bool) -> libc::c_long {
- const GRND_NONBLOCK: libc::c_uint = 0x0001;
-
- if NR_GETRANDOM == 0 { return -1 };
-
- unsafe {
- libc::syscall(NR_GETRANDOM, buf.as_mut_ptr(), buf.len(),
- if blocking { 0 } else { GRND_NONBLOCK })
- }
-}
-
-fn getrandom_try_fill(dest: &mut [u8], blocking: bool) -> Result<(), Error> {
- let mut read = 0;
- while read < dest.len() {
- let result = getrandom(&mut dest[read..], blocking);
- if result == -1 {
- let err = io::Error::last_os_error();
- let kind = err.kind();
- if kind == io::ErrorKind::Interrupted {
- continue;
- } else if kind == io::ErrorKind::WouldBlock {
- return Err(Error::with_cause(
- ErrorKind::NotReady,
- "getrandom not ready",
- err,
- ));
- } else {
- return Err(Error::with_cause(
- ErrorKind::Unavailable,
- "unexpected getrandom error",
- err,
- ));
- }
- } else {
- read += result as usize;
- }
- }
- Ok(())
-}
-
-fn is_getrandom_available() -> bool {
- static CHECKER: Once = ONCE_INIT;
- static AVAILABLE: AtomicBool = ATOMIC_BOOL_INIT;
-
- if NR_GETRANDOM == 0 { return false };
-
- CHECKER.call_once(|| {
- debug!("OsRng: testing getrandom");
- let mut buf: [u8; 0] = [];
- let result = getrandom(&mut buf, false);
- let available = if result == -1 {
- let err = io::Error::last_os_error().raw_os_error();
- err != Some(libc::ENOSYS)
- } else {
- true
- };
- AVAILABLE.store(available, Ordering::Relaxed);
- info!("OsRng: using {}", if available { "getrandom" } else { "/dev/urandom" });
- });
-
- AVAILABLE.load(Ordering::Relaxed)
-}
diff --git a/rand/rand_os/src/macos.rs b/rand/rand_os/src/macos.rs
deleted file mode 100644
index 6c67251..0000000
--- a/rand/rand_os/src/macos.rs
+++ /dev/null
@@ -1,53 +0,0 @@
-// Copyright 2018 Developers of the Rand project.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-//! Implementation for MacOS / iOS
-
-extern crate libc;
-
-use rand_core::{Error, ErrorKind};
-use super::OsRngImpl;
-
-use std::io;
-use self::libc::{c_int, size_t};
-
-#[derive(Clone, Debug)]
-pub struct OsRng;
-
-enum SecRandom {}
-
-#[allow(non_upper_case_globals)]
-const kSecRandomDefault: *const SecRandom = 0 as *const SecRandom;
-
-#[link(name = "Security", kind = "framework")]
-extern {
- fn SecRandomCopyBytes(rnd: *const SecRandom,
- count: size_t, bytes: *mut u8) -> c_int;
-}
-
-impl OsRngImpl for OsRng {
- fn new() -> Result<OsRng, Error> { Ok(OsRng) }
-
- fn fill_chunk(&mut self, dest: &mut [u8]) -> Result<(), Error> {
- let ret = unsafe {
- SecRandomCopyBytes(kSecRandomDefault,
- dest.len() as size_t,
- dest.as_mut_ptr())
- };
- if ret == -1 {
- Err(Error::with_cause(
- ErrorKind::Unavailable,
- "couldn't generate random bytes",
- io::Error::last_os_error()))
- } else {
- Ok(())
- }
- }
-
- fn method_str(&self) -> &'static str { "SecRandomCopyBytes" }
-}
diff --git a/rand/rand_os/src/netbsd.rs b/rand/rand_os/src/netbsd.rs
deleted file mode 100644
index cf4b6c7..0000000
--- a/rand/rand_os/src/netbsd.rs
+++ /dev/null
@@ -1,54 +0,0 @@
-// Copyright 2018 Developers of the Rand project.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-//! Implementation for NetBSD
-
-use rand_core::Error;
-use super::random_device;
-use super::OsRngImpl;
-
-use std::fs::File;
-use std::io::Read;
-use std::sync::atomic::{AtomicBool, ATOMIC_BOOL_INIT, Ordering};
-
-#[derive(Clone, Debug)]
-pub struct OsRng { initialized: bool }
-
-impl OsRngImpl for OsRng {
- fn new() -> Result<OsRng, Error> {
- random_device::open("/dev/urandom", &|p| File::open(p))?;
- Ok(OsRng { initialized: false })
- }
-
- fn fill_chunk(&mut self, dest: &mut [u8]) -> Result<(), Error> {
- random_device::read(dest)
- }
-
- // Read a single byte from `/dev/random` to determine if the OS RNG is
- // already seeded. NetBSD always blocks if not yet ready.
- fn test_initialized(&mut self, dest: &mut [u8], _blocking: bool)
- -> Result<usize, Error>
- {
- static OS_RNG_INITIALIZED: AtomicBool = ATOMIC_BOOL_INIT;
- if !self.initialized {
- self.initialized = OS_RNG_INITIALIZED.load(Ordering::Relaxed);
- }
- if self.initialized { return Ok(0); }
-
- info!("OsRng: testing random device /dev/random");
- let mut file =
- File::open("/dev/random").map_err(random_device::map_err)?;
- file.read(&mut dest[..1]).map_err(random_device::map_err)?;
-
- OS_RNG_INITIALIZED.store(true, Ordering::Relaxed);
- self.initialized = true;
- Ok(1)
- }
-
- fn method_str(&self) -> &'static str { "/dev/urandom" }
-}
diff --git a/rand/rand_os/src/openbsd_bitrig.rs b/rand/rand_os/src/openbsd_bitrig.rs
deleted file mode 100644
index c9b35a6..0000000
--- a/rand/rand_os/src/openbsd_bitrig.rs
+++ /dev/null
@@ -1,40 +0,0 @@
-// Copyright 2018 Developers of the Rand project.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-//! Implementation for OpenBSD / Bitrig
-
-extern crate libc;
-
-use rand_core::{Error, ErrorKind};
-use super::OsRngImpl;
-
-use std::io;
-
-#[derive(Clone, Debug)]
-pub struct OsRng;
-
-impl OsRngImpl for OsRng {
- fn new() -> Result<OsRng, Error> { Ok(OsRng) }
-
- fn fill_chunk(&mut self, dest: &mut [u8]) -> Result<(), Error> {
- let ret = unsafe {
- libc::getentropy(dest.as_mut_ptr() as *mut libc::c_void, dest.len())
- };
- if ret == -1 {
- return Err(Error::with_cause(
- ErrorKind::Unavailable,
- "getentropy failed",
- io::Error::last_os_error()));
- }
- Ok(())
- }
-
- fn max_chunk_size(&self) -> usize { 256 }
-
- fn method_str(&self) -> &'static str { "getentropy" }
-}
diff --git a/rand/rand_os/src/random_device.rs b/rand/rand_os/src/random_device.rs
deleted file mode 100644
index 5da9194..0000000
--- a/rand/rand_os/src/random_device.rs
+++ /dev/null
@@ -1,70 +0,0 @@
-// Copyright 2018 Developers of the Rand project.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-//! Helper functions to read from a random device such as `/dev/urandom`.
-//!
-//! All instances use a single internal file handle, to prevent possible
-//! exhaustion of file descriptors.
-use rand_core::{Error, ErrorKind};
-use std::fs::File;
-use std::io;
-use std::io::Read;
-use std::sync::{Once, Mutex, ONCE_INIT};
-
-// TODO: remove outer Option when `Mutex::new(None)` is a constant expression
-static mut READ_RNG_FILE: Option<Mutex<Option<File>>> = None;
-static READ_RNG_ONCE: Once = ONCE_INIT;
-
-#[allow(unused)]
-pub fn open<F>(path: &'static str, open_fn: F) -> Result<(), Error>
- where F: Fn(&'static str) -> Result<File, io::Error>
-{
- READ_RNG_ONCE.call_once(|| {
- unsafe { READ_RNG_FILE = Some(Mutex::new(None)) }
- });
-
- // We try opening the file outside the `call_once` fn because we cannot
- // clone the error, thus we must retry on failure.
-
- let mutex = unsafe { READ_RNG_FILE.as_ref().unwrap() };
- let mut guard = mutex.lock().unwrap();
- if (*guard).is_none() {
- info!("OsRng: opening random device {}", path);
- let file = open_fn(path).map_err(map_err)?;
- *guard = Some(file);
- };
- Ok(())
-}
-
-pub fn read(dest: &mut [u8]) -> Result<(), Error> {
- // We expect this function only to be used after `random_device::open`
- // was succesful. Therefore we can assume that our memory was set with a
- // valid object.
- let mutex = unsafe { READ_RNG_FILE.as_ref().unwrap() };
- let mut guard = mutex.lock().unwrap();
- let file = (*guard).as_mut().unwrap();
-
- // Use `std::io::read_exact`, which retries on `ErrorKind::Interrupted`.
- file.read_exact(dest).map_err(|err| {
- Error::with_cause(ErrorKind::Unavailable,
- "error reading random device", err)
- })
-
-}
-
-pub fn map_err(err: io::Error) -> Error {
- match err.kind() {
- io::ErrorKind::Interrupted =>
- Error::new(ErrorKind::Transient, "interrupted"),
- io::ErrorKind::WouldBlock =>
- Error::with_cause(ErrorKind::NotReady,
- "OS RNG not yet seeded", err),
- _ => Error::with_cause(ErrorKind::Unavailable,
- "error while opening random device", err)
- }
-}
diff --git a/rand/rand_os/src/redox.rs b/rand/rand_os/src/redox.rs
deleted file mode 100644
index 36fae26..0000000
--- a/rand/rand_os/src/redox.rs
+++ /dev/null
@@ -1,30 +0,0 @@
-// Copyright 2018 Developers of the Rand project.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-//! Implementation for Redox
-
-use rand_core::Error;
-use super::random_device;
-use super::OsRngImpl;
-use std::fs::File;
-
-#[derive(Clone, Debug)]
-pub struct OsRng();
-
-impl OsRngImpl for OsRng {
- fn new() -> Result<OsRng, Error> {
- random_device::open("rand:", &|p| File::open(p))?;
- Ok(OsRng())
- }
-
- fn fill_chunk(&mut self, dest: &mut [u8]) -> Result<(), Error> {
- random_device::read(dest)
- }
-
- fn method_str(&self) -> &'static str { "'rand:'" }
-}
diff --git a/rand/rand_os/src/sgx.rs b/rand/rand_os/src/sgx.rs
deleted file mode 100644
index 43ae0ef..0000000
--- a/rand/rand_os/src/sgx.rs
+++ /dev/null
@@ -1,38 +0,0 @@
-// Copyright 2018 Developers of the Rand project.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-use super::OsRngImpl;
-use Error;
-use rdrand::RdRand;
-use rand_core::RngCore;
-use std::fmt::{Debug, Formatter, Result as FmtResult};
-
-#[derive(Clone)]
-pub struct OsRng{
- gen: RdRand
-}
-
-impl OsRngImpl for OsRng {
- fn new() -> Result<OsRng, Error> {
- let rng = RdRand::new()?;
- Ok(OsRng{ gen: rng })
- }
-
- fn fill_chunk(&mut self, dest: &mut [u8]) -> Result<(), Error> {
- self.gen.try_fill_bytes(dest)
- }
-
- fn method_str(&self) -> &'static str { "RDRAND" }
-}
-
-impl Debug for OsRng {
- fn fmt(&self, f: &mut Formatter) -> FmtResult {
- f.debug_struct("OsRng")
- .finish()
- }
-}
diff --git a/rand/rand_os/src/solaris.rs b/rand/rand_os/src/solaris.rs
deleted file mode 100644
index e8965fd..0000000
--- a/rand/rand_os/src/solaris.rs
+++ /dev/null
@@ -1,175 +0,0 @@
-// Copyright 2018 Developers of the Rand project.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-//! Implementation for the Solaris family
-//!
-//! Read from `/dev/random`, with chunks of limited size (1040 bytes).
-//! `/dev/random` uses the Hash_DRBG with SHA512 algorithm from NIST SP 800-90A.
-//! `/dev/urandom` uses the FIPS 186-2 algorithm, which is considered less
-//! secure. We choose to read from `/dev/random`.
-//!
-//! Since Solaris 11.3 the `getrandom` syscall is available. To make sure we can
-//! compile on both Solaris and on OpenSolaris derivatives, that do not have the
-//! function, we do a direct syscall instead of calling a library function.
-//!
-//! We have no way to differentiate between Solaris, illumos, SmartOS, etc.
-extern crate libc;
-
-use rand_core::{Error, ErrorKind};
-use super::random_device;
-use super::OsRngImpl;
-
-use std::io;
-use std::io::Read;
-use std::fs::{File, OpenOptions};
-use std::os::unix::fs::OpenOptionsExt;
-use std::sync::atomic::{AtomicBool, ATOMIC_BOOL_INIT, Ordering};
-use std::cmp;
-
-#[derive(Clone, Debug)]
-pub struct OsRng {
- method: OsRngMethod,
- initialized: bool,
-}
-
-#[derive(Clone, Debug)]
-enum OsRngMethod {
- GetRandom,
- RandomDevice,
-}
-
-impl OsRngImpl for OsRng {
- fn new() -> Result<OsRng, Error> {
- if is_getrandom_available() {
- return Ok(OsRng { method: OsRngMethod::GetRandom,
- initialized: false });
- }
- let open = |p| OpenOptions::new()
- .read(true)
- .custom_flags(libc::O_NONBLOCK)
- .open(p);
- random_device::open("/dev/random", &open)?;
- Ok(OsRng { method: OsRngMethod::RandomDevice, initialized: false })
- }
-
- fn fill_chunk(&mut self, dest: &mut [u8]) -> Result<(), Error> {
- match self.method {
- OsRngMethod::GetRandom => getrandom_try_fill(dest, false),
- OsRngMethod::RandomDevice => random_device::read(dest),
- }
- }
-
- fn test_initialized(&mut self, dest: &mut [u8], blocking: bool)
- -> Result<usize, Error>
- {
- static OS_RNG_INITIALIZED: AtomicBool = ATOMIC_BOOL_INIT;
- if !self.initialized {
- self.initialized = OS_RNG_INITIALIZED.load(Ordering::Relaxed);
- }
- if self.initialized { return Ok(0); }
-
- let chunk_len = cmp::min(1024, dest.len());
- let dest = &mut dest[..chunk_len];
-
- match self.method {
- OsRngMethod::GetRandom => getrandom_try_fill(dest, blocking)?,
- OsRngMethod::RandomDevice => {
- if blocking {
- info!("OsRng: testing random device /dev/random");
- // We already have a non-blocking handle, but now need a
- // blocking one. Not much choice except opening it twice
- let mut file = File::open("/dev/random")
- .map_err(random_device::map_err)?;
- file.read(dest).map_err(random_device::map_err)?;
- } else {
- self.fill_chunk(dest)?;
- }
- }
- };
- OS_RNG_INITIALIZED.store(true, Ordering::Relaxed);
- self.initialized = true;
- Ok(chunk_len)
- }
-
- fn max_chunk_size(&self) -> usize {
- // The documentation says 1024 is the maximum for getrandom, but
- // 1040 for /dev/random.
- 1024
- }
-
- fn method_str(&self) -> &'static str {
- match self.method {
- OsRngMethod::GetRandom => "getrandom",
- OsRngMethod::RandomDevice => "/dev/random",
- }
- }
-}
-
-fn getrandom(buf: &mut [u8], blocking: bool) -> libc::c_long {
- extern "C" {
- fn syscall(number: libc::c_long, ...) -> libc::c_long;
- }
-
- const SYS_GETRANDOM: libc::c_long = 143;
- const GRND_NONBLOCK: libc::c_uint = 0x0001;
- const GRND_RANDOM: libc::c_uint = 0x0002;
-
- unsafe {
- syscall(SYS_GETRANDOM, buf.as_mut_ptr(), buf.len(),
- if blocking { 0 } else { GRND_NONBLOCK } | GRND_RANDOM)
- }
-}
-
-fn getrandom_try_fill(dest: &mut [u8], blocking: bool) -> Result<(), Error> {
- let result = getrandom(dest, blocking);
- if result == -1 || result == 0 {
- let err = io::Error::last_os_error();
- let kind = err.kind();
- if kind == io::ErrorKind::WouldBlock {
- return Err(Error::with_cause(
- ErrorKind::NotReady,
- "getrandom not ready",
- err,
- ));
- } else {
- return Err(Error::with_cause(
- ErrorKind::Unavailable,
- "unexpected getrandom error",
- err,
- ));
- }
- } else if result != dest.len() as i64 {
- return Err(Error::new(ErrorKind::Unavailable,
- "unexpected getrandom error"));
- }
- Ok(())
-}
-
-fn is_getrandom_available() -> bool {
- use std::sync::atomic::{AtomicBool, ATOMIC_BOOL_INIT, Ordering};
- use std::sync::{Once, ONCE_INIT};
-
- static CHECKER: Once = ONCE_INIT;
- static AVAILABLE: AtomicBool = ATOMIC_BOOL_INIT;
-
- CHECKER.call_once(|| {
- debug!("OsRng: testing getrandom");
- let mut buf: [u8; 0] = [];
- let result = getrandom(&mut buf, false);
- let available = if result == -1 {
- let err = io::Error::last_os_error().raw_os_error();
- err != Some(libc::ENOSYS)
- } else {
- true
- };
- AVAILABLE.store(available, Ordering::Relaxed);
- info!("OsRng: using {}", if available { "getrandom" } else { "/dev/random" });
- });
-
- AVAILABLE.load(Ordering::Relaxed)
-}
diff --git a/rand/rand_os/src/wasm32_bindgen.rs b/rand/rand_os/src/wasm32_bindgen.rs
deleted file mode 100644
index 8e7c979..0000000
--- a/rand/rand_os/src/wasm32_bindgen.rs
+++ /dev/null
@@ -1,125 +0,0 @@
-// Copyright 2018 Developers of the Rand project.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-//! Implementation for WASM via wasm-bindgen
-
-use rand_core::{Error, ErrorKind};
-use super::OsRngImpl;
-
-use wasm_bindgen::prelude::*;
-
-#[wasm_bindgen]
-extern "C" {
- pub type Function;
- #[wasm_bindgen(constructor)]
- pub fn new(s: &str) -> Function;
- #[wasm_bindgen(method)]
- pub fn call(this: &Function, self_: &JsValue) -> JsValue;
-
- pub type This;
- #[wasm_bindgen(method, getter, structural, js_name = self)]
- pub fn self_(me: &This) -> JsValue;
- #[wasm_bindgen(method, getter, structural)]
- pub fn crypto(me: &This) -> JsValue;
-
- #[derive(Clone, Debug)]
- pub type BrowserCrypto;
-
- // TODO: these `structural` annotations here ideally wouldn't be here to
- // avoid a JS shim, but for now with feature detection they're
- // unavoidable.
- #[wasm_bindgen(method, js_name = getRandomValues, structural, getter)]
- pub fn get_random_values_fn(me: &BrowserCrypto) -> JsValue;
- #[wasm_bindgen(method, js_name = getRandomValues, structural)]
- pub fn get_random_values(me: &BrowserCrypto, buf: &mut [u8]);
-
- #[wasm_bindgen(js_name = require)]
- pub fn node_require(s: &str) -> NodeCrypto;
-
- #[derive(Clone, Debug)]
- pub type NodeCrypto;
-
- #[wasm_bindgen(method, js_name = randomFillSync, structural)]
- pub fn random_fill_sync(me: &NodeCrypto, buf: &mut [u8]);
-}
-
-#[derive(Clone, Debug)]
-pub enum OsRng {
- Node(NodeCrypto),
- Browser(BrowserCrypto),
-}
-
-impl OsRngImpl for OsRng {
- fn new() -> Result<OsRng, Error> {
- // First up we need to detect if we're running in node.js or a
- // browser. To do this we get ahold of the `this` object (in a bit
- // of a roundabout fashion).
- //
- // Once we have `this` we look at its `self` property, which is
- // only defined on the web (either a main window or web worker).
- let this = Function::new("return this").call(&JsValue::undefined());
- assert!(this != JsValue::undefined());
- let this = This::from(this);
- let is_browser = this.self_() != JsValue::undefined();
-
- if !is_browser {
- return Ok(OsRng::Node(node_require("crypto")))
- }
-
- // If `self` is defined then we're in a browser somehow (main window
- // or web worker). Here we want to try to use
- // `crypto.getRandomValues`, but if `crypto` isn't defined we assume
- // we're in an older web browser and the OS RNG isn't available.
- let crypto = this.crypto();
- if crypto.is_undefined() {
- let msg = "self.crypto is undefined";
- return Err(Error::new(ErrorKind::Unavailable, msg))
- }
-
- // Test if `crypto.getRandomValues` is undefined as well
- let crypto: BrowserCrypto = crypto.into();
- if crypto.get_random_values_fn().is_undefined() {
- let msg = "crypto.getRandomValues is undefined";
- return Err(Error::new(ErrorKind::Unavailable, msg))
- }
-
- // Ok! `self.crypto.getRandomValues` is a defined value, so let's
- // assume we can do browser crypto.
- Ok(OsRng::Browser(crypto))
- }
-
- fn fill_chunk(&mut self, dest: &mut [u8]) -> Result<(), Error> {
- match *self {
- OsRng::Node(ref n) => n.random_fill_sync(dest),
- OsRng::Browser(ref n) => n.get_random_values(dest),
- }
- Ok(())
- }
-
- fn max_chunk_size(&self) -> usize {
- match *self {
- OsRng::Node(_) => usize::max_value(),
- OsRng::Browser(_) => {
- // see https://developer.mozilla.org/en-US/docs/Web/API/Crypto/getRandomValues
- //
- // where it says:
- //
- // > A QuotaExceededError DOMException is thrown if the
- // > requested length is greater than 65536 bytes.
- 65536
- }
- }
- }
-
- fn method_str(&self) -> &'static str {
- match *self {
- OsRng::Node(_) => "crypto.randomFillSync",
- OsRng::Browser(_) => "crypto.getRandomValues",
- }
- }
-}
diff --git a/rand/rand_os/src/wasm32_stdweb.rs b/rand/rand_os/src/wasm32_stdweb.rs
deleted file mode 100644
index 3be0ce6..0000000
--- a/rand/rand_os/src/wasm32_stdweb.rs
+++ /dev/null
@@ -1,107 +0,0 @@
-// Copyright 2018 Developers of the Rand project.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-//! Implementation for WASM via stdweb
-
-use std::mem;
-use stdweb::unstable::TryInto;
-use stdweb::web::error::Error as WebError;
-use rand_core::{Error, ErrorKind};
-use super::OsRngImpl;
-
-#[derive(Clone, Debug)]
-enum OsRngMethod {
- Browser,
- Node
-}
-
-#[derive(Clone, Debug)]
-pub struct OsRng(OsRngMethod);
-
-impl OsRngImpl for OsRng {
- fn new() -> Result<OsRng, Error> {
- let result = js! {
- try {
- if (
- typeof self === "object" &&
- typeof self.crypto === "object" &&
- typeof self.crypto.getRandomValues === "function"
- ) {
- return { success: true, ty: 1 };
- }
-
- if (typeof require("crypto").randomBytes === "function") {
- return { success: true, ty: 2 };
- }
-
- return { success: false, error: new Error("not supported") };
- } catch(err) {
- return { success: false, error: err };
- }
- };
-
- if js!{ return @{ result.as_ref() }.success } == true {
- let ty = js!{ return @{ result }.ty };
-
- if ty == 1 { Ok(OsRng(OsRngMethod::Browser)) }
- else if ty == 2 { Ok(OsRng(OsRngMethod::Node)) }
- else { unreachable!() }
- } else {
- let err: WebError = js!{ return @{ result }.error }.try_into().unwrap();
- Err(Error::with_cause(ErrorKind::Unavailable, "WASM Error", err))
- }
- }
-
-
- fn fill_chunk(&mut self, dest: &mut [u8]) -> Result<(), Error> {
- assert_eq!(mem::size_of::<usize>(), 4);
-
- let len = dest.len() as u32;
- let ptr = dest.as_mut_ptr() as i32;
-
- let result = match self.0 {
- OsRngMethod::Browser => js! {
- try {
- let array = new Uint8Array(@{ len });
- self.crypto.getRandomValues(array);
- HEAPU8.set(array, @{ ptr });
-
- return { success: true };
- } catch(err) {
- return { success: false, error: err };
- }
- },
- OsRngMethod::Node => js! {
- try {
- let bytes = require("crypto").randomBytes(@{ len });
- HEAPU8.set(new Uint8Array(bytes), @{ ptr });
-
- return { success: true };
- } catch(err) {
- return { success: false, error: err };
- }
- }
- };
-
- if js!{ return @{ result.as_ref() }.success } == true {
- Ok(())
- } else {
- let err: WebError = js!{ return @{ result }.error }.try_into().unwrap();
- Err(Error::with_cause(ErrorKind::Unexpected, "WASM Error", err))
- }
- }
-
- fn max_chunk_size(&self) -> usize { 65536 }
-
- fn method_str(&self) -> &'static str {
- match self.0 {
- OsRngMethod::Browser => "Crypto.getRandomValues",
- OsRngMethod::Node => "crypto.randomBytes",
- }
- }
-}
diff --git a/rand/rand_os/src/windows.rs b/rand/rand_os/src/windows.rs
deleted file mode 100644
index 6b06c7a..0000000
--- a/rand/rand_os/src/windows.rs
+++ /dev/null
@@ -1,44 +0,0 @@
-// Copyright 2018 Developers of the Rand project.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-//! Implementation for Windows
-
-extern crate winapi;
-
-use rand_core::{Error, ErrorKind};
-use super::OsRngImpl;
-
-use std::io;
-
-use self::winapi::shared::minwindef::ULONG;
-use self::winapi::um::ntsecapi::RtlGenRandom;
-use self::winapi::um::winnt::PVOID;
-
-#[derive(Clone, Debug)]
-pub struct OsRng;
-
-impl OsRngImpl for OsRng {
- fn new() -> Result<OsRng, Error> { Ok(OsRng) }
-
- fn fill_chunk(&mut self, dest: &mut [u8]) -> Result<(), Error> {
- let ret = unsafe {
- RtlGenRandom(dest.as_mut_ptr() as PVOID, dest.len() as ULONG)
- };
- if ret == 0 {
- return Err(Error::with_cause(
- ErrorKind::Unavailable,
- "couldn't generate random bytes",
- io::Error::last_os_error()));
- }
- Ok(())
- }
-
- fn max_chunk_size(&self) -> usize { <ULONG>::max_value() as usize }
-
- fn method_str(&self) -> &'static str { "RtlGenRandom" }
-}
diff --git a/rand/rand_os/tests/mod.rs b/rand/rand_os/tests/mod.rs
deleted file mode 100644
index 2130e16..0000000
--- a/rand/rand_os/tests/mod.rs
+++ /dev/null
@@ -1,80 +0,0 @@
-extern crate rand_os;
-
-use rand_os::rand_core::RngCore;
-use rand_os::OsRng;
-
-#[test]
-fn test_os_rng() {
- let mut r = OsRng::new().unwrap();
-
- r.next_u32();
- r.next_u64();
-
- let mut v1 = [0u8; 1000];
- r.fill_bytes(&mut v1);
-
- let mut v2 = [0u8; 1000];
- r.fill_bytes(&mut v2);
-
- let mut n_diff_bits = 0;
- for i in 0..v1.len() {
- n_diff_bits += (v1[i] ^ v2[i]).count_ones();
- }
-
- // Check at least 1 bit per byte differs. p(failure) < 1e-1000 with random input.
- assert!(n_diff_bits >= v1.len() as u32);
-}
-
-#[test]
-fn test_os_rng_empty() {
- let mut r = OsRng::new().unwrap();
-
- let mut empty = [0u8; 0];
- r.fill_bytes(&mut empty);
-}
-
-#[test]
-fn test_os_rng_huge() {
- let mut r = OsRng::new().unwrap();
-
- let mut huge = [0u8; 100_000];
- r.fill_bytes(&mut huge);
-}
-
-#[cfg(not(any(target_arch = "wasm32", target_arch = "asmjs")))]
-#[test]
-fn test_os_rng_tasks() {
- use std::sync::mpsc::channel;
- use std::thread;
-
- let mut txs = vec!();
- for _ in 0..20 {
- let (tx, rx) = channel();
- txs.push(tx);
-
- thread::spawn(move|| {
- // wait until all the tasks are ready to go.
- rx.recv().unwrap();
-
- // deschedule to attempt to interleave things as much
- // as possible (XXX: is this a good test?)
- let mut r = OsRng::new().unwrap();
- thread::yield_now();
- let mut v = [0u8; 1000];
-
- for _ in 0..100 {
- r.next_u32();
- thread::yield_now();
- r.next_u64();
- thread::yield_now();
- r.fill_bytes(&mut v);
- thread::yield_now();
- }
- });
- }
-
- // start all the tasks
- for tx in txs.iter() {
- tx.send(()).unwrap();
- }
-}
diff --git a/rand/rand_pcg/CHANGELOG.md b/rand/rand_pcg/CHANGELOG.md
deleted file mode 100644
index 6f793cf..0000000
--- a/rand/rand_pcg/CHANGELOG.md
+++ /dev/null
@@ -1,19 +0,0 @@
-# Changelog
-All notable changes to this project will be documented in this file.
-
-The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
-and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
-
-## [0.1.2] - unreleased
-- potential blocker: https://github.com/TyOverby/bincode/issues/250
-- make `bincode` a dev-dependency again
-- clean up tests and Serde support
-
-## [0.1.1] - 2018-10-04
-- make `bincode` an explicit dependency when using Serde
-
-## [0.1.0] - 2018-10-04
-Initial release, including:
-
-- `Lcg64Xsh32` aka `Pcg32`
-- `Mcg128Xsl64` aka `Pcg64Mcg`
diff --git a/rand/rand_pcg/COPYRIGHT b/rand/rand_pcg/COPYRIGHT
deleted file mode 100644
index 468d907..0000000
--- a/rand/rand_pcg/COPYRIGHT
+++ /dev/null
@@ -1,12 +0,0 @@
-Copyrights in the Rand project are retained by their contributors. No
-copyright assignment is required to contribute to the Rand project.
-
-For full authorship information, see the version control history.
-
-Except as otherwise noted (below and/or in individual files), Rand is
-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.
-
-The Rand project includes code from the Rust project
-published under these same licenses.
diff --git a/rand/rand_pcg/Cargo.toml b/rand/rand_pcg/Cargo.toml
deleted file mode 100644
index c2fcb7d..0000000
--- a/rand/rand_pcg/Cargo.toml
+++ /dev/null
@@ -1,37 +0,0 @@
-[package]
-name = "rand_pcg"
-version = "0.1.1"
-authors = ["The Rand Project Developers"]
-license = "MIT/Apache-2.0"
-readme = "README.md"
-repository = "https://github.com/rust-random/rand"
-documentation = "https://rust-random.github.io/rand/rand_pcg"
-homepage = "https://crates.io/crates/rand_pcg"
-description = """
-Selected PCG random number generators
-"""
-keywords = ["random", "rng", "pcg"]
-categories = ["algorithms", "no-std"]
-build = "build.rs"
-
-[badges]
-travis-ci = { repository = "rust-random/rand" }
-appveyor = { repository = "rust-random/rand" }
-
-[features]
-serde1 = ["serde", "serde_derive"]
-
-[dependencies]
-rand_core = { path = "../rand_core", version = "0.3", default-features=false }
-serde = { version = "1", optional = true }
-serde_derive = { version = "^1.0.38", optional = true }
-
-[dev-dependencies]
-# This is for testing serde, unfortunately we can't specify feature-gated dev
-# deps yet, see: https://github.com/rust-lang/cargo/issues/1596
-# TODO: we shouldn't have to depend on i128 directly; it breaks tests on old
-# compilers. `bincode` should automatically support this.
-bincode = { version = "1", features = ["i128"] }
-
-[build-dependencies]
-autocfg = "0.1"
diff --git a/rand/rand_pcg/LICENSE-APACHE b/rand/rand_pcg/LICENSE-APACHE
deleted file mode 100644
index 17d7468..0000000
--- a/rand/rand_pcg/LICENSE-APACHE
+++ /dev/null
@@ -1,201 +0,0 @@
- Apache License
- Version 2.0, January 2004
- https://www.apache.org/licenses/
-
-TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
-1. Definitions.
-
- "License" shall mean the terms and conditions for use, reproduction,
- and distribution as defined by Sections 1 through 9 of this document.
-
- "Licensor" shall mean the copyright owner or entity authorized by
- the copyright owner that is granting the License.
-
- "Legal Entity" shall mean the union of the acting entity and all
- other entities that control, are controlled by, or are under common
- control with that entity. For the purposes of this definition,
- "control" means (i) the power, direct or indirect, to cause the
- direction or management of such entity, whether by contract or
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
- outstanding shares, or (iii) beneficial ownership of such entity.
-
- "You" (or "Your") shall mean an individual or Legal Entity
- exercising permissions granted by this License.
-
- "Source" form shall mean the preferred form for making modifications,
- including but not limited to software source code, documentation
- source, and configuration files.
-
- "Object" form shall mean any form resulting from mechanical
- transformation or translation of a Source form, including but
- not limited to compiled object code, generated documentation,
- and conversions to other media types.
-
- "Work" shall mean the work of authorship, whether in Source or
- Object form, made available under the License, as indicated by a
- copyright notice that is included in or attached to the work
- (an example is provided in the Appendix below).
-
- "Derivative Works" shall mean any work, whether in Source or Object
- form, that is based on (or derived from) the Work and for which the
- editorial revisions, annotations, elaborations, or other modifications
- represent, as a whole, an original work of authorship. For the purposes
- of this License, Derivative Works shall not include works that remain
- separable from, or merely link (or bind by name) to the interfaces of,
- the Work and Derivative Works thereof.
-
- "Contribution" shall mean any work of authorship, including
- the original version of the Work and any modifications or additions
- to that Work or Derivative Works thereof, that is intentionally
- submitted to Licensor for inclusion in the Work by the copyright owner
- or by an individual or Legal Entity authorized to submit on behalf of
- the copyright owner. For the purposes of this definition, "submitted"
- means any form of electronic, verbal, or written communication sent
- to the Licensor or its representatives, including but not limited to
- communication on electronic mailing lists, source code control systems,
- and issue tracking systems that are managed by, or on behalf of, the
- Licensor for the purpose of discussing and improving the Work, but
- excluding communication that is conspicuously marked or otherwise
- designated in writing by the copyright owner as "Not a Contribution."
-
- "Contributor" shall mean Licensor and any individual or Legal Entity
- on behalf of whom a Contribution has been received by Licensor and
- subsequently incorporated within the Work.
-
-2. Grant of Copyright License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- copyright license to reproduce, prepare Derivative Works of,
- publicly display, publicly perform, sublicense, and distribute the
- Work and such Derivative Works in Source or Object form.
-
-3. Grant of Patent License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- (except as stated in this section) patent license to make, have made,
- use, offer to sell, sell, import, and otherwise transfer the Work,
- where such license applies only to those patent claims licensable
- by such Contributor that are necessarily infringed by their
- Contribution(s) alone or by combination of their Contribution(s)
- with the Work to which such Contribution(s) was submitted. If You
- institute patent litigation against any entity (including a
- cross-claim or counterclaim in a lawsuit) alleging that the Work
- or a Contribution incorporated within the Work constitutes direct
- or contributory patent infringement, then any patent licenses
- granted to You under this License for that Work shall terminate
- as of the date such litigation is filed.
-
-4. Redistribution. You may reproduce and distribute copies of the
- Work or Derivative Works thereof in any medium, with or without
- modifications, and in Source or Object form, provided that You
- meet the following conditions:
-
- (a) You must give any other recipients of the Work or
- Derivative Works a copy of this License; and
-
- (b) You must cause any modified files to carry prominent notices
- stating that You changed the files; and
-
- (c) You must retain, in the Source form of any Derivative Works
- that You distribute, all copyright, patent, trademark, and
- attribution notices from the Source form of the Work,
- excluding those notices that do not pertain to any part of
- the Derivative Works; and
-
- (d) If the Work includes a "NOTICE" text file as part of its
- distribution, then any Derivative Works that You distribute must
- include a readable copy of the attribution notices contained
- within such NOTICE file, excluding those notices that do not
- pertain to any part of the Derivative Works, in at least one
- of the following places: within a NOTICE text file distributed
- as part of the Derivative Works; within the Source form or
- documentation, if provided along with the Derivative Works; or,
- within a display generated by the Derivative Works, if and
- wherever such third-party notices normally appear. The contents
- of the NOTICE file are for informational purposes only and
- do not modify the License. You may add Your own attribution
- notices within Derivative Works that You distribute, alongside
- or as an addendum to the NOTICE text from the Work, provided
- that such additional attribution notices cannot be construed
- as modifying the License.
-
- You may add Your own copyright statement to Your modifications and
- may provide additional or different license terms and conditions
- for use, reproduction, or distribution of Your modifications, or
- for any such Derivative Works as a whole, provided Your use,
- reproduction, and distribution of the Work otherwise complies with
- the conditions stated in this License.
-
-5. Submission of Contributions. Unless You explicitly state otherwise,
- any Contribution intentionally submitted for inclusion in the Work
- by You to the Licensor shall be under the terms and conditions of
- this License, without any additional terms or conditions.
- Notwithstanding the above, nothing herein shall supersede or modify
- the terms of any separate license agreement you may have executed
- with Licensor regarding such Contributions.
-
-6. Trademarks. This License does not grant permission to use the trade
- names, trademarks, service marks, or product names of the Licensor,
- except as required for reasonable and customary use in describing the
- origin of the Work and reproducing the content of the NOTICE file.
-
-7. Disclaimer of Warranty. Unless required by applicable law or
- agreed to in writing, Licensor provides the Work (and each
- Contributor provides its Contributions) on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- implied, including, without limitation, any warranties or conditions
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
- PARTICULAR PURPOSE. You are solely responsible for determining the
- appropriateness of using or redistributing the Work and assume any
- risks associated with Your exercise of permissions under this License.
-
-8. Limitation of Liability. In no event and under no legal theory,
- whether in tort (including negligence), contract, or otherwise,
- unless required by applicable law (such as deliberate and grossly
- negligent acts) or agreed to in writing, shall any Contributor be
- liable to You for damages, including any direct, indirect, special,
- incidental, or consequential damages of any character arising as a
- result of this License or out of the use or inability to use the
- Work (including but not limited to damages for loss of goodwill,
- work stoppage, computer failure or malfunction, or any and all
- other commercial damages or losses), even if such Contributor
- has been advised of the possibility of such damages.
-
-9. Accepting Warranty or Additional Liability. While redistributing
- the Work or Derivative Works thereof, You may choose to offer,
- and charge a fee for, acceptance of support, warranty, indemnity,
- or other liability obligations and/or rights consistent with this
- License. However, in accepting such obligations, You may act only
- on Your own behalf and on Your sole responsibility, not on behalf
- of any other Contributor, and only if You agree to indemnify,
- defend, and hold each Contributor harmless for any liability
- incurred by, or claims asserted against, such Contributor by reason
- of your accepting any such warranty or additional liability.
-
-END OF TERMS AND CONDITIONS
-
-APPENDIX: How to apply the Apache License to your work.
-
- To apply the Apache License to your work, attach the following
- boilerplate notice, with the fields enclosed by brackets "[]"
- replaced with your own identifying information. (Don't include
- the brackets!) The text should be enclosed in the appropriate
- comment syntax for the file format. We also recommend that a
- file or class name and description of purpose be included on the
- same "printed page" as the copyright notice for easier
- identification within third-party archives.
-
-Copyright [yyyy] [name of copyright owner]
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
- https://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
diff --git a/rand/rand_pcg/LICENSE-MIT b/rand/rand_pcg/LICENSE-MIT
deleted file mode 100644
index d46f058..0000000
--- a/rand/rand_pcg/LICENSE-MIT
+++ /dev/null
@@ -1,26 +0,0 @@
-Copyright (c) 2014-2017 Melissa O'Neill and PCG Project contributors
-Copyright 2018 Developers of the Rand project
-
-Permission is hereby granted, free of charge, to any
-person obtaining a copy of this software and associated
-documentation files (the "Software"), to deal in the
-Software without restriction, including without
-limitation the rights to use, copy, modify, merge,
-publish, distribute, sublicense, and/or sell copies of
-the Software, and to permit persons to whom the Software
-is furnished to do so, subject to the following
-conditions:
-
-The above copyright notice and this permission notice
-shall be included in all copies or substantial portions
-of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
-ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
-TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
-PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
-SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
-CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
-IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
-DEALINGS IN THE SOFTWARE.
diff --git a/rand/rand_pcg/README.md b/rand/rand_pcg/README.md
deleted file mode 100644
index 4599813..0000000
--- a/rand/rand_pcg/README.md
+++ /dev/null
@@ -1,51 +0,0 @@
-# rand_pcg
-
-[![Build Status](https://travis-ci.org/rust-random/rand.svg?branch=master)](https://travis-ci.org/rust-random/rand)
-[![Build Status](https://ci.appveyor.com/api/projects/status/github/rust-random/rand?svg=true)](https://ci.appveyor.com/project/rust-random/rand)
-[![Latest version](https://img.shields.io/crates/v/rand_pcg.svg)](https://crates.io/crates/rand_pcg)
-[[![Book](https://img.shields.io/badge/book-master-yellow.svg)](https://rust-random.github.io/book/)
-[![API](https://img.shields.io/badge/api-master-yellow.svg)](https://rust-random.github.io/rand/rand_pcg)
-[![API](https://docs.rs/rand_pcg/badge.svg)](https://docs.rs/rand_pcg)
-[![Minimum rustc version](https://img.shields.io/badge/rustc-1.22+-lightgray.svg)](https://github.com/rust-random/rand#rust-version-requirements)
-
-Implements a selection of PCG random number generators.
-
-> PCG is a family of simple fast space-efficient statistically good algorithms
-> for random number generation. [Melissa O'Neill, Harvey Mudd College, 2014].
-
-The PCG algorithms are not suitable for cryptographic uses, but perform well
-in statistical tests, use little memory and are fairly fast.
-See the [pcg-random website](http://www.pcg-random.org/).
-
-This crate depends on [rand_core](https://crates.io/crates/rand_core) and is
-part of the [Rand project](https://github.com/rust-random/rand).
-
-Links:
-
-- [API documentation (master)](https://rust-random.github.io/rand/rand_pcg)
-- [API documentation (docs.rs)](https://docs.rs/rand_pcg)
-- [Changelog](CHANGELOG.md)
-
-
-## Crate Features
-
-`rand_pcg` is `no_std` compatible. It does not require any functionality
-outside of the `core` lib, thus there are no features to configure.
-
-The `serde1` feature includes implementations of `Serialize` and `Deserialize`
-for the included RNGs. NOTE: to use binary serialisation with any of the 64-bit
-output (128-bit internal) RNGs, you must add the following dependency, since the
-`i128` feature is not current enabled by default (this should be fixed soon):
-
-```
-bincode = { version = "1", features = ["i128"] }
-```
-
-
-## License
-
-`rand_pcg` is distributed under the terms of both the MIT license and the
-Apache License (Version 2.0).
-
-See [LICENSE-APACHE](LICENSE-APACHE) and [LICENSE-MIT](LICENSE-MIT), and
-[COPYRIGHT](COPYRIGHT) for details.
diff --git a/rand/rand_pcg/build.rs b/rand/rand_pcg/build.rs
deleted file mode 100644
index 06e12a4..0000000
--- a/rand/rand_pcg/build.rs
+++ /dev/null
@@ -1,7 +0,0 @@
-extern crate autocfg;
-
-fn main() {
- println!("cargo:rerun-if-changed=build.rs");
- let ac = autocfg::new();
- ac.emit_rustc_version(1, 26);
-}
diff --git a/rand/rand_pcg/src/lib.rs b/rand/rand_pcg/src/lib.rs
deleted file mode 100644
index 9648e85..0000000
--- a/rand/rand_pcg/src/lib.rs
+++ /dev/null
@@ -1,48 +0,0 @@
-// Copyright 2018 Developers of the Rand project.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-//! The PCG random number generators.
-//!
-//! This is a native Rust implementation of a small selection of PCG generators.
-//! The primary goal of this crate is simple, minimal, well-tested code; in
-//! other words it is explicitly not a goal to re-implement all of PCG.
-//!
-//! This crate provides:
-//!
-//! - `Pcg32` aka `Lcg64Xsh32`, officially known as `pcg32`, a general
-//! purpose RNG. This is a good choice on both 32-bit and 64-bit CPUs
-//! (for 32-bit output).
-//! - `Pcg64Mcg` aka `Mcg128Xsl64`, officially known as `mcg_xsl_rr_128_64`,
-//! a general purpose RNG using 128-bit multiplications. This has poor
-//! performance on 32-bit CPUs but is a good choice on 64-bit CPUs for
-//! both 32-bit and 64-bit output. (Note: this RNG is only available using
-//! Rust 1.26 or later.)
-//!
-//! Both of these use 16 bytes of state and 128-bit seeds, and are considered
-//! value-stable (i.e. any change affecting the output given a fixed seed would
-//! be considered a breaking change to the crate).
-
-#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk.png",
- html_favicon_url = "https://www.rust-lang.org/favicon.ico",
- html_root_url = "https://rust-random.github.io/rand/")]
-
-#![deny(missing_docs)]
-#![deny(missing_debug_implementations)]
-
-#![no_std]
-
-pub extern crate rand_core;
-
-#[cfg(feature="serde1")] extern crate serde;
-#[cfg(feature="serde1")] #[macro_use] extern crate serde_derive;
-
-mod pcg64;
-#[cfg(all(rustc_1_26, not(target_os = "emscripten")))] mod pcg128;
-
-pub use self::pcg64::{Pcg32, Lcg64Xsh32};
-#[cfg(all(rustc_1_26, not(target_os = "emscripten")))] pub use self::pcg128::{Pcg64Mcg, Mcg128Xsl64};
diff --git a/rand/rand_pcg/src/pcg128.rs b/rand/rand_pcg/src/pcg128.rs
deleted file mode 100644
index 9aff506..0000000
--- a/rand/rand_pcg/src/pcg128.rs
+++ /dev/null
@@ -1,122 +0,0 @@
-// Copyright 2018 Developers of the Rand project.
-// Copyright 2017 Paul Dicker.
-// Copyright 2014-2017 Melissa O'Neill and PCG Project contributors
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-//! PCG random number generators
-
-// This is the default multiplier used by PCG for 64-bit state.
-const MULTIPLIER: u128 = 0x2360_ED05_1FC6_5DA4_4385_DF64_9FCC_F645;
-
-use core::fmt;
-use core::mem::transmute;
-use rand_core::{RngCore, SeedableRng, Error, le};
-
-/// A PCG random number generator (XSL 128/64 (MCG) variant).
-///
-/// Permuted Congruential Generator with 128-bit state, internal Multiplicative
-/// Congruential Generator, and 64-bit output via "xorshift low (bits),
-/// random rotation" output function.
-///
-/// This is a 128-bit MCG with the PCG-XSL-RR output function.
-/// Note that compared to the standard `pcg64` (128-bit LCG with PCG-XSL-RR
-/// output function), this RNG is faster, also has a long cycle, and still has
-/// good performance on statistical tests.
-///
-/// Note: this RNG is only available using Rust 1.26 or later.
-#[derive(Clone)]
-#[cfg_attr(feature="serde1", derive(Serialize,Deserialize))]
-pub struct Mcg128Xsl64 {
- state: u128,
-}
-
-/// A friendly name for `Mcg128Xsl64`.
-pub type Pcg64Mcg = Mcg128Xsl64;
-
-impl Mcg128Xsl64 {
- /// Construct an instance compatible with PCG seed.
- ///
- /// Note that PCG specifies a default value for the parameter:
- ///
- /// - `state = 0xcafef00dd15ea5e5`
- pub fn new(state: u128) -> Self {
- // Force low bit to 1, as in C version (C++ uses `state | 3` instead).
- Mcg128Xsl64 { state: state | 1 }
- }
-}
-
-// Custom Debug implementation that does not expose the internal state
-impl fmt::Debug for Mcg128Xsl64 {
- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
- write!(f, "Mcg128Xsl64 {{}}")
- }
-}
-
-/// We use a single 126-bit seed to initialise the state and select a stream.
-/// Two `seed` bits (lowest order of last byte) are ignored.
-impl SeedableRng for Mcg128Xsl64 {
- type Seed = [u8; 16];
-
- fn from_seed(seed: Self::Seed) -> Self {
- // Read as if a little-endian u128 value:
- let mut seed_u64 = [0u64; 2];
- le::read_u64_into(&seed, &mut seed_u64);
- let state = (seed_u64[0] as u128) |
- (seed_u64[1] as u128) << 64;
- Mcg128Xsl64::new(state)
- }
-}
-
-impl RngCore for Mcg128Xsl64 {
- #[inline]
- fn next_u32(&mut self) -> u32 {
- self.next_u64() as u32
- }
-
- #[inline]
- fn next_u64(&mut self) -> u64 {
- // prepare the LCG for the next round
- let state = self.state.wrapping_mul(MULTIPLIER);
- self.state = state;
-
- // Output function XSL RR ("xorshift low (bits), random rotation")
- // Constants are for 128-bit state, 64-bit output
- const XSHIFT: u32 = 64; // (128 - 64 + 64) / 2
- const ROTATE: u32 = 122; // 128 - 6
-
- let rot = (state >> ROTATE) as u32;
- let xsl = ((state >> XSHIFT) as u64) ^ (state as u64);
- xsl.rotate_right(rot)
- }
-
- #[inline]
- fn fill_bytes(&mut self, dest: &mut [u8]) {
- // specialisation of impls::fill_bytes_via_next; approx 3x faster
- let mut left = dest;
- while left.len() >= 8 {
- let (l, r) = {left}.split_at_mut(8);
- left = r;
- let chunk: [u8; 8] = unsafe {
- transmute(self.next_u64().to_le())
- };
- l.copy_from_slice(&chunk);
- }
- let n = left.len();
- if n > 0 {
- let chunk: [u8; 8] = unsafe {
- transmute(self.next_u64().to_le())
- };
- left.copy_from_slice(&chunk[..n]);
- }
- }
-
- #[inline]
- fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), Error> {
- Ok(self.fill_bytes(dest))
- }
-}
diff --git a/rand/rand_pcg/src/pcg64.rs b/rand/rand_pcg/src/pcg64.rs
deleted file mode 100644
index 9177ec2..0000000
--- a/rand/rand_pcg/src/pcg64.rs
+++ /dev/null
@@ -1,141 +0,0 @@
-// Copyright 2018 Developers of the Rand project.
-// Copyright 2017 Paul Dicker.
-// Copyright 2014-2017 Melissa O'Neill and PCG Project contributors
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-//! PCG random number generators
-
-use core::fmt;
-use core::mem::transmute;
-use rand_core::{RngCore, SeedableRng, Error, le, impls};
-
-// This is the default multiplier used by PCG for 64-bit state.
-const MULTIPLIER: u64 = 6364136223846793005;
-
-/// A PCG random number generator (XSH RR 64/32 (LCG) variant).
-///
-/// Permuted Congruential Generator with 64-bit state, internal Linear
-/// Congruential Generator, and 32-bit output via "xorshift high (bits),
-/// random rotation" output function.
-///
-/// This is a 64-bit LCG with explicitly chosen stream with the PCG-XSH-RR
-/// output function. This combination is the standard `pcg32`.
-///
-/// Despite the name, this implementation uses 16 bytes (128 bit) space
-/// comprising 64 bits of state and 64 bits stream selector. These are both set
-/// by `SeedableRng`, using a 128-bit seed.
-#[derive(Clone)]
-#[cfg_attr(feature="serde1", derive(Serialize,Deserialize))]
-pub struct Lcg64Xsh32 {
- state: u64,
- increment: u64,
-}
-
-/// `Lcg64Xsh32` is also officially known as `pcg32`.
-pub type Pcg32 = Lcg64Xsh32;
-
-impl Lcg64Xsh32 {
- /// Construct an instance compatible with PCG seed and stream.
- ///
- /// Note that PCG specifies default values for both parameters:
- ///
- /// - `state = 0xcafef00dd15ea5e5`
- /// - `stream = 721347520444481703`
- pub fn new(state: u64, stream: u64) -> Self {
- // The increment must be odd, hence we discard one bit:
- let increment = (stream << 1) | 1;
- Lcg64Xsh32::from_state_incr(state, increment)
- }
-
- #[inline]
- fn from_state_incr(state: u64, increment: u64) -> Self {
- let mut pcg = Lcg64Xsh32 { state, increment };
- // Move away from inital value:
- pcg.state = pcg.state.wrapping_add(pcg.increment);
- pcg.step();
- pcg
- }
-
- #[inline]
- fn step(&mut self) {
- // prepare the LCG for the next round
- self.state = self.state
- .wrapping_mul(MULTIPLIER)
- .wrapping_add(self.increment);
- }
-}
-
-// Custom Debug implementation that does not expose the internal state
-impl fmt::Debug for Lcg64Xsh32 {
- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
- write!(f, "Lcg64Xsh32 {{}}")
- }
-}
-
-/// We use a single 127-bit seed to initialise the state and select a stream.
-/// One `seed` bit (lowest bit of `seed[8]`) is ignored.
-impl SeedableRng for Lcg64Xsh32 {
- type Seed = [u8; 16];
-
- fn from_seed(seed: Self::Seed) -> Self {
- let mut seed_u64 = [0u64; 2];
- le::read_u64_into(&seed, &mut seed_u64);
-
- // The increment must be odd, hence we discard one bit:
- Lcg64Xsh32::from_state_incr(seed_u64[0], seed_u64[1] | 1)
- }
-}
-
-impl RngCore for Lcg64Xsh32 {
- #[inline]
- fn next_u32(&mut self) -> u32 {
- let state = self.state;
- self.step();
-
- // Output function XSH RR: xorshift high (bits), followed by a random rotate
- // Constants are for 64-bit state, 32-bit output
- const ROTATE: u32 = 59; // 64 - 5
- const XSHIFT: u32 = 18; // (5 + 32) / 2
- const SPARE: u32 = 27; // 64 - 32 - 5
-
- let rot = (state >> ROTATE) as u32;
- let xsh = (((state >> XSHIFT) ^ state) >> SPARE) as u32;
- xsh.rotate_right(rot)
- }
-
- #[inline]
- fn next_u64(&mut self) -> u64 {
- impls::next_u64_via_u32(self)
- }
-
- #[inline]
- fn fill_bytes(&mut self, dest: &mut [u8]) {
- // specialisation of impls::fill_bytes_via_next; approx 40% faster
- let mut left = dest;
- while left.len() >= 4 {
- let (l, r) = {left}.split_at_mut(4);
- left = r;
- let chunk: [u8; 4] = unsafe {
- transmute(self.next_u32().to_le())
- };
- l.copy_from_slice(&chunk);
- }
- let n = left.len();
- if n > 0 {
- let chunk: [u8; 4] = unsafe {
- transmute(self.next_u32().to_le())
- };
- left.copy_from_slice(&chunk[..n]);
- }
- }
-
- #[inline]
- fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), Error> {
- Ok(self.fill_bytes(dest))
- }
-}
diff --git a/rand/rand_pcg/tests/lcg64xsh32.rs b/rand/rand_pcg/tests/lcg64xsh32.rs
deleted file mode 100644
index 775b12c..0000000
--- a/rand/rand_pcg/tests/lcg64xsh32.rs
+++ /dev/null
@@ -1,58 +0,0 @@
-extern crate rand_pcg;
-extern crate rand_core;
-#[cfg(all(feature="serde1", test))] extern crate bincode;
-
-use rand_core::{RngCore, SeedableRng};
-use rand_pcg::{Lcg64Xsh32, Pcg32};
-
-#[test]
-fn test_lcg64xsh32_construction() {
- // Test that various construction techniques produce a working RNG.
- let seed = [1,2,3,4, 5,6,7,8, 9,10,11,12, 13,14,15,16];
- let mut rng1 = Lcg64Xsh32::from_seed(seed);
- assert_eq!(rng1.next_u64(), 1204678643940597513);
-
- let mut rng2 = Lcg64Xsh32::from_rng(&mut rng1).unwrap();
- assert_eq!(rng2.next_u64(), 12384929573776311845);
-
- let mut rng3 = Lcg64Xsh32::seed_from_u64(0);
- assert_eq!(rng3.next_u64(), 18195738587432868099);
-
- // This is the same as Lcg64Xsh32, so we only have a single test:
- let mut rng4 = Pcg32::seed_from_u64(0);
- assert_eq!(rng4.next_u64(), 18195738587432868099);
-}
-
-#[test]
-fn test_lcg64xsh32_true_values() {
- // Numbers copied from official test suite.
- let mut rng = Lcg64Xsh32::new(42, 54);
-
- let mut results = [0u32; 6];
- for i in results.iter_mut() { *i = rng.next_u32(); }
- let expected: [u32; 6] = [0xa15c02b7, 0x7b47f409, 0xba1d3330,
- 0x83d2f293, 0xbfa4784b, 0xcbed606e];
- assert_eq!(results, expected);
-}
-
-#[cfg(feature="serde1")]
-#[test]
-fn test_lcg64xsh32_serde() {
- use bincode;
- use std::io::{BufWriter, BufReader};
-
- let mut rng = Lcg64Xsh32::seed_from_u64(0);
-
- let buf: Vec<u8> = Vec::new();
- let mut buf = BufWriter::new(buf);
- bincode::serialize_into(&mut buf, &rng).expect("Could not serialize");
-
- let buf = buf.into_inner().unwrap();
- let mut read = BufReader::new(&buf[..]);
- let mut deserialized: Lcg64Xsh32 = bincode::deserialize_from(&mut read)
- .expect("Could not deserialize");
-
- for _ in 0..16 {
- assert_eq!(rng.next_u64(), deserialized.next_u64());
- }
-}
diff --git a/rand/rand_pcg/tests/mcg128xsl64.rs b/rand/rand_pcg/tests/mcg128xsl64.rs
deleted file mode 100644
index 3279536..0000000
--- a/rand/rand_pcg/tests/mcg128xsl64.rs
+++ /dev/null
@@ -1,59 +0,0 @@
-#![cfg(rustc_1_26)]
-extern crate rand_pcg;
-extern crate rand_core;
-#[cfg(all(feature="serde1", test))] extern crate bincode;
-
-use rand_core::{RngCore, SeedableRng};
-use rand_pcg::{Mcg128Xsl64, Pcg64Mcg};
-
-#[test]
-fn test_mcg128xsl64_construction() {
- // Test that various construction techniques produce a working RNG.
- let seed = [1,2,3,4, 5,6,7,8, 9,10,11,12, 13,14,15,16];
- let mut rng1 = Mcg128Xsl64::from_seed(seed);
- assert_eq!(rng1.next_u64(), 7071994460355047496);
-
- let mut rng2 = Mcg128Xsl64::from_rng(&mut rng1).unwrap();
- assert_eq!(rng2.next_u64(), 12300796107712034932);
-
- let mut rng3 = Mcg128Xsl64::seed_from_u64(0);
- assert_eq!(rng3.next_u64(), 6198063878555692194);
-
- // This is the same as Mcg128Xsl64, so we only have a single test:
- let mut rng4 = Pcg64Mcg::seed_from_u64(0);
- assert_eq!(rng4.next_u64(), 6198063878555692194);
-}
-
-#[test]
-fn test_mcg128xsl64_true_values() {
- // Numbers copied from official test suite (C version).
- let mut rng = Mcg128Xsl64::new(42);
-
- let mut results = [0u64; 6];
- for i in results.iter_mut() { *i = rng.next_u64(); }
- let expected: [u64; 6] = [0x63b4a3a813ce700a, 0x382954200617ab24,
- 0xa7fd85ae3fe950ce, 0xd715286aa2887737, 0x60c92fee2e59f32c, 0x84c4e96beff30017];
- assert_eq!(results, expected);
-}
-
-#[cfg(feature="serde1")]
-#[test]
-fn test_mcg128xsl64_serde() {
- use bincode;
- use std::io::{BufWriter, BufReader};
-
- let mut rng = Mcg128Xsl64::seed_from_u64(0);
-
- let buf: Vec<u8> = Vec::new();
- let mut buf = BufWriter::new(buf);
- bincode::serialize_into(&mut buf, &rng).expect("Could not serialize");
-
- let buf = buf.into_inner().unwrap();
- let mut read = BufReader::new(&buf[..]);
- let mut deserialized: Mcg128Xsl64 = bincode::deserialize_from(&mut read)
- .expect("Could not deserialize");
-
- for _ in 0..16 {
- assert_eq!(rng.next_u64(), deserialized.next_u64());
- }
-}
diff --git a/rand/rand_xorshift/CHANGELOG.md b/rand/rand_xorshift/CHANGELOG.md
deleted file mode 100644
index 539af41..0000000
--- a/rand/rand_xorshift/CHANGELOG.md
+++ /dev/null
@@ -1,11 +0,0 @@
-# Changelog
-All notable changes to this project will be documented in this file.
-
-The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
-and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
-
-## [0.1.1] - 2019-01-04
-- Reorganise code and tests; tweak doc
-
-## [0.1.0] - 2018-07-16
-- Pulled out of the Rand crate
diff --git a/rand/rand_xorshift/COPYRIGHT b/rand/rand_xorshift/COPYRIGHT
deleted file mode 100644
index 468d907..0000000
--- a/rand/rand_xorshift/COPYRIGHT
+++ /dev/null
@@ -1,12 +0,0 @@
-Copyrights in the Rand project are retained by their contributors. No
-copyright assignment is required to contribute to the Rand project.
-
-For full authorship information, see the version control history.
-
-Except as otherwise noted (below and/or in individual files), Rand is
-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.
-
-The Rand project includes code from the Rust project
-published under these same licenses.
diff --git a/rand/rand_xorshift/Cargo.toml b/rand/rand_xorshift/Cargo.toml
deleted file mode 100644
index 114fee9..0000000
--- a/rand/rand_xorshift/Cargo.toml
+++ /dev/null
@@ -1,31 +0,0 @@
-[package]
-name = "rand_xorshift"
-version = "0.1.1"
-authors = ["The Rand Project Developers", "The Rust Project Developers"]
-license = "MIT/Apache-2.0"
-readme = "README.md"
-repository = "https://github.com/rust-random/rand"
-documentation = "https://rust-random.github.io/rand/rand_xorshift"
-homepage = "https://crates.io/crates/rand_xorshift"
-description = """
-Xorshift random number generator
-"""
-keywords = ["random", "rng", "xorshift"]
-categories = ["algorithms", "no-std"]
-
-[badges]
-travis-ci = { repository = "rust-random/rand" }
-appveyor = { repository = "rust-random/rand" }
-
-[features]
-serde1 = ["serde", "serde_derive"]
-
-[dependencies]
-rand_core = { path = "../rand_core", version = ">=0.2, <0.4", default-features=false }
-serde = { version = "1", optional = true }
-serde_derive = { version = "^1.0.38", optional = true }
-
-[dev-dependencies]
-# This is for testing serde, unfortunately we can't specify feature-gated dev
-# deps yet, see: https://github.com/rust-lang/cargo/issues/1596
-bincode = "1"
diff --git a/rand/rand_xorshift/LICENSE-APACHE b/rand/rand_xorshift/LICENSE-APACHE
deleted file mode 100644
index 17d7468..0000000
--- a/rand/rand_xorshift/LICENSE-APACHE
+++ /dev/null
@@ -1,201 +0,0 @@
- Apache License
- Version 2.0, January 2004
- https://www.apache.org/licenses/
-
-TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
-1. Definitions.
-
- "License" shall mean the terms and conditions for use, reproduction,
- and distribution as defined by Sections 1 through 9 of this document.
-
- "Licensor" shall mean the copyright owner or entity authorized by
- the copyright owner that is granting the License.
-
- "Legal Entity" shall mean the union of the acting entity and all
- other entities that control, are controlled by, or are under common
- control with that entity. For the purposes of this definition,
- "control" means (i) the power, direct or indirect, to cause the
- direction or management of such entity, whether by contract or
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
- outstanding shares, or (iii) beneficial ownership of such entity.
-
- "You" (or "Your") shall mean an individual or Legal Entity
- exercising permissions granted by this License.
-
- "Source" form shall mean the preferred form for making modifications,
- including but not limited to software source code, documentation
- source, and configuration files.
-
- "Object" form shall mean any form resulting from mechanical
- transformation or translation of a Source form, including but
- not limited to compiled object code, generated documentation,
- and conversions to other media types.
-
- "Work" shall mean the work of authorship, whether in Source or
- Object form, made available under the License, as indicated by a
- copyright notice that is included in or attached to the work
- (an example is provided in the Appendix below).
-
- "Derivative Works" shall mean any work, whether in Source or Object
- form, that is based on (or derived from) the Work and for which the
- editorial revisions, annotations, elaborations, or other modifications
- represent, as a whole, an original work of authorship. For the purposes
- of this License, Derivative Works shall not include works that remain
- separable from, or merely link (or bind by name) to the interfaces of,
- the Work and Derivative Works thereof.
-
- "Contribution" shall mean any work of authorship, including
- the original version of the Work and any modifications or additions
- to that Work or Derivative Works thereof, that is intentionally
- submitted to Licensor for inclusion in the Work by the copyright owner
- or by an individual or Legal Entity authorized to submit on behalf of
- the copyright owner. For the purposes of this definition, "submitted"
- means any form of electronic, verbal, or written communication sent
- to the Licensor or its representatives, including but not limited to
- communication on electronic mailing lists, source code control systems,
- and issue tracking systems that are managed by, or on behalf of, the
- Licensor for the purpose of discussing and improving the Work, but
- excluding communication that is conspicuously marked or otherwise
- designated in writing by the copyright owner as "Not a Contribution."
-
- "Contributor" shall mean Licensor and any individual or Legal Entity
- on behalf of whom a Contribution has been received by Licensor and
- subsequently incorporated within the Work.
-
-2. Grant of Copyright License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- copyright license to reproduce, prepare Derivative Works of,
- publicly display, publicly perform, sublicense, and distribute the
- Work and such Derivative Works in Source or Object form.
-
-3. Grant of Patent License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- (except as stated in this section) patent license to make, have made,
- use, offer to sell, sell, import, and otherwise transfer the Work,
- where such license applies only to those patent claims licensable
- by such Contributor that are necessarily infringed by their
- Contribution(s) alone or by combination of their Contribution(s)
- with the Work to which such Contribution(s) was submitted. If You
- institute patent litigation against any entity (including a
- cross-claim or counterclaim in a lawsuit) alleging that the Work
- or a Contribution incorporated within the Work constitutes direct
- or contributory patent infringement, then any patent licenses
- granted to You under this License for that Work shall terminate
- as of the date such litigation is filed.
-
-4. Redistribution. You may reproduce and distribute copies of the
- Work or Derivative Works thereof in any medium, with or without
- modifications, and in Source or Object form, provided that You
- meet the following conditions:
-
- (a) You must give any other recipients of the Work or
- Derivative Works a copy of this License; and
-
- (b) You must cause any modified files to carry prominent notices
- stating that You changed the files; and
-
- (c) You must retain, in the Source form of any Derivative Works
- that You distribute, all copyright, patent, trademark, and
- attribution notices from the Source form of the Work,
- excluding those notices that do not pertain to any part of
- the Derivative Works; and
-
- (d) If the Work includes a "NOTICE" text file as part of its
- distribution, then any Derivative Works that You distribute must
- include a readable copy of the attribution notices contained
- within such NOTICE file, excluding those notices that do not
- pertain to any part of the Derivative Works, in at least one
- of the following places: within a NOTICE text file distributed
- as part of the Derivative Works; within the Source form or
- documentation, if provided along with the Derivative Works; or,
- within a display generated by the Derivative Works, if and
- wherever such third-party notices normally appear. The contents
- of the NOTICE file are for informational purposes only and
- do not modify the License. You may add Your own attribution
- notices within Derivative Works that You distribute, alongside
- or as an addendum to the NOTICE text from the Work, provided
- that such additional attribution notices cannot be construed
- as modifying the License.
-
- You may add Your own copyright statement to Your modifications and
- may provide additional or different license terms and conditions
- for use, reproduction, or distribution of Your modifications, or
- for any such Derivative Works as a whole, provided Your use,
- reproduction, and distribution of the Work otherwise complies with
- the conditions stated in this License.
-
-5. Submission of Contributions. Unless You explicitly state otherwise,
- any Contribution intentionally submitted for inclusion in the Work
- by You to the Licensor shall be under the terms and conditions of
- this License, without any additional terms or conditions.
- Notwithstanding the above, nothing herein shall supersede or modify
- the terms of any separate license agreement you may have executed
- with Licensor regarding such Contributions.
-
-6. Trademarks. This License does not grant permission to use the trade
- names, trademarks, service marks, or product names of the Licensor,
- except as required for reasonable and customary use in describing the
- origin of the Work and reproducing the content of the NOTICE file.
-
-7. Disclaimer of Warranty. Unless required by applicable law or
- agreed to in writing, Licensor provides the Work (and each
- Contributor provides its Contributions) on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- implied, including, without limitation, any warranties or conditions
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
- PARTICULAR PURPOSE. You are solely responsible for determining the
- appropriateness of using or redistributing the Work and assume any
- risks associated with Your exercise of permissions under this License.
-
-8. Limitation of Liability. In no event and under no legal theory,
- whether in tort (including negligence), contract, or otherwise,
- unless required by applicable law (such as deliberate and grossly
- negligent acts) or agreed to in writing, shall any Contributor be
- liable to You for damages, including any direct, indirect, special,
- incidental, or consequential damages of any character arising as a
- result of this License or out of the use or inability to use the
- Work (including but not limited to damages for loss of goodwill,
- work stoppage, computer failure or malfunction, or any and all
- other commercial damages or losses), even if such Contributor
- has been advised of the possibility of such damages.
-
-9. Accepting Warranty or Additional Liability. While redistributing
- the Work or Derivative Works thereof, You may choose to offer,
- and charge a fee for, acceptance of support, warranty, indemnity,
- or other liability obligations and/or rights consistent with this
- License. However, in accepting such obligations, You may act only
- on Your own behalf and on Your sole responsibility, not on behalf
- of any other Contributor, and only if You agree to indemnify,
- defend, and hold each Contributor harmless for any liability
- incurred by, or claims asserted against, such Contributor by reason
- of your accepting any such warranty or additional liability.
-
-END OF TERMS AND CONDITIONS
-
-APPENDIX: How to apply the Apache License to your work.
-
- To apply the Apache License to your work, attach the following
- boilerplate notice, with the fields enclosed by brackets "[]"
- replaced with your own identifying information. (Don't include
- the brackets!) The text should be enclosed in the appropriate
- comment syntax for the file format. We also recommend that a
- file or class name and description of purpose be included on the
- same "printed page" as the copyright notice for easier
- identification within third-party archives.
-
-Copyright [yyyy] [name of copyright owner]
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
- https://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
diff --git a/rand/rand_xorshift/LICENSE-MIT b/rand/rand_xorshift/LICENSE-MIT
deleted file mode 100644
index d93b5ba..0000000
--- a/rand/rand_xorshift/LICENSE-MIT
+++ /dev/null
@@ -1,26 +0,0 @@
-Copyright 2018 Developers of the Rand project
-Copyright (c) 2014 The Rust Project Developers
-
-Permission is hereby granted, free of charge, to any
-person obtaining a copy of this software and associated
-documentation files (the "Software"), to deal in the
-Software without restriction, including without
-limitation the rights to use, copy, modify, merge,
-publish, distribute, sublicense, and/or sell copies of
-the Software, and to permit persons to whom the Software
-is furnished to do so, subject to the following
-conditions:
-
-The above copyright notice and this permission notice
-shall be included in all copies or substantial portions
-of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
-ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
-TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
-PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
-SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
-CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
-IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
-DEALINGS IN THE SOFTWARE.
diff --git a/rand/rand_xorshift/README.md b/rand/rand_xorshift/README.md
deleted file mode 100644
index 573ee12..0000000
--- a/rand/rand_xorshift/README.md
+++ /dev/null
@@ -1,45 +0,0 @@
-# rand_xorshift
-
-[![Build Status](https://travis-ci.org/rust-random/rand.svg)](https://travis-ci.org/rust-random/rand)
-[![Build Status](https://ci.appveyor.com/api/projects/status/github/rust-random/rand?svg=true)](https://ci.appveyor.com/project/rust-random/rand)
-[![Latest version](https://img.shields.io/crates/v/rand_xorshift.svg)](https://crates.io/crates/rand_xorshift)
-[![Book](https://img.shields.io/badge/book-master-yellow.svg)](https://rust-random.github.io/book/)
-[![API](https://img.shields.io/badge/api-master-yellow.svg)](https://rust-random.github.io/rand/rand_xorshift)
-[![API](https://docs.rs/rand_xorshift/badge.svg)](https://docs.rs/rand_xorshift)
-[![Minimum rustc version](https://img.shields.io/badge/rustc-1.22+-lightgray.svg)](https://github.com/rust-random/rand#rust-version-requirements)
-
-Implements the Xorshift random number generator.
-
-The Xorshift[^1] algorithm is not suitable for cryptographic purposes
-but is very fast. If you do not know for sure that it fits your
-requirements, use a more secure one such as `StdRng` or `OsRng`.
-
-[^1]: Marsaglia, George (July 2003).
- ["Xorshift RNGs"](https://www.jstatsoft.org/v08/i14/paper).
- *Journal of Statistical Software*. Vol. 8 (Issue 14).
-
-Links:
-
-- [API documentation (master)](https://rust-random.github.io/rand/rand_xorshift)
-- [API documentation (docs.rs)](https://docs.rs/rand_xorshift)
-- [Changelog](CHANGELOG.md)
-
-[rand]: https://crates.io/crates/rand
-
-
-## Crate Features
-
-`rand_xorshift` is `no_std` compatible. It does not require any functionality
-outside of the `core` lib, thus there are no features to configure.
-
-The `serde1` feature includes implementations of `Serialize` and `Deserialize`
-for the included RNGs.
-
-
-## License
-
-`rand_xorshift` is distributed under the terms of both the MIT license and the
-Apache License (Version 2.0).
-
-See [LICENSE-APACHE](LICENSE-APACHE) and [LICENSE-MIT](LICENSE-MIT), and
-[COPYRIGHT](COPYRIGHT) for details.
diff --git a/rand/rand_xorshift/src/lib.rs b/rand/rand_xorshift/src/lib.rs
deleted file mode 100644
index db42ba2..0000000
--- a/rand/rand_xorshift/src/lib.rs
+++ /dev/null
@@ -1,123 +0,0 @@
-// Copyright 2018 Developers of the Rand project.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-//! The xorshift random number generator.
-
-#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk.png",
- html_favicon_url = "https://www.rust-lang.org/favicon.ico",
- html_root_url = "https://rust-random.github.io/rand/")]
-
-#![deny(missing_docs)]
-#![deny(missing_debug_implementations)]
-
-#![no_std]
-
-pub extern crate rand_core;
-
-#[cfg(feature="serde1")] extern crate serde;
-#[cfg(feature="serde1")] #[macro_use] extern crate serde_derive;
-
-use core::num::Wrapping as w;
-use core::{fmt, slice};
-use rand_core::{RngCore, SeedableRng, Error, impls, le};
-
-/// An Xorshift random number generator.
-///
-/// The Xorshift[^1] algorithm is not suitable for cryptographic purposes
-/// but is very fast. If you do not know for sure that it fits your
-/// requirements, use a more secure one such as `StdRng` or `OsRng`.
-///
-/// [^1]: Marsaglia, George (July 2003).
-/// ["Xorshift RNGs"](https://www.jstatsoft.org/v08/i14/paper).
-/// *Journal of Statistical Software*. Vol. 8 (Issue 14).
-#[derive(Clone)]
-#[cfg_attr(feature="serde1", derive(Serialize,Deserialize))]
-pub struct XorShiftRng {
- x: w<u32>,
- y: w<u32>,
- z: w<u32>,
- w: w<u32>,
-}
-
-// Custom Debug implementation that does not expose the internal state
-impl fmt::Debug for XorShiftRng {
- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
- write!(f, "XorShiftRng {{}}")
- }
-}
-
-impl RngCore for XorShiftRng {
- #[inline]
- fn next_u32(&mut self) -> u32 {
- let x = self.x;
- let t = x ^ (x << 11);
- self.x = self.y;
- self.y = self.z;
- self.z = self.w;
- let w_ = self.w;
- self.w = w_ ^ (w_ >> 19) ^ (t ^ (t >> 8));
- self.w.0
- }
-
- #[inline]
- fn next_u64(&mut self) -> u64 {
- impls::next_u64_via_u32(self)
- }
-
- #[inline]
- fn fill_bytes(&mut self, dest: &mut [u8]) {
- impls::fill_bytes_via_next(self, dest)
- }
-
- fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), Error> {
- Ok(self.fill_bytes(dest))
- }
-}
-
-impl SeedableRng for XorShiftRng {
- type Seed = [u8; 16];
-
- fn from_seed(seed: Self::Seed) -> Self {
- let mut seed_u32 = [0u32; 4];
- le::read_u32_into(&seed, &mut seed_u32);
-
- // Xorshift cannot be seeded with 0 and we cannot return an Error, but
- // also do not wish to panic (because a random seed can legitimately be
- // 0); our only option is therefore to use a preset value.
- if seed_u32.iter().all(|&x| x == 0) {
- seed_u32 = [0xBAD_5EED, 0xBAD_5EED, 0xBAD_5EED, 0xBAD_5EED];
- }
-
- XorShiftRng {
- x: w(seed_u32[0]),
- y: w(seed_u32[1]),
- z: w(seed_u32[2]),
- w: w(seed_u32[3]),
- }
- }
-
- fn from_rng<R: RngCore>(mut rng: R) -> Result<Self, Error> {
- let mut seed_u32 = [0u32; 4];
- loop {
- unsafe {
- let ptr = seed_u32.as_mut_ptr() as *mut u8;
-
- let slice = slice::from_raw_parts_mut(ptr, 4 * 4);
- rng.try_fill_bytes(slice)?;
- }
- if !seed_u32.iter().all(|&x| x == 0) { break; }
- }
-
- Ok(XorShiftRng {
- x: w(seed_u32[0]),
- y: w(seed_u32[1]),
- z: w(seed_u32[2]),
- w: w(seed_u32[3]),
- })
- }
-}
diff --git a/rand/rand_xorshift/tests/mod.rs b/rand/rand_xorshift/tests/mod.rs
deleted file mode 100644
index 8374b64..0000000
--- a/rand/rand_xorshift/tests/mod.rs
+++ /dev/null
@@ -1,92 +0,0 @@
-extern crate rand_core;
-extern crate rand_xorshift;
-#[cfg(all(feature="serde1", test))] extern crate bincode;
-
-use rand_core::{RngCore, SeedableRng};
-use rand_xorshift::XorShiftRng;
-
-#[test]
-fn test_xorshift_construction() {
- // Test that various construction techniques produce a working RNG.
- let seed = [1,2,3,4, 5,6,7,8, 9,10,11,12, 13,14,15,16];
- let mut rng1 = XorShiftRng::from_seed(seed);
- assert_eq!(rng1.next_u64(), 4325440999699518727);
-
- let _rng2 = XorShiftRng::from_rng(rng1).unwrap();
- // Note: we cannot test the state of _rng2 because from_rng does not
- // fix Endianness. This is allowed in the trait specification.
-}
-
-#[test]
-fn test_xorshift_true_values() {
- let seed = [16,15,14,13, 12,11,10,9, 8,7,6,5, 4,3,2,1];
- let mut rng = XorShiftRng::from_seed(seed);
-
- let mut results = [0u32; 9];
- for i in results.iter_mut() { *i = rng.next_u32(); }
- let expected: [u32; 9] = [
- 2081028795, 620940381, 269070770, 16943764, 854422573, 29242889,
- 1550291885, 1227154591, 271695242];
- assert_eq!(results, expected);
-
- let mut results = [0u64; 9];
- for i in results.iter_mut() { *i = rng.next_u64(); }
- let expected: [u64; 9] = [
- 9247529084182843387, 8321512596129439293, 14104136531997710878,
- 6848554330849612046, 343577296533772213, 17828467390962600268,
- 9847333257685787782, 7717352744383350108, 1133407547287910111];
- assert_eq!(results, expected);
-
- let mut results = [0u8; 32];
- rng.fill_bytes(&mut results);
- let expected = [102, 57, 212, 16, 233, 130, 49, 183,
- 158, 187, 44, 203, 63, 149, 45, 17,
- 117, 129, 131, 160, 70, 121, 158, 155,
- 224, 209, 192, 53, 10, 62, 57, 72];
- assert_eq!(results, expected);
-}
-
-#[test]
-fn test_xorshift_zero_seed() {
- // Xorshift does not work with an all zero seed.
- // Assert it does not panic.
- let seed = [0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0];
- let mut rng = XorShiftRng::from_seed(seed);
- let a = rng.next_u64();
- let b = rng.next_u64();
- assert!(a != 0);
- assert!(b != a);
-}
-
-#[test]
-fn test_xorshift_clone() {
- let seed = [1,2,3,4, 5,5,7,8, 8,7,6,5, 4,3,2,1];
- let mut rng1 = XorShiftRng::from_seed(seed);
- let mut rng2 = rng1.clone();
- for _ in 0..16 {
- assert_eq!(rng1.next_u64(), rng2.next_u64());
- }
-}
-
-#[cfg(feature="serde1")]
-#[test]
-fn test_xorshift_serde() {
- use bincode;
- use std::io::{BufWriter, BufReader};
-
- let seed = [1,2,3,4, 5,6,7,8, 9,10,11,12, 13,14,15,16];
- let mut rng = XorShiftRng::from_seed(seed);
-
- let buf: Vec<u8> = Vec::new();
- let mut buf = BufWriter::new(buf);
- bincode::serialize_into(&mut buf, &rng).expect("Could not serialize");
-
- let buf = buf.into_inner().unwrap();
- let mut read = BufReader::new(&buf[..]);
- let mut deserialized: XorShiftRng = bincode::deserialize_from(&mut read)
- .expect("Could not deserialize");
-
- for _ in 0..16 {
- assert_eq!(rng.next_u64(), deserialized.next_u64());
- }
-}
diff --git a/rand/rand_xoshiro/CHANGELOG.md b/rand/rand_xoshiro/CHANGELOG.md
deleted file mode 100644
index b23c990..0000000
--- a/rand/rand_xoshiro/CHANGELOG.md
+++ /dev/null
@@ -1,8 +0,0 @@
-# Changelog
-All notable changes to this project will be documented in this file.
-
-The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
-and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
-
-## [0.1.0] - 2019-01-04
-Initial release.
diff --git a/rand/rand_xoshiro/COPYRIGHT b/rand/rand_xoshiro/COPYRIGHT
deleted file mode 100644
index 468d907..0000000
--- a/rand/rand_xoshiro/COPYRIGHT
+++ /dev/null
@@ -1,12 +0,0 @@
-Copyrights in the Rand project are retained by their contributors. No
-copyright assignment is required to contribute to the Rand project.
-
-For full authorship information, see the version control history.
-
-Except as otherwise noted (below and/or in individual files), Rand is
-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.
-
-The Rand project includes code from the Rust project
-published under these same licenses.
diff --git a/rand/rand_xoshiro/Cargo.toml b/rand/rand_xoshiro/Cargo.toml
deleted file mode 100644
index 8d174c7..0000000
--- a/rand/rand_xoshiro/Cargo.toml
+++ /dev/null
@@ -1,19 +0,0 @@
-[package]
-name = "rand_xoshiro"
-version = "0.1.0" # NB: When modifying, also modify html_root_url in lib.rs
-authors = ["The Rand Project Developers"]
-license = "MIT/Apache-2.0"
-readme = "README.md"
-repository = "https://github.com/rust-random/rand"
-documentation = "https://docs.rs/rand_xoshiro"
-homepage = "https://crates.io/crates/rand_xoshiro"
-description = "Xoshiro, xoroshiro and splitmix64 random number generators"
-keywords = ["random", "rng"]
-categories = ["algorithms"]
-
-[dependencies]
-byteorder = { version = "1", default-features=false }
-rand_core = { path = "../rand_core", version = "0.3", default-features=false }
-
-[dev-dependencies]
-rand = { path = "..", version = "0.6", default-features=false } # needed for doctests
diff --git a/rand/rand_xoshiro/LICENSE-APACHE b/rand/rand_xoshiro/LICENSE-APACHE
deleted file mode 100644
index 16fe87b..0000000
--- a/rand/rand_xoshiro/LICENSE-APACHE
+++ /dev/null
@@ -1,201 +0,0 @@
- Apache License
- Version 2.0, January 2004
- http://www.apache.org/licenses/
-
-TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
-1. Definitions.
-
- "License" shall mean the terms and conditions for use, reproduction,
- and distribution as defined by Sections 1 through 9 of this document.
-
- "Licensor" shall mean the copyright owner or entity authorized by
- the copyright owner that is granting the License.
-
- "Legal Entity" shall mean the union of the acting entity and all
- other entities that control, are controlled by, or are under common
- control with that entity. For the purposes of this definition,
- "control" means (i) the power, direct or indirect, to cause the
- direction or management of such entity, whether by contract or
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
- outstanding shares, or (iii) beneficial ownership of such entity.
-
- "You" (or "Your") shall mean an individual or Legal Entity
- exercising permissions granted by this License.
-
- "Source" form shall mean the preferred form for making modifications,
- including but not limited to software source code, documentation
- source, and configuration files.
-
- "Object" form shall mean any form resulting from mechanical
- transformation or translation of a Source form, including but
- not limited to compiled object code, generated documentation,
- and conversions to other media types.
-
- "Work" shall mean the work of authorship, whether in Source or
- Object form, made available under the License, as indicated by a
- copyright notice that is included in or attached to the work
- (an example is provided in the Appendix below).
-
- "Derivative Works" shall mean any work, whether in Source or Object
- form, that is based on (or derived from) the Work and for which the
- editorial revisions, annotations, elaborations, or other modifications
- represent, as a whole, an original work of authorship. For the purposes
- of this License, Derivative Works shall not include works that remain
- separable from, or merely link (or bind by name) to the interfaces of,
- the Work and Derivative Works thereof.
-
- "Contribution" shall mean any work of authorship, including
- the original version of the Work and any modifications or additions
- to that Work or Derivative Works thereof, that is intentionally
- submitted to Licensor for inclusion in the Work by the copyright owner
- or by an individual or Legal Entity authorized to submit on behalf of
- the copyright owner. For the purposes of this definition, "submitted"
- means any form of electronic, verbal, or written communication sent
- to the Licensor or its representatives, including but not limited to
- communication on electronic mailing lists, source code control systems,
- and issue tracking systems that are managed by, or on behalf of, the
- Licensor for the purpose of discussing and improving the Work, but
- excluding communication that is conspicuously marked or otherwise
- designated in writing by the copyright owner as "Not a Contribution."
-
- "Contributor" shall mean Licensor and any individual or Legal Entity
- on behalf of whom a Contribution has been received by Licensor and
- subsequently incorporated within the Work.
-
-2. Grant of Copyright License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- copyright license to reproduce, prepare Derivative Works of,
- publicly display, publicly perform, sublicense, and distribute the
- Work and such Derivative Works in Source or Object form.
-
-3. Grant of Patent License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- (except as stated in this section) patent license to make, have made,
- use, offer to sell, sell, import, and otherwise transfer the Work,
- where such license applies only to those patent claims licensable
- by such Contributor that are necessarily infringed by their
- Contribution(s) alone or by combination of their Contribution(s)
- with the Work to which such Contribution(s) was submitted. If You
- institute patent litigation against any entity (including a
- cross-claim or counterclaim in a lawsuit) alleging that the Work
- or a Contribution incorporated within the Work constitutes direct
- or contributory patent infringement, then any patent licenses
- granted to You under this License for that Work shall terminate
- as of the date such litigation is filed.
-
-4. Redistribution. You may reproduce and distribute copies of the
- Work or Derivative Works thereof in any medium, with or without
- modifications, and in Source or Object form, provided that You
- meet the following conditions:
-
- (a) You must give any other recipients of the Work or
- Derivative Works a copy of this License; and
-
- (b) You must cause any modified files to carry prominent notices
- stating that You changed the files; and
-
- (c) You must retain, in the Source form of any Derivative Works
- that You distribute, all copyright, patent, trademark, and
- attribution notices from the Source form of the Work,
- excluding those notices that do not pertain to any part of
- the Derivative Works; and
-
- (d) If the Work includes a "NOTICE" text file as part of its
- distribution, then any Derivative Works that You distribute must
- include a readable copy of the attribution notices contained
- within such NOTICE file, excluding those notices that do not
- pertain to any part of the Derivative Works, in at least one
- of the following places: within a NOTICE text file distributed
- as part of the Derivative Works; within the Source form or
- documentation, if provided along with the Derivative Works; or,
- within a display generated by the Derivative Works, if and
- wherever such third-party notices normally appear. The contents
- of the NOTICE file are for informational purposes only and
- do not modify the License. You may add Your own attribution
- notices within Derivative Works that You distribute, alongside
- or as an addendum to the NOTICE text from the Work, provided
- that such additional attribution notices cannot be construed
- as modifying the License.
-
- You may add Your own copyright statement to Your modifications and
- may provide additional or different license terms and conditions
- for use, reproduction, or distribution of Your modifications, or
- for any such Derivative Works as a whole, provided Your use,
- reproduction, and distribution of the Work otherwise complies with
- the conditions stated in this License.
-
-5. Submission of Contributions. Unless You explicitly state otherwise,
- any Contribution intentionally submitted for inclusion in the Work
- by You to the Licensor shall be under the terms and conditions of
- this License, without any additional terms or conditions.
- Notwithstanding the above, nothing herein shall supersede or modify
- the terms of any separate license agreement you may have executed
- with Licensor regarding such Contributions.
-
-6. Trademarks. This License does not grant permission to use the trade
- names, trademarks, service marks, or product names of the Licensor,
- except as required for reasonable and customary use in describing the
- origin of the Work and reproducing the content of the NOTICE file.
-
-7. Disclaimer of Warranty. Unless required by applicable law or
- agreed to in writing, Licensor provides the Work (and each
- Contributor provides its Contributions) on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- implied, including, without limitation, any warranties or conditions
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
- PARTICULAR PURPOSE. You are solely responsible for determining the
- appropriateness of using or redistributing the Work and assume any
- risks associated with Your exercise of permissions under this License.
-
-8. Limitation of Liability. In no event and under no legal theory,
- whether in tort (including negligence), contract, or otherwise,
- unless required by applicable law (such as deliberate and grossly
- negligent acts) or agreed to in writing, shall any Contributor be
- liable to You for damages, including any direct, indirect, special,
- incidental, or consequential damages of any character arising as a
- result of this License or out of the use or inability to use the
- Work (including but not limited to damages for loss of goodwill,
- work stoppage, computer failure or malfunction, or any and all
- other commercial damages or losses), even if such Contributor
- has been advised of the possibility of such damages.
-
-9. Accepting Warranty or Additional Liability. While redistributing
- the Work or Derivative Works thereof, You may choose to offer,
- and charge a fee for, acceptance of support, warranty, indemnity,
- or other liability obligations and/or rights consistent with this
- License. However, in accepting such obligations, You may act only
- on Your own behalf and on Your sole responsibility, not on behalf
- of any other Contributor, and only if You agree to indemnify,
- defend, and hold each Contributor harmless for any liability
- incurred by, or claims asserted against, such Contributor by reason
- of your accepting any such warranty or additional liability.
-
-END OF TERMS AND CONDITIONS
-
-APPENDIX: How to apply the Apache License to your work.
-
- To apply the Apache License to your work, attach the following
- boilerplate notice, with the fields enclosed by brackets "[]"
- replaced with your own identifying information. (Don't include
- the brackets!) The text should be enclosed in the appropriate
- comment syntax for the file format. We also recommend that a
- file or class name and description of purpose be included on the
- same "printed page" as the copyright notice for easier
- identification within third-party archives.
-
-Copyright [yyyy] [name of copyright owner]
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
diff --git a/rand/rand_xoshiro/LICENSE-MIT b/rand/rand_xoshiro/LICENSE-MIT
deleted file mode 100644
index a5e040c..0000000
--- a/rand/rand_xoshiro/LICENSE-MIT
+++ /dev/null
@@ -1,25 +0,0 @@
-Copyright (c) 2018 Developers of the Rand project
-
-Permission is hereby granted, free of charge, to any
-person obtaining a copy of this software and associated
-documentation files (the "Software"), to deal in the
-Software without restriction, including without
-limitation the rights to use, copy, modify, merge,
-publish, distribute, sublicense, and/or sell copies of
-the Software, and to permit persons to whom the Software
-is furnished to do so, subject to the following
-conditions:
-
-The above copyright notice and this permission notice
-shall be included in all copies or substantial portions
-of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
-ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
-TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
-PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
-SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
-CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
-IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
-DEALINGS IN THE SOFTWARE.
diff --git a/rand/rand_xoshiro/README.md b/rand/rand_xoshiro/README.md
deleted file mode 100644
index 014477e..0000000
--- a/rand/rand_xoshiro/README.md
+++ /dev/null
@@ -1,28 +0,0 @@
-# rand_xoshiro
-
-[![Build Status](https://travis-ci.org/rust-random/rand.svg?branch=master)](https://travis-ci.org/rust-random/rand)
-[![Build Status](https://ci.appveyor.com/api/projects/status/github/rust-random/rand?svg=true)](https://ci.appveyor.com/project/rust-random/rand)
-[![Latest version](https://img.shields.io/crates/v/rand_xoshiro.svg)](https://crates.io/crates/rand_xoshiro)
-[![Book](https://img.shields.io/badge/book-master-yellow.svg)](https://rust-random.github.io/book/)
-[![API](https://img.shields.io/badge/api-master-yellow.svg)](https://rust-random.github.io/rand/rand_xoshiro)
-[![API](https://docs.rs/rand_xoshiro/badge.svg)](https://docs.rs/rand_xoshiro)
-[![Minimum rustc version](https://img.shields.io/badge/rustc-1.22+-lightgray.svg)](https://github.com/rust-random/rand#rust-version-requirements)
-
-Rust implementation of the [xoshiro, xoroshiro and splitmix64](http://xoshiro.di.unimi.it) random number generators.
-
-This crate depends on [rand_core](https://crates.io/crates/rand_core) and is
-part of the [Rand project](https://github.com/rust-random/rand).
-
-Links:
-
-- [API documentation (master)](https://rust-random.github.io/rand/rand_xoshiro)
-- [API documentation (docs.rs)](https://docs.rs/rand_xoshiro)
-- [Changelog](CHANGELOG.md)
-
-## License
-
-`rand_xoshiro` is distributed under the terms of both the MIT license and the
-Apache License (Version 2.0).
-
-See [LICENSE-APACHE](LICENSE-APACHE) and [LICENSE-MIT](LICENSE-MIT), and
-[COPYRIGHT](COPYRIGHT) for details.
diff --git a/rand/rand_xoshiro/src/common.rs b/rand/rand_xoshiro/src/common.rs
deleted file mode 100644
index 9ee09e2..0000000
--- a/rand/rand_xoshiro/src/common.rs
+++ /dev/null
@@ -1,243 +0,0 @@
-// Copyright 2018 Developers of the Rand project.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-/// Initialize a RNG from a `u64` seed using `SplitMix64`.
-macro_rules! from_splitmix {
- ($seed:expr) => { {
- let mut rng = ::SplitMix64::seed_from_u64($seed);
- Self::from_rng(&mut rng).unwrap()
- } }
-}
-
-/// Apply the ** scrambler used by some RNGs from the xoshiro family.
-macro_rules! starstar_u64 {
- ($x:expr) => {
- $x.wrapping_mul(5).rotate_left(7).wrapping_mul(9)
- }
-}
-
-/// Apply the ** scrambler used by some RNGs from the xoshiro family.
-macro_rules! starstar_u32 {
- ($x:expr) => {
- $x.wrapping_mul(0x9E3779BB).rotate_left(5).wrapping_mul(5)
- }
-}
-
-/// Implement a jump function for an RNG from the xoshiro family.
-macro_rules! impl_jump {
- (u32, $self:expr, [$j0:expr, $j1:expr]) => {
- const JUMP: [u32; 2] = [$j0, $j1];
- let mut s0 = 0;
- let mut s1 = 0;
- for j in &JUMP {
- for b in 0..32 {
- if (j & 1 << b) != 0 {
- s0 ^= $self.s0;
- s1 ^= $self.s1;
- }
- $self.next_u32();
- }
- }
- $self.s0 = s0;
- $self.s1 = s1;
- };
- (u64, $self:expr, [$j0:expr, $j1:expr]) => {
- const JUMP: [u64; 2] = [$j0, $j1];
- let mut s0 = 0;
- let mut s1 = 0;
- for j in &JUMP {
- for b in 0..64 {
- if (j & 1 << b) != 0 {
- s0 ^= $self.s0;
- s1 ^= $self.s1;
- }
- $self.next_u64();
- }
- }
- $self.s0 = s0;
- $self.s1 = s1;
- };
- (u32, $self:expr, [$j0:expr, $j1:expr, $j2:expr, $j3:expr]) => {
- const JUMP: [u32; 4] = [$j0, $j1, $j2, $j3];
- let mut s0 = 0;
- let mut s1 = 0;
- let mut s2 = 0;
- let mut s3 = 0;
- for j in &JUMP {
- for b in 0..32 {
- if (j & 1 << b) != 0 {
- s0 ^= $self.s[0];
- s1 ^= $self.s[1];
- s2 ^= $self.s[2];
- s3 ^= $self.s[3];
- }
- $self.next_u32();
- }
- }
- $self.s[0] = s0;
- $self.s[1] = s1;
- $self.s[2] = s2;
- $self.s[3] = s3;
- };
- (u64, $self:expr, [$j0:expr, $j1:expr, $j2:expr, $j3:expr]) => {
- const JUMP: [u64; 4] = [$j0, $j1, $j2, $j3];
- let mut s0 = 0;
- let mut s1 = 0;
- let mut s2 = 0;
- let mut s3 = 0;
- for j in &JUMP {
- for b in 0..64 {
- if (j & 1 << b) != 0 {
- s0 ^= $self.s[0];
- s1 ^= $self.s[1];
- s2 ^= $self.s[2];
- s3 ^= $self.s[3];
- }
- $self.next_u64();
- }
- }
- $self.s[0] = s0;
- $self.s[1] = s1;
- $self.s[2] = s2;
- $self.s[3] = s3;
- };
- (u64, $self:expr, [$j0:expr, $j1:expr, $j2:expr, $j3:expr,
- $j4:expr, $j5:expr, $j6:expr, $j7:expr]) => {
- const JUMP: [u64; 8] = [$j0, $j1, $j2, $j3, $j4, $j5, $j6, $j7];
- let mut s = [0; 8];
- for j in &JUMP {
- for b in 0..64 {
- if (j & 1 << b) != 0 {
- s[0] ^= $self.s[0];
- s[1] ^= $self.s[1];
- s[2] ^= $self.s[2];
- s[3] ^= $self.s[3];
- s[4] ^= $self.s[4];
- s[5] ^= $self.s[5];
- s[6] ^= $self.s[6];
- s[7] ^= $self.s[7];
- }
- $self.next_u64();
- }
- }
- $self.s = s;
- };
-}
-
-/// Implement the xoroshiro iteration.
-macro_rules! impl_xoroshiro_u32 {
- ($self:expr) => {
- $self.s1 ^= $self.s0;
- $self.s0 = $self.s0.rotate_left(26) ^ $self.s1 ^ ($self.s1 << 9);
- $self.s1 = $self.s1.rotate_left(13);
- }
-}
-
-/// Implement the xoroshiro iteration.
-macro_rules! impl_xoroshiro_u64 {
- ($self:expr) => {
- $self.s1 ^= $self.s0;
- $self.s0 = $self.s0.rotate_left(24) ^ $self.s1 ^ ($self.s1 << 16);
- $self.s1 = $self.s1.rotate_left(37);
- }
-}
-
-/// Implement the xoshiro iteration for `u32` output.
-macro_rules! impl_xoshiro_u32 {
- ($self:expr) => {
- let t = $self.s[1] << 9;
-
- $self.s[2] ^= $self.s[0];
- $self.s[3] ^= $self.s[1];
- $self.s[1] ^= $self.s[2];
- $self.s[0] ^= $self.s[3];
-
- $self.s[2] ^= t;
-
- $self.s[3] = $self.s[3].rotate_left(11);
- }
-}
-
-/// Implement the xoshiro iteration for `u64` output.
-macro_rules! impl_xoshiro_u64 {
- ($self:expr) => {
- let t = $self.s[1] << 17;
-
- $self.s[2] ^= $self.s[0];
- $self.s[3] ^= $self.s[1];
- $self.s[1] ^= $self.s[2];
- $self.s[0] ^= $self.s[3];
-
- $self.s[2] ^= t;
-
- $self.s[3] = $self.s[3].rotate_left(45);
- }
-}
-
-/// Implement the large-state xoshiro iteration.
-macro_rules! impl_xoshiro_large {
- ($self:expr) => {
- let t = $self.s[1] << 11;
-
- $self.s[2] ^= $self.s[0];
- $self.s[5] ^= $self.s[1];
- $self.s[1] ^= $self.s[2];
- $self.s[7] ^= $self.s[3];
- $self.s[3] ^= $self.s[4];
- $self.s[4] ^= $self.s[5];
- $self.s[0] ^= $self.s[6];
- $self.s[6] ^= $self.s[7];
-
- $self.s[6] ^= t;
-
- $self.s[7] = $self.s[7].rotate_left(21);
- }
-}
-
-/// Map an all-zero seed to a different one.
-macro_rules! deal_with_zero_seed {
- ($seed:expr, $Self:ident) => {
- if $seed.iter().all(|&x| x == 0) {
- return $Self::seed_from_u64(0);
- }
- }
-}
-
-/// 512-bit seed for a generator.
-///
-/// This wrapper is necessary, because some traits required for a seed are not
-/// implemented on large arrays.
-#[derive(Clone)]
-pub struct Seed512(pub [u8; 64]);
-
-use core;
-impl Seed512 {
- /// Return an iterator over the seed.
- pub fn iter(&self) -> core::slice::Iter<u8> {
- self.0.iter()
- }
-}
-
-impl core::fmt::Debug for Seed512 {
- fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
- self.0[..].fmt(f)
- }
-}
-
-impl Default for Seed512 {
- fn default() -> Seed512 {
- Seed512([0; 64])
- }
-}
-
-impl AsMut<[u8]> for Seed512 {
- fn as_mut(&mut self) -> &mut [u8] {
- &mut self.0
- }
-}
-
diff --git a/rand/rand_xoshiro/src/lib.rs b/rand/rand_xoshiro/src/lib.rs
deleted file mode 100644
index 634db31..0000000
--- a/rand/rand_xoshiro/src/lib.rs
+++ /dev/null
@@ -1,106 +0,0 @@
-// Copyright 2018 Developers of the Rand project.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-//! This crate implements the [xoshiro] family of pseudorandom number generators
-//! designed by David Blackman and Sebastiano Vigna. They feature high
-//! perfomance and a small state and superseed the previous xorshift-based
-//! generators. However, they are no cryptographically secure and their output
-//! can be predicted by observing a few samples.
-//!
-//! The following generators are implemented:
-//!
-//! # 64-bit generators
-//! - [`Xoshiro256StarStar`]: Recommended for all purposes. Excellent speed and
-//! a state space (256 bits) large enough for any parallel application.
-//! - [`Xoshiro256Plus`]: Recommended for generating 64-bit floating-point
-//! numbers. About 15% faster than `Xoshiro256StarStar`, but has a [low linear
-//! complexity] in the lowest bits (which are discarded when generating
-//! floats), making it fail linearity tests. This is unlikely to have any
-//! impact in practise.
-//! - [`Xoroshiro128StarStar`]: An alternative to `Xoshiro256StarStar`, having
-//! the same speed but using half the state. Only suited for low-scale parallel
-//! applications.
-//! - [`Xoroshiro128Plus`]: An alternative to `Xoshiro256Plus`, having the same
-//! speed but using half the state. Only suited for low-scale parallel
-//! applications. Has a [low linear complexity] in the lowest bits (which are
-//! discarded when generating floats), making it fail linearity tests. This is
-//! unlikely to have any impact in practise.
-//! - [`Xoshiro512StarStar`]: An alternative to `Xoshiro256StarStar` with more
-//! state and the same speed.
-//! - [`Xoshiro512Plus`]: An alternative to `Xoshiro512Plus` with more
-//! state and the same speed. Has a [low linear complexity] in the lowest bits
-//! (which are discarded when generating floats), making it fail linearity
-//! tests. This is unlikely to have any impact in practise.
-//! - [`SplitMix64`]: Recommended for initializing generators of the xoshiro
-//! familiy from a 64-bit seed. Used for implementing `seed_from_u64`.
-//!
-//! # 32-bit generators
-//! - [`Xoshiro128StarStar`]: Recommended for all purposes. Excellent speed.
-//! - [`Xoshiro128Plus`]: Recommended for generating 32-bit floating-point
-//! numbers. Faster than `Xoshiro128StarStar`, but has a [low linear
-//! complexity] in the lowest bits (which are discarded when generating
-//! floats), making it fail linearity tests. This is unlikely to have any
-//! impact in practise.
-//! - [`Xoroshiro64StarStar`]: An alternative to `Xoshiro128StarStar`, having
-//! the same speed but using half the state.
-//! - [`Xoroshiro64Star`]: An alternative to `Xoshiro128Plus`, having the
-//! same speed but using half the state. Has a [low linear complexity] in the
-//! lowest bits (which are discarded when generating floats), making it fail
-//! linearity tests. This is unlikely to have any impact in practise.
-//!
-//! [xoshiro]: http://xoshiro.di.unimi.it/
-//! [low linear complexity]: http://xoshiro.di.unimi.it/lowcomp.php
-//! [`Xoshiro256StarStar`]: ./struct.Xoshiro256StarStar.html
-//! [`Xoshiro256Plus`]: ./struct.Xoshiro256Plus.html
-//! [`Xoroshiro128StarStar`]: ./struct.Xoroshiro128StarStar.html
-//! [`Xoroshiro128Plus`]: ./struct.Xoroshiro128Plus.html
-//! [`Xoshiro512StarStar`]: ./struct.Xoshiro512StarStar.html
-//! [`Xoshiro512Plus`]: ./struct.Xoshiro512Plus.html
-//! [`SplitMix64`]: ./struct.SplitMix64.html
-//! [`Xoshiro128StarStar`]: ./struct.Xoshiro128StarStar.html
-//! [`Xoshiro128Plus`]: ./struct.Xoshiro128Plus.html
-//! [`Xoroshiro64StarStar`]: ./struct.Xoroshiro64StarStar.html
-//! [`Xoroshiro64Star`]: ./struct.Xoroshiro64Star.html
-
-#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk.png",
- html_favicon_url = "https://www.rust-lang.org/favicon.ico",
- html_root_url = "https://docs.rs/rand_xoshiro/0.1.0")]
-
-#![deny(missing_docs)]
-#![deny(missing_debug_implementations)]
-#![cfg_attr(feature = "cargo-clippy", allow(unreadable_literal))]
-#![no_std]
-extern crate byteorder;
-pub extern crate rand_core;
-
-#[macro_use]
-mod common;
-mod splitmix64;
-mod xoshiro128starstar;
-mod xoshiro128plus;
-mod xoshiro256starstar;
-mod xoshiro256plus;
-mod xoshiro512starstar;
-mod xoshiro512plus;
-mod xoroshiro128plus;
-mod xoroshiro128starstar;
-mod xoroshiro64starstar;
-mod xoroshiro64star;
-
-pub use splitmix64::SplitMix64;
-pub use xoshiro128starstar::Xoshiro128StarStar;
-pub use xoshiro128plus::Xoshiro128Plus;
-pub use xoshiro256starstar::Xoshiro256StarStar;
-pub use xoshiro256plus::Xoshiro256Plus;
-pub use common::Seed512;
-pub use xoshiro512starstar::Xoshiro512StarStar;
-pub use xoshiro512plus::Xoshiro512Plus;
-pub use xoroshiro128plus::Xoroshiro128Plus;
-pub use xoroshiro128starstar::Xoroshiro128StarStar;
-pub use xoroshiro64starstar::Xoroshiro64StarStar;
-pub use xoroshiro64star::Xoroshiro64Star;
diff --git a/rand/rand_xoshiro/src/splitmix64.rs b/rand/rand_xoshiro/src/splitmix64.rs
deleted file mode 100644
index a7cac9f..0000000
--- a/rand/rand_xoshiro/src/splitmix64.rs
+++ /dev/null
@@ -1,150 +0,0 @@
-// Copyright 2018 Developers of the Rand project.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-use byteorder::{ByteOrder, LittleEndian};
-use rand_core::le::read_u64_into;
-use rand_core::impls::fill_bytes_via_next;
-use rand_core::{RngCore, SeedableRng, Error};
-
-/// A splitmix64 random number generator.
-///
-/// The splitmix algorithm is not suitable for cryptographic purposes, but is
-/// very fast and has a 64 bit state.
-///
-/// The algorithm used here is translated from [the `splitmix64.c`
-/// reference source code](http://xoshiro.di.unimi.it/splitmix64.c) by
-/// Sebastiano Vigna. For `next_u32`, a more efficient mixing function taken
-/// from [`dsiutils`](http://dsiutils.di.unimi.it/) is used.
-#[allow(missing_copy_implementations)]
-#[derive(Debug, Clone)]
-pub struct SplitMix64 {
- x: u64,
-}
-
-const PHI: u64 = 0x9e3779b97f4a7c15;
-
-impl RngCore for SplitMix64 {
- #[inline]
- fn next_u32(&mut self) -> u32 {
- self.x = self.x.wrapping_add(PHI);
- let mut z = self.x;
- // David Stafford's
- // (http://zimbry.blogspot.com/2011/09/better-bit-mixing-improving-on.html)
- // "Mix4" variant of the 64-bit finalizer in Austin Appleby's
- // MurmurHash3 algorithm.
- z = (z ^ (z >> 33)).wrapping_mul(0x62A9D9ED799705F5);
- z = (z ^ (z >> 28)).wrapping_mul(0xCB24D0A5C88C35B3);
- (z >> 32) as u32
- }
-
- #[inline]
- fn next_u64(&mut self) -> u64 {
- self.x = self.x.wrapping_add(PHI);
- let mut z = self.x;
- z = (z ^ (z >> 30)).wrapping_mul(0xbf58476d1ce4e5b9);
- z = (z ^ (z >> 27)).wrapping_mul(0x94d049bb133111eb);
- z ^ (z >> 31)
- }
-
- #[inline]
- fn fill_bytes(&mut self, dest: &mut [u8]) {
- fill_bytes_via_next(self, dest);
- }
-
- #[inline]
- fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), Error> {
- self.fill_bytes(dest);
- Ok(())
- }
-}
-
-impl SeedableRng for SplitMix64 {
- type Seed = [u8; 8];
-
- /// Create a new `SplitMix64`.
- fn from_seed(seed: [u8; 8]) -> SplitMix64 {
- let mut state = [0; 1];
- read_u64_into(&seed, &mut state);
- SplitMix64 {
- x: state[0],
- }
- }
-
- /// Seed a `SplitMix64` from a `u64`.
- fn seed_from_u64(seed: u64) -> SplitMix64 {
- let mut x = [0; 8];
- LittleEndian::write_u64(&mut x, seed);
- SplitMix64::from_seed(x)
- }
-}
-
-#[cfg(test)]
-mod tests {
- use super::*;
-
- #[test]
- fn reference() {
- let mut rng = SplitMix64::seed_from_u64(1477776061723855037);
- // These values were produced with the reference implementation:
- // http://xoshiro.di.unimi.it/splitmix64.c
- let expected : [u64 ; 50]= [
- 1985237415132408290, 2979275885539914483, 13511426838097143398,
- 8488337342461049707, 15141737807933549159, 17093170987380407015,
- 16389528042912955399, 13177319091862933652, 10841969400225389492,
- 17094824097954834098, 3336622647361835228, 9678412372263018368,
- 11111587619974030187, 7882215801036322410, 5709234165213761869,
- 7799681907651786826, 4616320717312661886, 4251077652075509767,
- 7836757050122171900, 5054003328188417616, 12919285918354108358,
- 16477564761813870717, 5124667218451240549, 18099554314556827626,
- 7603784838804469118, 6358551455431362471, 3037176434532249502,
- 3217550417701719149, 9958699920490216947, 5965803675992506258,
- 12000828378049868312, 12720568162811471118, 245696019213873792,
- 8351371993958923852, 14378754021282935786, 5655432093647472106,
- 5508031680350692005, 8515198786865082103, 6287793597487164412,
- 14963046237722101617, 3630795823534910476, 8422285279403485710,
- 10554287778700714153, 10871906555720704584, 8659066966120258468,
- 9420238805069527062, 10338115333623340156, 13514802760105037173,
- 14635952304031724449, 15419692541594102413,
- ];
- for &e in expected.iter() {
- assert_eq!(rng.next_u64(), e);
- }
- }
-
- #[test]
- fn next_u32() {
- let mut rng = SplitMix64::seed_from_u64(10);
- // These values were produced with the reference implementation:
- // http://dsiutils.di.unimi.it/dsiutils-2.5.1-src.tar.gz
- let expected : [u32 ; 100]= [
- 3930361779, 4016923089, 4113052479, 925926767, 1755287528,
- 802865554, 954171070, 3724185978, 173676273, 1414488795, 12664133,
- 1784889697, 1303817078, 261610523, 941280008, 2571813643,
- 2954453492, 378291111, 2546873158, 3923319175, 645257028,
- 3881821278, 2681538690, 3037029984, 1999958137, 1853970361,
- 2989951788, 2126166628, 839962987, 3989679659, 3656977858,
- 684284364, 1673258011, 170979192, 3037622326, 1600748179,
- 1780764218, 1141430714, 4139736875, 3336905707, 2262051600,
- 3830850262, 2430765325, 1073032139, 1668888979, 2716938970,
- 4102420032, 40305196, 386350562, 2754480591, 622869439, 2129598760,
- 2306038241, 4218338739, 412298926, 3453855056, 3061469690,
- 4284292697, 994843708, 1591016681, 414726151, 1238182607, 18073498,
- 1237631493, 351884714, 2347486264, 2488990876, 802846256, 645670443,
- 957607012, 3126589776, 1966356370, 3036485766, 868696717,
- 2808613630, 2070968151, 1025536863, 1743949425, 466212687,
- 2994327271, 209776458, 1246125124, 3344380309, 2203947859,
- 968313105, 2805485302, 197484837, 3472483632, 3931823935,
- 3288490351, 4165666529, 3671080416, 689542830, 1272555356,
- 1039141475, 3984640460, 4142959054, 2252788890, 2459379590,
- 991872507,
- ];
- for &e in expected.iter() {
- assert_eq!(rng.next_u32(), e);
- }
- }
-}
diff --git a/rand/rand_xoshiro/src/xoroshiro128plus.rs b/rand/rand_xoshiro/src/xoroshiro128plus.rs
deleted file mode 100644
index df032c8..0000000
--- a/rand/rand_xoshiro/src/xoroshiro128plus.rs
+++ /dev/null
@@ -1,132 +0,0 @@
-// Copyright 2018 Developers of the Rand project.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-use rand_core;
-use rand_core::le::read_u64_into;
-use rand_core::impls::fill_bytes_via_next;
-use rand_core::{RngCore, SeedableRng};
-
-/// A xoroshiro128+ random number generator.
-///
-/// The xoroshiro128+ algorithm is not suitable for cryptographic purposes, but
-/// is very fast and has good statistical properties, besides a low linear
-/// complexity in the lowest bits.
-///
-/// The algorithm used here is translated from [the `xoroshiro128plus.c`
-/// reference source code](http://xoshiro.di.unimi.it/xoroshiro128plus.c) by
-/// David Blackman and Sebastiano Vigna.
-#[allow(missing_copy_implementations)]
-#[derive(Debug, Clone)]
-pub struct Xoroshiro128Plus {
- s0: u64,
- s1: u64,
-}
-
-impl Xoroshiro128Plus {
- /// Jump forward, equivalently to 2^64 calls to `next_u64()`.
- ///
- /// This can be used to generate 2^64 non-overlapping subsequences for
- /// parallel computations.
- ///
- /// ```
- /// # extern crate rand;
- /// # extern crate rand_xoshiro;
- /// # fn main() {
- /// use rand::SeedableRng;
- /// use rand_xoshiro::Xoroshiro128Plus;
- ///
- /// let rng1 = Xoroshiro128Plus::seed_from_u64(0);
- /// let mut rng2 = rng1.clone();
- /// rng2.jump();
- /// let mut rng3 = rng2.clone();
- /// rng3.jump();
- /// # }
- /// ```
- pub fn jump(&mut self) {
- impl_jump!(u64, self, [0xdf900294d8f554a5, 0x170865df4b3201fc]);
- }
-
- /// Jump forward, equivalently to 2^96 calls to `next_u64()`.
- ///
- /// This can be used to generate 2^32 starting points, from each of which
- /// `jump()` will generate 2^32 non-overlapping subsequences for parallel
- /// distributed computations.
- pub fn long_jump(&mut self) {
- impl_jump!(u64, self, [0xd2a98b26625eee7b, 0xdddf9b1090aa7ac1]);
- }
-}
-
-impl RngCore for Xoroshiro128Plus {
- #[inline]
- fn next_u32(&mut self) -> u32 {
- // The two lowest bits have some linear dependencies, so we use the
- // upper bits instead.
- (self.next_u64() >> 32) as u32
- }
-
- #[inline]
- fn next_u64(&mut self) -> u64 {
- let r = self.s0.wrapping_add(self.s1);
- impl_xoroshiro_u64!(self);
- r
- }
-
- #[inline]
- fn fill_bytes(&mut self, dest: &mut [u8]) {
- fill_bytes_via_next(self, dest);
- }
-
- #[inline]
- fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), rand_core::Error> {
- self.fill_bytes(dest);
- Ok(())
- }
-}
-
-impl SeedableRng for Xoroshiro128Plus {
- type Seed = [u8; 16];
-
- /// Create a new `Xoroshiro128Plus`. If `seed` is entirely 0, it will be
- /// mapped to a different seed.
- fn from_seed(seed: [u8; 16]) -> Xoroshiro128Plus {
- deal_with_zero_seed!(seed, Self);
- let mut s = [0; 2];
- read_u64_into(&seed, &mut s);
-
- Xoroshiro128Plus {
- s0: s[0],
- s1: s[1],
- }
- }
-
- /// Seed a `Xoroshiro128Plus` from a `u64` using `SplitMix64`.
- fn seed_from_u64(seed: u64) -> Xoroshiro128Plus {
- from_splitmix!(seed)
- }
-}
-
-#[cfg(test)]
-mod tests {
- use super::*;
-
- #[test]
- fn reference() {
- let mut rng = Xoroshiro128Plus::from_seed(
- [1, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0]);
- // These values were produced with the reference implementation:
- // http://xoshiro.di.unimi.it/xoshiro128starstar.c
- let expected = [
- 3, 412333834243, 2360170716294286339, 9295852285959843169,
- 2797080929874688578, 6019711933173041966, 3076529664176959358,
- 3521761819100106140, 7493067640054542992, 920801338098114767,
- ];
- for &e in &expected {
- assert_eq!(rng.next_u64(), e);
- }
- }
-}
diff --git a/rand/rand_xoshiro/src/xoroshiro128starstar.rs b/rand/rand_xoshiro/src/xoroshiro128starstar.rs
deleted file mode 100644
index 2d27850..0000000
--- a/rand/rand_xoshiro/src/xoroshiro128starstar.rs
+++ /dev/null
@@ -1,129 +0,0 @@
-// Copyright 2018 Developers of the Rand project.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-use rand_core;
-use rand_core::le::read_u64_into;
-use rand_core::impls::fill_bytes_via_next;
-use rand_core::{RngCore, SeedableRng};
-
-/// A xoroshiro128** random number generator.
-///
-/// The xoroshiro128** algorithm is not suitable for cryptographic purposes, but
-/// is very fast and has excellent statistical properties.
-///
-/// The algorithm used here is translated from [the `xoroshiro128starstar.c`
-/// reference source code](http://xoshiro.di.unimi.it/xoroshiro128starstar.c) by
-/// David Blackman and Sebastiano Vigna.
-#[allow(missing_copy_implementations)]
-#[derive(Debug, Clone)]
-pub struct Xoroshiro128StarStar {
- s0: u64,
- s1: u64,
-}
-
-impl Xoroshiro128StarStar {
- /// Jump forward, equivalently to 2^64 calls to `next_u64()`.
- ///
- /// This can be used to generate 2^64 non-overlapping subsequences for
- /// parallel computations.
- ///
- /// ```
- /// # extern crate rand;
- /// # extern crate rand_xoshiro;
- /// # fn main() {
- /// use rand::SeedableRng;
- /// use rand_xoshiro::Xoroshiro128StarStar;
- ///
- /// let rng1 = Xoroshiro128StarStar::seed_from_u64(0);
- /// let mut rng2 = rng1.clone();
- /// rng2.jump();
- /// let mut rng3 = rng2.clone();
- /// rng3.jump();
- /// # }
- /// ```
- pub fn jump(&mut self) {
- impl_jump!(u64, self, [0xdf900294d8f554a5, 0x170865df4b3201fc]);
- }
-
- /// Jump forward, equivalently to 2^96 calls to `next_u64()`.
- ///
- /// This can be used to generate 2^32 starting points, from each of which
- /// `jump()` will generate 2^32 non-overlapping subsequences for parallel
- /// distributed computations.
- pub fn long_jump(&mut self) {
- impl_jump!(u64, self, [0xd2a98b26625eee7b, 0xdddf9b1090aa7ac1]);
- }
-}
-
-impl RngCore for Xoroshiro128StarStar {
- #[inline]
- fn next_u32(&mut self) -> u32 {
- self.next_u64() as u32
- }
-
- #[inline]
- fn next_u64(&mut self) -> u64 {
- let r = starstar_u64!(self.s0);
- impl_xoroshiro_u64!(self);
- r
- }
-
- #[inline]
- fn fill_bytes(&mut self, dest: &mut [u8]) {
- fill_bytes_via_next(self, dest);
- }
-
- #[inline]
- fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), rand_core::Error> {
- self.fill_bytes(dest);
- Ok(())
- }
-}
-
-impl SeedableRng for Xoroshiro128StarStar {
- type Seed = [u8; 16];
-
- /// Create a new `Xoroshiro128StarStar`. If `seed` is entirely 0, it will be
- /// mapped to a different seed.
- fn from_seed(seed: [u8; 16]) -> Xoroshiro128StarStar {
- deal_with_zero_seed!(seed, Self);
- let mut s = [0; 2];
- read_u64_into(&seed, &mut s);
-
- Xoroshiro128StarStar {
- s0: s[0],
- s1: s[1],
- }
- }
-
- /// Seed a `Xoroshiro128StarStar` from a `u64` using `SplitMix64`.
- fn seed_from_u64(seed: u64) -> Xoroshiro128StarStar {
- from_splitmix!(seed)
- }
-}
-
-#[cfg(test)]
-mod tests {
- use super::*;
-
- #[test]
- fn reference() {
- let mut rng = Xoroshiro128StarStar::from_seed(
- [1, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0]);
- // These values were produced with the reference implementation:
- // http://xoshiro.di.unimi.it/xoshiro128starstar.c
- let expected = [
- 5760, 97769243520, 9706862127477703552, 9223447511460779954,
- 8358291023205304566, 15695619998649302768, 8517900938696309774,
- 16586480348202605369, 6959129367028440372, 16822147227405758281,
- ];
- for &e in &expected {
- assert_eq!(rng.next_u64(), e);
- }
- }
-}
diff --git a/rand/rand_xoshiro/src/xoroshiro64star.rs b/rand/rand_xoshiro/src/xoroshiro64star.rs
deleted file mode 100644
index 86338fd..0000000
--- a/rand/rand_xoshiro/src/xoroshiro64star.rs
+++ /dev/null
@@ -1,97 +0,0 @@
-// Copyright 2018 Developers of the Rand project.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-use byteorder::{ByteOrder, LittleEndian};
-use rand_core;
-use rand_core::le::read_u32_into;
-use rand_core::impls::{fill_bytes_via_next, next_u64_via_u32};
-use rand_core::{RngCore, SeedableRng};
-
-/// A xoroshiro64* random number generator.
-///
-/// The xoroshiro64* algorithm is not suitable for cryptographic purposes, but
-/// is very fast and has good statistical properties, besides a low linear
-/// complexity in the lowest bits.
-///
-/// The algorithm used here is translated from [the `xoroshiro64star.c`
-/// reference source code](http://xoshiro.di.unimi.it/xoroshiro64star.c) by
-/// David Blackman and Sebastiano Vigna.
-#[allow(missing_copy_implementations)]
-#[derive(Debug, Clone)]
-pub struct Xoroshiro64Star {
- s0: u32,
- s1: u32,
-}
-
-impl RngCore for Xoroshiro64Star {
- #[inline]
- fn next_u32(&mut self) -> u32 {
- let r = self.s0.wrapping_mul(0x9E3779BB);
- impl_xoroshiro_u32!(self);
- r
- }
-
- #[inline]
- fn next_u64(&mut self) -> u64 {
- next_u64_via_u32(self)
- }
-
- #[inline]
- fn fill_bytes(&mut self, dest: &mut [u8]) {
- fill_bytes_via_next(self, dest);
- }
-
- #[inline]
- fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), rand_core::Error> {
- self.fill_bytes(dest);
- Ok(())
- }
-}
-
-impl SeedableRng for Xoroshiro64Star {
- type Seed = [u8; 8];
-
- /// Create a new `Xoroshiro64Star`. If `seed` is entirely 0, it will be
- /// mapped to a different seed.
- fn from_seed(seed: [u8; 8]) -> Xoroshiro64Star {
- deal_with_zero_seed!(seed, Self);
- let mut s = [0; 2];
- read_u32_into(&seed, &mut s);
-
- Xoroshiro64Star {
- s0: s[0],
- s1: s[1],
- }
- }
-
- /// Seed a `Xoroshiro64Star` from a `u64` using `SplitMix64`.
- fn seed_from_u64(seed: u64) -> Xoroshiro64Star {
- let mut s = [0; 8];
- LittleEndian::write_u64(&mut s, seed);
- Xoroshiro64Star::from_seed(s)
- }
-}
-
-#[cfg(test)]
-mod tests {
- use super::*;
-
- #[test]
- fn reference() {
- let mut rng = Xoroshiro64Star::from_seed([1, 0, 0, 0, 2, 0, 0, 0]);
- // These values were produced with the reference implementation:
- // http://xoshiro.di.unimi.it/xoshiro64star.c
- let expected = [
- 2654435771, 327208753, 4063491769, 4259754937, 261922412, 168123673,
- 552743735, 1672597395, 1031040050, 2755315674,
- ];
- for &e in &expected {
- assert_eq!(rng.next_u32(), e);
- }
- }
-}
diff --git a/rand/rand_xoshiro/src/xoroshiro64starstar.rs b/rand/rand_xoshiro/src/xoroshiro64starstar.rs
deleted file mode 100644
index a40baee..0000000
--- a/rand/rand_xoshiro/src/xoroshiro64starstar.rs
+++ /dev/null
@@ -1,96 +0,0 @@
-// Copyright 2018 Developers of the Rand project.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-use byteorder::{ByteOrder, LittleEndian};
-use rand_core;
-use rand_core::le::read_u32_into;
-use rand_core::impls::{fill_bytes_via_next, next_u64_via_u32};
-use rand_core::{RngCore, SeedableRng};
-
-/// A Xoroshiro64** random number generator.
-///
-/// The xoshiro64** algorithm is not suitable for cryptographic purposes, but
-/// is very fast and has excellent statistical properties.
-///
-/// The algorithm used here is translated from [the `xoroshiro64starstar.c`
-/// reference source code](http://xoshiro.di.unimi.it/xoroshiro64starstar.c) by
-/// David Blackman and Sebastiano Vigna.
-#[allow(missing_copy_implementations)]
-#[derive(Debug, Clone)]
-pub struct Xoroshiro64StarStar {
- s0: u32,
- s1: u32,
-}
-
-impl RngCore for Xoroshiro64StarStar {
- #[inline]
- fn next_u32(&mut self) -> u32 {
- let r = starstar_u32!(self.s0);
- impl_xoroshiro_u32!(self);
- r
- }
-
- #[inline]
- fn next_u64(&mut self) -> u64 {
- next_u64_via_u32(self)
- }
-
- #[inline]
- fn fill_bytes(&mut self, dest: &mut [u8]) {
- fill_bytes_via_next(self, dest);
- }
-
- #[inline]
- fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), rand_core::Error> {
- self.fill_bytes(dest);
- Ok(())
- }
-}
-
-impl SeedableRng for Xoroshiro64StarStar {
- type Seed = [u8; 8];
-
- /// Create a new `Xoroshiro64StarStar`. If `seed` is entirely 0, it will be
- /// mapped to a different seed.
- fn from_seed(seed: [u8; 8]) -> Xoroshiro64StarStar {
- deal_with_zero_seed!(seed, Self);
- let mut s = [0; 2];
- read_u32_into(&seed, &mut s);
-
- Xoroshiro64StarStar {
- s0: s[0],
- s1: s[1],
- }
- }
-
- /// Seed a `Xoroshiro64StarStar` from a `u64`.
- fn seed_from_u64(seed: u64) -> Xoroshiro64StarStar {
- let mut s = [0; 8];
- LittleEndian::write_u64(&mut s, seed);
- Xoroshiro64StarStar::from_seed(s)
- }
-}
-
-#[cfg(test)]
-mod tests {
- use super::*;
-
- #[test]
- fn reference() {
- let mut rng = Xoroshiro64StarStar::from_seed([1, 0, 0, 0, 2, 0, 0, 0]);
- // These values were produced with the reference implementation:
- // http://xoshiro.di.unimi.it/xoshiro64starstar.c
- let expected = [
- 3802928447, 813792938, 1618621494, 2955957307, 3252880261,
- 1129983909, 2539651700, 1327610908, 1757650787, 2763843748,
- ];
- for &e in &expected {
- assert_eq!(rng.next_u32(), e);
- }
- }
-}
diff --git a/rand/rand_xoshiro/src/xoshiro128plus.rs b/rand/rand_xoshiro/src/xoshiro128plus.rs
deleted file mode 100644
index b0c7cc7..0000000
--- a/rand/rand_xoshiro/src/xoshiro128plus.rs
+++ /dev/null
@@ -1,114 +0,0 @@
-// Copyright 2018 Developers of the Rand project.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-use rand_core::impls::{next_u64_via_u32, fill_bytes_via_next};
-use rand_core::le::read_u32_into;
-use rand_core::{SeedableRng, RngCore, Error};
-
-/// A xoshiro128+ random number generator.
-///
-/// The xoshiro128+ algorithm is not suitable for cryptographic purposes, but
-/// is very fast and has good statistical properties, besides a low linear
-/// complexity in the lowest bits.
-///
-/// The algorithm used here is translated from [the `xoshiro128starstar.c`
-/// reference source code](http://xoshiro.di.unimi.it/xoshiro128starstar.c) by
-/// David Blackman and Sebastiano Vigna.
-#[derive(Debug, Clone)]
-pub struct Xoshiro128Plus {
- s: [u32; 4],
-}
-
-impl Xoshiro128Plus {
- /// Jump forward, equivalently to 2^64 calls to `next_u32()`.
- ///
- /// This can be used to generate 2^64 non-overlapping subsequences for
- /// parallel computations.
- ///
- /// ```
- /// # extern crate rand;
- /// # extern crate rand_xoshiro;
- /// # fn main() {
- /// use rand::SeedableRng;
- /// use rand_xoshiro::Xoroshiro128StarStar;
- ///
- /// let rng1 = Xoroshiro128StarStar::seed_from_u64(0);
- /// let mut rng2 = rng1.clone();
- /// rng2.jump();
- /// let mut rng3 = rng2.clone();
- /// rng3.jump();
- /// # }
- /// ```
- pub fn jump(&mut self) {
- impl_jump!(u32, self, [0x8764000b, 0xf542d2d3, 0x6fa035c3, 0x77f2db5b]);
- }
-}
-
-impl SeedableRng for Xoshiro128Plus {
- type Seed = [u8; 16];
-
- /// Create a new `Xoshiro128Plus`. If `seed` is entirely 0, it will be
- /// mapped to a different seed.
- #[inline]
- fn from_seed(seed: [u8; 16]) -> Xoshiro128Plus {
- deal_with_zero_seed!(seed, Self);
- let mut state = [0; 4];
- read_u32_into(&seed, &mut state);
- Xoshiro128Plus { s: state }
- }
-
- /// Seed a `Xoshiro128Plus` from a `u64` using `SplitMix64`.
- fn seed_from_u64(seed: u64) -> Xoshiro128Plus {
- from_splitmix!(seed)
- }
-}
-
-impl RngCore for Xoshiro128Plus {
- #[inline]
- fn next_u32(&mut self) -> u32 {
- let result_plus = self.s[0].wrapping_add(self.s[3]);
- impl_xoshiro_u32!(self);
- result_plus
- }
-
- #[inline]
- fn next_u64(&mut self) -> u64 {
- next_u64_via_u32(self)
- }
-
- #[inline]
- fn fill_bytes(&mut self, dest: &mut [u8]) {
- fill_bytes_via_next(self, dest);
- }
-
- #[inline]
- fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), Error> {
- self.fill_bytes(dest);
- Ok(())
- }
-}
-
-#[cfg(test)]
-mod tests {
- use super::*;
-
- #[test]
- fn reference() {
- let mut rng = Xoshiro128Plus::from_seed(
- [1, 0, 0, 0, 2, 0, 0, 0, 3, 0, 0, 0, 4, 0, 0, 0]);
- // These values were produced with the reference implementation:
- // http://xoshiro.di.unimi.it/xoshiro128plus.c
- let expected = [
- 5, 12295, 25178119, 27286542, 39879690, 1140358681, 3276312097,
- 4110231701, 399823256, 2144435200,
- ];
- for &e in &expected {
- assert_eq!(rng.next_u32(), e);
- }
- }
-}
diff --git a/rand/rand_xoshiro/src/xoshiro128starstar.rs b/rand/rand_xoshiro/src/xoshiro128starstar.rs
deleted file mode 100644
index 836864e..0000000
--- a/rand/rand_xoshiro/src/xoshiro128starstar.rs
+++ /dev/null
@@ -1,113 +0,0 @@
-// Copyright 2018 Developers of the Rand project.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-use rand_core::impls::{next_u64_via_u32, fill_bytes_via_next};
-use rand_core::le::read_u32_into;
-use rand_core::{SeedableRng, RngCore, Error};
-
-/// A xoshiro128** random number generator.
-///
-/// The xoshiro128** algorithm is not suitable for cryptographic purposes, but
-/// is very fast and has excellent statistical properties.
-///
-/// The algorithm used here is translated from [the `xoshiro128starstar.c`
-/// reference source code](http://xoshiro.di.unimi.it/xoshiro128starstar.c) by
-/// David Blackman and Sebastiano Vigna.
-#[derive(Debug, Clone)]
-pub struct Xoshiro128StarStar {
- s: [u32; 4],
-}
-
-impl Xoshiro128StarStar {
- /// Jump forward, equivalently to 2^64 calls to `next_u32()`.
- ///
- /// This can be used to generate 2^64 non-overlapping subsequences for
- /// parallel computations.
- ///
- /// ```
- /// # extern crate rand;
- /// # extern crate rand_xoshiro;
- /// # fn main() {
- /// use rand::SeedableRng;
- /// use rand_xoshiro::Xoroshiro128StarStar;
- ///
- /// let rng1 = Xoroshiro128StarStar::seed_from_u64(0);
- /// let mut rng2 = rng1.clone();
- /// rng2.jump();
- /// let mut rng3 = rng2.clone();
- /// rng3.jump();
- /// # }
- /// ```
- pub fn jump(&mut self) {
- impl_jump!(u32, self, [0x8764000b, 0xf542d2d3, 0x6fa035c3, 0x77f2db5b]);
- }
-}
-
-impl SeedableRng for Xoshiro128StarStar {
- type Seed = [u8; 16];
-
- /// Create a new `Xoshiro128StarStar`. If `seed` is entirely 0, it will be
- /// mapped to a different seed.
- #[inline]
- fn from_seed(seed: [u8; 16]) -> Xoshiro128StarStar {
- deal_with_zero_seed!(seed, Self);
- let mut state = [0; 4];
- read_u32_into(&seed, &mut state);
- Xoshiro128StarStar { s: state }
- }
-
- /// Seed a `Xoshiro128StarStar` from a `u64` using `SplitMix64`.
- fn seed_from_u64(seed: u64) -> Xoshiro128StarStar {
- from_splitmix!(seed)
- }
-}
-
-impl RngCore for Xoshiro128StarStar {
- #[inline]
- fn next_u32(&mut self) -> u32 {
- let result_starstar = starstar_u64!(self.s[0]);
- impl_xoshiro_u32!(self);
- result_starstar
- }
-
- #[inline]
- fn next_u64(&mut self) -> u64 {
- next_u64_via_u32(self)
- }
-
- #[inline]
- fn fill_bytes(&mut self, dest: &mut [u8]) {
- fill_bytes_via_next(self, dest);
- }
-
- #[inline]
- fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), Error> {
- self.fill_bytes(dest);
- Ok(())
- }
-}
-
-#[cfg(test)]
-mod tests {
- use super::*;
-
- #[test]
- fn reference() {
- let mut rng = Xoshiro128StarStar::from_seed(
- [1, 0, 0, 0, 2, 0, 0, 0, 3, 0, 0, 0, 4, 0, 0, 0]);
- // These values were produced with the reference implementation:
- // http://xoshiro.di.unimi.it/xoshiro128starstar.c
- let expected = [
- 5760, 40320, 70819200, 3297914139, 2480851620, 1792823698,
- 4118739149, 1251203317, 1581886583, 1721184582,
- ];
- for &e in &expected {
- assert_eq!(rng.next_u32(), e);
- }
- }
-}
diff --git a/rand/rand_xoshiro/src/xoshiro256plus.rs b/rand/rand_xoshiro/src/xoshiro256plus.rs
deleted file mode 100644
index 08da5a8..0000000
--- a/rand/rand_xoshiro/src/xoshiro256plus.rs
+++ /dev/null
@@ -1,133 +0,0 @@
-// Copyright 2018 Developers of the Rand project.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-use rand_core::impls::fill_bytes_via_next;
-use rand_core::le::read_u64_into;
-use rand_core::{SeedableRng, RngCore, Error};
-
-/// A xoshiro256+ random number generator.
-///
-/// The xoshiro256+ algorithm is not suitable for cryptographic purposes, but
-/// is very fast and has good statistical properties, besides a low linear
-/// complexity in the lowest bits.
-///
-/// The algorithm used here is translated from [the `xoshiro256plus.c`
-/// reference source code](http://xoshiro.di.unimi.it/xoshiro256plus.c) by
-/// David Blackman and Sebastiano Vigna.
-#[derive(Debug, Clone)]
-pub struct Xoshiro256Plus {
- s: [u64; 4],
-}
-
-impl Xoshiro256Plus {
- /// Jump forward, equivalently to 2^128 calls to `next_u64()`.
- ///
- /// This can be used to generate 2^128 non-overlapping subsequences for
- /// parallel computations.
- ///
- /// ```
- /// # extern crate rand;
- /// # extern crate rand_xoshiro;
- /// # fn main() {
- /// use rand::SeedableRng;
- /// use rand_xoshiro::Xoshiro256Plus;
- ///
- /// let rng1 = Xoshiro256Plus::seed_from_u64(0);
- /// let mut rng2 = rng1.clone();
- /// rng2.jump();
- /// let mut rng3 = rng2.clone();
- /// rng3.jump();
- /// # }
- /// ```
- pub fn jump(&mut self) {
- impl_jump!(u64, self, [
- 0x180ec6d33cfd0aba, 0xd5a61266f0c9392c,
- 0xa9582618e03fc9aa, 0x39abdc4529b1661c
- ]);
- }
-
- /// Jump forward, equivalently to 2^192 calls to `next_u64()`.
- ///
- /// This can be used to generate 2^64 starting points, from each of which
- /// `jump()` will generate 2^64 non-overlapping subsequences for parallel
- /// distributed computations.
- pub fn long_jump(&mut self) {
- impl_jump!(u64, self, [
- 0x76e15d3efefdcbbf, 0xc5004e441c522fb3,
- 0x77710069854ee241, 0x39109bb02acbe635
- ]);
- }
-}
-
-impl SeedableRng for Xoshiro256Plus {
- type Seed = [u8; 32];
-
- /// Create a new `Xoshiro256Plus`. If `seed` is entirely 0, it will be
- /// mapped to a different seed.
- #[inline]
- fn from_seed(seed: [u8; 32]) -> Xoshiro256Plus {
- deal_with_zero_seed!(seed, Self);
- let mut state = [0; 4];
- read_u64_into(&seed, &mut state);
- Xoshiro256Plus { s: state }
- }
-
- /// Seed a `Xoshiro256Plus` from a `u64` using `SplitMix64`.
- fn seed_from_u64(seed: u64) -> Xoshiro256Plus {
- from_splitmix!(seed)
- }
-}
-
-impl RngCore for Xoshiro256Plus {
- #[inline]
- fn next_u32(&mut self) -> u32 {
- // The lowest bits have some linear dependencies, so we use the
- // upper bits instead.
- (self.next_u64() >> 32) as u32
- }
-
- #[inline]
- fn next_u64(&mut self) -> u64 {
- let result_plus = self.s[0].wrapping_add(self.s[3]);
- impl_xoshiro_u64!(self);
- result_plus
- }
-
- #[inline]
- fn fill_bytes(&mut self, dest: &mut [u8]) {
- fill_bytes_via_next(self, dest);
- }
-
- #[inline]
- fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), Error> {
- self.fill_bytes(dest);
- Ok(())
- }
-}
-
-#[cfg(test)]
-mod tests {
- use super::*;
-
- #[test]
- fn reference() {
- let mut rng = Xoshiro256Plus::from_seed(
- [1, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0,
- 3, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0]);
- // These values were produced with the reference implementation:
- // http://xoshiro.di.unimi.it/xoshiro256plus.c
- let expected = [
- 5, 211106232532999, 211106635186183, 9223759065350669058,
- 9250833439874351877, 13862484359527728515, 2346507365006083650,
- 1168864526675804870, 34095955243042024, 3466914240207415127,
- ];
- for &e in &expected {
- assert_eq!(rng.next_u64(), e);
- }
- }
-}
diff --git a/rand/rand_xoshiro/src/xoshiro256starstar.rs b/rand/rand_xoshiro/src/xoshiro256starstar.rs
deleted file mode 100644
index fc0a208..0000000
--- a/rand/rand_xoshiro/src/xoshiro256starstar.rs
+++ /dev/null
@@ -1,130 +0,0 @@
-// Copyright 2018 Developers of the Rand project.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-use rand_core::impls::fill_bytes_via_next;
-use rand_core::le::read_u64_into;
-use rand_core::{SeedableRng, RngCore, Error};
-
-/// A xoshiro256** random number generator.
-///
-/// The xoshiro256** algorithm is not suitable for cryptographic purposes, but
-/// is very fast and has excellent statistical properties.
-///
-/// The algorithm used here is translated from [the `xoshiro256starstar.c`
-/// reference source code](http://xoshiro.di.unimi.it/xoshiro256starstar.c) by
-/// David Blackman and Sebastiano Vigna.
-#[derive(Debug, Clone)]
-pub struct Xoshiro256StarStar {
- s: [u64; 4],
-}
-
-impl Xoshiro256StarStar {
- /// Jump forward, equivalently to 2^128 calls to `next_u64()`.
- ///
- /// This can be used to generate 2^128 non-overlapping subsequences for
- /// parallel computations.
- ///
- /// ```
- /// # extern crate rand;
- /// # extern crate rand_xoshiro;
- /// # fn main() {
- /// use rand::SeedableRng;
- /// use rand_xoshiro::Xoshiro256StarStar;
- ///
- /// let rng1 = Xoshiro256StarStar::seed_from_u64(0);
- /// let mut rng2 = rng1.clone();
- /// rng2.jump();
- /// let mut rng3 = rng2.clone();
- /// rng3.jump();
- /// # }
- /// ```
- pub fn jump(&mut self) {
- impl_jump!(u64, self, [
- 0x180ec6d33cfd0aba, 0xd5a61266f0c9392c,
- 0xa9582618e03fc9aa, 0x39abdc4529b1661c
- ]);
- }
-
- /// Jump forward, equivalently to 2^192 calls to `next_u64()`.
- ///
- /// This can be used to generate 2^64 starting points, from each of which
- /// `jump()` will generate 2^64 non-overlapping subsequences for parallel
- /// distributed computations.
- pub fn long_jump(&mut self) {
- impl_jump!(u64, self, [
- 0x76e15d3efefdcbbf, 0xc5004e441c522fb3,
- 0x77710069854ee241, 0x39109bb02acbe635
- ]);
- }
-}
-
-impl SeedableRng for Xoshiro256StarStar {
- type Seed = [u8; 32];
-
- /// Create a new `Xoshiro256StarStar`. If `seed` is entirely 0, it will be
- /// mapped to a different seed.
- #[inline]
- fn from_seed(seed: [u8; 32]) -> Xoshiro256StarStar {
- deal_with_zero_seed!(seed, Self);
- let mut state = [0; 4];
- read_u64_into(&seed, &mut state);
- Xoshiro256StarStar { s: state }
- }
-
- /// Seed a `Xoshiro256StarStar` from a `u64` using `SplitMix64`.
- fn seed_from_u64(seed: u64) -> Xoshiro256StarStar {
- from_splitmix!(seed)
- }
-}
-
-impl RngCore for Xoshiro256StarStar {
- #[inline]
- fn next_u32(&mut self) -> u32 {
- self.next_u64() as u32
- }
-
- #[inline]
- fn next_u64(&mut self) -> u64 {
- let result_starstar = starstar_u64!(self.s[1]);
- impl_xoshiro_u64!(self);
- result_starstar
- }
-
- #[inline]
- fn fill_bytes(&mut self, dest: &mut [u8]) {
- fill_bytes_via_next(self, dest);
- }
-
- #[inline]
- fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), Error> {
- self.fill_bytes(dest);
- Ok(())
- }
-}
-
-#[cfg(test)]
-mod tests {
- use super::*;
-
- #[test]
- fn reference() {
- let mut rng = Xoshiro256StarStar::from_seed(
- [1, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0,
- 3, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0]);
- // These values were produced with the reference implementation:
- // http://xoshiro.di.unimi.it/xoshiro128starstar.c
- let expected = [
- 11520, 0, 1509978240, 1215971899390074240, 1216172134540287360,
- 607988272756665600, 16172922978634559625, 8476171486693032832,
- 10595114339597558777, 2904607092377533576,
- ];
- for &e in &expected {
- assert_eq!(rng.next_u64(), e);
- }
- }
-}
diff --git a/rand/rand_xoshiro/src/xoshiro512plus.rs b/rand/rand_xoshiro/src/xoshiro512plus.rs
deleted file mode 100644
index fe982e4..0000000
--- a/rand/rand_xoshiro/src/xoshiro512plus.rs
+++ /dev/null
@@ -1,124 +0,0 @@
-// Copyright 2018 Developers of the Rand project.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-use rand_core::impls::fill_bytes_via_next;
-use rand_core::le::read_u64_into;
-use rand_core::{SeedableRng, RngCore, Error};
-
-use Seed512;
-
-/// A xoshiro512+ random number generator.
-///
-/// The xoshiro512+ algorithm is not suitable for cryptographic purposes, but
-/// is very fast and has good statistical properties, besides a low linear
-/// complexity in the lowest bits.
-///
-/// The algorithm used here is translated from [the `xoshiro512plus.c`
-/// reference source code](http://xoshiro.di.unimi.it/xoshiro512plus.c) by
-/// David Blackman and Sebastiano Vigna.
-#[derive(Debug, Clone)]
-pub struct Xoshiro512Plus {
- s: [u64; 8],
-}
-
-impl Xoshiro512Plus {
- /// Jump forward, equivalently to 2^256 calls to `next_u64()`.
- ///
- /// This can be used to generate 2^256 non-overlapping subsequences for
- /// parallel computations.
- ///
- /// ```
- /// # extern crate rand;
- /// # extern crate rand_xoshiro;
- /// # fn main() {
- /// use rand::SeedableRng;
- /// use rand_xoshiro::Xoshiro512Plus;
- ///
- /// let rng1 = Xoshiro512Plus::seed_from_u64(0);
- /// let mut rng2 = rng1.clone();
- /// rng2.jump();
- /// let mut rng3 = rng2.clone();
- /// rng3.jump();
- /// # }
- /// ```
- pub fn jump(&mut self) {
- impl_jump!(u64, self, [
- 0x33ed89b6e7a353f9, 0x760083d7955323be, 0x2837f2fbb5f22fae,
- 0x4b8c5674d309511c, 0xb11ac47a7ba28c25, 0xf1be7667092bcc1c,
- 0x53851efdb6df0aaf, 0x1ebbc8b23eaf25db
- ]);
- }
-}
-
-impl SeedableRng for Xoshiro512Plus {
- type Seed = Seed512;
-
- /// Create a new `Xoshiro512Plus`. If `seed` is entirely 0, it will be
- /// mapped to a different seed.
- #[inline]
- fn from_seed(seed: Seed512) -> Xoshiro512Plus {
- deal_with_zero_seed!(seed, Self);
- let mut state = [0; 8];
- read_u64_into(&seed.0, &mut state);
- Xoshiro512Plus { s: state }
- }
-
- /// Seed a `Xoshiro512Plus` from a `u64` using `SplitMix64`.
- fn seed_from_u64(seed: u64) -> Xoshiro512Plus {
- from_splitmix!(seed)
- }
-}
-
-impl RngCore for Xoshiro512Plus {
- #[inline]
- fn next_u32(&mut self) -> u32 {
- self.next_u64() as u32
- }
-
- #[inline]
- fn next_u64(&mut self) -> u64 {
- let result_plus = self.s[0].wrapping_add(self.s[2]);
- impl_xoshiro_large!(self);
- result_plus
- }
-
- #[inline]
- fn fill_bytes(&mut self, dest: &mut [u8]) {
- fill_bytes_via_next(self, dest);
- }
-
- #[inline]
- fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), Error> {
- self.fill_bytes(dest);
- Ok(())
- }
-}
-
-#[cfg(test)]
-mod tests {
- use super::*;
-
- #[test]
- fn reference() {
- let mut rng = Xoshiro512Plus::from_seed(Seed512(
- [1, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0,
- 3, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0,
- 5, 0, 0, 0, 0, 0, 0, 0, 6, 0, 0, 0, 0, 0, 0, 0,
- 7, 0, 0, 0, 0, 0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 0]));
- // These values were produced with the reference implementation:
- // http://xoshiro.di.unimi.it/xoshiro512plus.c
- let expected = [
- 4, 8, 4113, 25169936, 52776585412635, 57174648719367,
- 9223482039571869716, 9331471677901559830, 9340533895746033672,
- 14078399799840753678,
- ];
- for &e in &expected {
- assert_eq!(rng.next_u64(), e);
- }
- }
-}
diff --git a/rand/rand_xoshiro/src/xoshiro512starstar.rs b/rand/rand_xoshiro/src/xoshiro512starstar.rs
deleted file mode 100644
index 1a33f0a..0000000
--- a/rand/rand_xoshiro/src/xoshiro512starstar.rs
+++ /dev/null
@@ -1,124 +0,0 @@
-// Copyright 2018 Developers of the Rand project.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-use rand_core::impls::fill_bytes_via_next;
-use rand_core::le::read_u64_into;
-use rand_core::{SeedableRng, RngCore, Error};
-
-use Seed512;
-
-/// A xoshiro512** random number generator.
-///
-/// The xoshiro512** algorithm is not suitable for cryptographic purposes, but
-/// is very fast and has excellent statistical properties.
-///
-/// The algorithm used here is translated from [the `xoshiro512starstar.c`
-/// reference source code](http://xoshiro.di.unimi.it/xoshiro512starstar.c) by
-/// David Blackman and Sebastiano Vigna.
-#[derive(Debug, Clone)]
-pub struct Xoshiro512StarStar {
- s: [u64; 8],
-}
-
-impl Xoshiro512StarStar {
- /// Jump forward, equivalently to 2^256 calls to `next_u64()`.
- ///
- /// This can be used to generate 2^256 non-overlapping subsequences for
- /// parallel computations.
- ///
- /// ```
- /// # extern crate rand;
- /// # extern crate rand_xoshiro;
- /// # fn main() {
- /// use rand::SeedableRng;
- /// use rand_xoshiro::Xoshiro512StarStar;
- ///
- /// let rng1 = Xoshiro512StarStar::seed_from_u64(0);
- /// let mut rng2 = rng1.clone();
- /// rng2.jump();
- /// let mut rng3 = rng2.clone();
- /// rng3.jump();
- /// # }
- /// ```
- pub fn jump(&mut self) {
- impl_jump!(u64, self, [
- 0x33ed89b6e7a353f9, 0x760083d7955323be, 0x2837f2fbb5f22fae,
- 0x4b8c5674d309511c, 0xb11ac47a7ba28c25, 0xf1be7667092bcc1c,
- 0x53851efdb6df0aaf, 0x1ebbc8b23eaf25db
- ]);
- }
-}
-
-
-impl SeedableRng for Xoshiro512StarStar {
- type Seed = Seed512;
-
- /// Create a new `Xoshiro512StarStar`. If `seed` is entirely 0, it will be
- /// mapped to a different seed.
- #[inline]
- fn from_seed(seed: Seed512) -> Xoshiro512StarStar {
- deal_with_zero_seed!(seed, Self);
- let mut state = [0; 8];
- read_u64_into(&seed.0, &mut state);
- Xoshiro512StarStar { s: state }
- }
-
- /// Seed a `Xoshiro512StarStar` from a `u64` using `SplitMix64`.
- fn seed_from_u64(seed: u64) -> Xoshiro512StarStar {
- from_splitmix!(seed)
- }
-}
-
-impl RngCore for Xoshiro512StarStar {
- #[inline]
- fn next_u32(&mut self) -> u32 {
- self.next_u64() as u32
- }
-
- #[inline]
- fn next_u64(&mut self) -> u64 {
- let result_starstar = starstar_u64!(self.s[1]);
- impl_xoshiro_large!(self);
- result_starstar
- }
-
- #[inline]
- fn fill_bytes(&mut self, dest: &mut [u8]) {
- fill_bytes_via_next(self, dest);
- }
-
- #[inline]
- fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), Error> {
- self.fill_bytes(dest);
- Ok(())
- }
-}
-
-#[cfg(test)]
-mod tests {
- use super::*;
-
- #[test]
- fn reference() {
- let mut rng = Xoshiro512StarStar::from_seed(Seed512(
- [1, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0,
- 3, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0,
- 5, 0, 0, 0, 0, 0, 0, 0, 6, 0, 0, 0, 0, 0, 0, 0,
- 7, 0, 0, 0, 0, 0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 0]));
- // These values were produced with the reference implementation:
- // http://xoshiro.di.unimi.it/xoshiro512starstar.c
- let expected = [
- 11520, 0, 23040, 23667840, 144955163520, 303992986974289920,
- 25332796375735680, 296904390158016, 13911081092387501979,
- 15304787717237593024,
- ];
- for &e in &expected {
- assert_eq!(rng.next_u64(), e);
- }
- }
-}
diff --git a/rand/src/deprecated.rs b/rand/src/deprecated.rs
deleted file mode 100644
index 88eb09f..0000000
--- a/rand/src/deprecated.rs
+++ /dev/null
@@ -1,544 +0,0 @@
-// Copyright 2018 Developers of the Rand project.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-//! Deprecated re-exports (we can't add deprecation warnings otherwise)
-
-#![allow(deprecated)]
-
-use rngs;
-use {RngCore, CryptoRng, SeedableRng, Error};
-use rand_core::block::BlockRngCore;
-use rand_isaac;
-use rand_chacha;
-use rand_hc;
-
-#[cfg(feature="std")]
-use std::io::Read;
-
-#[derive(Clone, Debug)]
-#[deprecated(since="0.6.0",
- note="import from rand_isaac crate instead, or use the newer Hc128Rng")]
-pub struct IsaacRng(rand_isaac::IsaacRng);
-
-impl RngCore for IsaacRng {
- #[inline(always)]
- fn next_u32(&mut self) -> u32 {
- self.0.next_u32()
- }
-
- #[inline(always)]
- fn next_u64(&mut self) -> u64 {
- self.0.next_u64()
- }
-
- #[inline(always)]
- fn fill_bytes(&mut self, dest: &mut [u8]) {
- self.0.fill_bytes(dest);
- }
-
- #[inline(always)]
- fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), Error> {
- self.0.try_fill_bytes(dest)
- }
-}
-
-impl SeedableRng for IsaacRng {
- type Seed = <rand_isaac::IsaacRng as SeedableRng>::Seed;
-
- fn from_seed(seed: Self::Seed) -> Self {
- IsaacRng(rand_isaac::IsaacRng::from_seed(seed))
- }
-
- fn from_rng<R: RngCore>(rng: R) -> Result<Self, Error> {
- rand_isaac::IsaacRng::from_rng(rng).map(IsaacRng)
- }
-}
-
-impl IsaacRng {
- pub fn new_from_u64(seed: u64) -> Self {
- IsaacRng(rand_isaac::IsaacRng::new_from_u64(seed))
- }
-}
-
-
-#[derive(Clone, Debug)]
-#[deprecated(since="0.6.0",
- note="import from rand_isaac crate instead, or use newer Hc128Rng")]
-pub struct Isaac64Rng(rand_isaac::Isaac64Rng);
-
-impl RngCore for Isaac64Rng {
- #[inline(always)]
- fn next_u32(&mut self) -> u32 {
- self.0.next_u32()
- }
-
- #[inline(always)]
- fn next_u64(&mut self) -> u64 {
- self.0.next_u64()
- }
-
- #[inline(always)]
- fn fill_bytes(&mut self, dest: &mut [u8]) {
- self.0.fill_bytes(dest);
- }
-
- #[inline(always)]
- fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), Error> {
- self.0.try_fill_bytes(dest)
- }
-}
-
-impl SeedableRng for Isaac64Rng {
- type Seed = <rand_isaac::Isaac64Rng as SeedableRng>::Seed;
-
- fn from_seed(seed: Self::Seed) -> Self {
- Isaac64Rng(rand_isaac::Isaac64Rng::from_seed(seed))
- }
-
- fn from_rng<R: RngCore>(rng: R) -> Result<Self, Error> {
- rand_isaac::Isaac64Rng::from_rng(rng).map(Isaac64Rng)
- }
-}
-
-impl Isaac64Rng {
- pub fn new_from_u64(seed: u64) -> Self {
- Isaac64Rng(rand_isaac::Isaac64Rng::new_from_u64(seed))
- }
-}
-
-
-#[derive(Clone, Debug)]
-#[deprecated(since="0.6.0", note="import from rand_chacha crate instead")]
-pub struct ChaChaRng(rand_chacha::ChaChaRng);
-
-impl RngCore for ChaChaRng {
- #[inline(always)]
- fn next_u32(&mut self) -> u32 {
- self.0.next_u32()
- }
-
- #[inline(always)]
- fn next_u64(&mut self) -> u64 {
- self.0.next_u64()
- }
-
- #[inline(always)]
- fn fill_bytes(&mut self, dest: &mut [u8]) {
- self.0.fill_bytes(dest);
- }
-
- #[inline(always)]
- fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), Error> {
- self.0.try_fill_bytes(dest)
- }
-}
-
-impl SeedableRng for ChaChaRng {
- type Seed = <rand_chacha::ChaChaRng as SeedableRng>::Seed;
-
- fn from_seed(seed: Self::Seed) -> Self {
- ChaChaRng(rand_chacha::ChaChaRng::from_seed(seed))
- }
-
- fn from_rng<R: RngCore>(rng: R) -> Result<Self, Error> {
- rand_chacha::ChaChaRng::from_rng(rng).map(ChaChaRng)
- }
-}
-
-impl ChaChaRng {
- #[cfg(all(rustc_1_26, not(target_os = "emscripten")))]
- pub fn get_word_pos(&self) -> u128 {
- self.0.get_word_pos()
- }
-
- #[cfg(all(rustc_1_26, not(target_os = "emscripten")))]
- pub fn set_word_pos(&mut self, word_offset: u128) {
- self.0.set_word_pos(word_offset)
- }
-
- pub fn set_stream(&mut self, stream: u64) {
- self.0.set_stream(stream)
- }
-}
-
-impl CryptoRng for ChaChaRng {}
-
-
-#[derive(Clone, Debug)]
-#[deprecated(since="0.6.0", note="import from rand_hc crate instead")]
-pub struct Hc128Rng(rand_hc::Hc128Rng);
-
-impl RngCore for Hc128Rng {
- #[inline(always)]
- fn next_u32(&mut self) -> u32 {
- self.0.next_u32()
- }
-
- #[inline(always)]
- fn next_u64(&mut self) -> u64 {
- self.0.next_u64()
- }
-
- #[inline(always)]
- fn fill_bytes(&mut self, dest: &mut [u8]) {
- self.0.fill_bytes(dest);
- }
-
- #[inline(always)]
- fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), Error> {
- self.0.try_fill_bytes(dest)
- }
-}
-
-impl SeedableRng for Hc128Rng {
- type Seed = <rand_hc::Hc128Rng as SeedableRng>::Seed;
-
- fn from_seed(seed: Self::Seed) -> Self {
- Hc128Rng(rand_hc::Hc128Rng::from_seed(seed))
- }
-
- fn from_rng<R: RngCore>(rng: R) -> Result<Self, Error> {
- rand_hc::Hc128Rng::from_rng(rng).map(Hc128Rng)
- }
-}
-
-impl CryptoRng for Hc128Rng {}
-
-
-#[derive(Clone, Debug)]
-#[deprecated(since="0.6.0", note="import from rand_xorshift crate instead")]
-pub struct XorShiftRng(::rand_xorshift::XorShiftRng);
-
-impl RngCore for XorShiftRng {
- #[inline(always)]
- fn next_u32(&mut self) -> u32 {
- self.0.next_u32()
- }
-
- #[inline(always)]
- fn next_u64(&mut self) -> u64 {
- self.0.next_u64()
- }
-
- #[inline(always)]
- fn fill_bytes(&mut self, dest: &mut [u8]) {
- self.0.fill_bytes(dest);
- }
-
- #[inline(always)]
- fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), Error> {
- self.0.try_fill_bytes(dest)
- }
-}
-
-impl SeedableRng for XorShiftRng {
- type Seed = <::rand_xorshift::XorShiftRng as SeedableRng>::Seed;
-
- fn from_seed(seed: Self::Seed) -> Self {
- XorShiftRng(::rand_xorshift::XorShiftRng::from_seed(seed))
- }
-
- fn from_rng<R: RngCore>(rng: R) -> Result<Self, Error> {
- ::rand_xorshift::XorShiftRng::from_rng(rng).map(XorShiftRng)
- }
-}
-
-
-#[derive(Clone, Debug)]
-#[deprecated(since="0.6.0",
- note="import with rand::prelude::* or rand::rngs::StdRng instead")]
-pub struct StdRng(rngs::StdRng);
-
-impl RngCore for StdRng {
- #[inline(always)]
- fn next_u32(&mut self) -> u32 {
- self.0.next_u32()
- }
-
- #[inline(always)]
- fn next_u64(&mut self) -> u64 {
- self.0.next_u64()
- }
-
- #[inline(always)]
- fn fill_bytes(&mut self, dest: &mut [u8]) {
- self.0.fill_bytes(dest);
- }
-
- #[inline(always)]
- fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), Error> {
- self.0.try_fill_bytes(dest)
- }
-}
-
-impl SeedableRng for StdRng {
- type Seed = <rngs::StdRng as SeedableRng>::Seed;
-
- fn from_seed(seed: Self::Seed) -> Self {
- StdRng(rngs::StdRng::from_seed(seed))
- }
-
- fn from_rng<R: RngCore>(rng: R) -> Result<Self, Error> {
- rngs::StdRng::from_rng(rng).map(StdRng)
- }
-}
-
-impl CryptoRng for StdRng {}
-
-
-#[cfg(feature="rand_os")]
-#[derive(Clone, Debug)]
-#[deprecated(since="0.6.0", note="import with rand::rngs::OsRng instead")]
-pub struct OsRng(rngs::OsRng);
-
-#[cfg(feature="rand_os")]
-impl RngCore for OsRng {
- #[inline(always)]
- fn next_u32(&mut self) -> u32 {
- self.0.next_u32()
- }
-
- #[inline(always)]
- fn next_u64(&mut self) -> u64 {
- self.0.next_u64()
- }
-
- #[inline(always)]
- fn fill_bytes(&mut self, dest: &mut [u8]) {
- self.0.fill_bytes(dest);
- }
-
- #[inline(always)]
- fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), Error> {
- self.0.try_fill_bytes(dest)
- }
-}
-
-#[cfg(feature="rand_os")]
-impl OsRng {
- pub fn new() -> Result<Self, Error> {
- rngs::OsRng::new().map(OsRng)
- }
-}
-
-#[cfg(feature="rand_os")]
-impl CryptoRng for OsRng {}
-
-
-#[cfg(feature="std")]
-#[derive(Debug)]
-#[deprecated(since="0.6.0", note="import with rand::rngs::EntropyRng instead")]
-pub struct EntropyRng(rngs::EntropyRng);
-
-#[cfg(feature="std")]
-impl RngCore for EntropyRng {
- #[inline(always)]
- fn next_u32(&mut self) -> u32 {
- self.0.next_u32()
- }
-
- #[inline(always)]
- fn next_u64(&mut self) -> u64 {
- self.0.next_u64()
- }
-
- #[inline(always)]
- fn fill_bytes(&mut self, dest: &mut [u8]) {
- self.0.fill_bytes(dest);
- }
-
- #[inline(always)]
- fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), Error> {
- self.0.try_fill_bytes(dest)
- }
-}
-
-#[cfg(feature="std")]
-impl EntropyRng {
- pub fn new() -> Self {
- EntropyRng(rngs::EntropyRng::new())
- }
-}
-
-#[cfg(feature="std")]
-impl Default for EntropyRng {
- fn default() -> Self {
- EntropyRng::new()
- }
-}
-
-#[cfg(feature="std")]
-impl CryptoRng for EntropyRng {}
-
-
-#[derive(Clone, Debug)]
-#[deprecated(since="0.6.0", note="import with rand::rngs::JitterRng instead")]
-pub struct JitterRng(rngs::JitterRng);
-
-impl RngCore for JitterRng {
- #[inline(always)]
- fn next_u32(&mut self) -> u32 {
- self.0.next_u32()
- }
-
- #[inline(always)]
- fn next_u64(&mut self) -> u64 {
- self.0.next_u64()
- }
-
- #[inline(always)]
- fn fill_bytes(&mut self, dest: &mut [u8]) {
- self.0.fill_bytes(dest);
- }
-
- #[inline(always)]
- fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), Error> {
- self.0.try_fill_bytes(dest)
- }
-}
-
-impl JitterRng {
- #[cfg(all(feature="std", not(target_arch = "wasm32")))]
- pub fn new() -> Result<JitterRng, rngs::TimerError> {
- rngs::JitterRng::new().map(JitterRng)
- }
-
- pub fn new_with_timer(timer: fn() -> u64) -> JitterRng {
- JitterRng(rngs::JitterRng::new_with_timer(timer))
- }
-
- pub fn set_rounds(&mut self, rounds: u8) {
- self.0.set_rounds(rounds)
- }
-
- pub fn test_timer(&mut self) -> Result<u8, rngs::TimerError> {
- self.0.test_timer()
- }
-
- #[cfg(feature="std")]
- pub fn timer_stats(&mut self, var_rounds: bool) -> i64 {
- self.0.timer_stats(var_rounds)
- }
-}
-
-impl CryptoRng for JitterRng {}
-
-
-#[cfg(feature="std")]
-#[derive(Clone, Debug)]
-#[deprecated(since="0.6.0",
- note="import with rand::prelude::* or rand::rngs::ThreadRng instead")]
-pub struct ThreadRng(rngs::ThreadRng);
-
-#[cfg(feature="std")]
-impl RngCore for ThreadRng {
- #[inline(always)]
- fn next_u32(&mut self) -> u32 {
- self.0.next_u32()
- }
-
- #[inline(always)]
- fn next_u64(&mut self) -> u64 {
- self.0.next_u64()
- }
-
- #[inline(always)]
- fn fill_bytes(&mut self, dest: &mut [u8]) {
- self.0.fill_bytes(dest);
- }
-
- #[inline(always)]
- fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), Error> {
- self.0.try_fill_bytes(dest)
- }
-}
-
-#[cfg(feature="std")]
-impl CryptoRng for ThreadRng {}
-
-
-#[cfg(feature="std")]
-#[derive(Debug)]
-#[deprecated(since="0.6.0", note="import with rand::rngs::adapter::ReadRng instead")]
-pub struct ReadRng<R>(rngs::adapter::ReadRng<R>);
-
-#[cfg(feature="std")]
-impl<R: Read> RngCore for ReadRng<R> {
- #[inline(always)]
- fn next_u32(&mut self) -> u32 {
- self.0.next_u32()
- }
-
- #[inline(always)]
- fn next_u64(&mut self) -> u64 {
- self.0.next_u64()
- }
-
- #[inline(always)]
- fn fill_bytes(&mut self, dest: &mut [u8]) {
- self.0.fill_bytes(dest);
- }
-
- #[inline(always)]
- fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), Error> {
- self.0.try_fill_bytes(dest)
- }
-}
-
-#[cfg(feature="std")]
-impl<R: Read> ReadRng<R> {
- pub fn new(r: R) -> ReadRng<R> {
- ReadRng(rngs::adapter::ReadRng::new(r))
- }
-}
-
-
-#[derive(Clone, Debug)]
-pub struct ReseedingRng<R, Rsdr>(rngs::adapter::ReseedingRng<R, Rsdr>)
-where R: BlockRngCore + SeedableRng,
- Rsdr: RngCore;
-
-impl<R, Rsdr: RngCore> RngCore for ReseedingRng<R, Rsdr>
-where R: BlockRngCore<Item = u32> + SeedableRng,
- <R as BlockRngCore>::Results: AsRef<[u32]> + AsMut<[u32]>
-{
- #[inline(always)]
- fn next_u32(&mut self) -> u32 {
- self.0.next_u32()
- }
-
- #[inline(always)]
- fn next_u64(&mut self) -> u64 {
- self.0.next_u64()
- }
-
- fn fill_bytes(&mut self, dest: &mut [u8]) {
- self.0.fill_bytes(dest)
- }
-
- fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), Error> {
- self.0.try_fill_bytes(dest)
- }
-}
-
-impl<R, Rsdr> ReseedingRng<R, Rsdr>
-where R: BlockRngCore + SeedableRng,
- Rsdr: RngCore
-{
- pub fn new(rng: R, threshold: u64, reseeder: Rsdr) -> Self {
- ReseedingRng(rngs::adapter::ReseedingRng::new(rng, threshold, reseeder))
- }
-
- pub fn reseed(&mut self) -> Result<(), Error> {
- self.0.reseed()
- }
-}
-
-impl<R, Rsdr> CryptoRng for ReseedingRng<R, Rsdr>
-where R: BlockRngCore + SeedableRng + CryptoRng,
- Rsdr: RngCore + CryptoRng {}
diff --git a/rand/src/distributions/bernoulli.rs b/rand/src/distributions/bernoulli.rs
deleted file mode 100644
index f49618c..0000000
--- a/rand/src/distributions/bernoulli.rs
+++ /dev/null
@@ -1,165 +0,0 @@
-// Copyright 2018 Developers of the Rand project.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-//! The Bernoulli distribution.
-
-use Rng;
-use distributions::Distribution;
-
-/// The Bernoulli distribution.
-///
-/// This is a special case of the Binomial distribution where `n = 1`.
-///
-/// # Example
-///
-/// ```rust
-/// use rand::distributions::{Bernoulli, Distribution};
-///
-/// let d = Bernoulli::new(0.3);
-/// let v = d.sample(&mut rand::thread_rng());
-/// println!("{} is from a Bernoulli distribution", v);
-/// ```
-///
-/// # Precision
-///
-/// This `Bernoulli` distribution uses 64 bits from the RNG (a `u64`),
-/// so only probabilities that are multiples of 2<sup>-64</sup> can be
-/// represented.
-#[derive(Clone, Copy, Debug)]
-pub struct Bernoulli {
- /// Probability of success, relative to the maximal integer.
- p_int: u64,
-}
-
-// To sample from the Bernoulli distribution we use a method that compares a
-// random `u64` value `v < (p * 2^64)`.
-//
-// If `p == 1.0`, the integer `v` to compare against can not represented as a
-// `u64`. We manually set it to `u64::MAX` instead (2^64 - 1 instead of 2^64).
-// Note that value of `p < 1.0` can never result in `u64::MAX`, because an
-// `f64` only has 53 bits of precision, and the next largest value of `p` will
-// result in `2^64 - 2048`.
-//
-// Also there is a 100% theoretical concern: if someone consistenly wants to
-// generate `true` using the Bernoulli distribution (i.e. by using a probability
-// of `1.0`), just using `u64::MAX` is not enough. On average it would return
-// false once every 2^64 iterations. Some people apparently care about this
-// case.
-//
-// That is why we special-case `u64::MAX` to always return `true`, without using
-// the RNG, and pay the performance price for all uses that *are* reasonable.
-// Luckily, if `new()` and `sample` are close, the compiler can optimize out the
-// extra check.
-const ALWAYS_TRUE: u64 = ::core::u64::MAX;
-
-// This is just `2.0.powi(64)`, but written this way because it is not available
-// in `no_std` mode.
-const SCALE: f64 = 2.0 * (1u64 << 63) as f64;
-
-impl Bernoulli {
- /// Construct a new `Bernoulli` with the given probability of success `p`.
- ///
- /// # Panics
- ///
- /// If `p < 0` or `p > 1`.
- ///
- /// # Precision
- ///
- /// For `p = 1.0`, the resulting distribution will always generate true.
- /// For `p = 0.0`, the resulting distribution will always generate false.
- ///
- /// This method is accurate for any input `p` in the range `[0, 1]` which is
- /// a multiple of 2<sup>-64</sup>. (Note that not all multiples of
- /// 2<sup>-64</sup> in `[0, 1]` can be represented as a `f64`.)
- #[inline]
- pub fn new(p: f64) -> Bernoulli {
- if p < 0.0 || p >= 1.0 {
- if p == 1.0 { return Bernoulli { p_int: ALWAYS_TRUE } }
- panic!("Bernoulli::new not called with 0.0 <= p <= 1.0");
- }
- Bernoulli { p_int: (p * SCALE) as u64 }
- }
-
- /// Construct a new `Bernoulli` with the probability of success of
- /// `numerator`-in-`denominator`. I.e. `new_ratio(2, 3)` will return
- /// a `Bernoulli` with a 2-in-3 chance, or about 67%, of returning `true`.
- ///
- /// If `numerator == denominator` then the returned `Bernoulli` will always
- /// return `true`. If `numerator == 0` it will always return `false`.
- ///
- /// # Panics
- ///
- /// If `denominator == 0` or `numerator > denominator`.
- ///
- #[inline]
- pub fn from_ratio(numerator: u32, denominator: u32) -> Bernoulli {
- assert!(numerator <= denominator);
- if numerator == denominator {
- return Bernoulli { p_int: ::core::u64::MAX }
- }
- let p_int = ((numerator as f64 / denominator as f64) * SCALE) as u64;
- Bernoulli { p_int }
- }
-}
-
-impl Distribution<bool> for Bernoulli {
- #[inline]
- fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> bool {
- // Make sure to always return true for p = 1.0.
- if self.p_int == ALWAYS_TRUE { return true; }
- let v: u64 = rng.gen();
- v < self.p_int
- }
-}
-
-#[cfg(test)]
-mod test {
- use Rng;
- use distributions::Distribution;
- use super::Bernoulli;
-
- #[test]
- fn test_trivial() {
- let mut r = ::test::rng(1);
- let always_false = Bernoulli::new(0.0);
- let always_true = Bernoulli::new(1.0);
- for _ in 0..5 {
- assert_eq!(r.sample::<bool, _>(&always_false), false);
- assert_eq!(r.sample::<bool, _>(&always_true), true);
- assert_eq!(Distribution::<bool>::sample(&always_false, &mut r), false);
- assert_eq!(Distribution::<bool>::sample(&always_true, &mut r), true);
- }
- }
-
- #[test]
- fn test_average() {
- const P: f64 = 0.3;
- const NUM: u32 = 3;
- const DENOM: u32 = 10;
- let d1 = Bernoulli::new(P);
- let d2 = Bernoulli::from_ratio(NUM, DENOM);
- const N: u32 = 100_000;
-
- let mut sum1: u32 = 0;
- let mut sum2: u32 = 0;
- let mut rng = ::test::rng(2);
- for _ in 0..N {
- if d1.sample(&mut rng) {
- sum1 += 1;
- }
- if d2.sample(&mut rng) {
- sum2 += 1;
- }
- }
- let avg1 = (sum1 as f64) / (N as f64);
- assert!((avg1 - P).abs() < 5e-3);
-
- let avg2 = (sum2 as f64) / (N as f64);
- assert!((avg2 - (NUM as f64)/(DENOM as f64)).abs() < 5e-3);
- }
-}
diff --git a/rand/src/distributions/binomial.rs b/rand/src/distributions/binomial.rs
deleted file mode 100644
index 2df393e..0000000
--- a/rand/src/distributions/binomial.rs
+++ /dev/null
@@ -1,177 +0,0 @@
-// Copyright 2018 Developers of the Rand project.
-// Copyright 2016-2017 The Rust Project Developers.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-//! The binomial distribution.
-
-use Rng;
-use distributions::{Distribution, Bernoulli, Cauchy};
-use distributions::utils::log_gamma;
-
-/// The binomial distribution `Binomial(n, p)`.
-///
-/// This distribution has density function:
-/// `f(k) = n!/(k! (n-k)!) p^k (1-p)^(n-k)` for `k >= 0`.
-///
-/// # Example
-///
-/// ```
-/// use rand::distributions::{Binomial, Distribution};
-///
-/// let bin = Binomial::new(20, 0.3);
-/// let v = bin.sample(&mut rand::thread_rng());
-/// println!("{} is from a binomial distribution", v);
-/// ```
-#[derive(Clone, Copy, Debug)]
-pub struct Binomial {
- /// Number of trials.
- n: u64,
- /// Probability of success.
- p: f64,
-}
-
-impl Binomial {
- /// Construct a new `Binomial` with the given shape parameters `n` (number
- /// of trials) and `p` (probability of success).
- ///
- /// Panics if `p < 0` or `p > 1`.
- pub fn new(n: u64, p: f64) -> Binomial {
- assert!(p >= 0.0, "Binomial::new called with p < 0");
- assert!(p <= 1.0, "Binomial::new called with p > 1");
- Binomial { n, p }
- }
-}
-
-impl Distribution<u64> for Binomial {
- fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> u64 {
- // Handle these values directly.
- if self.p == 0.0 {
- return 0;
- } else if self.p == 1.0 {
- return self.n;
- }
-
- // For low n, it is faster to sample directly. For both methods,
- // performance is independent of p. On Intel Haswell CPU this method
- // appears to be faster for approx n < 300.
- if self.n < 300 {
- let mut result = 0;
- let d = Bernoulli::new(self.p);
- for _ in 0 .. self.n {
- result += rng.sample(d) as u32;
- }
- return result as u64;
- }
-
- // binomial distribution is symmetrical with respect to p -> 1-p, k -> n-k
- // switch p so that it is less than 0.5 - this allows for lower expected values
- // we will just invert the result at the end
- let p = if self.p <= 0.5 {
- self.p
- } else {
- 1.0 - self.p
- };
-
- // prepare some cached values
- let float_n = self.n as f64;
- let ln_fact_n = log_gamma(float_n + 1.0);
- let pc = 1.0 - p;
- let log_p = p.ln();
- let log_pc = pc.ln();
- let expected = self.n as f64 * p;
- let sq = (expected * (2.0 * pc)).sqrt();
-
- let mut lresult;
-
- // we use the Cauchy distribution as the comparison distribution
- // f(x) ~ 1/(1+x^2)
- let cauchy = Cauchy::new(0.0, 1.0);
- loop {
- let mut comp_dev: f64;
- loop {
- // draw from the Cauchy distribution
- comp_dev = rng.sample(cauchy);
- // shift the peak of the comparison ditribution
- lresult = expected + sq * comp_dev;
- // repeat the drawing until we are in the range of possible values
- if lresult >= 0.0 && lresult < float_n + 1.0 {
- break;
- }
- }
-
- // the result should be discrete
- lresult = lresult.floor();
-
- let log_binomial_dist = ln_fact_n - log_gamma(lresult+1.0) -
- log_gamma(float_n - lresult + 1.0) + lresult*log_p + (float_n - lresult)*log_pc;
- // this is the binomial probability divided by the comparison probability
- // we will generate a uniform random value and if it is larger than this,
- // we interpret it as a value falling out of the distribution and repeat
- let comparison_coeff = (log_binomial_dist.exp() * sq) * (1.2 * (1.0 + comp_dev*comp_dev));
-
- if comparison_coeff >= rng.gen() {
- break;
- }
- }
-
- // invert the result for p < 0.5
- if p != self.p {
- self.n - lresult as u64
- } else {
- lresult as u64
- }
- }
-}
-
-#[cfg(test)]
-mod test {
- use Rng;
- use distributions::Distribution;
- use super::Binomial;
-
- fn test_binomial_mean_and_variance<R: Rng>(n: u64, p: f64, rng: &mut R) {
- let binomial = Binomial::new(n, p);
-
- let expected_mean = n as f64 * p;
- let expected_variance = n as f64 * p * (1.0 - p);
-
- let mut results = [0.0; 1000];
- for i in results.iter_mut() { *i = binomial.sample(rng) as f64; }
-
- let mean = results.iter().sum::<f64>() / results.len() as f64;
- assert!((mean as f64 - expected_mean).abs() < expected_mean / 50.0);
-
- let variance =
- results.iter().map(|x| (x - mean) * (x - mean)).sum::<f64>()
- / results.len() as f64;
- assert!((variance - expected_variance).abs() < expected_variance / 10.0);
- }
-
- #[test]
- fn test_binomial() {
- let mut rng = ::test::rng(351);
- test_binomial_mean_and_variance(150, 0.1, &mut rng);
- test_binomial_mean_and_variance(70, 0.6, &mut rng);
- test_binomial_mean_and_variance(40, 0.5, &mut rng);
- test_binomial_mean_and_variance(20, 0.7, &mut rng);
- test_binomial_mean_and_variance(20, 0.5, &mut rng);
- }
-
- #[test]
- fn test_binomial_end_points() {
- let mut rng = ::test::rng(352);
- assert_eq!(rng.sample(Binomial::new(20, 0.0)), 0);
- assert_eq!(rng.sample(Binomial::new(20, 1.0)), 20);
- }
-
- #[test]
- #[should_panic]
- fn test_binomial_invalid_lambda_neg() {
- Binomial::new(20, -10.0);
- }
-}
diff --git a/rand/src/distributions/cauchy.rs b/rand/src/distributions/cauchy.rs
deleted file mode 100644
index feef015..0000000
--- a/rand/src/distributions/cauchy.rs
+++ /dev/null
@@ -1,115 +0,0 @@
-// Copyright 2018 Developers of the Rand project.
-// Copyright 2016-2017 The Rust Project Developers.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-//! The Cauchy distribution.
-
-use Rng;
-use distributions::Distribution;
-use std::f64::consts::PI;
-
-/// The Cauchy distribution `Cauchy(median, scale)`.
-///
-/// This distribution has a density function:
-/// `f(x) = 1 / (pi * scale * (1 + ((x - median) / scale)^2))`
-///
-/// # Example
-///
-/// ```
-/// use rand::distributions::{Cauchy, Distribution};
-///
-/// let cau = Cauchy::new(2.0, 5.0);
-/// let v = cau.sample(&mut rand::thread_rng());
-/// println!("{} is from a Cauchy(2, 5) distribution", v);
-/// ```
-#[derive(Clone, Copy, Debug)]
-pub struct Cauchy {
- median: f64,
- scale: f64
-}
-
-impl Cauchy {
- /// Construct a new `Cauchy` with the given shape parameters
- /// `median` the peak location and `scale` the scale factor.
- /// Panics if `scale <= 0`.
- pub fn new(median: f64, scale: f64) -> Cauchy {
- assert!(scale > 0.0, "Cauchy::new called with scale factor <= 0");
- Cauchy {
- median,
- scale
- }
- }
-}
-
-impl Distribution<f64> for Cauchy {
- fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> f64 {
- // sample from [0, 1)
- let x = rng.gen::<f64>();
- // get standard cauchy random number
- // note that π/2 is not exactly representable, even if x=0.5 the result is finite
- let comp_dev = (PI * x).tan();
- // shift and scale according to parameters
- let result = self.median + self.scale * comp_dev;
- result
- }
-}
-
-#[cfg(test)]
-mod test {
- use distributions::Distribution;
- use super::Cauchy;
-
- fn median(mut numbers: &mut [f64]) -> f64 {
- sort(&mut numbers);
- let mid = numbers.len() / 2;
- numbers[mid]
- }
-
- fn sort(numbers: &mut [f64]) {
- numbers.sort_by(|a, b| a.partial_cmp(b).unwrap());
- }
-
- #[test]
- fn test_cauchy_median() {
- let cauchy = Cauchy::new(10.0, 5.0);
- let mut rng = ::test::rng(123);
- let mut numbers: [f64; 1000] = [0.0; 1000];
- for i in 0..1000 {
- numbers[i] = cauchy.sample(&mut rng);
- }
- let median = median(&mut numbers);
- println!("Cauchy median: {}", median);
- assert!((median - 10.0).abs() < 0.5); // not 100% certain, but probable enough
- }
-
- #[test]
- fn test_cauchy_mean() {
- let cauchy = Cauchy::new(10.0, 5.0);
- let mut rng = ::test::rng(123);
- let mut sum = 0.0;
- for _ in 0..1000 {
- sum += cauchy.sample(&mut rng);
- }
- let mean = sum / 1000.0;
- println!("Cauchy mean: {}", mean);
- // for a Cauchy distribution the mean should not converge
- assert!((mean - 10.0).abs() > 0.5); // not 100% certain, but probable enough
- }
-
- #[test]
- #[should_panic]
- fn test_cauchy_invalid_scale_zero() {
- Cauchy::new(0.0, 0.0);
- }
-
- #[test]
- #[should_panic]
- fn test_cauchy_invalid_scale_neg() {
- Cauchy::new(0.0, -10.0);
- }
-}
diff --git a/rand/src/distributions/dirichlet.rs b/rand/src/distributions/dirichlet.rs
deleted file mode 100644
index 19384b8..0000000
--- a/rand/src/distributions/dirichlet.rs
+++ /dev/null
@@ -1,137 +0,0 @@
-// Copyright 2018 Developers of the Rand project.
-// Copyright 2013 The Rust Project Developers.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-//! The dirichlet distribution.
-
-use Rng;
-use distributions::Distribution;
-use distributions::gamma::Gamma;
-
-/// The dirichelet distribution `Dirichlet(alpha)`.
-///
-/// The Dirichlet distribution is a family of continuous multivariate
-/// probability distributions parameterized by a vector alpha of positive reals.
-/// It is a multivariate generalization of the beta distribution.
-///
-/// # Example
-///
-/// ```
-/// use rand::prelude::*;
-/// use rand::distributions::Dirichlet;
-///
-/// let dirichlet = Dirichlet::new(vec![1.0, 2.0, 3.0]);
-/// let samples = dirichlet.sample(&mut rand::thread_rng());
-/// println!("{:?} is from a Dirichlet([1.0, 2.0, 3.0]) distribution", samples);
-/// ```
-
-#[derive(Clone, Debug)]
-pub struct Dirichlet {
- /// Concentration parameters (alpha)
- alpha: Vec<f64>,
-}
-
-impl Dirichlet {
- /// Construct a new `Dirichlet` with the given alpha parameter `alpha`.
- ///
- /// # Panics
- /// - if `alpha.len() < 2`
- ///
- #[inline]
- pub fn new<V: Into<Vec<f64>>>(alpha: V) -> Dirichlet {
- let a = alpha.into();
- assert!(a.len() > 1);
- for i in 0..a.len() {
- assert!(a[i] > 0.0);
- }
-
- Dirichlet { alpha: a }
- }
-
- /// Construct a new `Dirichlet` with the given shape parameter `alpha` and `size`.
- ///
- /// # Panics
- /// - if `alpha <= 0.0`
- /// - if `size < 2`
- ///
- #[inline]
- pub fn new_with_param(alpha: f64, size: usize) -> Dirichlet {
- assert!(alpha > 0.0);
- assert!(size > 1);
- Dirichlet {
- alpha: vec![alpha; size],
- }
- }
-}
-
-impl Distribution<Vec<f64>> for Dirichlet {
- fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> Vec<f64> {
- let n = self.alpha.len();
- let mut samples = vec![0.0f64; n];
- let mut sum = 0.0f64;
-
- for i in 0..n {
- let g = Gamma::new(self.alpha[i], 1.0);
- samples[i] = g.sample(rng);
- sum += samples[i];
- }
- let invacc = 1.0 / sum;
- for i in 0..n {
- samples[i] *= invacc;
- }
- samples
- }
-}
-
-#[cfg(test)]
-mod test {
- use super::Dirichlet;
- use distributions::Distribution;
-
- #[test]
- fn test_dirichlet() {
- let d = Dirichlet::new(vec![1.0, 2.0, 3.0]);
- let mut rng = ::test::rng(221);
- let samples = d.sample(&mut rng);
- let _: Vec<f64> = samples
- .into_iter()
- .map(|x| {
- assert!(x > 0.0);
- x
- })
- .collect();
- }
-
- #[test]
- fn test_dirichlet_with_param() {
- let alpha = 0.5f64;
- let size = 2;
- let d = Dirichlet::new_with_param(alpha, size);
- let mut rng = ::test::rng(221);
- let samples = d.sample(&mut rng);
- let _: Vec<f64> = samples
- .into_iter()
- .map(|x| {
- assert!(x > 0.0);
- x
- })
- .collect();
- }
-
- #[test]
- #[should_panic]
- fn test_dirichlet_invalid_length() {
- Dirichlet::new_with_param(0.5f64, 1);
- }
-
- #[test]
- #[should_panic]
- fn test_dirichlet_invalid_alpha() {
- Dirichlet::new_with_param(0.0f64, 2);
- }
-}
diff --git a/rand/src/distributions/exponential.rs b/rand/src/distributions/exponential.rs
deleted file mode 100644
index a7d0500..0000000
--- a/rand/src/distributions/exponential.rs
+++ /dev/null
@@ -1,124 +0,0 @@
-// Copyright 2018 Developers of the Rand project.
-// Copyright 2013 The Rust Project Developers.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-//! The exponential distribution.
-
-use {Rng};
-use distributions::{ziggurat_tables, Distribution};
-use distributions::utils::ziggurat;
-
-/// Samples floating-point numbers according to the exponential distribution,
-/// with rate parameter `λ = 1`. This is equivalent to `Exp::new(1.0)` or
-/// sampling with `-rng.gen::<f64>().ln()`, but faster.
-///
-/// See `Exp` for the general exponential distribution.
-///
-/// Implemented via the ZIGNOR variant[^1] of the Ziggurat method. The exact
-/// description in the paper was adjusted to use tables for the exponential
-/// distribution rather than normal.
-///
-/// [^1]: Jurgen A. Doornik (2005). [*An Improved Ziggurat Method to
-/// Generate Normal Random Samples*](
-/// https://www.doornik.com/research/ziggurat.pdf).
-/// Nuffield College, Oxford
-///
-/// # Example
-/// ```
-/// use rand::prelude::*;
-/// use rand::distributions::Exp1;
-///
-/// let val: f64 = SmallRng::from_entropy().sample(Exp1);
-/// println!("{}", val);
-/// ```
-#[derive(Clone, Copy, Debug)]
-pub struct Exp1;
-
-// This could be done via `-rng.gen::<f64>().ln()` but that is slower.
-impl Distribution<f64> for Exp1 {
- #[inline]
- fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> f64 {
- #[inline]
- fn pdf(x: f64) -> f64 {
- (-x).exp()
- }
- #[inline]
- fn zero_case<R: Rng + ?Sized>(rng: &mut R, _u: f64) -> f64 {
- ziggurat_tables::ZIG_EXP_R - rng.gen::<f64>().ln()
- }
-
- ziggurat(rng, false,
- &ziggurat_tables::ZIG_EXP_X,
- &ziggurat_tables::ZIG_EXP_F,
- pdf, zero_case)
- }
-}
-
-/// The exponential distribution `Exp(lambda)`.
-///
-/// This distribution has density function: `f(x) = lambda * exp(-lambda * x)`
-/// for `x > 0`.
-///
-/// Note that [`Exp1`](struct.Exp1.html) is an optimised implementation for `lambda = 1`.
-///
-/// # Example
-///
-/// ```
-/// use rand::distributions::{Exp, Distribution};
-///
-/// let exp = Exp::new(2.0);
-/// let v = exp.sample(&mut rand::thread_rng());
-/// println!("{} is from a Exp(2) distribution", v);
-/// ```
-#[derive(Clone, Copy, Debug)]
-pub struct Exp {
- /// `lambda` stored as `1/lambda`, since this is what we scale by.
- lambda_inverse: f64
-}
-
-impl Exp {
- /// Construct a new `Exp` with the given shape parameter
- /// `lambda`. Panics if `lambda <= 0`.
- #[inline]
- pub fn new(lambda: f64) -> Exp {
- assert!(lambda > 0.0, "Exp::new called with `lambda` <= 0");
- Exp { lambda_inverse: 1.0 / lambda }
- }
-}
-
-impl Distribution<f64> for Exp {
- fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> f64 {
- let n: f64 = rng.sample(Exp1);
- n * self.lambda_inverse
- }
-}
-
-#[cfg(test)]
-mod test {
- use distributions::Distribution;
- use super::Exp;
-
- #[test]
- fn test_exp() {
- let exp = Exp::new(10.0);
- let mut rng = ::test::rng(221);
- for _ in 0..1000 {
- assert!(exp.sample(&mut rng) >= 0.0);
- }
- }
- #[test]
- #[should_panic]
- fn test_exp_invalid_lambda_zero() {
- Exp::new(0.0);
- }
- #[test]
- #[should_panic]
- fn test_exp_invalid_lambda_neg() {
- Exp::new(-10.0);
- }
-}
diff --git a/rand/src/distributions/float.rs b/rand/src/distributions/float.rs
deleted file mode 100644
index ece12f5..0000000
--- a/rand/src/distributions/float.rs
+++ /dev/null
@@ -1,259 +0,0 @@
-// Copyright 2018 Developers of the Rand project.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-//! Basic floating-point number distributions
-
-use core::mem;
-use Rng;
-use distributions::{Distribution, Standard};
-use distributions::utils::FloatSIMDUtils;
-#[cfg(feature="simd_support")]
-use packed_simd::*;
-
-/// A distribution to sample floating point numbers uniformly in the half-open
-/// interval `(0, 1]`, i.e. including 1 but not 0.
-///
-/// All values that can be generated are of the form `n * ε/2`. For `f32`
-/// the 23 most significant random bits of a `u32` are used and for `f64` the
-/// 53 most significant bits of a `u64` are used. The conversion uses the
-/// multiplicative method.
-///
-/// See also: [`Standard`] which samples from `[0, 1)`, [`Open01`]
-/// which samples from `(0, 1)` and [`Uniform`] which samples from arbitrary
-/// ranges.
-///
-/// # Example
-/// ```
-/// use rand::{thread_rng, Rng};
-/// use rand::distributions::OpenClosed01;
-///
-/// let val: f32 = thread_rng().sample(OpenClosed01);
-/// println!("f32 from (0, 1): {}", val);
-/// ```
-///
-/// [`Standard`]: struct.Standard.html
-/// [`Open01`]: struct.Open01.html
-/// [`Uniform`]: uniform/struct.Uniform.html
-#[derive(Clone, Copy, Debug)]
-pub struct OpenClosed01;
-
-/// A distribution to sample floating point numbers uniformly in the open
-/// interval `(0, 1)`, i.e. not including either endpoint.
-///
-/// All values that can be generated are of the form `n * ε + ε/2`. For `f32`
-/// the 22 most significant random bits of an `u32` are used, for `f64` 52 from
-/// an `u64`. The conversion uses a transmute-based method.
-///
-/// See also: [`Standard`] which samples from `[0, 1)`, [`OpenClosed01`]
-/// which samples from `(0, 1]` and [`Uniform`] which samples from arbitrary
-/// ranges.
-///
-/// # Example
-/// ```
-/// use rand::{thread_rng, Rng};
-/// use rand::distributions::Open01;
-///
-/// let val: f32 = thread_rng().sample(Open01);
-/// println!("f32 from (0, 1): {}", val);
-/// ```
-///
-/// [`Standard`]: struct.Standard.html
-/// [`OpenClosed01`]: struct.OpenClosed01.html
-/// [`Uniform`]: uniform/struct.Uniform.html
-#[derive(Clone, Copy, Debug)]
-pub struct Open01;
-
-
-pub(crate) trait IntoFloat {
- type F;
-
- /// Helper method to combine the fraction and a contant exponent into a
- /// float.
- ///
- /// Only the least significant bits of `self` may be set, 23 for `f32` and
- /// 52 for `f64`.
- /// The resulting value will fall in a range that depends on the exponent.
- /// As an example the range with exponent 0 will be
- /// [2<sup>0</sup>..2<sup>1</sup>), which is [1..2).
- fn into_float_with_exponent(self, exponent: i32) -> Self::F;
-}
-
-macro_rules! float_impls {
- ($ty:ident, $uty:ident, $f_scalar:ident, $u_scalar:ty,
- $fraction_bits:expr, $exponent_bias:expr) => {
- impl IntoFloat for $uty {
- type F = $ty;
- #[inline(always)]
- fn into_float_with_exponent(self, exponent: i32) -> $ty {
- // The exponent is encoded using an offset-binary representation
- let exponent_bits: $u_scalar =
- (($exponent_bias + exponent) as $u_scalar) << $fraction_bits;
- // TODO: use from_bits when min compiler > 1.25 (see #545)
- // $ty::from_bits(self | exponent_bits)
- unsafe{ mem::transmute(self | exponent_bits) }
- }
- }
-
- impl Distribution<$ty> for Standard {
- fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> $ty {
- // Multiply-based method; 24/53 random bits; [0, 1) interval.
- // We use the most significant bits because for simple RNGs
- // those are usually more random.
- let float_size = mem::size_of::<$f_scalar>() as u32 * 8;
- let precision = $fraction_bits + 1;
- let scale = 1.0 / ((1 as $u_scalar << precision) as $f_scalar);
-
- let value: $uty = rng.gen();
- let value = value >> (float_size - precision);
- scale * $ty::cast_from_int(value)
- }
- }
-
- impl Distribution<$ty> for OpenClosed01 {
- fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> $ty {
- // Multiply-based method; 24/53 random bits; (0, 1] interval.
- // We use the most significant bits because for simple RNGs
- // those are usually more random.
- let float_size = mem::size_of::<$f_scalar>() as u32 * 8;
- let precision = $fraction_bits + 1;
- let scale = 1.0 / ((1 as $u_scalar << precision) as $f_scalar);
-
- let value: $uty = rng.gen();
- let value = value >> (float_size - precision);
- // Add 1 to shift up; will not overflow because of right-shift:
- scale * $ty::cast_from_int(value + 1)
- }
- }
-
- impl Distribution<$ty> for Open01 {
- fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> $ty {
- // Transmute-based method; 23/52 random bits; (0, 1) interval.
- // We use the most significant bits because for simple RNGs
- // those are usually more random.
- use core::$f_scalar::EPSILON;
- let float_size = mem::size_of::<$f_scalar>() as u32 * 8;
-
- let value: $uty = rng.gen();
- let fraction = value >> (float_size - $fraction_bits);
- fraction.into_float_with_exponent(0) - (1.0 - EPSILON / 2.0)
- }
- }
- }
-}
-
-float_impls! { f32, u32, f32, u32, 23, 127 }
-float_impls! { f64, u64, f64, u64, 52, 1023 }
-
-#[cfg(feature="simd_support")]
-float_impls! { f32x2, u32x2, f32, u32, 23, 127 }
-#[cfg(feature="simd_support")]
-float_impls! { f32x4, u32x4, f32, u32, 23, 127 }
-#[cfg(feature="simd_support")]
-float_impls! { f32x8, u32x8, f32, u32, 23, 127 }
-#[cfg(feature="simd_support")]
-float_impls! { f32x16, u32x16, f32, u32, 23, 127 }
-
-#[cfg(feature="simd_support")]
-float_impls! { f64x2, u64x2, f64, u64, 52, 1023 }
-#[cfg(feature="simd_support")]
-float_impls! { f64x4, u64x4, f64, u64, 52, 1023 }
-#[cfg(feature="simd_support")]
-float_impls! { f64x8, u64x8, f64, u64, 52, 1023 }
-
-
-#[cfg(test)]
-mod tests {
- use Rng;
- use distributions::{Open01, OpenClosed01};
- use rngs::mock::StepRng;
- #[cfg(feature="simd_support")]
- use packed_simd::*;
-
- const EPSILON32: f32 = ::core::f32::EPSILON;
- const EPSILON64: f64 = ::core::f64::EPSILON;
-
- macro_rules! test_f32 {
- ($fnn:ident, $ty:ident, $ZERO:expr, $EPSILON:expr) => {
- #[test]
- fn $fnn() {
- // Standard
- let mut zeros = StepRng::new(0, 0);
- assert_eq!(zeros.gen::<$ty>(), $ZERO);
- let mut one = StepRng::new(1 << 8 | 1 << (8 + 32), 0);
- assert_eq!(one.gen::<$ty>(), $EPSILON / 2.0);
- let mut max = StepRng::new(!0, 0);
- assert_eq!(max.gen::<$ty>(), 1.0 - $EPSILON / 2.0);
-
- // OpenClosed01
- let mut zeros = StepRng::new(0, 0);
- assert_eq!(zeros.sample::<$ty, _>(OpenClosed01),
- 0.0 + $EPSILON / 2.0);
- let mut one = StepRng::new(1 << 8 | 1 << (8 + 32), 0);
- assert_eq!(one.sample::<$ty, _>(OpenClosed01), $EPSILON);
- let mut max = StepRng::new(!0, 0);
- assert_eq!(max.sample::<$ty, _>(OpenClosed01), $ZERO + 1.0);
-
- // Open01
- let mut zeros = StepRng::new(0, 0);
- assert_eq!(zeros.sample::<$ty, _>(Open01), 0.0 + $EPSILON / 2.0);
- let mut one = StepRng::new(1 << 9 | 1 << (9 + 32), 0);
- assert_eq!(one.sample::<$ty, _>(Open01), $EPSILON / 2.0 * 3.0);
- let mut max = StepRng::new(!0, 0);
- assert_eq!(max.sample::<$ty, _>(Open01), 1.0 - $EPSILON / 2.0);
- }
- }
- }
- test_f32! { f32_edge_cases, f32, 0.0, EPSILON32 }
- #[cfg(feature="simd_support")]
- test_f32! { f32x2_edge_cases, f32x2, f32x2::splat(0.0), f32x2::splat(EPSILON32) }
- #[cfg(feature="simd_support")]
- test_f32! { f32x4_edge_cases, f32x4, f32x4::splat(0.0), f32x4::splat(EPSILON32) }
- #[cfg(feature="simd_support")]
- test_f32! { f32x8_edge_cases, f32x8, f32x8::splat(0.0), f32x8::splat(EPSILON32) }
- #[cfg(feature="simd_support")]
- test_f32! { f32x16_edge_cases, f32x16, f32x16::splat(0.0), f32x16::splat(EPSILON32) }
-
- macro_rules! test_f64 {
- ($fnn:ident, $ty:ident, $ZERO:expr, $EPSILON:expr) => {
- #[test]
- fn $fnn() {
- // Standard
- let mut zeros = StepRng::new(0, 0);
- assert_eq!(zeros.gen::<$ty>(), $ZERO);
- let mut one = StepRng::new(1 << 11, 0);
- assert_eq!(one.gen::<$ty>(), $EPSILON / 2.0);
- let mut max = StepRng::new(!0, 0);
- assert_eq!(max.gen::<$ty>(), 1.0 - $EPSILON / 2.0);
-
- // OpenClosed01
- let mut zeros = StepRng::new(0, 0);
- assert_eq!(zeros.sample::<$ty, _>(OpenClosed01),
- 0.0 + $EPSILON / 2.0);
- let mut one = StepRng::new(1 << 11, 0);
- assert_eq!(one.sample::<$ty, _>(OpenClosed01), $EPSILON);
- let mut max = StepRng::new(!0, 0);
- assert_eq!(max.sample::<$ty, _>(OpenClosed01), $ZERO + 1.0);
-
- // Open01
- let mut zeros = StepRng::new(0, 0);
- assert_eq!(zeros.sample::<$ty, _>(Open01), 0.0 + $EPSILON / 2.0);
- let mut one = StepRng::new(1 << 12, 0);
- assert_eq!(one.sample::<$ty, _>(Open01), $EPSILON / 2.0 * 3.0);
- let mut max = StepRng::new(!0, 0);
- assert_eq!(max.sample::<$ty, _>(Open01), 1.0 - $EPSILON / 2.0);
- }
- }
- }
- test_f64! { f64_edge_cases, f64, 0.0, EPSILON64 }
- #[cfg(feature="simd_support")]
- test_f64! { f64x2_edge_cases, f64x2, f64x2::splat(0.0), f64x2::splat(EPSILON64) }
- #[cfg(feature="simd_support")]
- test_f64! { f64x4_edge_cases, f64x4, f64x4::splat(0.0), f64x4::splat(EPSILON64) }
- #[cfg(feature="simd_support")]
- test_f64! { f64x8_edge_cases, f64x8, f64x8::splat(0.0), f64x8::splat(EPSILON64) }
-}
diff --git a/rand/src/distributions/gamma.rs b/rand/src/distributions/gamma.rs
deleted file mode 100644
index 43ac2bc..0000000
--- a/rand/src/distributions/gamma.rs
+++ /dev/null
@@ -1,413 +0,0 @@
-// Copyright 2018 Developers of the Rand project.
-// Copyright 2013 The Rust Project Developers.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-//! The Gamma and derived distributions.
-
-use self::GammaRepr::*;
-use self::ChiSquaredRepr::*;
-
-use Rng;
-use distributions::normal::StandardNormal;
-use distributions::{Distribution, Exp, Open01};
-
-/// The Gamma distribution `Gamma(shape, scale)` distribution.
-///
-/// The density function of this distribution is
-///
-/// ```text
-/// f(x) = x^(k - 1) * exp(-x / θ) / (Γ(k) * θ^k)
-/// ```
-///
-/// where `Γ` is the Gamma function, `k` is the shape and `θ` is the
-/// scale and both `k` and `θ` are strictly positive.
-///
-/// The algorithm used is that described by Marsaglia & Tsang 2000[^1],
-/// falling back to directly sampling from an Exponential for `shape
-/// == 1`, and using the boosting technique described in that paper for
-/// `shape < 1`.
-///
-/// # Example
-///
-/// ```
-/// use rand::distributions::{Distribution, Gamma};
-///
-/// let gamma = Gamma::new(2.0, 5.0);
-/// let v = gamma.sample(&mut rand::thread_rng());
-/// println!("{} is from a Gamma(2, 5) distribution", v);
-/// ```
-///
-/// [^1]: George Marsaglia and Wai Wan Tsang. 2000. "A Simple Method for
-/// Generating Gamma Variables" *ACM Trans. Math. Softw.* 26, 3
-/// (September 2000), 363-372.
-/// DOI:[10.1145/358407.358414](https://doi.acm.org/10.1145/358407.358414)
-#[derive(Clone, Copy, Debug)]
-pub struct Gamma {
- repr: GammaRepr,
-}
-
-#[derive(Clone, Copy, Debug)]
-enum GammaRepr {
- Large(GammaLargeShape),
- One(Exp),
- Small(GammaSmallShape)
-}
-
-// These two helpers could be made public, but saving the
-// match-on-Gamma-enum branch from using them directly (e.g. if one
-// knows that the shape is always > 1) doesn't appear to be much
-// faster.
-
-/// Gamma distribution where the shape parameter is less than 1.
-///
-/// Note, samples from this require a compulsory floating-point `pow`
-/// call, which makes it significantly slower than sampling from a
-/// gamma distribution where the shape parameter is greater than or
-/// equal to 1.
-///
-/// See `Gamma` for sampling from a Gamma distribution with general
-/// shape parameters.
-#[derive(Clone, Copy, Debug)]
-struct GammaSmallShape {
- inv_shape: f64,
- large_shape: GammaLargeShape
-}
-
-/// Gamma distribution where the shape parameter is larger than 1.
-///
-/// See `Gamma` for sampling from a Gamma distribution with general
-/// shape parameters.
-#[derive(Clone, Copy, Debug)]
-struct GammaLargeShape {
- scale: f64,
- c: f64,
- d: f64
-}
-
-impl Gamma {
- /// Construct an object representing the `Gamma(shape, scale)`
- /// distribution.
- ///
- /// Panics if `shape <= 0` or `scale <= 0`.
- #[inline]
- pub fn new(shape: f64, scale: f64) -> Gamma {
- assert!(shape > 0.0, "Gamma::new called with shape <= 0");
- assert!(scale > 0.0, "Gamma::new called with scale <= 0");
-
- let repr = if shape == 1.0 {
- One(Exp::new(1.0 / scale))
- } else if shape < 1.0 {
- Small(GammaSmallShape::new_raw(shape, scale))
- } else {
- Large(GammaLargeShape::new_raw(shape, scale))
- };
- Gamma { repr }
- }
-}
-
-impl GammaSmallShape {
- fn new_raw(shape: f64, scale: f64) -> GammaSmallShape {
- GammaSmallShape {
- inv_shape: 1. / shape,
- large_shape: GammaLargeShape::new_raw(shape + 1.0, scale)
- }
- }
-}
-
-impl GammaLargeShape {
- fn new_raw(shape: f64, scale: f64) -> GammaLargeShape {
- let d = shape - 1. / 3.;
- GammaLargeShape {
- scale,
- c: 1. / (9. * d).sqrt(),
- d
- }
- }
-}
-
-impl Distribution<f64> for Gamma {
- fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> f64 {
- match self.repr {
- Small(ref g) => g.sample(rng),
- One(ref g) => g.sample(rng),
- Large(ref g) => g.sample(rng),
- }
- }
-}
-impl Distribution<f64> for GammaSmallShape {
- fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> f64 {
- let u: f64 = rng.sample(Open01);
-
- self.large_shape.sample(rng) * u.powf(self.inv_shape)
- }
-}
-impl Distribution<f64> for GammaLargeShape {
- fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> f64 {
- loop {
- let x = rng.sample(StandardNormal);
- let v_cbrt = 1.0 + self.c * x;
- if v_cbrt <= 0.0 { // a^3 <= 0 iff a <= 0
- continue
- }
-
- let v = v_cbrt * v_cbrt * v_cbrt;
- let u: f64 = rng.sample(Open01);
-
- let x_sqr = x * x;
- if u < 1.0 - 0.0331 * x_sqr * x_sqr ||
- u.ln() < 0.5 * x_sqr + self.d * (1.0 - v + v.ln()) {
- return self.d * v * self.scale
- }
- }
- }
-}
-
-/// The chi-squared distribution `χ²(k)`, where `k` is the degrees of
-/// freedom.
-///
-/// For `k > 0` integral, this distribution is the sum of the squares
-/// of `k` independent standard normal random variables. For other
-/// `k`, this uses the equivalent characterisation
-/// `χ²(k) = Gamma(k/2, 2)`.
-///
-/// # Example
-///
-/// ```
-/// use rand::distributions::{ChiSquared, Distribution};
-///
-/// let chi = ChiSquared::new(11.0);
-/// let v = chi.sample(&mut rand::thread_rng());
-/// println!("{} is from a χ²(11) distribution", v)
-/// ```
-#[derive(Clone, Copy, Debug)]
-pub struct ChiSquared {
- repr: ChiSquaredRepr,
-}
-
-#[derive(Clone, Copy, Debug)]
-enum ChiSquaredRepr {
- // k == 1, Gamma(alpha, ..) is particularly slow for alpha < 1,
- // e.g. when alpha = 1/2 as it would be for this case, so special-
- // casing and using the definition of N(0,1)^2 is faster.
- DoFExactlyOne,
- DoFAnythingElse(Gamma),
-}
-
-impl ChiSquared {
- /// Create a new chi-squared distribution with degrees-of-freedom
- /// `k`. Panics if `k < 0`.
- pub fn new(k: f64) -> ChiSquared {
- let repr = if k == 1.0 {
- DoFExactlyOne
- } else {
- assert!(k > 0.0, "ChiSquared::new called with `k` < 0");
- DoFAnythingElse(Gamma::new(0.5 * k, 2.0))
- };
- ChiSquared { repr }
- }
-}
-impl Distribution<f64> for ChiSquared {
- fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> f64 {
- match self.repr {
- DoFExactlyOne => {
- // k == 1 => N(0,1)^2
- let norm = rng.sample(StandardNormal);
- norm * norm
- }
- DoFAnythingElse(ref g) => g.sample(rng)
- }
- }
-}
-
-/// The Fisher F distribution `F(m, n)`.
-///
-/// This distribution is equivalent to the ratio of two normalised
-/// chi-squared distributions, that is, `F(m,n) = (χ²(m)/m) /
-/// (χ²(n)/n)`.
-///
-/// # Example
-///
-/// ```
-/// use rand::distributions::{FisherF, Distribution};
-///
-/// let f = FisherF::new(2.0, 32.0);
-/// let v = f.sample(&mut rand::thread_rng());
-/// println!("{} is from an F(2, 32) distribution", v)
-/// ```
-#[derive(Clone, Copy, Debug)]
-pub struct FisherF {
- numer: ChiSquared,
- denom: ChiSquared,
- // denom_dof / numer_dof so that this can just be a straight
- // multiplication, rather than a division.
- dof_ratio: f64,
-}
-
-impl FisherF {
- /// Create a new `FisherF` distribution, with the given
- /// parameter. Panics if either `m` or `n` are not positive.
- pub fn new(m: f64, n: f64) -> FisherF {
- assert!(m > 0.0, "FisherF::new called with `m < 0`");
- assert!(n > 0.0, "FisherF::new called with `n < 0`");
-
- FisherF {
- numer: ChiSquared::new(m),
- denom: ChiSquared::new(n),
- dof_ratio: n / m
- }
- }
-}
-impl Distribution<f64> for FisherF {
- fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> f64 {
- self.numer.sample(rng) / self.denom.sample(rng) * self.dof_ratio
- }
-}
-
-/// The Student t distribution, `t(nu)`, where `nu` is the degrees of
-/// freedom.
-///
-/// # Example
-///
-/// ```
-/// use rand::distributions::{StudentT, Distribution};
-///
-/// let t = StudentT::new(11.0);
-/// let v = t.sample(&mut rand::thread_rng());
-/// println!("{} is from a t(11) distribution", v)
-/// ```
-#[derive(Clone, Copy, Debug)]
-pub struct StudentT {
- chi: ChiSquared,
- dof: f64
-}
-
-impl StudentT {
- /// Create a new Student t distribution with `n` degrees of
- /// freedom. Panics if `n <= 0`.
- pub fn new(n: f64) -> StudentT {
- assert!(n > 0.0, "StudentT::new called with `n <= 0`");
- StudentT {
- chi: ChiSquared::new(n),
- dof: n
- }
- }
-}
-impl Distribution<f64> for StudentT {
- fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> f64 {
- let norm = rng.sample(StandardNormal);
- norm * (self.dof / self.chi.sample(rng)).sqrt()
- }
-}
-
-/// The Beta distribution with shape parameters `alpha` and `beta`.
-///
-/// # Example
-///
-/// ```
-/// use rand::distributions::{Distribution, Beta};
-///
-/// let beta = Beta::new(2.0, 5.0);
-/// let v = beta.sample(&mut rand::thread_rng());
-/// println!("{} is from a Beta(2, 5) distribution", v);
-/// ```
-#[derive(Clone, Copy, Debug)]
-pub struct Beta {
- gamma_a: Gamma,
- gamma_b: Gamma,
-}
-
-impl Beta {
- /// Construct an object representing the `Beta(alpha, beta)`
- /// distribution.
- ///
- /// Panics if `shape <= 0` or `scale <= 0`.
- pub fn new(alpha: f64, beta: f64) -> Beta {
- assert!((alpha > 0.) & (beta > 0.));
- Beta {
- gamma_a: Gamma::new(alpha, 1.),
- gamma_b: Gamma::new(beta, 1.),
- }
- }
-}
-
-impl Distribution<f64> for Beta {
- fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> f64 {
- let x = self.gamma_a.sample(rng);
- let y = self.gamma_b.sample(rng);
- x / (x + y)
- }
-}
-
-#[cfg(test)]
-mod test {
- use distributions::Distribution;
- use super::{Beta, ChiSquared, StudentT, FisherF};
-
- #[test]
- fn test_chi_squared_one() {
- let chi = ChiSquared::new(1.0);
- let mut rng = ::test::rng(201);
- for _ in 0..1000 {
- chi.sample(&mut rng);
- }
- }
- #[test]
- fn test_chi_squared_small() {
- let chi = ChiSquared::new(0.5);
- let mut rng = ::test::rng(202);
- for _ in 0..1000 {
- chi.sample(&mut rng);
- }
- }
- #[test]
- fn test_chi_squared_large() {
- let chi = ChiSquared::new(30.0);
- let mut rng = ::test::rng(203);
- for _ in 0..1000 {
- chi.sample(&mut rng);
- }
- }
- #[test]
- #[should_panic]
- fn test_chi_squared_invalid_dof() {
- ChiSquared::new(-1.0);
- }
-
- #[test]
- fn test_f() {
- let f = FisherF::new(2.0, 32.0);
- let mut rng = ::test::rng(204);
- for _ in 0..1000 {
- f.sample(&mut rng);
- }
- }
-
- #[test]
- fn test_t() {
- let t = StudentT::new(11.0);
- let mut rng = ::test::rng(205);
- for _ in 0..1000 {
- t.sample(&mut rng);
- }
- }
-
- #[test]
- fn test_beta() {
- let beta = Beta::new(1.0, 2.0);
- let mut rng = ::test::rng(201);
- for _ in 0..1000 {
- beta.sample(&mut rng);
- }
- }
-
- #[test]
- #[should_panic]
- fn test_beta_invalid_dof() {
- Beta::new(0., 0.);
- }
-}
diff --git a/rand/src/distributions/integer.rs b/rand/src/distributions/integer.rs
deleted file mode 100644
index 7e408db..0000000
--- a/rand/src/distributions/integer.rs
+++ /dev/null
@@ -1,161 +0,0 @@
-// Copyright 2018 Developers of the Rand project.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-//! The implementations of the `Standard` distribution for integer types.
-
-use {Rng};
-use distributions::{Distribution, Standard};
-#[cfg(feature="simd_support")]
-use packed_simd::*;
-#[cfg(all(target_arch = "x86", feature="nightly"))]
-use core::arch::x86::*;
-#[cfg(all(target_arch = "x86_64", feature="nightly"))]
-use core::arch::x86_64::*;
-
-impl Distribution<u8> for Standard {
- #[inline]
- fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> u8 {
- rng.next_u32() as u8
- }
-}
-
-impl Distribution<u16> for Standard {
- #[inline]
- fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> u16 {
- rng.next_u32() as u16
- }
-}
-
-impl Distribution<u32> for Standard {
- #[inline]
- fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> u32 {
- rng.next_u32()
- }
-}
-
-impl Distribution<u64> for Standard {
- #[inline]
- fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> u64 {
- rng.next_u64()
- }
-}
-
-#[cfg(all(rustc_1_26, not(target_os = "emscripten")))]
-impl Distribution<u128> for Standard {
- #[inline]
- fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> u128 {
- // Use LE; we explicitly generate one value before the next.
- let x = rng.next_u64() as u128;
- let y = rng.next_u64() as u128;
- (y << 64) | x
- }
-}
-
-impl Distribution<usize> for Standard {
- #[inline]
- #[cfg(any(target_pointer_width = "32", target_pointer_width = "16"))]
- fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> usize {
- rng.next_u32() as usize
- }
-
- #[inline]
- #[cfg(target_pointer_width = "64")]
- fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> usize {
- rng.next_u64() as usize
- }
-}
-
-macro_rules! impl_int_from_uint {
- ($ty:ty, $uty:ty) => {
- impl Distribution<$ty> for Standard {
- #[inline]
- fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> $ty {
- rng.gen::<$uty>() as $ty
- }
- }
- }
-}
-
-impl_int_from_uint! { i8, u8 }
-impl_int_from_uint! { i16, u16 }
-impl_int_from_uint! { i32, u32 }
-impl_int_from_uint! { i64, u64 }
-#[cfg(all(rustc_1_26, not(target_os = "emscripten")))] impl_int_from_uint! { i128, u128 }
-impl_int_from_uint! { isize, usize }
-
-#[cfg(feature="simd_support")]
-macro_rules! simd_impl {
- ($(($intrinsic:ident, $vec:ty),)+) => {$(
- impl Distribution<$intrinsic> for Standard {
- #[inline]
- fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> $intrinsic {
- $intrinsic::from_bits(rng.gen::<$vec>())
- }
- }
- )+};
-
- ($bits:expr,) => {};
- ($bits:expr, $ty:ty, $($ty_more:ty,)*) => {
- simd_impl!($bits, $($ty_more,)*);
-
- impl Distribution<$ty> for Standard {
- #[inline]
- fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> $ty {
- let mut vec: $ty = Default::default();
- unsafe {
- let ptr = &mut vec;
- let b_ptr = &mut *(ptr as *mut $ty as *mut [u8; $bits/8]);
- rng.fill_bytes(b_ptr);
- }
- vec.to_le()
- }
- }
- };
-}
-
-#[cfg(feature="simd_support")]
-simd_impl!(16, u8x2, i8x2,);
-#[cfg(feature="simd_support")]
-simd_impl!(32, u8x4, i8x4, u16x2, i16x2,);
-#[cfg(feature="simd_support")]
-simd_impl!(64, u8x8, i8x8, u16x4, i16x4, u32x2, i32x2,);
-#[cfg(feature="simd_support")]
-simd_impl!(128, u8x16, i8x16, u16x8, i16x8, u32x4, i32x4, u64x2, i64x2,);
-#[cfg(feature="simd_support")]
-simd_impl!(256, u8x32, i8x32, u16x16, i16x16, u32x8, i32x8, u64x4, i64x4,);
-#[cfg(feature="simd_support")]
-simd_impl!(512, u8x64, i8x64, u16x32, i16x32, u32x16, i32x16, u64x8, i64x8,);
-#[cfg(all(feature="simd_support", feature="nightly", any(target_arch="x86", target_arch="x86_64")))]
-simd_impl!((__m64, u8x8), (__m128i, u8x16), (__m256i, u8x32),);
-
-#[cfg(test)]
-mod tests {
- use Rng;
- use distributions::{Standard};
-
- #[test]
- fn test_integers() {
- let mut rng = ::test::rng(806);
-
- rng.sample::<isize, _>(Standard);
- rng.sample::<i8, _>(Standard);
- rng.sample::<i16, _>(Standard);
- rng.sample::<i32, _>(Standard);
- rng.sample::<i64, _>(Standard);
- #[cfg(all(rustc_1_26, not(target_os = "emscripten")))]
- rng.sample::<i128, _>(Standard);
-
- rng.sample::<usize, _>(Standard);
- rng.sample::<u8, _>(Standard);
- rng.sample::<u16, _>(Standard);
- rng.sample::<u32, _>(Standard);
- rng.sample::<u64, _>(Standard);
- #[cfg(all(rustc_1_26, not(target_os = "emscripten")))]
- rng.sample::<u128, _>(Standard);
- }
-}
diff --git a/rand/src/distributions/mod.rs b/rand/src/distributions/mod.rs
deleted file mode 100644
index 5e879cb..0000000
--- a/rand/src/distributions/mod.rs
+++ /dev/null
@@ -1,621 +0,0 @@
-// Copyright 2018 Developers of the Rand project.
-// Copyright 2013-2017 The Rust Project Developers.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-//! Generating random samples from probability distributions.
-//!
-//! This module is the home of the [`Distribution`] trait and several of its
-//! implementations. It is the workhorse behind some of the convenient
-//! functionality of the [`Rng`] trait, including [`gen`], [`gen_range`] and
-//! of course [`sample`].
-//!
-//! Abstractly, a [probability distribution] describes the probability of
-//! occurance of each value in its sample space.
-//!
-//! More concretely, an implementation of `Distribution<T>` for type `X` is an
-//! algorithm for choosing values from the sample space (a subset of `T`)
-//! according to the distribution `X` represents, using an external source of
-//! randomness (an RNG supplied to the `sample` function).
-//!
-//! A type `X` may implement `Distribution<T>` for multiple types `T`.
-//! Any type implementing [`Distribution`] is stateless (i.e. immutable),
-//! but it may have internal parameters set at construction time (for example,
-//! [`Uniform`] allows specification of its sample space as a range within `T`).
-//!
-//!
-//! # The `Standard` distribution
-//!
-//! The [`Standard`] distribution is important to mention. This is the
-//! distribution used by [`Rng::gen()`] and represents the "default" way to
-//! produce a random value for many different types, including most primitive
-//! types, tuples, arrays, and a few derived types. See the documentation of
-//! [`Standard`] for more details.
-//!
-//! Implementing `Distribution<T>` for [`Standard`] for user types `T` makes it
-//! possible to generate type `T` with [`Rng::gen()`], and by extension also
-//! with the [`random()`] function.
-//!
-//!
-//! # Distribution to sample from a `Uniform` range
-//!
-//! The [`Uniform`] distribution is more flexible than [`Standard`], but also
-//! more specialised: it supports fewer target types, but allows the sample
-//! space to be specified as an arbitrary range within its target type `T`.
-//! Both [`Standard`] and [`Uniform`] are in some sense uniform distributions.
-//!
-//! Values may be sampled from this distribution using [`Rng::gen_range`] or
-//! by creating a distribution object with [`Uniform::new`],
-//! [`Uniform::new_inclusive`] or `From<Range>`. When the range limits are not
-//! known at compile time it is typically faster to reuse an existing
-//! distribution object than to call [`Rng::gen_range`].
-//!
-//! User types `T` may also implement `Distribution<T>` for [`Uniform`],
-//! although this is less straightforward than for [`Standard`] (see the
-//! documentation in the [`uniform` module]. Doing so enables generation of
-//! values of type `T` with [`Rng::gen_range`].
-//!
-//!
-//! # Other distributions
-//!
-//! There are surprisingly many ways to uniformly generate random floats. A
-//! range between 0 and 1 is standard, but the exact bounds (open vs closed)
-//! and accuracy differ. In addition to the [`Standard`] distribution Rand offers
-//! [`Open01`] and [`OpenClosed01`]. See [Floating point implementation] for
-//! more details.
-//!
-//! [`Alphanumeric`] is a simple distribution to sample random letters and
-//! numbers of the `char` type; in contrast [`Standard`] may sample any valid
-//! `char`.
-//!
-//! [`WeightedIndex`] can be used to do weighted sampling from a set of items,
-//! such as from an array.
-//!
-//! # Non-uniform probability distributions
-//!
-//! Rand currently provides the following probability distributions:
-//!
-//! - Related to real-valued quantities that grow linearly
-//! (e.g. errors, offsets):
-//! - [`Normal`] distribution, and [`StandardNormal`] as a primitive
-//! - [`Cauchy`] distribution
-//! - Related to Bernoulli trials (yes/no events, with a given probability):
-//! - [`Binomial`] distribution
-//! - [`Bernoulli`] distribution, similar to [`Rng::gen_bool`].
-//! - Related to positive real-valued quantities that grow exponentially
-//! (e.g. prices, incomes, populations):
-//! - [`LogNormal`] distribution
-//! - Related to the occurrence of independent events at a given rate:
-//! - [`Pareto`] distribution
-//! - [`Poisson`] distribution
-//! - [`Exp`]onential distribution, and [`Exp1`] as a primitive
-//! - [`Weibull`] distribution
-//! - Gamma and derived distributions:
-//! - [`Gamma`] distribution
-//! - [`ChiSquared`] distribution
-//! - [`StudentT`] distribution
-//! - [`FisherF`] distribution
-//! - Triangular distribution:
-//! - [`Beta`] distribution
-//! - [`Triangular`] distribution
-//! - Multivariate probability distributions
-//! - [`Dirichlet`] distribution
-//! - [`UnitSphereSurface`] distribution
-//! - [`UnitCircle`] distribution
-//!
-//! # Examples
-//!
-//! Sampling from a distribution:
-//!
-//! ```
-//! use rand::{thread_rng, Rng};
-//! use rand::distributions::Exp;
-//!
-//! let exp = Exp::new(2.0);
-//! let v = thread_rng().sample(exp);
-//! println!("{} is from an Exp(2) distribution", v);
-//! ```
-//!
-//! Implementing the [`Standard`] distribution for a user type:
-//!
-//! ```
-//! # #![allow(dead_code)]
-//! use rand::Rng;
-//! use rand::distributions::{Distribution, Standard};
-//!
-//! struct MyF32 {
-//! x: f32,
-//! }
-//!
-//! impl Distribution<MyF32> for Standard {
-//! fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> MyF32 {
-//! MyF32 { x: rng.gen() }
-//! }
-//! }
-//! ```
-//!
-//!
-//! [probability distribution]: https://en.wikipedia.org/wiki/Probability_distribution
-//! [`Distribution`]: trait.Distribution.html
-//! [`gen_range`]: ../trait.Rng.html#method.gen_range
-//! [`gen`]: ../trait.Rng.html#method.gen
-//! [`sample`]: ../trait.Rng.html#method.sample
-//! [`new_inclusive`]: struct.Uniform.html#method.new_inclusive
-//! [`random()`]: ../fn.random.html
-//! [`Rng::gen_bool`]: ../trait.Rng.html#method.gen_bool
-//! [`Rng::gen_range`]: ../trait.Rng.html#method.gen_range
-//! [`Rng::gen()`]: ../trait.Rng.html#method.gen
-//! [`Rng`]: ../trait.Rng.html
-//! [`uniform` module]: uniform/index.html
-//! [Floating point implementation]: struct.Standard.html#floating-point-implementation
-// distributions
-//! [`Alphanumeric`]: struct.Alphanumeric.html
-//! [`Bernoulli`]: struct.Bernoulli.html
-//! [`Beta`]: struct.Beta.html
-//! [`Binomial`]: struct.Binomial.html
-//! [`Cauchy`]: struct.Cauchy.html
-//! [`ChiSquared`]: struct.ChiSquared.html
-//! [`Dirichlet`]: struct.Dirichlet.html
-//! [`Exp`]: struct.Exp.html
-//! [`Exp1`]: struct.Exp1.html
-//! [`FisherF`]: struct.FisherF.html
-//! [`Gamma`]: struct.Gamma.html
-//! [`LogNormal`]: struct.LogNormal.html
-//! [`Normal`]: struct.Normal.html
-//! [`Open01`]: struct.Open01.html
-//! [`OpenClosed01`]: struct.OpenClosed01.html
-//! [`Pareto`]: struct.Pareto.html
-//! [`Poisson`]: struct.Poisson.html
-//! [`Standard`]: struct.Standard.html
-//! [`StandardNormal`]: struct.StandardNormal.html
-//! [`StudentT`]: struct.StudentT.html
-//! [`Triangular`]: struct.Triangular.html
-//! [`Uniform`]: struct.Uniform.html
-//! [`Uniform::new`]: struct.Uniform.html#method.new
-//! [`Uniform::new_inclusive`]: struct.Uniform.html#method.new_inclusive
-//! [`UnitSphereSurface`]: struct.UnitSphereSurface.html
-//! [`UnitCircle`]: struct.UnitCircle.html
-//! [`Weibull`]: struct.Weibull.html
-//! [`WeightedIndex`]: struct.WeightedIndex.html
-
-#[cfg(any(rustc_1_26, features="nightly"))]
-use core::iter;
-use Rng;
-
-pub use self::other::Alphanumeric;
-#[doc(inline)] pub use self::uniform::Uniform;
-pub use self::float::{OpenClosed01, Open01};
-pub use self::bernoulli::Bernoulli;
-#[cfg(feature="alloc")] pub use self::weighted::{WeightedIndex, WeightedError};
-#[cfg(feature="std")] pub use self::unit_sphere::UnitSphereSurface;
-#[cfg(feature="std")] pub use self::unit_circle::UnitCircle;
-#[cfg(feature="std")] pub use self::gamma::{Gamma, ChiSquared, FisherF,
- StudentT, Beta};
-#[cfg(feature="std")] pub use self::normal::{Normal, LogNormal, StandardNormal};
-#[cfg(feature="std")] pub use self::exponential::{Exp, Exp1};
-#[cfg(feature="std")] pub use self::pareto::Pareto;
-#[cfg(feature="std")] pub use self::poisson::Poisson;
-#[cfg(feature="std")] pub use self::binomial::Binomial;
-#[cfg(feature="std")] pub use self::cauchy::Cauchy;
-#[cfg(feature="std")] pub use self::dirichlet::Dirichlet;
-#[cfg(feature="std")] pub use self::triangular::Triangular;
-#[cfg(feature="std")] pub use self::weibull::Weibull;
-
-pub mod uniform;
-mod bernoulli;
-#[cfg(feature="alloc")] mod weighted;
-#[cfg(feature="std")] mod unit_sphere;
-#[cfg(feature="std")] mod unit_circle;
-#[cfg(feature="std")] mod gamma;
-#[cfg(feature="std")] mod normal;
-#[cfg(feature="std")] mod exponential;
-#[cfg(feature="std")] mod pareto;
-#[cfg(feature="std")] mod poisson;
-#[cfg(feature="std")] mod binomial;
-#[cfg(feature="std")] mod cauchy;
-#[cfg(feature="std")] mod dirichlet;
-#[cfg(feature="std")] mod triangular;
-#[cfg(feature="std")] mod weibull;
-
-mod float;
-mod integer;
-mod other;
-mod utils;
-#[cfg(feature="std")] mod ziggurat_tables;
-
-/// Types (distributions) that can be used to create a random instance of `T`.
-///
-/// It is possible to sample from a distribution through both the
-/// `Distribution` and [`Rng`] traits, via `distr.sample(&mut rng)` and
-/// `rng.sample(distr)`. They also both offer the [`sample_iter`] method, which
-/// produces an iterator that samples from the distribution.
-///
-/// All implementations are expected to be immutable; this has the significant
-/// advantage of not needing to consider thread safety, and for most
-/// distributions efficient state-less sampling algorithms are available.
-///
-/// [`Rng`]: ../trait.Rng.html
-/// [`sample_iter`]: trait.Distribution.html#method.sample_iter
-pub trait Distribution<T> {
- /// Generate a random value of `T`, using `rng` as the source of randomness.
- fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> T;
-
- /// Create an iterator that generates random values of `T`, using `rng` as
- /// the source of randomness.
- ///
- /// # Example
- ///
- /// ```
- /// use rand::thread_rng;
- /// use rand::distributions::{Distribution, Alphanumeric, Uniform, Standard};
- ///
- /// let mut rng = thread_rng();
- ///
- /// // Vec of 16 x f32:
- /// let v: Vec<f32> = Standard.sample_iter(&mut rng).take(16).collect();
- ///
- /// // String:
- /// let s: String = Alphanumeric.sample_iter(&mut rng).take(7).collect();
- ///
- /// // Dice-rolling:
- /// let die_range = Uniform::new_inclusive(1, 6);
- /// let mut roll_die = die_range.sample_iter(&mut rng);
- /// while roll_die.next().unwrap() != 6 {
- /// println!("Not a 6; rolling again!");
- /// }
- /// ```
- fn sample_iter<'a, R>(&'a self, rng: &'a mut R) -> DistIter<'a, Self, R, T>
- where Self: Sized, R: Rng
- {
- DistIter {
- distr: self,
- rng: rng,
- phantom: ::core::marker::PhantomData,
- }
- }
-}
-
-impl<'a, T, D: Distribution<T>> Distribution<T> for &'a D {
- fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> T {
- (*self).sample(rng)
- }
-}
-
-
-/// An iterator that generates random values of `T` with distribution `D`,
-/// using `R` as the source of randomness.
-///
-/// This `struct` is created by the [`sample_iter`] method on [`Distribution`].
-/// See its documentation for more.
-///
-/// [`Distribution`]: trait.Distribution.html
-/// [`sample_iter`]: trait.Distribution.html#method.sample_iter
-#[derive(Debug)]
-pub struct DistIter<'a, D: 'a, R: 'a, T> {
- distr: &'a D,
- rng: &'a mut R,
- phantom: ::core::marker::PhantomData<T>,
-}
-
-impl<'a, D, R, T> Iterator for DistIter<'a, D, R, T>
- where D: Distribution<T>, R: Rng + 'a
-{
- type Item = T;
-
- #[inline(always)]
- fn next(&mut self) -> Option<T> {
- Some(self.distr.sample(self.rng))
- }
-
- fn size_hint(&self) -> (usize, Option<usize>) {
- (usize::max_value(), None)
- }
-}
-
-#[cfg(rustc_1_26)]
-impl<'a, D, R, T> iter::FusedIterator for DistIter<'a, D, R, T>
- where D: Distribution<T>, R: Rng + 'a {}
-
-#[cfg(features = "nightly")]
-impl<'a, D, R, T> iter::TrustedLen for DistIter<'a, D, R, T>
- where D: Distribution<T>, R: Rng + 'a {}
-
-
-/// A generic random value distribution, implemented for many primitive types.
-/// Usually generates values with a numerically uniform distribution, and with a
-/// range appropriate to the type.
-///
-/// ## Built-in Implementations
-///
-/// Assuming the provided `Rng` is well-behaved, these implementations
-/// generate values with the following ranges and distributions:
-///
-/// * Integers (`i32`, `u32`, `isize`, `usize`, etc.): Uniformly distributed
-/// over all values of the type.
-/// * `char`: Uniformly distributed over all Unicode scalar values, i.e. all
-/// code points in the range `0...0x10_FFFF`, except for the range
-/// `0xD800...0xDFFF` (the surrogate code points). This includes
-/// unassigned/reserved code points.
-/// * `bool`: Generates `false` or `true`, each with probability 0.5.
-/// * Floating point types (`f32` and `f64`): Uniformly distributed in the
-/// half-open range `[0, 1)`. See notes below.
-/// * Wrapping integers (`Wrapping<T>`), besides the type identical to their
-/// normal integer variants.
-///
-/// The following aggregate types also implement the distribution `Standard` as
-/// long as their component types implement it:
-///
-/// * Tuples and arrays: Each element of the tuple or array is generated
-/// independently, using the `Standard` distribution recursively.
-/// * `Option<T>` where `Standard` is implemented for `T`: Returns `None` with
-/// probability 0.5; otherwise generates a random `x: T` and returns `Some(x)`.
-///
-/// # Example
-/// ```
-/// use rand::prelude::*;
-/// use rand::distributions::Standard;
-///
-/// let val: f32 = SmallRng::from_entropy().sample(Standard);
-/// println!("f32 from [0, 1): {}", val);
-/// ```
-///
-/// # Floating point implementation
-/// The floating point implementations for `Standard` generate a random value in
-/// the half-open interval `[0, 1)`, i.e. including 0 but not 1.
-///
-/// All values that can be generated are of the form `n * ε/2`. For `f32`
-/// the 23 most significant random bits of a `u32` are used and for `f64` the
-/// 53 most significant bits of a `u64` are used. The conversion uses the
-/// multiplicative method: `(rng.gen::<$uty>() >> N) as $ty * (ε/2)`.
-///
-/// See also: [`Open01`] which samples from `(0, 1)`, [`OpenClosed01`] which
-/// samples from `(0, 1]` and `Rng::gen_range(0, 1)` which also samples from
-/// `[0, 1)`. Note that `Open01` and `gen_range` (which uses [`Uniform`]) use
-/// transmute-based methods which yield 1 bit less precision but may perform
-/// faster on some architectures (on modern Intel CPUs all methods have
-/// approximately equal performance).
-///
-/// [`Open01`]: struct.Open01.html
-/// [`OpenClosed01`]: struct.OpenClosed01.html
-/// [`Uniform`]: uniform/struct.Uniform.html
-#[derive(Clone, Copy, Debug)]
-pub struct Standard;
-
-
-/// A value with a particular weight for use with `WeightedChoice`.
-#[deprecated(since="0.6.0", note="use WeightedIndex instead")]
-#[allow(deprecated)]
-#[derive(Copy, Clone, Debug)]
-pub struct Weighted<T> {
- /// The numerical weight of this item
- pub weight: u32,
- /// The actual item which is being weighted
- pub item: T,
-}
-
-/// A distribution that selects from a finite collection of weighted items.
-///
-/// Deprecated: use [`WeightedIndex`] instead.
-///
-/// [`WeightedIndex`]: struct.WeightedIndex.html
-#[deprecated(since="0.6.0", note="use WeightedIndex instead")]
-#[allow(deprecated)]
-#[derive(Debug)]
-pub struct WeightedChoice<'a, T:'a> {
- items: &'a mut [Weighted<T>],
- weight_range: Uniform<u32>,
-}
-
-#[deprecated(since="0.6.0", note="use WeightedIndex instead")]
-#[allow(deprecated)]
-impl<'a, T: Clone> WeightedChoice<'a, T> {
- /// Create a new `WeightedChoice`.
- ///
- /// Panics if:
- ///
- /// - `items` is empty
- /// - the total weight is 0
- /// - the total weight is larger than a `u32` can contain.
- pub fn new(items: &'a mut [Weighted<T>]) -> WeightedChoice<'a, T> {
- // strictly speaking, this is subsumed by the total weight == 0 case
- assert!(!items.is_empty(), "WeightedChoice::new called with no items");
-
- let mut running_total: u32 = 0;
-
- // we convert the list from individual weights to cumulative
- // weights so we can binary search. This *could* drop elements
- // with weight == 0 as an optimisation.
- for item in items.iter_mut() {
- running_total = match running_total.checked_add(item.weight) {
- Some(n) => n,
- None => panic!("WeightedChoice::new called with a total weight \
- larger than a u32 can contain")
- };
-
- item.weight = running_total;
- }
- assert!(running_total != 0, "WeightedChoice::new called with a total weight of 0");
-
- WeightedChoice {
- items,
- // we're likely to be generating numbers in this range
- // relatively often, so might as well cache it
- weight_range: Uniform::new(0, running_total)
- }
- }
-}
-
-#[deprecated(since="0.6.0", note="use WeightedIndex instead")]
-#[allow(deprecated)]
-impl<'a, T: Clone> Distribution<T> for WeightedChoice<'a, T> {
- fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> T {
- // we want to find the first element that has cumulative
- // weight > sample_weight, which we do by binary since the
- // cumulative weights of self.items are sorted.
-
- // choose a weight in [0, total_weight)
- let sample_weight = self.weight_range.sample(rng);
-
- // short circuit when it's the first item
- if sample_weight < self.items[0].weight {
- return self.items[0].item.clone();
- }
-
- let mut idx = 0;
- let mut modifier = self.items.len();
-
- // now we know that every possibility has an element to the
- // left, so we can just search for the last element that has
- // cumulative weight <= sample_weight, then the next one will
- // be "it". (Note that this greatest element will never be the
- // last element of the vector, since sample_weight is chosen
- // in [0, total_weight) and the cumulative weight of the last
- // one is exactly the total weight.)
- while modifier > 1 {
- let i = idx + modifier / 2;
- if self.items[i].weight <= sample_weight {
- // we're small, so look to the right, but allow this
- // exact element still.
- idx = i;
- // we need the `/ 2` to round up otherwise we'll drop
- // the trailing elements when `modifier` is odd.
- modifier += 1;
- } else {
- // otherwise we're too big, so go left. (i.e. do
- // nothing)
- }
- modifier /= 2;
- }
- self.items[idx + 1].item.clone()
- }
-}
-
-#[cfg(test)]
-mod tests {
- use rngs::mock::StepRng;
- #[allow(deprecated)]
- use super::{WeightedChoice, Weighted, Distribution};
-
- #[test]
- #[allow(deprecated)]
- fn test_weighted_choice() {
- // this makes assumptions about the internal implementation of
- // WeightedChoice. It may fail when the implementation in
- // `distributions::uniform::UniformInt` changes.
-
- macro_rules! t {
- ($items:expr, $expected:expr) => {{
- let mut items = $items;
- let mut total_weight = 0;
- for item in &items { total_weight += item.weight; }
-
- let wc = WeightedChoice::new(&mut items);
- let expected = $expected;
-
- // Use extremely large steps between the random numbers, because
- // we test with small ranges and `UniformInt` is designed to prefer
- // the most significant bits.
- let mut rng = StepRng::new(0, !0 / (total_weight as u64));
-
- for &val in expected.iter() {
- assert_eq!(wc.sample(&mut rng), val)
- }
- }}
- }
-
- t!([Weighted { weight: 1, item: 10}], [10]);
-
- // skip some
- t!([Weighted { weight: 0, item: 20},
- Weighted { weight: 2, item: 21},
- Weighted { weight: 0, item: 22},
- Weighted { weight: 1, item: 23}],
- [21, 21, 23]);
-
- // different weights
- t!([Weighted { weight: 4, item: 30},
- Weighted { weight: 3, item: 31}],
- [30, 31, 30, 31, 30, 31, 30]);
-
- // check that we're binary searching
- // correctly with some vectors of odd
- // length.
- t!([Weighted { weight: 1, item: 40},
- Weighted { weight: 1, item: 41},
- Weighted { weight: 1, item: 42},
- Weighted { weight: 1, item: 43},
- Weighted { weight: 1, item: 44}],
- [40, 41, 42, 43, 44]);
- t!([Weighted { weight: 1, item: 50},
- Weighted { weight: 1, item: 51},
- Weighted { weight: 1, item: 52},
- Weighted { weight: 1, item: 53},
- Weighted { weight: 1, item: 54},
- Weighted { weight: 1, item: 55},
- Weighted { weight: 1, item: 56}],
- [50, 54, 51, 55, 52, 56, 53]);
- }
-
- #[test]
- #[allow(deprecated)]
- fn test_weighted_clone_initialization() {
- let initial : Weighted<u32> = Weighted {weight: 1, item: 1};
- let clone = initial.clone();
- assert_eq!(initial.weight, clone.weight);
- assert_eq!(initial.item, clone.item);
- }
-
- #[test] #[should_panic]
- #[allow(deprecated)]
- fn test_weighted_clone_change_weight() {
- let initial : Weighted<u32> = Weighted {weight: 1, item: 1};
- let mut clone = initial.clone();
- clone.weight = 5;
- assert_eq!(initial.weight, clone.weight);
- }
-
- #[test] #[should_panic]
- #[allow(deprecated)]
- fn test_weighted_clone_change_item() {
- let initial : Weighted<u32> = Weighted {weight: 1, item: 1};
- let mut clone = initial.clone();
- clone.item = 5;
- assert_eq!(initial.item, clone.item);
-
- }
-
- #[test] #[should_panic]
- #[allow(deprecated)]
- fn test_weighted_choice_no_items() {
- WeightedChoice::<isize>::new(&mut []);
- }
- #[test] #[should_panic]
- #[allow(deprecated)]
- fn test_weighted_choice_zero_weight() {
- WeightedChoice::new(&mut [Weighted { weight: 0, item: 0},
- Weighted { weight: 0, item: 1}]);
- }
- #[test] #[should_panic]
- #[allow(deprecated)]
- fn test_weighted_choice_weight_overflows() {
- let x = ::core::u32::MAX / 2; // x + x + 2 is the overflow
- WeightedChoice::new(&mut [Weighted { weight: x, item: 0 },
- Weighted { weight: 1, item: 1 },
- Weighted { weight: x, item: 2 },
- Weighted { weight: 1, item: 3 }]);
- }
-
- #[cfg(feature="std")]
- #[test]
- fn test_distributions_iter() {
- use distributions::Normal;
- let mut rng = ::test::rng(210);
- let distr = Normal::new(10.0, 10.0);
- let results: Vec<_> = distr.sample_iter(&mut rng).take(100).collect();
- println!("{:?}", results);
- }
-}
diff --git a/rand/src/distributions/normal.rs b/rand/src/distributions/normal.rs
deleted file mode 100644
index b8d632e..0000000
--- a/rand/src/distributions/normal.rs
+++ /dev/null
@@ -1,197 +0,0 @@
-// Copyright 2018 Developers of the Rand project.
-// Copyright 2013 The Rust Project Developers.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-//! The normal and derived distributions.
-
-use Rng;
-use distributions::{ziggurat_tables, Distribution, Open01};
-use distributions::utils::ziggurat;
-
-/// Samples floating-point numbers according to the normal distribution
-/// `N(0, 1)` (a.k.a. a standard normal, or Gaussian). This is equivalent to
-/// `Normal::new(0.0, 1.0)` but faster.
-///
-/// See `Normal` for the general normal distribution.
-///
-/// Implemented via the ZIGNOR variant[^1] of the Ziggurat method.
-///
-/// [^1]: Jurgen A. Doornik (2005). [*An Improved Ziggurat Method to
-/// Generate Normal Random Samples*](
-/// https://www.doornik.com/research/ziggurat.pdf).
-/// Nuffield College, Oxford
-///
-/// # Example
-/// ```
-/// use rand::prelude::*;
-/// use rand::distributions::StandardNormal;
-///
-/// let val: f64 = SmallRng::from_entropy().sample(StandardNormal);
-/// println!("{}", val);
-/// ```
-#[derive(Clone, Copy, Debug)]
-pub struct StandardNormal;
-
-impl Distribution<f64> for StandardNormal {
- fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> f64 {
- #[inline]
- fn pdf(x: f64) -> f64 {
- (-x*x/2.0).exp()
- }
- #[inline]
- fn zero_case<R: Rng + ?Sized>(rng: &mut R, u: f64) -> f64 {
- // compute a random number in the tail by hand
-
- // strange initial conditions, because the loop is not
- // do-while, so the condition should be true on the first
- // run, they get overwritten anyway (0 < 1, so these are
- // good).
- let mut x = 1.0f64;
- let mut y = 0.0f64;
-
- while -2.0 * y < x * x {
- let x_: f64 = rng.sample(Open01);
- let y_: f64 = rng.sample(Open01);
-
- x = x_.ln() / ziggurat_tables::ZIG_NORM_R;
- y = y_.ln();
- }
-
- if u < 0.0 { x - ziggurat_tables::ZIG_NORM_R } else { ziggurat_tables::ZIG_NORM_R - x }
- }
-
- ziggurat(rng, true, // this is symmetric
- &ziggurat_tables::ZIG_NORM_X,
- &ziggurat_tables::ZIG_NORM_F,
- pdf, zero_case)
- }
-}
-
-/// The normal distribution `N(mean, std_dev**2)`.
-///
-/// This uses the ZIGNOR variant of the Ziggurat method, see [`StandardNormal`]
-/// for more details.
-///
-/// Note that [`StandardNormal`] is an optimised implementation for mean 0, and
-/// standard deviation 1.
-///
-/// # Example
-///
-/// ```
-/// use rand::distributions::{Normal, Distribution};
-///
-/// // mean 2, standard deviation 3
-/// let normal = Normal::new(2.0, 3.0);
-/// let v = normal.sample(&mut rand::thread_rng());
-/// println!("{} is from a N(2, 9) distribution", v)
-/// ```
-///
-/// [`StandardNormal`]: struct.StandardNormal.html
-#[derive(Clone, Copy, Debug)]
-pub struct Normal {
- mean: f64,
- std_dev: f64,
-}
-
-impl Normal {
- /// Construct a new `Normal` distribution with the given mean and
- /// standard deviation.
- ///
- /// # Panics
- ///
- /// Panics if `std_dev < 0`.
- #[inline]
- pub fn new(mean: f64, std_dev: f64) -> Normal {
- assert!(std_dev >= 0.0, "Normal::new called with `std_dev` < 0");
- Normal {
- mean,
- std_dev
- }
- }
-}
-impl Distribution<f64> for Normal {
- fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> f64 {
- let n = rng.sample(StandardNormal);
- self.mean + self.std_dev * n
- }
-}
-
-
-/// The log-normal distribution `ln N(mean, std_dev**2)`.
-///
-/// If `X` is log-normal distributed, then `ln(X)` is `N(mean, std_dev**2)`
-/// distributed.
-///
-/// # Example
-///
-/// ```
-/// use rand::distributions::{LogNormal, Distribution};
-///
-/// // mean 2, standard deviation 3
-/// let log_normal = LogNormal::new(2.0, 3.0);
-/// let v = log_normal.sample(&mut rand::thread_rng());
-/// println!("{} is from an ln N(2, 9) distribution", v)
-/// ```
-#[derive(Clone, Copy, Debug)]
-pub struct LogNormal {
- norm: Normal
-}
-
-impl LogNormal {
- /// Construct a new `LogNormal` distribution with the given mean
- /// and standard deviation.
- ///
- /// # Panics
- ///
- /// Panics if `std_dev < 0`.
- #[inline]
- pub fn new(mean: f64, std_dev: f64) -> LogNormal {
- assert!(std_dev >= 0.0, "LogNormal::new called with `std_dev` < 0");
- LogNormal { norm: Normal::new(mean, std_dev) }
- }
-}
-impl Distribution<f64> for LogNormal {
- fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> f64 {
- self.norm.sample(rng).exp()
- }
-}
-
-#[cfg(test)]
-mod tests {
- use distributions::Distribution;
- use super::{Normal, LogNormal};
-
- #[test]
- fn test_normal() {
- let norm = Normal::new(10.0, 10.0);
- let mut rng = ::test::rng(210);
- for _ in 0..1000 {
- norm.sample(&mut rng);
- }
- }
- #[test]
- #[should_panic]
- fn test_normal_invalid_sd() {
- Normal::new(10.0, -1.0);
- }
-
-
- #[test]
- fn test_log_normal() {
- let lnorm = LogNormal::new(10.0, 10.0);
- let mut rng = ::test::rng(211);
- for _ in 0..1000 {
- lnorm.sample(&mut rng);
- }
- }
- #[test]
- #[should_panic]
- fn test_log_normal_invalid_sd() {
- LogNormal::new(10.0, -1.0);
- }
-}
diff --git a/rand/src/distributions/other.rs b/rand/src/distributions/other.rs
deleted file mode 100644
index 2295f79..0000000
--- a/rand/src/distributions/other.rs
+++ /dev/null
@@ -1,219 +0,0 @@
-// Copyright 2018 Developers of the Rand project.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-//! The implementations of the `Standard` distribution for other built-in types.
-
-use core::char;
-use core::num::Wrapping;
-
-use {Rng};
-use distributions::{Distribution, Standard, Uniform};
-
-// ----- Sampling distributions -----
-
-/// Sample a `char`, uniformly distributed over ASCII letters and numbers:
-/// a-z, A-Z and 0-9.
-///
-/// # Example
-///
-/// ```
-/// use std::iter;
-/// use rand::{Rng, thread_rng};
-/// use rand::distributions::Alphanumeric;
-///
-/// let mut rng = thread_rng();
-/// let chars: String = iter::repeat(())
-/// .map(|()| rng.sample(Alphanumeric))
-/// .take(7)
-/// .collect();
-/// println!("Random chars: {}", chars);
-/// ```
-#[derive(Debug)]
-pub struct Alphanumeric;
-
-
-// ----- Implementations of distributions -----
-
-impl Distribution<char> for Standard {
- #[inline]
- fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> char {
- // A valid `char` is either in the interval `[0, 0xD800)` or
- // `(0xDFFF, 0x11_0000)`. All `char`s must therefore be in
- // `[0, 0x11_0000)` but not in the "gap" `[0xD800, 0xDFFF]` which is
- // reserved for surrogates. This is the size of that gap.
- const GAP_SIZE: u32 = 0xDFFF - 0xD800 + 1;
-
- // Uniform::new(0, 0x11_0000 - GAP_SIZE) can also be used but it
- // seemed slower.
- let range = Uniform::new(GAP_SIZE, 0x11_0000);
-
- let mut n = range.sample(rng);
- if n <= 0xDFFF {
- n -= GAP_SIZE;
- }
- unsafe { char::from_u32_unchecked(n) }
- }
-}
-
-impl Distribution<char> for Alphanumeric {
- fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> char {
- const RANGE: u32 = 26 + 26 + 10;
- const GEN_ASCII_STR_CHARSET: &[u8] =
- b"ABCDEFGHIJKLMNOPQRSTUVWXYZ\
- abcdefghijklmnopqrstuvwxyz\
- 0123456789";
- // We can pick from 62 characters. This is so close to a power of 2, 64,
- // that we can do better than `Uniform`. Use a simple bitshift and
- // rejection sampling. We do not use a bitmask, because for small RNGs
- // the most significant bits are usually of higher quality.
- loop {
- let var = rng.next_u32() >> (32 - 6);
- if var < RANGE {
- return GEN_ASCII_STR_CHARSET[var as usize] as char
- }
- }
- }
-}
-
-impl Distribution<bool> for Standard {
- #[inline]
- fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> bool {
- // We can compare against an arbitrary bit of an u32 to get a bool.
- // Because the least significant bits of a lower quality RNG can have
- // simple patterns, we compare against the most significant bit. This is
- // easiest done using a sign test.
- (rng.next_u32() as i32) < 0
- }
-}
-
-macro_rules! tuple_impl {
- // use variables to indicate the arity of the tuple
- ($($tyvar:ident),* ) => {
- // the trailing commas are for the 1 tuple
- impl< $( $tyvar ),* >
- Distribution<( $( $tyvar ),* , )>
- for Standard
- where $( Standard: Distribution<$tyvar> ),*
- {
- #[inline]
- fn sample<R: Rng + ?Sized>(&self, _rng: &mut R) -> ( $( $tyvar ),* , ) {
- (
- // use the $tyvar's to get the appropriate number of
- // repeats (they're not actually needed)
- $(
- _rng.gen::<$tyvar>()
- ),*
- ,
- )
- }
- }
- }
-}
-
-impl Distribution<()> for Standard {
- #[inline]
- fn sample<R: Rng + ?Sized>(&self, _: &mut R) -> () { () }
-}
-tuple_impl!{A}
-tuple_impl!{A, B}
-tuple_impl!{A, B, C}
-tuple_impl!{A, B, C, D}
-tuple_impl!{A, B, C, D, E}
-tuple_impl!{A, B, C, D, E, F}
-tuple_impl!{A, B, C, D, E, F, G}
-tuple_impl!{A, B, C, D, E, F, G, H}
-tuple_impl!{A, B, C, D, E, F, G, H, I}
-tuple_impl!{A, B, C, D, E, F, G, H, I, J}
-tuple_impl!{A, B, C, D, E, F, G, H, I, J, K}
-tuple_impl!{A, B, C, D, E, F, G, H, I, J, K, L}
-
-macro_rules! array_impl {
- // recursive, given at least one type parameter:
- {$n:expr, $t:ident, $($ts:ident,)*} => {
- array_impl!{($n - 1), $($ts,)*}
-
- impl<T> Distribution<[T; $n]> for Standard where Standard: Distribution<T> {
- #[inline]
- fn sample<R: Rng + ?Sized>(&self, _rng: &mut R) -> [T; $n] {
- [_rng.gen::<$t>(), $(_rng.gen::<$ts>()),*]
- }
- }
- };
- // empty case:
- {$n:expr,} => {
- impl<T> Distribution<[T; $n]> for Standard {
- fn sample<R: Rng + ?Sized>(&self, _rng: &mut R) -> [T; $n] { [] }
- }
- };
-}
-
-array_impl!{32, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T,}
-
-impl<T> Distribution<Option<T>> for Standard where Standard: Distribution<T> {
- #[inline]
- fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> Option<T> {
- // UFCS is needed here: https://github.com/rust-lang/rust/issues/24066
- if rng.gen::<bool>() {
- Some(rng.gen())
- } else {
- None
- }
- }
-}
-
-impl<T> Distribution<Wrapping<T>> for Standard where Standard: Distribution<T> {
- #[inline]
- fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> Wrapping<T> {
- Wrapping(rng.gen())
- }
-}
-
-
-#[cfg(test)]
-mod tests {
- use {Rng, RngCore, Standard};
- use distributions::Alphanumeric;
- #[cfg(all(not(feature="std"), feature="alloc"))] use alloc::string::String;
-
- #[test]
- fn test_misc() {
- let rng: &mut RngCore = &mut ::test::rng(820);
-
- rng.sample::<char, _>(Standard);
- rng.sample::<bool, _>(Standard);
- }
-
- #[cfg(feature="alloc")]
- #[test]
- fn test_chars() {
- use core::iter;
- let mut rng = ::test::rng(805);
-
- // Test by generating a relatively large number of chars, so we also
- // take the rejection sampling path.
- let word: String = iter::repeat(())
- .map(|()| rng.gen::<char>()).take(1000).collect();
- assert!(word.len() != 0);
- }
-
- #[test]
- fn test_alphanumeric() {
- let mut rng = ::test::rng(806);
-
- // Test by generating a relatively large number of chars, so we also
- // take the rejection sampling path.
- let mut incorrect = false;
- for _ in 0..100 {
- let c = rng.sample(Alphanumeric);
- incorrect |= !((c >= '0' && c <= '9') ||
- (c >= 'A' && c <= 'Z') ||
- (c >= 'a' && c <= 'z') );
- }
- assert!(incorrect == false);
- }
-}
diff --git a/rand/src/distributions/pareto.rs b/rand/src/distributions/pareto.rs
deleted file mode 100644
index 744a157..0000000
--- a/rand/src/distributions/pareto.rs
+++ /dev/null
@@ -1,74 +0,0 @@
-// Copyright 2018 Developers of the Rand project.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-//! The Pareto distribution.
-
-use Rng;
-use distributions::{Distribution, OpenClosed01};
-
-/// Samples floating-point numbers according to the Pareto distribution
-///
-/// # Example
-/// ```
-/// use rand::prelude::*;
-/// use rand::distributions::Pareto;
-///
-/// let val: f64 = SmallRng::from_entropy().sample(Pareto::new(1., 2.));
-/// println!("{}", val);
-/// ```
-#[derive(Clone, Copy, Debug)]
-pub struct Pareto {
- scale: f64,
- inv_neg_shape: f64,
-}
-
-impl Pareto {
- /// Construct a new Pareto distribution with given `scale` and `shape`.
- ///
- /// In the literature, `scale` is commonly written as x<sub>m</sub> or k and
- /// `shape` is often written as α.
- ///
- /// # Panics
- ///
- /// `scale` and `shape` have to be non-zero and positive.
- pub fn new(scale: f64, shape: f64) -> Pareto {
- assert!((scale > 0.) & (shape > 0.));
- Pareto { scale, inv_neg_shape: -1.0 / shape }
- }
-}
-
-impl Distribution<f64> for Pareto {
- fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> f64 {
- let u: f64 = rng.sample(OpenClosed01);
- self.scale * u.powf(self.inv_neg_shape)
- }
-}
-
-#[cfg(test)]
-mod tests {
- use distributions::Distribution;
- use super::Pareto;
-
- #[test]
- #[should_panic]
- fn invalid() {
- Pareto::new(0., 0.);
- }
-
- #[test]
- fn sample() {
- let scale = 1.0;
- let shape = 2.0;
- let d = Pareto::new(scale, shape);
- let mut rng = ::test::rng(1);
- for _ in 0..1000 {
- let r = d.sample(&mut rng);
- assert!(r >= scale);
- }
- }
-}
diff --git a/rand/src/distributions/poisson.rs b/rand/src/distributions/poisson.rs
deleted file mode 100644
index 1244caa..0000000
--- a/rand/src/distributions/poisson.rs
+++ /dev/null
@@ -1,157 +0,0 @@
-// Copyright 2018 Developers of the Rand project.
-// Copyright 2016-2017 The Rust Project Developers.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-//! The Poisson distribution.
-
-use Rng;
-use distributions::{Distribution, Cauchy};
-use distributions::utils::log_gamma;
-
-/// The Poisson distribution `Poisson(lambda)`.
-///
-/// This distribution has a density function:
-/// `f(k) = lambda^k * exp(-lambda) / k!` for `k >= 0`.
-///
-/// # Example
-///
-/// ```
-/// use rand::distributions::{Poisson, Distribution};
-///
-/// let poi = Poisson::new(2.0);
-/// let v = poi.sample(&mut rand::thread_rng());
-/// println!("{} is from a Poisson(2) distribution", v);
-/// ```
-#[derive(Clone, Copy, Debug)]
-pub struct Poisson {
- lambda: f64,
- // precalculated values
- exp_lambda: f64,
- log_lambda: f64,
- sqrt_2lambda: f64,
- magic_val: f64,
-}
-
-impl Poisson {
- /// Construct a new `Poisson` with the given shape parameter
- /// `lambda`. Panics if `lambda <= 0`.
- pub fn new(lambda: f64) -> Poisson {
- assert!(lambda > 0.0, "Poisson::new called with lambda <= 0");
- let log_lambda = lambda.ln();
- Poisson {
- lambda,
- exp_lambda: (-lambda).exp(),
- log_lambda,
- sqrt_2lambda: (2.0 * lambda).sqrt(),
- magic_val: lambda * log_lambda - log_gamma(1.0 + lambda),
- }
- }
-}
-
-impl Distribution<u64> for Poisson {
- fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> u64 {
- // using the algorithm from Numerical Recipes in C
-
- // for low expected values use the Knuth method
- if self.lambda < 12.0 {
- let mut result = 0;
- let mut p = 1.0;
- while p > self.exp_lambda {
- p *= rng.gen::<f64>();
- result += 1;
- }
- result - 1
- }
- // high expected values - rejection method
- else {
- let mut int_result: u64;
-
- // we use the Cauchy distribution as the comparison distribution
- // f(x) ~ 1/(1+x^2)
- let cauchy = Cauchy::new(0.0, 1.0);
-
- loop {
- let mut result;
- let mut comp_dev;
-
- loop {
- // draw from the Cauchy distribution
- comp_dev = rng.sample(cauchy);
- // shift the peak of the comparison ditribution
- result = self.sqrt_2lambda * comp_dev + self.lambda;
- // repeat the drawing until we are in the range of possible values
- if result >= 0.0 {
- break;
- }
- }
- // now the result is a random variable greater than 0 with Cauchy distribution
- // the result should be an integer value
- result = result.floor();
- int_result = result as u64;
-
- // this is the ratio of the Poisson distribution to the comparison distribution
- // the magic value scales the distribution function to a range of approximately 0-1
- // since it is not exact, we multiply the ratio by 0.9 to avoid ratios greater than 1
- // this doesn't change the resulting distribution, only increases the rate of failed drawings
- let check = 0.9 * (1.0 + comp_dev * comp_dev)
- * (result * self.log_lambda - log_gamma(1.0 + result) - self.magic_val).exp();
-
- // check with uniform random value - if below the threshold, we are within the target distribution
- if rng.gen::<f64>() <= check {
- break;
- }
- }
- int_result
- }
- }
-}
-
-#[cfg(test)]
-mod test {
- use distributions::Distribution;
- use super::Poisson;
-
- #[test]
- fn test_poisson_10() {
- let poisson = Poisson::new(10.0);
- let mut rng = ::test::rng(123);
- let mut sum = 0;
- for _ in 0..1000 {
- sum += poisson.sample(&mut rng);
- }
- let avg = (sum as f64) / 1000.0;
- println!("Poisson average: {}", avg);
- assert!((avg - 10.0).abs() < 0.5); // not 100% certain, but probable enough
- }
-
- #[test]
- fn test_poisson_15() {
- // Take the 'high expected values' path
- let poisson = Poisson::new(15.0);
- let mut rng = ::test::rng(123);
- let mut sum = 0;
- for _ in 0..1000 {
- sum += poisson.sample(&mut rng);
- }
- let avg = (sum as f64) / 1000.0;
- println!("Poisson average: {}", avg);
- assert!((avg - 15.0).abs() < 0.5); // not 100% certain, but probable enough
- }
-
- #[test]
- #[should_panic]
- fn test_poisson_invalid_lambda_zero() {
- Poisson::new(0.0);
- }
-
- #[test]
- #[should_panic]
- fn test_poisson_invalid_lambda_neg() {
- Poisson::new(-10.0);
- }
-}
diff --git a/rand/src/distributions/triangular.rs b/rand/src/distributions/triangular.rs
deleted file mode 100644
index a6eef5c..0000000
--- a/rand/src/distributions/triangular.rs
+++ /dev/null
@@ -1,86 +0,0 @@
-// Copyright 2018 Developers of the Rand project.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-//! The triangular distribution.
-
-use Rng;
-use distributions::{Distribution, Standard};
-
-/// The triangular distribution.
-///
-/// # Example
-///
-/// ```rust
-/// use rand::distributions::{Triangular, Distribution};
-///
-/// let d = Triangular::new(0., 5., 2.5);
-/// let v = d.sample(&mut rand::thread_rng());
-/// println!("{} is from a triangular distribution", v);
-/// ```
-#[derive(Clone, Copy, Debug)]
-pub struct Triangular {
- min: f64,
- max: f64,
- mode: f64,
-}
-
-impl Triangular {
- /// Construct a new `Triangular` with minimum `min`, maximum `max` and mode
- /// `mode`.
- ///
- /// # Panics
- ///
- /// If `max < mode`, `mode < max` or `max == min`.
- ///
- #[inline]
- pub fn new(min: f64, max: f64, mode: f64) -> Triangular {
- assert!(max >= mode);
- assert!(mode >= min);
- assert!(max != min);
- Triangular { min, max, mode }
- }
-}
-
-impl Distribution<f64> for Triangular {
- #[inline]
- fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> f64 {
- let f: f64 = rng.sample(Standard);
- let diff_mode_min = self.mode - self.min;
- let diff_max_min = self.max - self.min;
- if f * diff_max_min < diff_mode_min {
- self.min + (f * diff_max_min * diff_mode_min).sqrt()
- } else {
- self.max - ((1. - f) * diff_max_min * (self.max - self.mode)).sqrt()
- }
- }
-}
-
-#[cfg(test)]
-mod test {
- use distributions::Distribution;
- use super::Triangular;
-
- #[test]
- fn test_new() {
- for &(min, max, mode) in &[
- (-1., 1., 0.), (1., 2., 1.), (5., 25., 25.), (1e-5, 1e5, 1e-3),
- (0., 1., 0.9), (-4., -0.5, -2.), (-13.039, 8.41, 1.17),
- ] {
- println!("{} {} {}", min, max, mode);
- let _ = Triangular::new(min, max, mode);
- }
- }
-
- #[test]
- fn test_sample() {
- let norm = Triangular::new(0., 1., 0.5);
- let mut rng = ::test::rng(1);
- for _ in 0..1000 {
- norm.sample(&mut rng);
- }
- }
-}
diff --git a/rand/src/distributions/uniform.rs b/rand/src/distributions/uniform.rs
deleted file mode 100644
index ceed77d..0000000
--- a/rand/src/distributions/uniform.rs
+++ /dev/null
@@ -1,1298 +0,0 @@
-// Copyright 2018 Developers of the Rand project.
-// Copyright 2017 The Rust Project Developers.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-//! A distribution uniformly sampling numbers within a given range.
-//!
-//! [`Uniform`] is the standard distribution to sample uniformly from a range;
-//! e.g. `Uniform::new_inclusive(1, 6)` can sample integers from 1 to 6, like a
-//! standard die. [`Rng::gen_range`] supports any type supported by
-//! [`Uniform`].
-//!
-//! This distribution is provided with support for several primitive types
-//! (all integer and floating-point types) as well as `std::time::Duration`,
-//! and supports extension to user-defined types via a type-specific *back-end*
-//! implementation.
-//!
-//! The types [`UniformInt`], [`UniformFloat`] and [`UniformDuration`] are the
-//! back-ends supporting sampling from primitive integer and floating-point
-//! ranges as well as from `std::time::Duration`; these types do not normally
-//! need to be used directly (unless implementing a derived back-end).
-//!
-//! # Example usage
-//!
-//! ```
-//! use rand::{Rng, thread_rng};
-//! use rand::distributions::Uniform;
-//!
-//! let mut rng = thread_rng();
-//! let side = Uniform::new(-10.0, 10.0);
-//!
-//! // sample between 1 and 10 points
-//! for _ in 0..rng.gen_range(1, 11) {
-//! // sample a point from the square with sides -10 - 10 in two dimensions
-//! let (x, y) = (rng.sample(side), rng.sample(side));
-//! println!("Point: {}, {}", x, y);
-//! }
-//! ```
-//!
-//! # Extending `Uniform` to support a custom type
-//!
-//! To extend [`Uniform`] to support your own types, write a back-end which
-//! implements the [`UniformSampler`] trait, then implement the [`SampleUniform`]
-//! helper trait to "register" your back-end. See the `MyF32` example below.
-//!
-//! At a minimum, the back-end needs to store any parameters needed for sampling
-//! (e.g. the target range) and implement `new`, `new_inclusive` and `sample`.
-//! Those methods should include an assert to check the range is valid (i.e.
-//! `low < high`). The example below merely wraps another back-end.
-//!
-//! The `new`, `new_inclusive` and `sample_single` functions use arguments of
-//! type SampleBorrow<X> in order to support passing in values by reference or
-//! by value. In the implementation of these functions, you can choose to
-//! simply use the reference returned by [`SampleBorrow::borrow`], or you can choose
-//! to copy or clone the value, whatever is appropriate for your type.
-//!
-//! ```
-//! use rand::prelude::*;
-//! use rand::distributions::uniform::{Uniform, SampleUniform,
-//! UniformSampler, UniformFloat, SampleBorrow};
-//!
-//! struct MyF32(f32);
-//!
-//! #[derive(Clone, Copy, Debug)]
-//! struct UniformMyF32 {
-//! inner: UniformFloat<f32>,
-//! }
-//!
-//! impl UniformSampler for UniformMyF32 {
-//! type X = MyF32;
-//! fn new<B1, B2>(low: B1, high: B2) -> Self
-//! where B1: SampleBorrow<Self::X> + Sized,
-//! B2: SampleBorrow<Self::X> + Sized
-//! {
-//! UniformMyF32 {
-//! inner: UniformFloat::<f32>::new(low.borrow().0, high.borrow().0),
-//! }
-//! }
-//! fn new_inclusive<B1, B2>(low: B1, high: B2) -> Self
-//! where B1: SampleBorrow<Self::X> + Sized,
-//! B2: SampleBorrow<Self::X> + Sized
-//! {
-//! UniformSampler::new(low, high)
-//! }
-//! fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> Self::X {
-//! MyF32(self.inner.sample(rng))
-//! }
-//! }
-//!
-//! impl SampleUniform for MyF32 {
-//! type Sampler = UniformMyF32;
-//! }
-//!
-//! let (low, high) = (MyF32(17.0f32), MyF32(22.0f32));
-//! let uniform = Uniform::new(low, high);
-//! let x = uniform.sample(&mut thread_rng());
-//! ```
-//!
-//! [`Uniform`]: struct.Uniform.html
-//! [`Rng::gen_range`]: ../../trait.Rng.html#method.gen_range
-//! [`SampleUniform`]: trait.SampleUniform.html
-//! [`UniformSampler`]: trait.UniformSampler.html
-//! [`UniformInt`]: struct.UniformInt.html
-//! [`UniformFloat`]: struct.UniformFloat.html
-//! [`UniformDuration`]: struct.UniformDuration.html
-//! [`SampleBorrow::borrow`]: trait.SampleBorrow.html#method.borrow
-
-#[cfg(feature = "std")]
-use std::time::Duration;
-#[cfg(all(not(feature = "std"), rustc_1_25))]
-use core::time::Duration;
-
-use Rng;
-use distributions::Distribution;
-use distributions::float::IntoFloat;
-use distributions::utils::{WideningMultiply, FloatSIMDUtils, FloatAsSIMD, BoolAsSIMD};
-
-#[cfg(not(feature = "std"))]
-#[allow(unused_imports)] // rustc doesn't detect that this is actually used
-use distributions::utils::Float;
-
-
-#[cfg(feature="simd_support")]
-use packed_simd::*;
-
-/// Sample values uniformly between two bounds.
-///
-/// [`Uniform::new`] and [`Uniform::new_inclusive`] construct a uniform
-/// distribution sampling from the given range; these functions may do extra
-/// work up front to make sampling of multiple values faster.
-///
-/// When sampling from a constant range, many calculations can happen at
-/// compile-time and all methods should be fast; for floating-point ranges and
-/// the full range of integer types this should have comparable performance to
-/// the `Standard` distribution.
-///
-/// Steps are taken to avoid bias which might be present in naive
-/// implementations; for example `rng.gen::<u8>() % 170` samples from the range
-/// `[0, 169]` but is twice as likely to select numbers less than 85 than other
-/// values. Further, the implementations here give more weight to the high-bits
-/// generated by the RNG than the low bits, since with some RNGs the low-bits
-/// are of lower quality than the high bits.
-///
-/// Implementations must sample in `[low, high)` range for
-/// `Uniform::new(low, high)`, i.e., excluding `high`. In particular care must
-/// be taken to ensure that rounding never results values `< low` or `>= high`.
-///
-/// # Example
-///
-/// ```
-/// use rand::distributions::{Distribution, Uniform};
-///
-/// fn main() {
-/// let between = Uniform::from(10..10000);
-/// let mut rng = rand::thread_rng();
-/// let mut sum = 0;
-/// for _ in 0..1000 {
-/// sum += between.sample(&mut rng);
-/// }
-/// println!("{}", sum);
-/// }
-/// ```
-///
-/// [`Uniform::new`]: struct.Uniform.html#method.new
-/// [`Uniform::new_inclusive`]: struct.Uniform.html#method.new_inclusive
-/// [`new`]: struct.Uniform.html#method.new
-/// [`new_inclusive`]: struct.Uniform.html#method.new_inclusive
-#[derive(Clone, Copy, Debug)]
-pub struct Uniform<X: SampleUniform> {
- inner: X::Sampler,
-}
-
-impl<X: SampleUniform> Uniform<X> {
- /// Create a new `Uniform` instance which samples uniformly from the half
- /// open range `[low, high)` (excluding `high`). Panics if `low >= high`.
- pub fn new<B1, B2>(low: B1, high: B2) -> Uniform<X>
- where B1: SampleBorrow<X> + Sized,
- B2: SampleBorrow<X> + Sized
- {
- Uniform { inner: X::Sampler::new(low, high) }
- }
-
- /// Create a new `Uniform` instance which samples uniformly from the closed
- /// range `[low, high]` (inclusive). Panics if `low > high`.
- pub fn new_inclusive<B1, B2>(low: B1, high: B2) -> Uniform<X>
- where B1: SampleBorrow<X> + Sized,
- B2: SampleBorrow<X> + Sized
- {
- Uniform { inner: X::Sampler::new_inclusive(low, high) }
- }
-}
-
-impl<X: SampleUniform> Distribution<X> for Uniform<X> {
- fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> X {
- self.inner.sample(rng)
- }
-}
-
-/// Helper trait for creating objects using the correct implementation of
-/// [`UniformSampler`] for the sampling type.
-///
-/// See the [module documentation] on how to implement [`Uniform`] range
-/// sampling for a custom type.
-///
-/// [`UniformSampler`]: trait.UniformSampler.html
-/// [module documentation]: index.html
-/// [`Uniform`]: struct.Uniform.html
-pub trait SampleUniform: Sized {
- /// The `UniformSampler` implementation supporting type `X`.
- type Sampler: UniformSampler<X = Self>;
-}
-
-/// Helper trait handling actual uniform sampling.
-///
-/// See the [module documentation] on how to implement [`Uniform`] range
-/// sampling for a custom type.
-///
-/// Implementation of [`sample_single`] is optional, and is only useful when
-/// the implementation can be faster than `Self::new(low, high).sample(rng)`.
-///
-/// [module documentation]: index.html
-/// [`Uniform`]: struct.Uniform.html
-/// [`sample_single`]: trait.UniformSampler.html#method.sample_single
-pub trait UniformSampler: Sized {
- /// The type sampled by this implementation.
- type X;
-
- /// Construct self, with inclusive lower bound and exclusive upper bound
- /// `[low, high)`.
- ///
- /// Usually users should not call this directly but instead use
- /// `Uniform::new`, which asserts that `low < high` before calling this.
- fn new<B1, B2>(low: B1, high: B2) -> Self
- where B1: SampleBorrow<Self::X> + Sized,
- B2: SampleBorrow<Self::X> + Sized;
-
- /// Construct self, with inclusive bounds `[low, high]`.
- ///
- /// Usually users should not call this directly but instead use
- /// `Uniform::new_inclusive`, which asserts that `low <= high` before
- /// calling this.
- fn new_inclusive<B1, B2>(low: B1, high: B2) -> Self
- where B1: SampleBorrow<Self::X> + Sized,
- B2: SampleBorrow<Self::X> + Sized;
-
- /// Sample a value.
- fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> Self::X;
-
- /// Sample a single value uniformly from a range with inclusive lower bound
- /// and exclusive upper bound `[low, high)`.
- ///
- /// Usually users should not call this directly but instead use
- /// `Uniform::sample_single`, which asserts that `low < high` before calling
- /// this.
- ///
- /// Via this method, implementations can provide a method optimized for
- /// sampling only a single value from the specified range. The default
- /// implementation simply calls `UniformSampler::new` then `sample` on the
- /// result.
- fn sample_single<R: Rng + ?Sized, B1, B2>(low: B1, high: B2, rng: &mut R)
- -> Self::X
- where B1: SampleBorrow<Self::X> + Sized,
- B2: SampleBorrow<Self::X> + Sized
- {
- let uniform: Self = UniformSampler::new(low, high);
- uniform.sample(rng)
- }
-}
-
-impl<X: SampleUniform> From<::core::ops::Range<X>> for Uniform<X> {
- fn from(r: ::core::ops::Range<X>) -> Uniform<X> {
- Uniform::new(r.start, r.end)
- }
-}
-
-#[cfg(rustc_1_27)]
-impl<X: SampleUniform> From<::core::ops::RangeInclusive<X>> for Uniform<X> {
- fn from(r: ::core::ops::RangeInclusive<X>) -> Uniform<X> {
- Uniform::new_inclusive(r.start(), r.end())
- }
-}
-
-/// Helper trait similar to [`Borrow`] but implemented
-/// only for SampleUniform and references to SampleUniform in
-/// order to resolve ambiguity issues.
-///
-/// [`Borrow`]: https://doc.rust-lang.org/std/borrow/trait.Borrow.html
-pub trait SampleBorrow<Borrowed> {
- /// Immutably borrows from an owned value. See [`Borrow::borrow`]
- ///
- /// [`Borrow::borrow`]: https://doc.rust-lang.org/std/borrow/trait.Borrow.html#tymethod.borrow
- fn borrow(&self) -> &Borrowed;
-}
-impl<Borrowed> SampleBorrow<Borrowed> for Borrowed where Borrowed: SampleUniform {
- #[inline(always)]
- fn borrow(&self) -> &Borrowed { self }
-}
-impl<'a, Borrowed> SampleBorrow<Borrowed> for &'a Borrowed where Borrowed: SampleUniform {
- #[inline(always)]
- fn borrow(&self) -> &Borrowed { *self }
-}
-
-////////////////////////////////////////////////////////////////////////////////
-
-// What follows are all back-ends.
-
-
-/// The back-end implementing [`UniformSampler`] for integer types.
-///
-/// Unless you are implementing [`UniformSampler`] for your own type, this type
-/// should not be used directly, use [`Uniform`] instead.
-///
-/// # Implementation notes
-///
-/// For a closed range, the number of possible numbers we should generate is
-/// `range = (high - low + 1)`. It is not possible to end up with a uniform
-/// distribution if we map *all* the random integers that can be generated to
-/// this range. We have to map integers from a `zone` that is a multiple of the
-/// range. The rest of the integers, that cause a bias, are rejected.
-///
-/// The problem with `range` is that to cover the full range of the type, it has
-/// to store `unsigned_max + 1`, which can't be represented. But if the range
-/// covers the full range of the type, no modulus is needed. A range of size 0
-/// can't exist, so we use that to represent this special case. Wrapping
-/// arithmetic even makes representing `unsigned_max + 1` as 0 simple.
-///
-/// We don't calculate `zone` directly, but first calculate the number of
-/// integers to reject. To handle `unsigned_max + 1` not fitting in the type,
-/// we use:
-/// `ints_to_reject = (unsigned_max + 1) % range;`
-/// `ints_to_reject = (unsigned_max - range + 1) % range;`
-///
-/// The smallest integer PRNGs generate is `u32`. That is why for small integer
-/// sizes (`i8`/`u8` and `i16`/`u16`) there is an optimization: don't pick the
-/// largest zone that can fit in the small type, but pick the largest zone that
-/// can fit in an `u32`. `ints_to_reject` is always less than half the size of
-/// the small integer. This means the first bit of `zone` is always 1, and so
-/// are all the other preceding bits of a larger integer. The easiest way to
-/// grow the `zone` for the larger type is to simply sign extend it.
-///
-/// An alternative to using a modulus is widening multiply: After a widening
-/// multiply by `range`, the result is in the high word. Then comparing the low
-/// word against `zone` makes sure our distribution is uniform.
-///
-/// [`UniformSampler`]: trait.UniformSampler.html
-/// [`Uniform`]: struct.Uniform.html
-#[derive(Clone, Copy, Debug)]
-pub struct UniformInt<X> {
- low: X,
- range: X,
- zone: X,
-}
-
-macro_rules! uniform_int_impl {
- ($ty:ty, $signed:ty, $unsigned:ident,
- $i_large:ident, $u_large:ident) => {
- impl SampleUniform for $ty {
- type Sampler = UniformInt<$ty>;
- }
-
- impl UniformSampler for UniformInt<$ty> {
- // We play free and fast with unsigned vs signed here
- // (when $ty is signed), but that's fine, since the
- // contract of this macro is for $ty and $unsigned to be
- // "bit-equal", so casting between them is a no-op.
-
- type X = $ty;
-
- #[inline] // if the range is constant, this helps LLVM to do the
- // calculations at compile-time.
- fn new<B1, B2>(low_b: B1, high_b: B2) -> Self
- where B1: SampleBorrow<Self::X> + Sized,
- B2: SampleBorrow<Self::X> + Sized
- {
- let low = *low_b.borrow();
- let high = *high_b.borrow();
- assert!(low < high, "Uniform::new called with `low >= high`");
- UniformSampler::new_inclusive(low, high - 1)
- }
-
- #[inline] // if the range is constant, this helps LLVM to do the
- // calculations at compile-time.
- fn new_inclusive<B1, B2>(low_b: B1, high_b: B2) -> Self
- where B1: SampleBorrow<Self::X> + Sized,
- B2: SampleBorrow<Self::X> + Sized
- {
- let low = *low_b.borrow();
- let high = *high_b.borrow();
- assert!(low <= high,
- "Uniform::new_inclusive called with `low > high`");
- let unsigned_max = ::core::$unsigned::MAX;
-
- let range = high.wrapping_sub(low).wrapping_add(1) as $unsigned;
- let ints_to_reject =
- if range > 0 {
- (unsigned_max - range + 1) % range
- } else {
- 0
- };
- let zone = unsigned_max - ints_to_reject;
-
- UniformInt {
- low: low,
- // These are really $unsigned values, but store as $ty:
- range: range as $ty,
- zone: zone as $ty
- }
- }
-
- fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> Self::X {
- let range = self.range as $unsigned as $u_large;
- if range > 0 {
- // Grow `zone` to fit a type of at least 32 bits, by
- // sign-extending it (the first bit is always 1, so are all
- // the preceding bits of the larger type).
- // For types that already have the right size, all the
- // casting is a no-op.
- let zone = self.zone as $signed as $i_large as $u_large;
- loop {
- let v: $u_large = rng.gen();
- let (hi, lo) = v.wmul(range);
- if lo <= zone {
- return self.low.wrapping_add(hi as $ty);
- }
- }
- } else {
- // Sample from the entire integer range.
- rng.gen()
- }
- }
-
- fn sample_single<R: Rng + ?Sized, B1, B2>(low_b: B1, high_b: B2, rng: &mut R)
- -> Self::X
- where B1: SampleBorrow<Self::X> + Sized,
- B2: SampleBorrow<Self::X> + Sized
- {
- let low = *low_b.borrow();
- let high = *high_b.borrow();
- assert!(low < high,
- "Uniform::sample_single called with low >= high");
- let range = high.wrapping_sub(low) as $unsigned as $u_large;
- let zone =
- if ::core::$unsigned::MAX <= ::core::u16::MAX as $unsigned {
- // Using a modulus is faster than the approximation for
- // i8 and i16. I suppose we trade the cost of one
- // modulus for near-perfect branch prediction.
- let unsigned_max: $u_large = ::core::$u_large::MAX;
- let ints_to_reject = (unsigned_max - range + 1) % range;
- unsigned_max - ints_to_reject
- } else {
- // conservative but fast approximation. `- 1` is necessary to allow the
- // same comparison without bias.
- (range << range.leading_zeros()).wrapping_sub(1)
- };
-
- loop {
- let v: $u_large = rng.gen();
- let (hi, lo) = v.wmul(range);
- if lo <= zone {
- return low.wrapping_add(hi as $ty);
- }
- }
- }
- }
- }
-}
-
-uniform_int_impl! { i8, i8, u8, i32, u32 }
-uniform_int_impl! { i16, i16, u16, i32, u32 }
-uniform_int_impl! { i32, i32, u32, i32, u32 }
-uniform_int_impl! { i64, i64, u64, i64, u64 }
-#[cfg(all(rustc_1_26, not(target_os = "emscripten")))]
-uniform_int_impl! { i128, i128, u128, u128, u128 }
-uniform_int_impl! { isize, isize, usize, isize, usize }
-uniform_int_impl! { u8, i8, u8, i32, u32 }
-uniform_int_impl! { u16, i16, u16, i32, u32 }
-uniform_int_impl! { u32, i32, u32, i32, u32 }
-uniform_int_impl! { u64, i64, u64, i64, u64 }
-uniform_int_impl! { usize, isize, usize, isize, usize }
-#[cfg(all(rustc_1_26, not(target_os = "emscripten")))]
-uniform_int_impl! { u128, u128, u128, i128, u128 }
-
-#[cfg(all(feature = "simd_support", feature = "nightly"))]
-macro_rules! uniform_simd_int_impl {
- ($ty:ident, $unsigned:ident, $u_scalar:ident) => {
- // The "pick the largest zone that can fit in an `u32`" optimization
- // is less useful here. Multiple lanes complicate things, we don't
- // know the PRNG's minimal output size, and casting to a larger vector
- // is generally a bad idea for SIMD performance. The user can still
- // implement it manually.
-
- // TODO: look into `Uniform::<u32x4>::new(0u32, 100)` functionality
- // perhaps `impl SampleUniform for $u_scalar`?
- impl SampleUniform for $ty {
- type Sampler = UniformInt<$ty>;
- }
-
- impl UniformSampler for UniformInt<$ty> {
- type X = $ty;
-
- #[inline] // if the range is constant, this helps LLVM to do the
- // calculations at compile-time.
- fn new<B1, B2>(low_b: B1, high_b: B2) -> Self
- where B1: SampleBorrow<Self::X> + Sized,
- B2: SampleBorrow<Self::X> + Sized
- {
- let low = *low_b.borrow();
- let high = *high_b.borrow();
- assert!(low.lt(high).all(), "Uniform::new called with `low >= high`");
- UniformSampler::new_inclusive(low, high - 1)
- }
-
- #[inline] // if the range is constant, this helps LLVM to do the
- // calculations at compile-time.
- fn new_inclusive<B1, B2>(low_b: B1, high_b: B2) -> Self
- where B1: SampleBorrow<Self::X> + Sized,
- B2: SampleBorrow<Self::X> + Sized
- {
- let low = *low_b.borrow();
- let high = *high_b.borrow();
- assert!(low.le(high).all(),
- "Uniform::new_inclusive called with `low > high`");
- let unsigned_max = ::core::$u_scalar::MAX;
-
- // NOTE: these may need to be replaced with explicitly
- // wrapping operations if `packed_simd` changes
- let range: $unsigned = ((high - low) + 1).cast();
- // `% 0` will panic at runtime.
- let not_full_range = range.gt($unsigned::splat(0));
- // replacing 0 with `unsigned_max` allows a faster `select`
- // with bitwise OR
- let modulo = not_full_range.select(range, $unsigned::splat(unsigned_max));
- // wrapping addition
- let ints_to_reject = (unsigned_max - range + 1) % modulo;
- // When `range` is 0, `lo` of `v.wmul(range)` will always be
- // zero which means only one sample is needed.
- let zone = unsigned_max - ints_to_reject;
-
- UniformInt {
- low: low,
- // These are really $unsigned values, but store as $ty:
- range: range.cast(),
- zone: zone.cast(),
- }
- }
-
- fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> Self::X {
- let range: $unsigned = self.range.cast();
- let zone: $unsigned = self.zone.cast();
-
- // This might seem very slow, generating a whole new
- // SIMD vector for every sample rejection. For most uses
- // though, the chance of rejection is small and provides good
- // general performance. With multiple lanes, that chance is
- // multiplied. To mitigate this, we replace only the lanes of
- // the vector which fail, iteratively reducing the chance of
- // rejection. The replacement method does however add a little
- // overhead. Benchmarking or calculating probabilities might
- // reveal contexts where this replacement method is slower.
- let mut v: $unsigned = rng.gen();
- loop {
- let (hi, lo) = v.wmul(range);
- let mask = lo.le(zone);
- if mask.all() {
- let hi: $ty = hi.cast();
- // wrapping addition
- let result = self.low + hi;
- // `select` here compiles to a blend operation
- // When `range.eq(0).none()` the compare and blend
- // operations are avoided.
- let v: $ty = v.cast();
- return range.gt($unsigned::splat(0)).select(result, v);
- }
- // Replace only the failing lanes
- v = mask.select(v, rng.gen());
- }
- }
- }
- };
-
- // bulk implementation
- ($(($unsigned:ident, $signed:ident),)+ $u_scalar:ident) => {
- $(
- uniform_simd_int_impl!($unsigned, $unsigned, $u_scalar);
- uniform_simd_int_impl!($signed, $unsigned, $u_scalar);
- )+
- };
-}
-
-#[cfg(all(feature = "simd_support", feature = "nightly"))]
-uniform_simd_int_impl! {
- (u64x2, i64x2),
- (u64x4, i64x4),
- (u64x8, i64x8),
- u64
-}
-
-#[cfg(all(feature = "simd_support", feature = "nightly"))]
-uniform_simd_int_impl! {
- (u32x2, i32x2),
- (u32x4, i32x4),
- (u32x8, i32x8),
- (u32x16, i32x16),
- u32
-}
-
-#[cfg(all(feature = "simd_support", feature = "nightly"))]
-uniform_simd_int_impl! {
- (u16x2, i16x2),
- (u16x4, i16x4),
- (u16x8, i16x8),
- (u16x16, i16x16),
- (u16x32, i16x32),
- u16
-}
-
-#[cfg(all(feature = "simd_support", feature = "nightly"))]
-uniform_simd_int_impl! {
- (u8x2, i8x2),
- (u8x4, i8x4),
- (u8x8, i8x8),
- (u8x16, i8x16),
- (u8x32, i8x32),
- (u8x64, i8x64),
- u8
-}
-
-
-/// The back-end implementing [`UniformSampler`] for floating-point types.
-///
-/// Unless you are implementing [`UniformSampler`] for your own type, this type
-/// should not be used directly, use [`Uniform`] instead.
-///
-/// # Implementation notes
-///
-/// Instead of generating a float in the `[0, 1)` range using [`Standard`], the
-/// `UniformFloat` implementation converts the output of an PRNG itself. This
-/// way one or two steps can be optimized out.
-///
-/// The floats are first converted to a value in the `[1, 2)` interval using a
-/// transmute-based method, and then mapped to the expected range with a
-/// multiply and addition. Values produced this way have what equals 22 bits of
-/// random digits for an `f32`, and 52 for an `f64`.
-///
-/// [`UniformSampler`]: trait.UniformSampler.html
-/// [`new`]: trait.UniformSampler.html#tymethod.new
-/// [`new_inclusive`]: trait.UniformSampler.html#tymethod.new_inclusive
-/// [`Uniform`]: struct.Uniform.html
-/// [`Standard`]: ../struct.Standard.html
-#[derive(Clone, Copy, Debug)]
-pub struct UniformFloat<X> {
- low: X,
- scale: X,
-}
-
-macro_rules! uniform_float_impl {
- ($ty:ty, $uty:ident, $f_scalar:ident, $u_scalar:ident, $bits_to_discard:expr) => {
- impl SampleUniform for $ty {
- type Sampler = UniformFloat<$ty>;
- }
-
- impl UniformSampler for UniformFloat<$ty> {
- type X = $ty;
-
- fn new<B1, B2>(low_b: B1, high_b: B2) -> Self
- where B1: SampleBorrow<Self::X> + Sized,
- B2: SampleBorrow<Self::X> + Sized
- {
- let low = *low_b.borrow();
- let high = *high_b.borrow();
- assert!(low.all_lt(high),
- "Uniform::new called with `low >= high`");
- assert!(low.all_finite() && high.all_finite(),
- "Uniform::new called with non-finite boundaries");
- let max_rand = <$ty>::splat((::core::$u_scalar::MAX >> $bits_to_discard)
- .into_float_with_exponent(0) - 1.0);
-
- let mut scale = high - low;
-
- loop {
- let mask = (scale * max_rand + low).ge_mask(high);
- if mask.none() {
- break;
- }
- scale = scale.decrease_masked(mask);
- }
-
- debug_assert!(<$ty>::splat(0.0).all_le(scale));
-
- UniformFloat { low, scale }
- }
-
- fn new_inclusive<B1, B2>(low_b: B1, high_b: B2) -> Self
- where B1: SampleBorrow<Self::X> + Sized,
- B2: SampleBorrow<Self::X> + Sized
- {
- let low = *low_b.borrow();
- let high = *high_b.borrow();
- assert!(low.all_le(high),
- "Uniform::new_inclusive called with `low > high`");
- assert!(low.all_finite() && high.all_finite(),
- "Uniform::new_inclusive called with non-finite boundaries");
- let max_rand = <$ty>::splat((::core::$u_scalar::MAX >> $bits_to_discard)
- .into_float_with_exponent(0) - 1.0);
-
- let mut scale = (high - low) / max_rand;
-
- loop {
- let mask = (scale * max_rand + low).gt_mask(high);
- if mask.none() {
- break;
- }
- scale = scale.decrease_masked(mask);
- }
-
- debug_assert!(<$ty>::splat(0.0).all_le(scale));
-
- UniformFloat { low, scale }
- }
-
- fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> Self::X {
- // Generate a value in the range [1, 2)
- let value1_2 = (rng.gen::<$uty>() >> $bits_to_discard)
- .into_float_with_exponent(0);
-
- // Get a value in the range [0, 1) in order to avoid
- // overflowing into infinity when multiplying with scale
- let value0_1 = value1_2 - 1.0;
-
- // We don't use `f64::mul_add`, because it is not available with
- // `no_std`. Furthermore, it is slower for some targets (but
- // faster for others). However, the order of multiplication and
- // addition is important, because on some platforms (e.g. ARM)
- // it will be optimized to a single (non-FMA) instruction.
- value0_1 * self.scale + self.low
- }
-
- #[inline]
- fn sample_single<R: Rng + ?Sized, B1, B2>(low_b: B1, high_b: B2, rng: &mut R)
- -> Self::X
- where B1: SampleBorrow<Self::X> + Sized,
- B2: SampleBorrow<Self::X> + Sized
- {
- let low = *low_b.borrow();
- let high = *high_b.borrow();
- assert!(low.all_lt(high),
- "Uniform::sample_single called with low >= high");
- let mut scale = high - low;
-
- loop {
- // Generate a value in the range [1, 2)
- let value1_2 = (rng.gen::<$uty>() >> $bits_to_discard)
- .into_float_with_exponent(0);
-
- // Get a value in the range [0, 1) in order to avoid
- // overflowing into infinity when multiplying with scale
- let value0_1 = value1_2 - 1.0;
-
- // Doing multiply before addition allows some architectures
- // to use a single instruction.
- let res = value0_1 * scale + low;
-
- debug_assert!(low.all_le(res) || !scale.all_finite());
- if res.all_lt(high) {
- return res;
- }
-
- // This handles a number of edge cases.
- // * `low` or `high` is NaN. In this case `scale` and
- // `res` are going to end up as NaN.
- // * `low` is negative infinity and `high` is finite.
- // `scale` is going to be infinite and `res` will be
- // NaN.
- // * `high` is positive infinity and `low` is finite.
- // `scale` is going to be infinite and `res` will
- // be infinite or NaN (if value0_1 is 0).
- // * `low` is negative infinity and `high` is positive
- // infinity. `scale` will be infinite and `res` will
- // be NaN.
- // * `low` and `high` are finite, but `high - low`
- // overflows to infinite. `scale` will be infinite
- // and `res` will be infinite or NaN (if value0_1 is 0).
- // So if `high` or `low` are non-finite, we are guaranteed
- // to fail the `res < high` check above and end up here.
- //
- // While we technically should check for non-finite `low`
- // and `high` before entering the loop, by doing the checks
- // here instead, we allow the common case to avoid these
- // checks. But we are still guaranteed that if `low` or
- // `high` are non-finite we'll end up here and can do the
- // appropriate checks.
- //
- // Likewise `high - low` overflowing to infinity is also
- // rare, so handle it here after the common case.
- let mask = !scale.finite_mask();
- if mask.any() {
- assert!(low.all_finite() && high.all_finite(),
- "Uniform::sample_single called with non-finite boundaries");
- scale = scale.decrease_masked(mask);
- }
- }
- }
- }
- }
-}
-
-uniform_float_impl! { f32, u32, f32, u32, 32 - 23 }
-uniform_float_impl! { f64, u64, f64, u64, 64 - 52 }
-
-#[cfg(feature="simd_support")]
-uniform_float_impl! { f32x2, u32x2, f32, u32, 32 - 23 }
-#[cfg(feature="simd_support")]
-uniform_float_impl! { f32x4, u32x4, f32, u32, 32 - 23 }
-#[cfg(feature="simd_support")]
-uniform_float_impl! { f32x8, u32x8, f32, u32, 32 - 23 }
-#[cfg(feature="simd_support")]
-uniform_float_impl! { f32x16, u32x16, f32, u32, 32 - 23 }
-
-#[cfg(feature="simd_support")]
-uniform_float_impl! { f64x2, u64x2, f64, u64, 64 - 52 }
-#[cfg(feature="simd_support")]
-uniform_float_impl! { f64x4, u64x4, f64, u64, 64 - 52 }
-#[cfg(feature="simd_support")]
-uniform_float_impl! { f64x8, u64x8, f64, u64, 64 - 52 }
-
-
-
-/// The back-end implementing [`UniformSampler`] for `Duration`.
-///
-/// Unless you are implementing [`UniformSampler`] for your own types, this type
-/// should not be used directly, use [`Uniform`] instead.
-///
-/// [`UniformSampler`]: trait.UniformSampler.html
-/// [`Uniform`]: struct.Uniform.html
-#[cfg(any(feature = "std", rustc_1_25))]
-#[derive(Clone, Copy, Debug)]
-pub struct UniformDuration {
- mode: UniformDurationMode,
- offset: u32,
-}
-
-#[cfg(any(feature = "std", rustc_1_25))]
-#[derive(Debug, Copy, Clone)]
-enum UniformDurationMode {
- Small {
- secs: u64,
- nanos: Uniform<u32>,
- },
- Medium {
- nanos: Uniform<u64>,
- },
- Large {
- max_secs: u64,
- max_nanos: u32,
- secs: Uniform<u64>,
- }
-}
-
-#[cfg(any(feature = "std", rustc_1_25))]
-impl SampleUniform for Duration {
- type Sampler = UniformDuration;
-}
-
-#[cfg(any(feature = "std", rustc_1_25))]
-impl UniformSampler for UniformDuration {
- type X = Duration;
-
- #[inline]
- fn new<B1, B2>(low_b: B1, high_b: B2) -> Self
- where B1: SampleBorrow<Self::X> + Sized,
- B2: SampleBorrow<Self::X> + Sized
- {
- let low = *low_b.borrow();
- let high = *high_b.borrow();
- assert!(low < high, "Uniform::new called with `low >= high`");
- UniformDuration::new_inclusive(low, high - Duration::new(0, 1))
- }
-
- #[inline]
- fn new_inclusive<B1, B2>(low_b: B1, high_b: B2) -> Self
- where B1: SampleBorrow<Self::X> + Sized,
- B2: SampleBorrow<Self::X> + Sized
- {
- let low = *low_b.borrow();
- let high = *high_b.borrow();
- assert!(low <= high, "Uniform::new_inclusive called with `low > high`");
-
- let low_s = low.as_secs();
- let low_n = low.subsec_nanos();
- let mut high_s = high.as_secs();
- let mut high_n = high.subsec_nanos();
-
- if high_n < low_n {
- high_s = high_s - 1;
- high_n = high_n + 1_000_000_000;
- }
-
- let mode = if low_s == high_s {
- UniformDurationMode::Small {
- secs: low_s,
- nanos: Uniform::new_inclusive(low_n, high_n),
- }
- } else {
- let max = high_s
- .checked_mul(1_000_000_000)
- .and_then(|n| n.checked_add(high_n as u64));
-
- if let Some(higher_bound) = max {
- let lower_bound = low_s * 1_000_000_000 + low_n as u64;
- UniformDurationMode::Medium {
- nanos: Uniform::new_inclusive(lower_bound, higher_bound),
- }
- } else {
- // An offset is applied to simplify generation of nanoseconds
- let max_nanos = high_n - low_n;
- UniformDurationMode::Large {
- max_secs: high_s,
- max_nanos,
- secs: Uniform::new_inclusive(low_s, high_s),
- }
- }
- };
- UniformDuration {
- mode,
- offset: low_n,
- }
- }
-
- #[inline]
- fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> Duration {
- match self.mode {
- UniformDurationMode::Small { secs, nanos } => {
- let n = nanos.sample(rng);
- Duration::new(secs, n)
- }
- UniformDurationMode::Medium { nanos } => {
- let nanos = nanos.sample(rng);
- Duration::new(nanos / 1_000_000_000, (nanos % 1_000_000_000) as u32)
- }
- UniformDurationMode::Large { max_secs, max_nanos, secs } => {
- // constant folding means this is at least as fast as `gen_range`
- let nano_range = Uniform::new(0, 1_000_000_000);
- loop {
- let s = secs.sample(rng);
- let n = nano_range.sample(rng);
- if !(s == max_secs && n > max_nanos) {
- let sum = n + self.offset;
- break Duration::new(s, sum);
- }
- }
- }
- }
- }
-}
-
-#[cfg(test)]
-mod tests {
- use Rng;
- use rngs::mock::StepRng;
- use distributions::uniform::Uniform;
- use distributions::utils::FloatAsSIMD;
- #[cfg(feature="simd_support")] use packed_simd::*;
-
- #[should_panic]
- #[test]
- fn test_uniform_bad_limits_equal_int() {
- Uniform::new(10, 10);
- }
-
- #[test]
- fn test_uniform_good_limits_equal_int() {
- let mut rng = ::test::rng(804);
- let dist = Uniform::new_inclusive(10, 10);
- for _ in 0..20 {
- assert_eq!(rng.sample(dist), 10);
- }
- }
-
- #[should_panic]
- #[test]
- fn test_uniform_bad_limits_flipped_int() {
- Uniform::new(10, 5);
- }
-
- #[test]
- fn test_integers() {
- use core::{i8, i16, i32, i64, isize};
- use core::{u8, u16, u32, u64, usize};
- #[cfg(all(rustc_1_26, not(target_os = "emscripten")))]
- use core::{i128, u128};
-
- let mut rng = ::test::rng(251);
- macro_rules! t {
- ($ty:ident, $v:expr, $le:expr, $lt:expr) => {{
- for &(low, high) in $v.iter() {
- let my_uniform = Uniform::new(low, high);
- for _ in 0..1000 {
- let v: $ty = rng.sample(my_uniform);
- assert!($le(low, v) && $lt(v, high));
- }
-
- let my_uniform = Uniform::new_inclusive(low, high);
- for _ in 0..1000 {
- let v: $ty = rng.sample(my_uniform);
- assert!($le(low, v) && $le(v, high));
- }
-
- let my_uniform = Uniform::new(&low, high);
- for _ in 0..1000 {
- let v: $ty = rng.sample(my_uniform);
- assert!($le(low, v) && $lt(v, high));
- }
-
- let my_uniform = Uniform::new_inclusive(&low, &high);
- for _ in 0..1000 {
- let v: $ty = rng.sample(my_uniform);
- assert!($le(low, v) && $le(v, high));
- }
-
- for _ in 0..1000 {
- let v: $ty = rng.gen_range(low, high);
- assert!($le(low, v) && $lt(v, high));
- }
- }
- }};
-
- // scalar bulk
- ($($ty:ident),*) => {{
- $(t!(
- $ty,
- [(0, 10), (10, 127), ($ty::MIN, $ty::MAX)],
- |x, y| x <= y,
- |x, y| x < y
- );)*
- }};
-
- // simd bulk
- ($($ty:ident),* => $scalar:ident) => {{
- $(t!(
- $ty,
- [
- ($ty::splat(0), $ty::splat(10)),
- ($ty::splat(10), $ty::splat(127)),
- ($ty::splat($scalar::MIN), $ty::splat($scalar::MAX)),
- ],
- |x: $ty, y| x.le(y).all(),
- |x: $ty, y| x.lt(y).all()
- );)*
- }};
- }
- t!(i8, i16, i32, i64, isize,
- u8, u16, u32, u64, usize);
- #[cfg(all(rustc_1_26, not(target_os = "emscripten")))]
- t!(i128, u128);
-
- #[cfg(all(feature = "simd_support", feature = "nightly"))]
- {
- t!(u8x2, u8x4, u8x8, u8x16, u8x32, u8x64 => u8);
- t!(i8x2, i8x4, i8x8, i8x16, i8x32, i8x64 => i8);
- t!(u16x2, u16x4, u16x8, u16x16, u16x32 => u16);
- t!(i16x2, i16x4, i16x8, i16x16, i16x32 => i16);
- t!(u32x2, u32x4, u32x8, u32x16 => u32);
- t!(i32x2, i32x4, i32x8, i32x16 => i32);
- t!(u64x2, u64x4, u64x8 => u64);
- t!(i64x2, i64x4, i64x8 => i64);
- }
- }
-
- #[test]
- fn test_floats() {
- let mut rng = ::test::rng(252);
- let mut zero_rng = StepRng::new(0, 0);
- let mut max_rng = StepRng::new(0xffff_ffff_ffff_ffff, 0);
- macro_rules! t {
- ($ty:ty, $f_scalar:ident, $bits_shifted:expr) => {{
- let v: &[($f_scalar, $f_scalar)]=
- &[(0.0, 100.0),
- (-1e35, -1e25),
- (1e-35, 1e-25),
- (-1e35, 1e35),
- (<$f_scalar>::from_bits(0), <$f_scalar>::from_bits(3)),
- (-<$f_scalar>::from_bits(10), -<$f_scalar>::from_bits(1)),
- (-<$f_scalar>::from_bits(5), 0.0),
- (-<$f_scalar>::from_bits(7), -0.0),
- (10.0, ::core::$f_scalar::MAX),
- (-100.0, ::core::$f_scalar::MAX),
- (-::core::$f_scalar::MAX / 5.0, ::core::$f_scalar::MAX),
- (-::core::$f_scalar::MAX, ::core::$f_scalar::MAX / 5.0),
- (-::core::$f_scalar::MAX * 0.8, ::core::$f_scalar::MAX * 0.7),
- (-::core::$f_scalar::MAX, ::core::$f_scalar::MAX),
- ];
- for &(low_scalar, high_scalar) in v.iter() {
- for lane in 0..<$ty>::lanes() {
- let low = <$ty>::splat(0.0 as $f_scalar).replace(lane, low_scalar);
- let high = <$ty>::splat(1.0 as $f_scalar).replace(lane, high_scalar);
- let my_uniform = Uniform::new(low, high);
- let my_incl_uniform = Uniform::new_inclusive(low, high);
- for _ in 0..100 {
- let v = rng.sample(my_uniform).extract(lane);
- assert!(low_scalar <= v && v < high_scalar);
- let v = rng.sample(my_incl_uniform).extract(lane);
- assert!(low_scalar <= v && v <= high_scalar);
- let v = rng.gen_range(low, high).extract(lane);
- assert!(low_scalar <= v && v < high_scalar);
- }
-
- assert_eq!(rng.sample(Uniform::new_inclusive(low, low)).extract(lane), low_scalar);
-
- assert_eq!(zero_rng.sample(my_uniform).extract(lane), low_scalar);
- assert_eq!(zero_rng.sample(my_incl_uniform).extract(lane), low_scalar);
- assert_eq!(zero_rng.gen_range(low, high).extract(lane), low_scalar);
- assert!(max_rng.sample(my_uniform).extract(lane) < high_scalar);
- assert!(max_rng.sample(my_incl_uniform).extract(lane) <= high_scalar);
-
- // Don't run this test for really tiny differences between high and low
- // since for those rounding might result in selecting high for a very
- // long time.
- if (high_scalar - low_scalar) > 0.0001 {
- let mut lowering_max_rng =
- StepRng::new(0xffff_ffff_ffff_ffff,
- (-1i64 << $bits_shifted) as u64);
- assert!(lowering_max_rng.gen_range(low, high).extract(lane) < high_scalar);
- }
- }
- }
-
- assert_eq!(rng.sample(Uniform::new_inclusive(::core::$f_scalar::MAX,
- ::core::$f_scalar::MAX)),
- ::core::$f_scalar::MAX);
- assert_eq!(rng.sample(Uniform::new_inclusive(-::core::$f_scalar::MAX,
- -::core::$f_scalar::MAX)),
- -::core::$f_scalar::MAX);
- }}
- }
-
- t!(f32, f32, 32 - 23);
- t!(f64, f64, 64 - 52);
- #[cfg(feature="simd_support")]
- {
- t!(f32x2, f32, 32 - 23);
- t!(f32x4, f32, 32 - 23);
- t!(f32x8, f32, 32 - 23);
- t!(f32x16, f32, 32 - 23);
- t!(f64x2, f64, 64 - 52);
- t!(f64x4, f64, 64 - 52);
- t!(f64x8, f64, 64 - 52);
- }
- }
-
- #[test]
- #[cfg(all(feature="std",
- not(target_arch = "wasm32"),
- not(target_arch = "asmjs")))]
- fn test_float_assertions() {
- use std::panic::catch_unwind;
- use super::SampleUniform;
- fn range<T: SampleUniform>(low: T, high: T) {
- let mut rng = ::test::rng(253);
- rng.gen_range(low, high);
- }
-
- macro_rules! t {
- ($ty:ident, $f_scalar:ident) => {{
- let v: &[($f_scalar, $f_scalar)] =
- &[(::std::$f_scalar::NAN, 0.0),
- (1.0, ::std::$f_scalar::NAN),
- (::std::$f_scalar::NAN, ::std::$f_scalar::NAN),
- (1.0, 0.5),
- (::std::$f_scalar::MAX, -::std::$f_scalar::MAX),
- (::std::$f_scalar::INFINITY, ::std::$f_scalar::INFINITY),
- (::std::$f_scalar::NEG_INFINITY, ::std::$f_scalar::NEG_INFINITY),
- (::std::$f_scalar::NEG_INFINITY, 5.0),
- (5.0, ::std::$f_scalar::INFINITY),
- (::std::$f_scalar::NAN, ::std::$f_scalar::INFINITY),
- (::std::$f_scalar::NEG_INFINITY, ::std::$f_scalar::NAN),
- (::std::$f_scalar::NEG_INFINITY, ::std::$f_scalar::INFINITY),
- ];
- for &(low_scalar, high_scalar) in v.iter() {
- for lane in 0..<$ty>::lanes() {
- let low = <$ty>::splat(0.0 as $f_scalar).replace(lane, low_scalar);
- let high = <$ty>::splat(1.0 as $f_scalar).replace(lane, high_scalar);
- assert!(catch_unwind(|| range(low, high)).is_err());
- assert!(catch_unwind(|| Uniform::new(low, high)).is_err());
- assert!(catch_unwind(|| Uniform::new_inclusive(low, high)).is_err());
- assert!(catch_unwind(|| range(low, low)).is_err());
- assert!(catch_unwind(|| Uniform::new(low, low)).is_err());
- }
- }
- }}
- }
-
- t!(f32, f32);
- t!(f64, f64);
- #[cfg(feature="simd_support")]
- {
- t!(f32x2, f32);
- t!(f32x4, f32);
- t!(f32x8, f32);
- t!(f32x16, f32);
- t!(f64x2, f64);
- t!(f64x4, f64);
- t!(f64x8, f64);
- }
- }
-
-
- #[test]
- #[cfg(any(feature = "std", rustc_1_25))]
- fn test_durations() {
- #[cfg(feature = "std")]
- use std::time::Duration;
- #[cfg(all(not(feature = "std"), rustc_1_25))]
- use core::time::Duration;
-
- let mut rng = ::test::rng(253);
-
- let v = &[(Duration::new(10, 50000), Duration::new(100, 1234)),
- (Duration::new(0, 100), Duration::new(1, 50)),
- (Duration::new(0, 0), Duration::new(u64::max_value(), 999_999_999))];
- for &(low, high) in v.iter() {
- let my_uniform = Uniform::new(low, high);
- for _ in 0..1000 {
- let v = rng.sample(my_uniform);
- assert!(low <= v && v < high);
- }
- }
- }
-
- #[test]
- fn test_custom_uniform() {
- use distributions::uniform::{UniformSampler, UniformFloat, SampleUniform, SampleBorrow};
- #[derive(Clone, Copy, PartialEq, PartialOrd)]
- struct MyF32 {
- x: f32,
- }
- #[derive(Clone, Copy, Debug)]
- struct UniformMyF32 {
- inner: UniformFloat<f32>,
- }
- impl UniformSampler for UniformMyF32 {
- type X = MyF32;
- fn new<B1, B2>(low: B1, high: B2) -> Self
- where B1: SampleBorrow<Self::X> + Sized,
- B2: SampleBorrow<Self::X> + Sized
- {
- UniformMyF32 {
- inner: UniformFloat::<f32>::new(low.borrow().x, high.borrow().x),
- }
- }
- fn new_inclusive<B1, B2>(low: B1, high: B2) -> Self
- where B1: SampleBorrow<Self::X> + Sized,
- B2: SampleBorrow<Self::X> + Sized
- {
- UniformSampler::new(low, high)
- }
- fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> Self::X {
- MyF32 { x: self.inner.sample(rng) }
- }
- }
- impl SampleUniform for MyF32 {
- type Sampler = UniformMyF32;
- }
-
- let (low, high) = (MyF32{ x: 17.0f32 }, MyF32{ x: 22.0f32 });
- let uniform = Uniform::new(low, high);
- let mut rng = ::test::rng(804);
- for _ in 0..100 {
- let x: MyF32 = rng.sample(uniform);
- assert!(low <= x && x < high);
- }
- }
-
- #[test]
- fn test_uniform_from_std_range() {
- let r = Uniform::from(2u32..7);
- assert_eq!(r.inner.low, 2);
- assert_eq!(r.inner.range, 5);
- let r = Uniform::from(2.0f64..7.0);
- assert_eq!(r.inner.low, 2.0);
- assert_eq!(r.inner.scale, 5.0);
- }
-
- #[cfg(rustc_1_27)]
- #[test]
- fn test_uniform_from_std_range_inclusive() {
- let r = Uniform::from(2u32..=6);
- assert_eq!(r.inner.low, 2);
- assert_eq!(r.inner.range, 5);
- let r = Uniform::from(2.0f64..=7.0);
- assert_eq!(r.inner.low, 2.0);
- assert!(r.inner.scale > 5.0);
- assert!(r.inner.scale < 5.0 + 1e-14);
- }
-}
diff --git a/rand/src/distributions/unit_circle.rs b/rand/src/distributions/unit_circle.rs
deleted file mode 100644
index 01ab76a..0000000
--- a/rand/src/distributions/unit_circle.rs
+++ /dev/null
@@ -1,101 +0,0 @@
-// Copyright 2018 Developers of the Rand project.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-use Rng;
-use distributions::{Distribution, Uniform};
-
-/// Samples uniformly from the edge of the unit circle in two dimensions.
-///
-/// Implemented via a method by von Neumann[^1].
-///
-///
-/// # Example
-///
-/// ```
-/// use rand::distributions::{UnitCircle, Distribution};
-///
-/// let circle = UnitCircle::new();
-/// let v = circle.sample(&mut rand::thread_rng());
-/// println!("{:?} is from the unit circle.", v)
-/// ```
-///
-/// [^1]: von Neumann, J. (1951) [*Various Techniques Used in Connection with
-/// Random Digits.*](https://mcnp.lanl.gov/pdf_files/nbs_vonneumann.pdf)
-/// NBS Appl. Math. Ser., No. 12. Washington, DC: U.S. Government Printing
-/// Office, pp. 36-38.
-#[derive(Clone, Copy, Debug)]
-pub struct UnitCircle;
-
-impl UnitCircle {
- /// Construct a new `UnitCircle` distribution.
- #[inline]
- pub fn new() -> UnitCircle {
- UnitCircle
- }
-}
-
-impl Distribution<[f64; 2]> for UnitCircle {
- #[inline]
- fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> [f64; 2] {
- let uniform = Uniform::new(-1., 1.);
- let mut x1;
- let mut x2;
- let mut sum;
- loop {
- x1 = uniform.sample(rng);
- x2 = uniform.sample(rng);
- sum = x1*x1 + x2*x2;
- if sum < 1. {
- break;
- }
- }
- let diff = x1*x1 - x2*x2;
- [diff / sum, 2.*x1*x2 / sum]
- }
-}
-
-#[cfg(test)]
-mod tests {
- use distributions::Distribution;
- use super::UnitCircle;
-
- /// Assert that two numbers are almost equal to each other.
- ///
- /// On panic, this macro will print the values of the expressions with their
- /// debug representations.
- macro_rules! assert_almost_eq {
- ($a:expr, $b:expr, $prec:expr) => (
- let diff = ($a - $b).abs();
- if diff > $prec {
- panic!(format!(
- "assertion failed: `abs(left - right) = {:.1e} < {:e}`, \
- (left: `{}`, right: `{}`)",
- diff, $prec, $a, $b));
- }
- );
- }
-
- #[test]
- fn norm() {
- let mut rng = ::test::rng(1);
- let dist = UnitCircle::new();
- for _ in 0..1000 {
- let x = dist.sample(&mut rng);
- assert_almost_eq!(x[0]*x[0] + x[1]*x[1], 1., 1e-15);
- }
- }
-
- #[test]
- fn value_stability() {
- let mut rng = ::test::rng(2);
- let dist = UnitCircle::new();
- assert_eq!(dist.sample(&mut rng), [-0.8032118336637037, 0.5956935036263119]);
- assert_eq!(dist.sample(&mut rng), [-0.4742919588505423, -0.880367615130018]);
- assert_eq!(dist.sample(&mut rng), [0.9297328981467168, 0.368234623716601]);
- }
-}
diff --git a/rand/src/distributions/unit_sphere.rs b/rand/src/distributions/unit_sphere.rs
deleted file mode 100644
index 37de88b..0000000
--- a/rand/src/distributions/unit_sphere.rs
+++ /dev/null
@@ -1,99 +0,0 @@
-// Copyright 2018 Developers of the Rand project.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-use Rng;
-use distributions::{Distribution, Uniform};
-
-/// Samples uniformly from the surface of the unit sphere in three dimensions.
-///
-/// Implemented via a method by Marsaglia[^1].
-///
-///
-/// # Example
-///
-/// ```
-/// use rand::distributions::{UnitSphereSurface, Distribution};
-///
-/// let sphere = UnitSphereSurface::new();
-/// let v = sphere.sample(&mut rand::thread_rng());
-/// println!("{:?} is from the unit sphere surface.", v)
-/// ```
-///
-/// [^1]: Marsaglia, George (1972). [*Choosing a Point from the Surface of a
-/// Sphere.*](https://doi.org/10.1214/aoms/1177692644)
-/// Ann. Math. Statist. 43, no. 2, 645--646.
-#[derive(Clone, Copy, Debug)]
-pub struct UnitSphereSurface;
-
-impl UnitSphereSurface {
- /// Construct a new `UnitSphereSurface` distribution.
- #[inline]
- pub fn new() -> UnitSphereSurface {
- UnitSphereSurface
- }
-}
-
-impl Distribution<[f64; 3]> for UnitSphereSurface {
- #[inline]
- fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> [f64; 3] {
- let uniform = Uniform::new(-1., 1.);
- loop {
- let (x1, x2) = (uniform.sample(rng), uniform.sample(rng));
- let sum = x1*x1 + x2*x2;
- if sum >= 1. {
- continue;
- }
- let factor = 2. * (1.0_f64 - sum).sqrt();
- return [x1 * factor, x2 * factor, 1. - 2.*sum];
- }
- }
-}
-
-#[cfg(test)]
-mod tests {
- use distributions::Distribution;
- use super::UnitSphereSurface;
-
- /// Assert that two numbers are almost equal to each other.
- ///
- /// On panic, this macro will print the values of the expressions with their
- /// debug representations.
- macro_rules! assert_almost_eq {
- ($a:expr, $b:expr, $prec:expr) => (
- let diff = ($a - $b).abs();
- if diff > $prec {
- panic!(format!(
- "assertion failed: `abs(left - right) = {:.1e} < {:e}`, \
- (left: `{}`, right: `{}`)",
- diff, $prec, $a, $b));
- }
- );
- }
-
- #[test]
- fn norm() {
- let mut rng = ::test::rng(1);
- let dist = UnitSphereSurface::new();
- for _ in 0..1000 {
- let x = dist.sample(&mut rng);
- assert_almost_eq!(x[0]*x[0] + x[1]*x[1] + x[2]*x[2], 1., 1e-15);
- }
- }
-
- #[test]
- fn value_stability() {
- let mut rng = ::test::rng(2);
- let dist = UnitSphereSurface::new();
- assert_eq!(dist.sample(&mut rng),
- [-0.24950027180862533, -0.7552572587896719, 0.6060825747478084]);
- assert_eq!(dist.sample(&mut rng),
- [0.47604534507233487, -0.797200864987207, -0.3712837328763685]);
- assert_eq!(dist.sample(&mut rng),
- [0.9795722330927367, 0.18692349236651176, 0.07414747571708524]);
- }
-}
diff --git a/rand/src/distributions/utils.rs b/rand/src/distributions/utils.rs
deleted file mode 100644
index d4d3642..0000000
--- a/rand/src/distributions/utils.rs
+++ /dev/null
@@ -1,504 +0,0 @@
-// Copyright 2018 Developers of the Rand project.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-//! Math helper functions
-
-#[cfg(feature="simd_support")]
-use packed_simd::*;
-#[cfg(feature="std")]
-use distributions::ziggurat_tables;
-#[cfg(feature="std")]
-use Rng;
-
-
-pub trait WideningMultiply<RHS = Self> {
- type Output;
-
- fn wmul(self, x: RHS) -> Self::Output;
-}
-
-macro_rules! wmul_impl {
- ($ty:ty, $wide:ty, $shift:expr) => {
- impl WideningMultiply for $ty {
- type Output = ($ty, $ty);
-
- #[inline(always)]
- fn wmul(self, x: $ty) -> Self::Output {
- let tmp = (self as $wide) * (x as $wide);
- ((tmp >> $shift) as $ty, tmp as $ty)
- }
- }
- };
-
- // simd bulk implementation
- ($(($ty:ident, $wide:ident),)+, $shift:expr) => {
- $(
- impl WideningMultiply for $ty {
- type Output = ($ty, $ty);
-
- #[inline(always)]
- fn wmul(self, x: $ty) -> Self::Output {
- // For supported vectors, this should compile to a couple
- // supported multiply & swizzle instructions (no actual
- // casting).
- // TODO: optimize
- let y: $wide = self.cast();
- let x: $wide = x.cast();
- let tmp = y * x;
- let hi: $ty = (tmp >> $shift).cast();
- let lo: $ty = tmp.cast();
- (hi, lo)
- }
- }
- )+
- };
-}
-wmul_impl! { u8, u16, 8 }
-wmul_impl! { u16, u32, 16 }
-wmul_impl! { u32, u64, 32 }
-#[cfg(all(rustc_1_26, not(target_os = "emscripten")))]
-wmul_impl! { u64, u128, 64 }
-
-// This code is a translation of the __mulddi3 function in LLVM's
-// compiler-rt. It is an optimised variant of the common method
-// `(a + b) * (c + d) = ac + ad + bc + bd`.
-//
-// For some reason LLVM can optimise the C version very well, but
-// keeps shuffling registers in this Rust translation.
-macro_rules! wmul_impl_large {
- ($ty:ty, $half:expr) => {
- impl WideningMultiply for $ty {
- type Output = ($ty, $ty);
-
- #[inline(always)]
- fn wmul(self, b: $ty) -> Self::Output {
- const LOWER_MASK: $ty = !0 >> $half;
- let mut low = (self & LOWER_MASK).wrapping_mul(b & LOWER_MASK);
- let mut t = low >> $half;
- low &= LOWER_MASK;
- t += (self >> $half).wrapping_mul(b & LOWER_MASK);
- low += (t & LOWER_MASK) << $half;
- let mut high = t >> $half;
- t = low >> $half;
- low &= LOWER_MASK;
- t += (b >> $half).wrapping_mul(self & LOWER_MASK);
- low += (t & LOWER_MASK) << $half;
- high += t >> $half;
- high += (self >> $half).wrapping_mul(b >> $half);
-
- (high, low)
- }
- }
- };
-
- // simd bulk implementation
- (($($ty:ty,)+) $scalar:ty, $half:expr) => {
- $(
- impl WideningMultiply for $ty {
- type Output = ($ty, $ty);
-
- #[inline(always)]
- fn wmul(self, b: $ty) -> Self::Output {
- // needs wrapping multiplication
- const LOWER_MASK: $scalar = !0 >> $half;
- let mut low = (self & LOWER_MASK) * (b & LOWER_MASK);
- let mut t = low >> $half;
- low &= LOWER_MASK;
- t += (self >> $half) * (b & LOWER_MASK);
- low += (t & LOWER_MASK) << $half;
- let mut high = t >> $half;
- t = low >> $half;
- low &= LOWER_MASK;
- t += (b >> $half) * (self & LOWER_MASK);
- low += (t & LOWER_MASK) << $half;
- high += t >> $half;
- high += (self >> $half) * (b >> $half);
-
- (high, low)
- }
- }
- )+
- };
-}
-#[cfg(not(all(rustc_1_26, not(target_os = "emscripten"))))]
-wmul_impl_large! { u64, 32 }
-#[cfg(all(rustc_1_26, not(target_os = "emscripten")))]
-wmul_impl_large! { u128, 64 }
-
-macro_rules! wmul_impl_usize {
- ($ty:ty) => {
- impl WideningMultiply for usize {
- type Output = (usize, usize);
-
- #[inline(always)]
- fn wmul(self, x: usize) -> Self::Output {
- let (high, low) = (self as $ty).wmul(x as $ty);
- (high as usize, low as usize)
- }
- }
- }
-}
-#[cfg(target_pointer_width = "32")]
-wmul_impl_usize! { u32 }
-#[cfg(target_pointer_width = "64")]
-wmul_impl_usize! { u64 }
-
-#[cfg(all(feature = "simd_support", feature = "nightly"))]
-mod simd_wmul {
- #[cfg(target_arch = "x86")]
- use core::arch::x86::*;
- #[cfg(target_arch = "x86_64")]
- use core::arch::x86_64::*;
- use super::*;
-
- wmul_impl! {
- (u8x2, u16x2),
- (u8x4, u16x4),
- (u8x8, u16x8),
- (u8x16, u16x16),
- (u8x32, u16x32),,
- 8
- }
-
- wmul_impl! { (u16x2, u32x2),, 16 }
- #[cfg(not(target_feature = "sse2"))]
- wmul_impl! { (u16x4, u32x4),, 16 }
- #[cfg(not(target_feature = "sse4.2"))]
- wmul_impl! { (u16x8, u32x8),, 16 }
- #[cfg(not(target_feature = "avx2"))]
- wmul_impl! { (u16x16, u32x16),, 16 }
-
- // 16-bit lane widths allow use of the x86 `mulhi` instructions, which
- // means `wmul` can be implemented with only two instructions.
- #[allow(unused_macros)]
- macro_rules! wmul_impl_16 {
- ($ty:ident, $intrinsic:ident, $mulhi:ident, $mullo:ident) => {
- impl WideningMultiply for $ty {
- type Output = ($ty, $ty);
-
- #[inline(always)]
- fn wmul(self, x: $ty) -> Self::Output {
- let b = $intrinsic::from_bits(x);
- let a = $intrinsic::from_bits(self);
- let hi = $ty::from_bits(unsafe { $mulhi(a, b) });
- let lo = $ty::from_bits(unsafe { $mullo(a, b) });
- (hi, lo)
- }
- }
- };
- }
-
- #[cfg(target_feature = "sse2")]
- wmul_impl_16! { u16x4, __m64, _mm_mulhi_pu16, _mm_mullo_pi16 }
- #[cfg(target_feature = "sse4.2")]
- wmul_impl_16! { u16x8, __m128i, _mm_mulhi_epu16, _mm_mullo_epi16 }
- #[cfg(target_feature = "avx2")]
- wmul_impl_16! { u16x16, __m256i, _mm256_mulhi_epu16, _mm256_mullo_epi16 }
- // FIXME: there are no `__m512i` types in stdsimd yet, so `wmul::<u16x32>`
- // cannot use the same implementation.
-
- wmul_impl! {
- (u32x2, u64x2),
- (u32x4, u64x4),
- (u32x8, u64x8),,
- 32
- }
-
- // TODO: optimize, this seems to seriously slow things down
- wmul_impl_large! { (u8x64,) u8, 4 }
- wmul_impl_large! { (u16x32,) u16, 8 }
- wmul_impl_large! { (u32x16,) u32, 16 }
- wmul_impl_large! { (u64x2, u64x4, u64x8,) u64, 32 }
-}
-#[cfg(all(feature = "simd_support", feature = "nightly"))]
-pub use self::simd_wmul::*;
-
-
-/// Helper trait when dealing with scalar and SIMD floating point types.
-pub(crate) trait FloatSIMDUtils {
- // `PartialOrd` for vectors compares lexicographically. We want to compare all
- // the individual SIMD lanes instead, and get the combined result over all
- // lanes. This is possible using something like `a.lt(b).all()`, but we
- // implement it as a trait so we can write the same code for `f32` and `f64`.
- // Only the comparison functions we need are implemented.
- fn all_lt(self, other: Self) -> bool;
- fn all_le(self, other: Self) -> bool;
- fn all_finite(self) -> bool;
-
- type Mask;
- fn finite_mask(self) -> Self::Mask;
- fn gt_mask(self, other: Self) -> Self::Mask;
- fn ge_mask(self, other: Self) -> Self::Mask;
-
- // Decrease all lanes where the mask is `true` to the next lower value
- // representable by the floating-point type. At least one of the lanes
- // must be set.
- fn decrease_masked(self, mask: Self::Mask) -> Self;
-
- // Convert from int value. Conversion is done while retaining the numerical
- // value, not by retaining the binary representation.
- type UInt;
- fn cast_from_int(i: Self::UInt) -> Self;
-}
-
-/// Implement functions available in std builds but missing from core primitives
-#[cfg(not(std))]
-pub(crate) trait Float : Sized {
- type Bits;
-
- fn is_nan(self) -> bool;
- fn is_infinite(self) -> bool;
- fn is_finite(self) -> bool;
- fn to_bits(self) -> Self::Bits;
- fn from_bits(v: Self::Bits) -> Self;
-}
-
-/// Implement functions on f32/f64 to give them APIs similar to SIMD types
-pub(crate) trait FloatAsSIMD : Sized {
- #[inline(always)]
- fn lanes() -> usize { 1 }
- #[inline(always)]
- fn splat(scalar: Self) -> Self { scalar }
- #[inline(always)]
- fn extract(self, index: usize) -> Self { debug_assert_eq!(index, 0); self }
- #[inline(always)]
- fn replace(self, index: usize, new_value: Self) -> Self { debug_assert_eq!(index, 0); new_value }
-}
-
-pub(crate) trait BoolAsSIMD : Sized {
- fn any(self) -> bool;
- fn all(self) -> bool;
- fn none(self) -> bool;
-}
-
-impl BoolAsSIMD for bool {
- #[inline(always)]
- fn any(self) -> bool { self }
- #[inline(always)]
- fn all(self) -> bool { self }
- #[inline(always)]
- fn none(self) -> bool { !self }
-}
-
-macro_rules! scalar_float_impl {
- ($ty:ident, $uty:ident) => {
- #[cfg(not(std))]
- impl Float for $ty {
- type Bits = $uty;
-
- #[inline]
- fn is_nan(self) -> bool {
- self != self
- }
-
- #[inline]
- fn is_infinite(self) -> bool {
- self == ::core::$ty::INFINITY || self == ::core::$ty::NEG_INFINITY
- }
-
- #[inline]
- fn is_finite(self) -> bool {
- !(self.is_nan() || self.is_infinite())
- }
-
- #[inline]
- fn to_bits(self) -> Self::Bits {
- unsafe { ::core::mem::transmute(self) }
- }
-
- #[inline]
- fn from_bits(v: Self::Bits) -> Self {
- // It turns out the safety issues with sNaN were overblown! Hooray!
- unsafe { ::core::mem::transmute(v) }
- }
- }
-
- impl FloatSIMDUtils for $ty {
- type Mask = bool;
- #[inline(always)]
- fn all_lt(self, other: Self) -> bool { self < other }
- #[inline(always)]
- fn all_le(self, other: Self) -> bool { self <= other }
- #[inline(always)]
- fn all_finite(self) -> bool { self.is_finite() }
- #[inline(always)]
- fn finite_mask(self) -> Self::Mask { self.is_finite() }
- #[inline(always)]
- fn gt_mask(self, other: Self) -> Self::Mask { self > other }
- #[inline(always)]
- fn ge_mask(self, other: Self) -> Self::Mask { self >= other }
- #[inline(always)]
- fn decrease_masked(self, mask: Self::Mask) -> Self {
- debug_assert!(mask, "At least one lane must be set");
- <$ty>::from_bits(self.to_bits() - 1)
- }
- type UInt = $uty;
- fn cast_from_int(i: Self::UInt) -> Self { i as $ty }
- }
-
- impl FloatAsSIMD for $ty {}
- }
-}
-
-scalar_float_impl!(f32, u32);
-scalar_float_impl!(f64, u64);
-
-
-#[cfg(feature="simd_support")]
-macro_rules! simd_impl {
- ($ty:ident, $f_scalar:ident, $mty:ident, $uty:ident) => {
- impl FloatSIMDUtils for $ty {
- type Mask = $mty;
- #[inline(always)]
- fn all_lt(self, other: Self) -> bool { self.lt(other).all() }
- #[inline(always)]
- fn all_le(self, other: Self) -> bool { self.le(other).all() }
- #[inline(always)]
- fn all_finite(self) -> bool { self.finite_mask().all() }
- #[inline(always)]
- fn finite_mask(self) -> Self::Mask {
- // This can possibly be done faster by checking bit patterns
- let neg_inf = $ty::splat(::core::$f_scalar::NEG_INFINITY);
- let pos_inf = $ty::splat(::core::$f_scalar::INFINITY);
- self.gt(neg_inf) & self.lt(pos_inf)
- }
- #[inline(always)]
- fn gt_mask(self, other: Self) -> Self::Mask { self.gt(other) }
- #[inline(always)]
- fn ge_mask(self, other: Self) -> Self::Mask { self.ge(other) }
- #[inline(always)]
- fn decrease_masked(self, mask: Self::Mask) -> Self {
- // Casting a mask into ints will produce all bits set for
- // true, and 0 for false. Adding that to the binary
- // representation of a float means subtracting one from
- // the binary representation, resulting in the next lower
- // value representable by $ty. This works even when the
- // current value is infinity.
- debug_assert!(mask.any(), "At least one lane must be set");
- <$ty>::from_bits(<$uty>::from_bits(self) + <$uty>::from_bits(mask))
- }
- type UInt = $uty;
- fn cast_from_int(i: Self::UInt) -> Self { i.cast() }
- }
- }
-}
-
-#[cfg(feature="simd_support")] simd_impl! { f32x2, f32, m32x2, u32x2 }
-#[cfg(feature="simd_support")] simd_impl! { f32x4, f32, m32x4, u32x4 }
-#[cfg(feature="simd_support")] simd_impl! { f32x8, f32, m32x8, u32x8 }
-#[cfg(feature="simd_support")] simd_impl! { f32x16, f32, m32x16, u32x16 }
-#[cfg(feature="simd_support")] simd_impl! { f64x2, f64, m64x2, u64x2 }
-#[cfg(feature="simd_support")] simd_impl! { f64x4, f64, m64x4, u64x4 }
-#[cfg(feature="simd_support")] simd_impl! { f64x8, f64, m64x8, u64x8 }
-
-/// Calculates ln(gamma(x)) (natural logarithm of the gamma
-/// function) using the Lanczos approximation.
-///
-/// The approximation expresses the gamma function as:
-/// `gamma(z+1) = sqrt(2*pi)*(z+g+0.5)^(z+0.5)*exp(-z-g-0.5)*Ag(z)`
-/// `g` is an arbitrary constant; we use the approximation with `g=5`.
-///
-/// Noting that `gamma(z+1) = z*gamma(z)` and applying `ln` to both sides:
-/// `ln(gamma(z)) = (z+0.5)*ln(z+g+0.5)-(z+g+0.5) + ln(sqrt(2*pi)*Ag(z)/z)`
-///
-/// `Ag(z)` is an infinite series with coefficients that can be calculated
-/// ahead of time - we use just the first 6 terms, which is good enough
-/// for most purposes.
-#[cfg(feature="std")]
-pub fn log_gamma(x: f64) -> f64 {
- // precalculated 6 coefficients for the first 6 terms of the series
- let coefficients: [f64; 6] = [
- 76.18009172947146,
- -86.50532032941677,
- 24.01409824083091,
- -1.231739572450155,
- 0.1208650973866179e-2,
- -0.5395239384953e-5,
- ];
-
- // (x+0.5)*ln(x+g+0.5)-(x+g+0.5)
- let tmp = x + 5.5;
- let log = (x + 0.5) * tmp.ln() - tmp;
-
- // the first few terms of the series for Ag(x)
- let mut a = 1.000000000190015;
- let mut denom = x;
- for coeff in &coefficients {
- denom += 1.0;
- a += coeff / denom;
- }
-
- // get everything together
- // a is Ag(x)
- // 2.5066... is sqrt(2pi)
- log + (2.5066282746310005 * a / x).ln()
-}
-
-/// Sample a random number using the Ziggurat method (specifically the
-/// ZIGNOR variant from Doornik 2005). Most of the arguments are
-/// directly from the paper:
-///
-/// * `rng`: source of randomness
-/// * `symmetric`: whether this is a symmetric distribution, or one-sided with P(x < 0) = 0.
-/// * `X`: the $x_i$ abscissae.
-/// * `F`: precomputed values of the PDF at the $x_i$, (i.e. $f(x_i)$)
-/// * `F_DIFF`: precomputed values of $f(x_i) - f(x_{i+1})$
-/// * `pdf`: the probability density function
-/// * `zero_case`: manual sampling from the tail when we chose the
-/// bottom box (i.e. i == 0)
-
-// the perf improvement (25-50%) is definitely worth the extra code
-// size from force-inlining.
-#[cfg(feature="std")]
-#[inline(always)]
-pub fn ziggurat<R: Rng + ?Sized, P, Z>(
- rng: &mut R,
- symmetric: bool,
- x_tab: ziggurat_tables::ZigTable,
- f_tab: ziggurat_tables::ZigTable,
- mut pdf: P,
- mut zero_case: Z)
- -> f64 where P: FnMut(f64) -> f64, Z: FnMut(&mut R, f64) -> f64 {
- use distributions::float::IntoFloat;
- loop {
- // As an optimisation we re-implement the conversion to a f64.
- // From the remaining 12 most significant bits we use 8 to construct `i`.
- // This saves us generating a whole extra random number, while the added
- // precision of using 64 bits for f64 does not buy us much.
- let bits = rng.next_u64();
- let i = bits as usize & 0xff;
-
- let u = if symmetric {
- // Convert to a value in the range [2,4) and substract to get [-1,1)
- // We can't convert to an open range directly, that would require
- // substracting `3.0 - EPSILON`, which is not representable.
- // It is possible with an extra step, but an open range does not
- // seem neccesary for the ziggurat algorithm anyway.
- (bits >> 12).into_float_with_exponent(1) - 3.0
- } else {
- // Convert to a value in the range [1,2) and substract to get (0,1)
- (bits >> 12).into_float_with_exponent(0)
- - (1.0 - ::core::f64::EPSILON / 2.0)
- };
- let x = u * x_tab[i];
-
- let test_x = if symmetric { x.abs() } else {x};
-
- // algebraically equivalent to |u| < x_tab[i+1]/x_tab[i] (or u < x_tab[i+1]/x_tab[i])
- if test_x < x_tab[i + 1] {
- return x;
- }
- if i == 0 {
- return zero_case(rng, u);
- }
- // algebraically equivalent to f1 + DRanU()*(f0 - f1) < 1
- if f_tab[i + 1] + (f_tab[i] - f_tab[i + 1]) * rng.gen::<f64>() < pdf(x) {
- return x;
- }
- }
-}
diff --git a/rand/src/distributions/weibull.rs b/rand/src/distributions/weibull.rs
deleted file mode 100644
index 5fbe10a..0000000
--- a/rand/src/distributions/weibull.rs
+++ /dev/null
@@ -1,71 +0,0 @@
-// Copyright 2018 Developers of the Rand project.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-//! The Weibull distribution.
-
-use Rng;
-use distributions::{Distribution, OpenClosed01};
-
-/// Samples floating-point numbers according to the Weibull distribution
-///
-/// # Example
-/// ```
-/// use rand::prelude::*;
-/// use rand::distributions::Weibull;
-///
-/// let val: f64 = SmallRng::from_entropy().sample(Weibull::new(1., 10.));
-/// println!("{}", val);
-/// ```
-#[derive(Clone, Copy, Debug)]
-pub struct Weibull {
- inv_shape: f64,
- scale: f64,
-}
-
-impl Weibull {
- /// Construct a new `Weibull` distribution with given `scale` and `shape`.
- ///
- /// # Panics
- ///
- /// `scale` and `shape` have to be non-zero and positive.
- pub fn new(scale: f64, shape: f64) -> Weibull {
- assert!((scale > 0.) & (shape > 0.));
- Weibull { inv_shape: 1./shape, scale }
- }
-}
-
-impl Distribution<f64> for Weibull {
- fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> f64 {
- let x: f64 = rng.sample(OpenClosed01);
- self.scale * (-x.ln()).powf(self.inv_shape)
- }
-}
-
-#[cfg(test)]
-mod tests {
- use distributions::Distribution;
- use super::Weibull;
-
- #[test]
- #[should_panic]
- fn invalid() {
- Weibull::new(0., 0.);
- }
-
- #[test]
- fn sample() {
- let scale = 1.0;
- let shape = 2.0;
- let d = Weibull::new(scale, shape);
- let mut rng = ::test::rng(1);
- for _ in 0..1000 {
- let r = d.sample(&mut rng);
- assert!(r >= 0.);
- }
- }
-}
diff --git a/rand/src/distributions/weighted.rs b/rand/src/distributions/weighted.rs
deleted file mode 100644
index 01c8fe6..0000000
--- a/rand/src/distributions/weighted.rs
+++ /dev/null
@@ -1,232 +0,0 @@
-// Copyright 2018 Developers of the Rand project.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-use Rng;
-use distributions::Distribution;
-use distributions::uniform::{UniformSampler, SampleUniform, SampleBorrow};
-use ::core::cmp::PartialOrd;
-use core::fmt;
-
-// Note that this whole module is only imported if feature="alloc" is enabled.
-#[cfg(not(feature="std"))] use alloc::vec::Vec;
-
-/// A distribution using weighted sampling to pick a discretely selected
-/// item.
-///
-/// Sampling a `WeightedIndex` distribution returns the index of a randomly
-/// selected element from the iterator used when the `WeightedIndex` was
-/// created. The chance of a given element being picked is proportional to the
-/// value of the element. The weights can use any type `X` for which an
-/// implementation of [`Uniform<X>`] exists.
-///
-/// # Performance
-///
-/// A `WeightedIndex<X>` contains a `Vec<X>` and a [`Uniform<X>`] and so its
-/// size is the sum of the size of those objects, possibly plus some alignment.
-///
-/// Creating a `WeightedIndex<X>` will allocate enough space to hold `N - 1`
-/// weights of type `X`, where `N` is the number of weights. However, since
-/// `Vec` doesn't guarantee a particular growth strategy, additional memory
-/// might be allocated but not used. Since the `WeightedIndex` object also
-/// contains, this might cause additional allocations, though for primitive
-/// types, ['Uniform<X>`] doesn't allocate any memory.
-///
-/// Time complexity of sampling from `WeightedIndex` is `O(log N)` where
-/// `N` is the number of weights.
-///
-/// Sampling from `WeightedIndex` will result in a single call to
-/// [`Uniform<X>::sample`], which typically will request a single value from
-/// the underlying [`RngCore`], though the exact number depends on the
-/// implementaiton of [`Uniform<X>::sample`].
-///
-/// # Example
-///
-/// ```
-/// use rand::prelude::*;
-/// use rand::distributions::WeightedIndex;
-///
-/// let choices = ['a', 'b', 'c'];
-/// let weights = [2, 1, 1];
-/// let dist = WeightedIndex::new(&weights).unwrap();
-/// let mut rng = thread_rng();
-/// for _ in 0..100 {
-/// // 50% chance to print 'a', 25% chance to print 'b', 25% chance to print 'c'
-/// println!("{}", choices[dist.sample(&mut rng)]);
-/// }
-///
-/// let items = [('a', 0), ('b', 3), ('c', 7)];
-/// let dist2 = WeightedIndex::new(items.iter().map(|item| item.1)).unwrap();
-/// for _ in 0..100 {
-/// // 0% chance to print 'a', 30% chance to print 'b', 70% chance to print 'c'
-/// println!("{}", items[dist2.sample(&mut rng)].0);
-/// }
-/// ```
-///
-/// [`Uniform<X>`]: struct.Uniform.html
-/// [`Uniform<X>::sample`]: struct.Uniform.html#method.sample
-/// [`RngCore`]: ../trait.RngCore.html
-#[derive(Debug, Clone)]
-pub struct WeightedIndex<X: SampleUniform + PartialOrd> {
- cumulative_weights: Vec<X>,
- weight_distribution: X::Sampler,
-}
-
-impl<X: SampleUniform + PartialOrd> WeightedIndex<X> {
- /// Creates a new a `WeightedIndex` [`Distribution`] using the values
- /// in `weights`. The weights can use any type `X` for which an
- /// implementation of [`Uniform<X>`] exists.
- ///
- /// Returns an error if the iterator is empty, if any weight is `< 0`, or
- /// if its total value is 0.
- ///
- /// [`Distribution`]: trait.Distribution.html
- /// [`Uniform<X>`]: struct.Uniform.html
- pub fn new<I>(weights: I) -> Result<WeightedIndex<X>, WeightedError>
- where I: IntoIterator,
- I::Item: SampleBorrow<X>,
- X: for<'a> ::core::ops::AddAssign<&'a X> +
- Clone +
- Default {
- let mut iter = weights.into_iter();
- let mut total_weight: X = iter.next()
- .ok_or(WeightedError::NoItem)?
- .borrow()
- .clone();
-
- let zero = <X as Default>::default();
- if total_weight < zero {
- return Err(WeightedError::NegativeWeight);
- }
-
- let mut weights = Vec::<X>::with_capacity(iter.size_hint().0);
- for w in iter {
- if *w.borrow() < zero {
- return Err(WeightedError::NegativeWeight);
- }
- weights.push(total_weight.clone());
- total_weight += w.borrow();
- }
-
- if total_weight == zero {
- return Err(WeightedError::AllWeightsZero);
- }
- let distr = X::Sampler::new(zero, total_weight);
-
- Ok(WeightedIndex { cumulative_weights: weights, weight_distribution: distr })
- }
-}
-
-impl<X> Distribution<usize> for WeightedIndex<X> where
- X: SampleUniform + PartialOrd {
- fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> usize {
- use ::core::cmp::Ordering;
- let chosen_weight = self.weight_distribution.sample(rng);
- // Find the first item which has a weight *higher* than the chosen weight.
- self.cumulative_weights.binary_search_by(
- |w| if *w <= chosen_weight { Ordering::Less } else { Ordering::Greater }).unwrap_err()
- }
-}
-
-#[cfg(test)]
-mod test {
- use super::*;
-
- #[test]
- fn test_weightedindex() {
- let mut r = ::test::rng(700);
- const N_REPS: u32 = 5000;
- let weights = [1u32, 2, 3, 0, 5, 6, 7, 1, 2, 3, 4, 5, 6, 7];
- let total_weight = weights.iter().sum::<u32>() as f32;
-
- let verify = |result: [i32; 14]| {
- for (i, count) in result.iter().enumerate() {
- let exp = (weights[i] * N_REPS) as f32 / total_weight;
- let mut err = (*count as f32 - exp).abs();
- if err != 0.0 {
- err /= exp;
- }
- assert!(err <= 0.25);
- }
- };
-
- // WeightedIndex from vec
- let mut chosen = [0i32; 14];
- let distr = WeightedIndex::new(weights.to_vec()).unwrap();
- for _ in 0..N_REPS {
- chosen[distr.sample(&mut r)] += 1;
- }
- verify(chosen);
-
- // WeightedIndex from slice
- chosen = [0i32; 14];
- let distr = WeightedIndex::new(&weights[..]).unwrap();
- for _ in 0..N_REPS {
- chosen[distr.sample(&mut r)] += 1;
- }
- verify(chosen);
-
- // WeightedIndex from iterator
- chosen = [0i32; 14];
- let distr = WeightedIndex::new(weights.iter()).unwrap();
- for _ in 0..N_REPS {
- chosen[distr.sample(&mut r)] += 1;
- }
- verify(chosen);
-
- for _ in 0..5 {
- assert_eq!(WeightedIndex::new(&[0, 1]).unwrap().sample(&mut r), 1);
- assert_eq!(WeightedIndex::new(&[1, 0]).unwrap().sample(&mut r), 0);
- assert_eq!(WeightedIndex::new(&[0, 0, 0, 0, 10, 0]).unwrap().sample(&mut r), 4);
- }
-
- assert_eq!(WeightedIndex::new(&[10][0..0]).unwrap_err(), WeightedError::NoItem);
- assert_eq!(WeightedIndex::new(&[0]).unwrap_err(), WeightedError::AllWeightsZero);
- assert_eq!(WeightedIndex::new(&[10, 20, -1, 30]).unwrap_err(), WeightedError::NegativeWeight);
- assert_eq!(WeightedIndex::new(&[-10, 20, 1, 30]).unwrap_err(), WeightedError::NegativeWeight);
- assert_eq!(WeightedIndex::new(&[-10]).unwrap_err(), WeightedError::NegativeWeight);
- }
-}
-
-/// Error type returned from `WeightedIndex::new`.
-#[derive(Debug, Clone, Copy, PartialEq, Eq)]
-pub enum WeightedError {
- /// The provided iterator contained no items.
- NoItem,
-
- /// A weight lower than zero was used.
- NegativeWeight,
-
- /// All items in the provided iterator had a weight of zero.
- AllWeightsZero,
-}
-
-impl WeightedError {
- fn msg(&self) -> &str {
- match *self {
- WeightedError::NoItem => "No items found",
- WeightedError::NegativeWeight => "Item has negative weight",
- WeightedError::AllWeightsZero => "All items had weight zero",
- }
- }
-}
-
-#[cfg(feature="std")]
-impl ::std::error::Error for WeightedError {
- fn description(&self) -> &str {
- self.msg()
- }
- fn cause(&self) -> Option<&::std::error::Error> {
- None
- }
-}
-
-impl fmt::Display for WeightedError {
- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
- write!(f, "{}", self.msg())
- }
-}
diff --git a/rand/src/distributions/ziggurat_tables.rs b/rand/src/distributions/ziggurat_tables.rs
deleted file mode 100644
index ca1ce30..0000000
--- a/rand/src/distributions/ziggurat_tables.rs
+++ /dev/null
@@ -1,279 +0,0 @@
-// Copyright 2018 Developers of the Rand project.
-// Copyright 2013 The Rust Project Developers.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-// Tables for distributions which are sampled using the ziggurat
-// algorithm. Autogenerated by `ziggurat_tables.py`.
-
-pub type ZigTable = &'static [f64; 257];
-pub const ZIG_NORM_R: f64 = 3.654152885361008796;
-pub static ZIG_NORM_X: [f64; 257] =
- [3.910757959537090045, 3.654152885361008796, 3.449278298560964462, 3.320244733839166074,
- 3.224575052047029100, 3.147889289517149969, 3.083526132001233044, 3.027837791768635434,
- 2.978603279880844834, 2.934366867207854224, 2.894121053612348060, 2.857138730872132548,
- 2.822877396825325125, 2.790921174000785765, 2.760944005278822555, 2.732685359042827056,
- 2.705933656121858100, 2.680514643284522158, 2.656283037575502437, 2.633116393630324570,
- 2.610910518487548515, 2.589575986706995181, 2.569035452680536569, 2.549221550323460761,
- 2.530075232158516929, 2.511544441625342294, 2.493583041269680667, 2.476149939669143318,
- 2.459208374333311298, 2.442725318198956774, 2.426670984935725972, 2.411018413899685520,
- 2.395743119780480601, 2.380822795170626005, 2.366237056715818632, 2.351967227377659952,
- 2.337996148795031370, 2.324308018869623016, 2.310888250599850036, 2.297723348901329565,
- 2.284800802722946056, 2.272108990226823888, 2.259637095172217780, 2.247375032945807760,
- 2.235313384928327984, 2.223443340090905718, 2.211756642882544366, 2.200245546609647995,
- 2.188902771624720689, 2.177721467738641614, 2.166695180352645966, 2.155817819875063268,
- 2.145083634046203613, 2.134487182844320152, 2.124023315687815661, 2.113687150684933957,
- 2.103474055713146829, 2.093379631137050279, 2.083399693996551783, 2.073530263516978778,
- 2.063767547809956415, 2.054107931648864849, 2.044547965215732788, 2.035084353727808715,
- 2.025713947862032960, 2.016433734904371722, 2.007240830558684852, 1.998132471356564244,
- 1.989106007615571325, 1.980158896898598364, 1.971288697931769640, 1.962493064942461896,
- 1.953769742382734043, 1.945116560006753925, 1.936531428273758904, 1.928012334050718257,
- 1.919557336591228847, 1.911164563769282232, 1.902832208548446369, 1.894558525668710081,
- 1.886341828534776388, 1.878180486290977669, 1.870072921069236838, 1.862017605397632281,
- 1.854013059758148119, 1.846057850283119750, 1.838150586580728607, 1.830289919680666566,
- 1.822474540091783224, 1.814703175964167636, 1.806974591348693426, 1.799287584547580199,
- 1.791640986550010028, 1.784033659547276329, 1.776464495522344977, 1.768932414909077933,
- 1.761436365316706665, 1.753975320315455111, 1.746548278279492994, 1.739154261283669012,
- 1.731792314050707216, 1.724461502945775715, 1.717160915015540690, 1.709889657069006086,
- 1.702646854797613907, 1.695431651932238548, 1.688243209434858727, 1.681080704722823338,
- 1.673943330923760353, 1.666830296159286684, 1.659740822855789499, 1.652674147080648526,
- 1.645629517902360339, 1.638606196773111146, 1.631603456932422036, 1.624620582830568427,
- 1.617656869570534228, 1.610711622367333673, 1.603784156023583041, 1.596873794420261339,
- 1.589979870021648534, 1.583101723393471438, 1.576238702733332886, 1.569390163412534456,
- 1.562555467528439657, 1.555733983466554893, 1.548925085471535512, 1.542128153226347553,
- 1.535342571438843118, 1.528567729435024614, 1.521803020758293101, 1.515047842773992404,
- 1.508301596278571965, 1.501563685112706548, 1.494833515777718391, 1.488110497054654369,
- 1.481394039625375747, 1.474683555695025516, 1.467978458615230908, 1.461278162507407830,
- 1.454582081885523293, 1.447889631277669675, 1.441200224845798017, 1.434513276002946425,
- 1.427828197027290358, 1.421144398672323117, 1.414461289772464658, 1.407778276843371534,
- 1.401094763676202559, 1.394410150925071257, 1.387723835686884621, 1.381035211072741964,
- 1.374343665770030531, 1.367648583594317957, 1.360949343030101844, 1.354245316759430606,
- 1.347535871177359290, 1.340820365893152122, 1.334098153216083604, 1.327368577624624679,
- 1.320630975217730096, 1.313884673146868964, 1.307128989027353860, 1.300363230327433728,
- 1.293586693733517645, 1.286798664489786415, 1.279998415710333237, 1.273185207661843732,
- 1.266358287014688333, 1.259516886060144225, 1.252660221891297887, 1.245787495544997903,
- 1.238897891102027415, 1.231990574742445110, 1.225064693752808020, 1.218119375481726552,
- 1.211153726239911244, 1.204166830140560140, 1.197157747875585931, 1.190125515422801650,
- 1.183069142678760732, 1.175987612011489825, 1.168879876726833800, 1.161744859441574240,
- 1.154581450355851802, 1.147388505416733873, 1.140164844363995789, 1.132909248648336975,
- 1.125620459211294389, 1.118297174115062909, 1.110938046009249502, 1.103541679420268151,
- 1.096106627847603487, 1.088631390649514197, 1.081114409698889389, 1.073554065787871714,
- 1.065948674757506653, 1.058296483326006454, 1.050595664586207123, 1.042844313139370538,
- 1.035040439828605274, 1.027181966030751292, 1.019266717460529215, 1.011292417434978441,
- 1.003256679539591412, 0.995156999629943084, 0.986990747093846266, 0.978755155288937750,
- 0.970447311058864615, 0.962064143217605250, 0.953602409875572654, 0.945058684462571130,
- 0.936429340280896860, 0.927710533396234771, 0.918898183643734989, 0.909987953490768997,
- 0.900975224455174528, 0.891855070726792376, 0.882622229578910122, 0.873271068082494550,
- 0.863795545546826915, 0.854189171001560554, 0.844444954902423661, 0.834555354079518752,
- 0.824512208745288633, 0.814306670128064347, 0.803929116982664893, 0.793369058833152785,
- 0.782615023299588763, 0.771654424216739354, 0.760473406422083165, 0.749056662009581653,
- 0.737387211425838629, 0.725446140901303549, 0.713212285182022732, 0.700661841097584448,
- 0.687767892786257717, 0.674499822827436479, 0.660822574234205984, 0.646695714884388928,
- 0.632072236375024632, 0.616896989996235545, 0.601104617743940417, 0.584616766093722262,
- 0.567338257040473026, 0.549151702313026790, 0.529909720646495108, 0.509423329585933393,
- 0.487443966121754335, 0.463634336771763245, 0.437518402186662658, 0.408389134588000746,
- 0.375121332850465727, 0.335737519180459465, 0.286174591747260509, 0.215241895913273806,
- 0.000000000000000000];
-pub static ZIG_NORM_F: [f64; 257] =
- [0.000477467764586655, 0.001260285930498598, 0.002609072746106363, 0.004037972593371872,
- 0.005522403299264754, 0.007050875471392110, 0.008616582769422917, 0.010214971439731100,
- 0.011842757857943104, 0.013497450601780807, 0.015177088307982072, 0.016880083152595839,
- 0.018605121275783350, 0.020351096230109354, 0.022117062707379922, 0.023902203305873237,
- 0.025705804008632656, 0.027527235669693315, 0.029365939758230111, 0.031221417192023690,
- 0.033093219458688698, 0.034980941461833073, 0.036884215688691151, 0.038802707404656918,
- 0.040736110656078753, 0.042684144916619378, 0.044646552251446536, 0.046623094902089664,
- 0.048613553216035145, 0.050617723861121788, 0.052635418276973649, 0.054666461325077916,
- 0.056710690106399467, 0.058767952921137984, 0.060838108349751806, 0.062921024437977854,
- 0.065016577971470438, 0.067124653828023989, 0.069245144397250269, 0.071377949059141965,
- 0.073522973714240991, 0.075680130359194964, 0.077849336702372207, 0.080030515814947509,
- 0.082223595813495684, 0.084428509570654661, 0.086645194450867782, 0.088873592068594229,
- 0.091113648066700734, 0.093365311913026619, 0.095628536713353335, 0.097903279039215627,
- 0.100189498769172020, 0.102487158942306270, 0.104796225622867056, 0.107116667775072880,
- 0.109448457147210021, 0.111791568164245583, 0.114145977828255210, 0.116511665626037014,
- 0.118888613443345698, 0.121276805485235437, 0.123676228202051403, 0.126086870220650349,
- 0.128508722280473636, 0.130941777174128166, 0.133386029692162844, 0.135841476571757352,
- 0.138308116449064322, 0.140785949814968309, 0.143274978974047118, 0.145775208006537926,
- 0.148286642733128721, 0.150809290682410169, 0.153343161060837674, 0.155888264725064563,
- 0.158444614156520225, 0.161012223438117663, 0.163591108232982951, 0.166181285765110071,
- 0.168782774801850333, 0.171395595638155623, 0.174019770082499359, 0.176655321444406654,
- 0.179302274523530397, 0.181960655600216487, 0.184630492427504539, 0.187311814224516926,
- 0.190004651671193070, 0.192709036904328807, 0.195425003514885592, 0.198152586546538112,
- 0.200891822495431333, 0.203642749311121501, 0.206405406398679298, 0.209179834621935651,
- 0.211966076307852941, 0.214764175252008499, 0.217574176725178370, 0.220396127481011589,
- 0.223230075764789593, 0.226076071323264877, 0.228934165415577484, 0.231804410825248525,
- 0.234686861873252689, 0.237581574432173676, 0.240488605941449107, 0.243408015423711988,
- 0.246339863502238771, 0.249284212419516704, 0.252241126056943765, 0.255210669955677150,
- 0.258192911338648023, 0.261187919133763713, 0.264195763998317568, 0.267216518344631837,
- 0.270250256366959984, 0.273297054069675804, 0.276356989296781264, 0.279430141762765316,
- 0.282516593084849388, 0.285616426816658109, 0.288729728483353931, 0.291856585618280984,
- 0.294997087801162572, 0.298151326697901342, 0.301319396102034120, 0.304501391977896274,
- 0.307697412505553769, 0.310907558127563710, 0.314131931597630143, 0.317370638031222396,
- 0.320623784958230129, 0.323891482377732021, 0.327173842814958593, 0.330470981380537099,
- 0.333783015832108509, 0.337110066638412809, 0.340452257045945450, 0.343809713148291340,
- 0.347182563958251478, 0.350570941482881204, 0.353974980801569250, 0.357394820147290515,
- 0.360830600991175754, 0.364282468130549597, 0.367750569780596226, 0.371235057669821344,
- 0.374736087139491414, 0.378253817247238111, 0.381788410875031348, 0.385340034841733958,
- 0.388908860020464597, 0.392495061461010764, 0.396098818517547080, 0.399720314981931668,
- 0.403359739222868885, 0.407017284331247953, 0.410693148271983222, 0.414387534042706784,
- 0.418100649839684591, 0.421832709231353298, 0.425583931339900579, 0.429354541031341519,
- 0.433144769114574058, 0.436954852549929273, 0.440785034667769915, 0.444635565397727750,
- 0.448506701509214067, 0.452398706863882505, 0.456311852680773566, 0.460246417814923481,
- 0.464202689050278838, 0.468180961407822172, 0.472181538469883255, 0.476204732721683788,
- 0.480250865911249714, 0.484320269428911598, 0.488413284707712059, 0.492530263646148658,
- 0.496671569054796314, 0.500837575128482149, 0.505028667945828791, 0.509245245998136142,
- 0.513487720749743026, 0.517756517232200619, 0.522052074674794864, 0.526374847174186700,
- 0.530725304406193921, 0.535103932383019565, 0.539511234259544614, 0.543947731192649941,
- 0.548413963257921133, 0.552910490428519918, 0.557437893621486324, 0.561996775817277916,
- 0.566587763258951771, 0.571211506738074970, 0.575868682975210544, 0.580559996103683473,
- 0.585286179266300333, 0.590047996335791969, 0.594846243770991268, 0.599681752622167719,
- 0.604555390700549533, 0.609468064928895381, 0.614420723892076803, 0.619414360609039205,
- 0.624450015550274240, 0.629528779928128279, 0.634651799290960050, 0.639820277456438991,
- 0.645035480824251883, 0.650298743114294586, 0.655611470583224665, 0.660975147780241357,
- 0.666391343912380640, 0.671861719900766374, 0.677388036222513090, 0.682972161648791376,
- 0.688616083008527058, 0.694321916130032579, 0.700091918140490099, 0.705928501336797409,
- 0.711834248882358467, 0.717811932634901395, 0.723864533472881599, 0.729995264565802437,
- 0.736207598131266683, 0.742505296344636245, 0.748892447223726720, 0.755373506511754500,
- 0.761953346841546475, 0.768637315803334831, 0.775431304986138326, 0.782341832659861902,
- 0.789376143571198563, 0.796542330428254619, 0.803849483176389490, 0.811307874318219935,
- 0.818929191609414797, 0.826726833952094231, 0.834716292992930375, 0.842915653118441077,
- 0.851346258465123684, 0.860033621203008636, 0.869008688043793165, 0.878309655816146839,
- 0.887984660763399880, 0.898095921906304051, 0.908726440060562912, 0.919991505048360247,
- 0.932060075968990209, 0.945198953453078028, 0.959879091812415930, 0.977101701282731328,
- 1.000000000000000000];
-pub const ZIG_EXP_R: f64 = 7.697117470131050077;
-pub static ZIG_EXP_X: [f64; 257] =
- [8.697117470131052741, 7.697117470131050077, 6.941033629377212577, 6.478378493832569696,
- 6.144164665772472667, 5.882144315795399869, 5.666410167454033697, 5.482890627526062488,
- 5.323090505754398016, 5.181487281301500047, 5.054288489981304089, 4.938777085901250530,
- 4.832939741025112035, 4.735242996601741083, 4.644491885420085175, 4.559737061707351380,
- 4.480211746528421912, 4.405287693473573185, 4.334443680317273007, 4.267242480277365857,
- 4.203313713735184365, 4.142340865664051464, 4.084051310408297830, 4.028208544647936762,
- 3.974606066673788796, 3.923062500135489739, 3.873417670399509127, 3.825529418522336744,
- 3.779270992411667862, 3.734528894039797375, 3.691201090237418825, 3.649195515760853770,
- 3.608428813128909507, 3.568825265648337020, 3.530315889129343354, 3.492837654774059608,
- 3.456332821132760191, 3.420748357251119920, 3.386035442460300970, 3.352149030900109405,
- 3.319047470970748037, 3.286692171599068679, 3.255047308570449882, 3.224079565286264160,
- 3.193757903212240290, 3.164053358025972873, 3.134938858084440394, 3.106389062339824481,
- 3.078380215254090224, 3.050890016615455114, 3.023897504455676621, 2.997382949516130601,
- 2.971327759921089662, 2.945714394895045718, 2.920526286512740821, 2.895747768600141825,
- 2.871364012015536371, 2.847360965635188812, 2.823725302450035279, 2.800444370250737780,
- 2.777506146439756574, 2.754899196562344610, 2.732612636194700073, 2.710636095867928752,
- 2.688959688741803689, 2.667573980773266573, 2.646469963151809157, 2.625639026797788489,
- 2.605072938740835564, 2.584763820214140750, 2.564704126316905253, 2.544886627111869970,
- 2.525304390037828028, 2.505950763528594027, 2.486819361740209455, 2.467904050297364815,
- 2.449198932978249754, 2.430698339264419694, 2.412396812688870629, 2.394289099921457886,
- 2.376370140536140596, 2.358635057409337321, 2.341079147703034380, 2.323697874390196372,
- 2.306486858283579799, 2.289441870532269441, 2.272558825553154804, 2.255833774367219213,
- 2.239262898312909034, 2.222842503111036816, 2.206569013257663858, 2.190438966723220027,
- 2.174449009937774679, 2.158595893043885994, 2.142876465399842001, 2.127287671317368289,
- 2.111826546019042183, 2.096490211801715020, 2.081275874393225145, 2.066180819490575526,
- 2.051202409468584786, 2.036338080248769611, 2.021585338318926173, 2.006941757894518563,
- 1.992404978213576650, 1.977972700957360441, 1.963642687789548313, 1.949412758007184943,
- 1.935280786297051359, 1.921244700591528076, 1.907302480018387536, 1.893452152939308242,
- 1.879691795072211180, 1.866019527692827973, 1.852433515911175554, 1.838931967018879954,
- 1.825513128903519799, 1.812175288526390649, 1.798916770460290859, 1.785735935484126014,
- 1.772631179231305643, 1.759600930889074766, 1.746643651946074405, 1.733757834985571566,
- 1.720942002521935299, 1.708194705878057773, 1.695514524101537912, 1.682900062917553896,
- 1.670349953716452118, 1.657862852574172763, 1.645437439303723659, 1.633072416535991334,
- 1.620766508828257901, 1.608518461798858379, 1.596327041286483395, 1.584191032532688892,
- 1.572109239386229707, 1.560080483527888084, 1.548103603714513499, 1.536177455041032092,
- 1.524300908219226258, 1.512472848872117082, 1.500692176842816750, 1.488957805516746058,
- 1.477268661156133867, 1.465623682245745352, 1.454021818848793446, 1.442462031972012504,
- 1.430943292938879674, 1.419464582769983219, 1.408024891569535697, 1.396623217917042137,
- 1.385258568263121992, 1.373929956328490576, 1.362636402505086775, 1.351376933258335189,
- 1.340150580529504643, 1.328956381137116560, 1.317793376176324749, 1.306660610415174117,
- 1.295557131686601027, 1.284481990275012642, 1.273434238296241139, 1.262412929069615330,
- 1.251417116480852521, 1.240445854334406572, 1.229498195693849105, 1.218573192208790124,
- 1.207669893426761121, 1.196787346088403092, 1.185924593404202199, 1.175080674310911677,
- 1.164254622705678921, 1.153445466655774743, 1.142652227581672841, 1.131873919411078511,
- 1.121109547701330200, 1.110358108727411031, 1.099618588532597308, 1.088889961938546813,
- 1.078171191511372307, 1.067461226479967662, 1.056759001602551429, 1.046063435977044209,
- 1.035373431790528542, 1.024687873002617211, 1.014005623957096480, 1.003325527915696735,
- 0.992646405507275897, 0.981967053085062602, 0.971286240983903260, 0.960602711668666509,
- 0.949915177764075969, 0.939222319955262286, 0.928522784747210395, 0.917815182070044311,
- 0.907098082715690257, 0.896370015589889935, 0.885629464761751528, 0.874874866291025066,
- 0.864104604811004484, 0.853317009842373353, 0.842510351810368485, 0.831682837734273206,
- 0.820832606554411814, 0.809957724057418282, 0.799056177355487174, 0.788125868869492430,
- 0.777164609759129710, 0.766170112735434672, 0.755139984181982249, 0.744071715500508102,
- 0.732962673584365398, 0.721810090308756203, 0.710611050909655040, 0.699362481103231959,
- 0.688061132773747808, 0.676703568029522584, 0.665286141392677943, 0.653804979847664947,
- 0.642255960424536365, 0.630634684933490286, 0.618936451394876075, 0.607156221620300030,
- 0.595288584291502887, 0.583327712748769489, 0.571267316532588332, 0.559100585511540626,
- 0.546820125163310577, 0.534417881237165604, 0.521885051592135052, 0.509211982443654398,
- 0.496388045518671162, 0.483401491653461857, 0.470239275082169006, 0.456886840931420235,
- 0.443327866073552401, 0.429543940225410703, 0.415514169600356364, 0.401214678896277765,
- 0.386617977941119573, 0.371692145329917234, 0.356399760258393816, 0.340696481064849122,
- 0.324529117016909452, 0.307832954674932158, 0.290527955491230394, 0.272513185478464703,
- 0.253658363385912022, 0.233790483059674731, 0.212671510630966620, 0.189958689622431842,
- 0.165127622564187282, 0.137304980940012589, 0.104838507565818778, 0.063852163815001570,
- 0.000000000000000000];
-pub static ZIG_EXP_F: [f64; 257] =
- [0.000167066692307963, 0.000454134353841497, 0.000967269282327174, 0.001536299780301573,
- 0.002145967743718907, 0.002788798793574076, 0.003460264777836904, 0.004157295120833797,
- 0.004877655983542396, 0.005619642207205489, 0.006381905937319183, 0.007163353183634991,
- 0.007963077438017043, 0.008780314985808977, 0.009614413642502212, 0.010464810181029981,
- 0.011331013597834600, 0.012212592426255378, 0.013109164931254991, 0.014020391403181943,
- 0.014945968011691148, 0.015885621839973156, 0.016839106826039941, 0.017806200410911355,
- 0.018786700744696024, 0.019780424338009740, 0.020787204072578114, 0.021806887504283581,
- 0.022839335406385240, 0.023884420511558174, 0.024942026419731787, 0.026012046645134221,
- 0.027094383780955803, 0.028188948763978646, 0.029295660224637411, 0.030414443910466622,
- 0.031545232172893622, 0.032687963508959555, 0.033842582150874358, 0.035009037697397431,
- 0.036187284781931443, 0.037377282772959382, 0.038578995503074871, 0.039792391023374139,
- 0.041017441380414840, 0.042254122413316254, 0.043502413568888197, 0.044762297732943289,
- 0.046033761076175184, 0.047316792913181561, 0.048611385573379504, 0.049917534282706379,
- 0.051235237055126281, 0.052564494593071685, 0.053905310196046080, 0.055257689676697030,
- 0.056621641283742870, 0.057997175631200659, 0.059384305633420280, 0.060783046445479660,
- 0.062193415408541036, 0.063615431999807376, 0.065049117786753805, 0.066494496385339816,
- 0.067951593421936643, 0.069420436498728783, 0.070901055162371843, 0.072393480875708752,
- 0.073897746992364746, 0.075413888734058410, 0.076941943170480517, 0.078481949201606435,
- 0.080033947542319905, 0.081597980709237419, 0.083174093009632397, 0.084762330532368146,
- 0.086362741140756927, 0.087975374467270231, 0.089600281910032886, 0.091237516631040197,
- 0.092887133556043569, 0.094549189376055873, 0.096223742550432825, 0.097910853311492213,
- 0.099610583670637132, 0.101322997425953631, 0.103048160171257702, 0.104786139306570145,
- 0.106537004050001632, 0.108300825451033755, 0.110077676405185357, 0.111867631670056283,
- 0.113670767882744286, 0.115487163578633506, 0.117316899211555525, 0.119160057175327641,
- 0.121016721826674792, 0.122886979509545108, 0.124770918580830933, 0.126668629437510671,
- 0.128580204545228199, 0.130505738468330773, 0.132445327901387494, 0.134399071702213602,
- 0.136367070926428829, 0.138349428863580176, 0.140346251074862399, 0.142357645432472146,
- 0.144383722160634720, 0.146424593878344889, 0.148480375643866735, 0.150551185001039839,
- 0.152637142027442801, 0.154738369384468027, 0.156854992369365148, 0.158987138969314129,
- 0.161134939917591952, 0.163298528751901734, 0.165478041874935922, 0.167673618617250081,
- 0.169885401302527550, 0.172113535315319977, 0.174358169171353411, 0.176619454590494829,
- 0.178897546572478278, 0.181192603475496261, 0.183504787097767436, 0.185834262762197083,
- 0.188181199404254262, 0.190545769663195363, 0.192928149976771296, 0.195328520679563189,
- 0.197747066105098818, 0.200183974691911210, 0.202639439093708962, 0.205113656293837654,
- 0.207606827724221982, 0.210119159388988230, 0.212650861992978224, 0.215202151075378628,
- 0.217773247148700472, 0.220364375843359439, 0.222975768058120111, 0.225607660116683956,
- 0.228260293930716618, 0.230933917169627356, 0.233628783437433291, 0.236345152457059560,
- 0.239083290262449094, 0.241843469398877131, 0.244625969131892024, 0.247431075665327543,
- 0.250259082368862240, 0.253110290015629402, 0.255985007030415324, 0.258883549749016173,
- 0.261806242689362922, 0.264753418835062149, 0.267725419932044739, 0.270722596799059967,
- 0.273745309652802915, 0.276793928448517301, 0.279868833236972869, 0.282970414538780746,
- 0.286099073737076826, 0.289255223489677693, 0.292439288161892630, 0.295651704281261252,
- 0.298892921015581847, 0.302163400675693528, 0.305463619244590256, 0.308794066934560185,
- 0.312155248774179606, 0.315547685227128949, 0.318971912844957239, 0.322428484956089223,
- 0.325917972393556354, 0.329440964264136438, 0.332998068761809096, 0.336589914028677717,
- 0.340217149066780189, 0.343880444704502575, 0.347580494621637148, 0.351318016437483449,
- 0.355093752866787626, 0.358908472948750001, 0.362762973354817997, 0.366658079781514379,
- 0.370594648435146223, 0.374573567615902381, 0.378595759409581067, 0.382662181496010056,
- 0.386773829084137932, 0.390931736984797384, 0.395136981833290435, 0.399390684475231350,
- 0.403694012530530555, 0.408048183152032673, 0.412454465997161457, 0.416914186433003209,
- 0.421428728997616908, 0.425999541143034677, 0.430628137288459167, 0.435316103215636907,
- 0.440065100842354173, 0.444876873414548846, 0.449753251162755330, 0.454696157474615836,
- 0.459707615642138023, 0.464789756250426511, 0.469944825283960310, 0.475175193037377708,
- 0.480483363930454543, 0.485871987341885248, 0.491343869594032867, 0.496901987241549881,
- 0.502549501841348056, 0.508289776410643213, 0.514126393814748894, 0.520063177368233931,
- 0.526104213983620062, 0.532253880263043655, 0.538516872002862246, 0.544898237672440056,
- 0.551403416540641733, 0.558038282262587892, 0.564809192912400615, 0.571723048664826150,
- 0.578787358602845359, 0.586010318477268366, 0.593400901691733762, 0.600968966365232560,
- 0.608725382079622346, 0.616682180915207878, 0.624852738703666200, 0.633251994214366398,
- 0.641896716427266423, 0.650805833414571433, 0.660000841079000145, 0.669506316731925177,
- 0.679350572264765806, 0.689566496117078431, 0.700192655082788606, 0.711274760805076456,
- 0.722867659593572465, 0.735038092431424039, 0.747868621985195658, 0.761463388849896838,
- 0.775956852040116218, 0.791527636972496285, 0.808421651523009044, 0.826993296643051101,
- 0.847785500623990496, 0.871704332381204705, 0.900469929925747703, 0.938143680862176477,
- 1.000000000000000000];
diff --git a/rand/src/lib.rs b/rand/src/lib.rs
deleted file mode 100644
index ca231b5..0000000
--- a/rand/src/lib.rs
+++ /dev/null
@@ -1,852 +0,0 @@
-// Copyright 2018 Developers of the Rand project.
-// Copyright 2013-2017 The Rust Project Developers.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-//! Utilities for random number generation
-//!
-//! Rand provides utilities to generate random numbers, to convert them to
-//! useful types and distributions, and some randomness-related algorithms.
-//!
-//! # Quick Start
-//!
-//! To get you started quickly, the easiest and highest-level way to get
-//! a random value is to use [`random()`]; alternatively you can use
-//! [`thread_rng()`]. The [`Rng`] trait provides a useful API on all RNGs, while
-//! the [`distributions` module] and [`seq` module] provide further
-//! functionality on top of RNGs.
-//!
-//! ```
-//! use rand::prelude::*;
-//!
-//! if rand::random() { // generates a boolean
-//! // Try printing a random unicode code point (probably a bad idea)!
-//! println!("char: {}", rand::random::<char>());
-//! }
-//!
-//! let mut rng = rand::thread_rng();
-//! let y: f64 = rng.gen(); // generates a float between 0 and 1
-//!
-//! let mut nums: Vec<i32> = (1..100).collect();
-//! nums.shuffle(&mut rng);
-//! ```
-//!
-//! # The Book
-//!
-//! For the user guide and futher documentation, please read
-//! [The Rust Rand Book](https://rust-random.github.io/book).
-//!
-//! [`distributions` module]: distributions/index.html
-//! [`random()`]: fn.random.html
-//! [`Rng`]: trait.Rng.html
-//! [`seq` module]: seq/index.html
-//! [`thread_rng()`]: fn.thread_rng.html
-
-
-#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk.png",
- html_favicon_url = "https://www.rust-lang.org/favicon.ico",
- html_root_url = "https://rust-random.github.io/rand/")]
-
-#![deny(missing_docs)]
-#![deny(missing_debug_implementations)]
-#![doc(test(attr(allow(unused_variables), deny(warnings))))]
-
-#![cfg_attr(not(feature="std"), no_std)]
-#![cfg_attr(all(feature="alloc", not(feature="std")), feature(alloc))]
-#![cfg_attr(all(feature="simd_support", feature="nightly"), feature(stdsimd))]
-
-#[cfg(feature = "std")] extern crate core;
-#[cfg(all(feature = "alloc", not(feature="std")))] #[macro_use] extern crate alloc;
-
-#[cfg(feature="simd_support")] extern crate packed_simd;
-
-#[cfg(feature = "rand_os")]
-extern crate rand_os;
-
-extern crate rand_core;
-extern crate rand_isaac; // only for deprecations
-extern crate rand_chacha; // only for deprecations
-extern crate rand_hc;
-extern crate rand_pcg;
-extern crate rand_xorshift;
-
-#[cfg(feature = "log")] #[macro_use] extern crate log;
-#[allow(unused)]
-#[cfg(not(feature = "log"))] macro_rules! trace { ($($x:tt)*) => () }
-#[allow(unused)]
-#[cfg(not(feature = "log"))] macro_rules! debug { ($($x:tt)*) => () }
-#[allow(unused)]
-#[cfg(not(feature = "log"))] macro_rules! info { ($($x:tt)*) => () }
-#[allow(unused)]
-#[cfg(not(feature = "log"))] macro_rules! warn { ($($x:tt)*) => () }
-#[allow(unused)]
-#[cfg(not(feature = "log"))] macro_rules! error { ($($x:tt)*) => () }
-
-
-// Re-exports from rand_core
-pub use rand_core::{RngCore, CryptoRng, SeedableRng};
-pub use rand_core::{ErrorKind, Error};
-
-// Public exports
-#[cfg(feature="std")] pub use rngs::thread::thread_rng;
-
-// Public modules
-pub mod distributions;
-pub mod prelude;
-#[deprecated(since="0.6.0")]
-pub mod prng;
-pub mod rngs;
-pub mod seq;
-
-////////////////////////////////////////////////////////////////////////////////
-// Compatibility re-exports. Documentation is hidden; will be removed eventually.
-
-#[doc(hidden)] mod deprecated;
-
-#[allow(deprecated)]
-#[doc(hidden)] pub use deprecated::ReseedingRng;
-
-#[allow(deprecated)]
-#[cfg(feature="std")] #[doc(hidden)] pub use deprecated::EntropyRng;
-
-#[allow(deprecated)]
-#[cfg(feature="rand_os")]
-#[doc(hidden)]
-pub use deprecated::OsRng;
-
-#[allow(deprecated)]
-#[doc(hidden)] pub use deprecated::{ChaChaRng, IsaacRng, Isaac64Rng, XorShiftRng};
-#[allow(deprecated)]
-#[doc(hidden)] pub use deprecated::StdRng;
-
-
-#[allow(deprecated)]
-#[doc(hidden)]
-pub mod jitter {
- pub use deprecated::JitterRng;
- pub use rngs::TimerError;
-}
-#[allow(deprecated)]
-#[cfg(feature="rand_os")]
-#[doc(hidden)]
-pub mod os {
- pub use deprecated::OsRng;
-}
-#[allow(deprecated)]
-#[doc(hidden)]
-pub mod chacha {
- pub use deprecated::ChaChaRng;
-}
-#[allow(deprecated)]
-#[doc(hidden)]
-pub mod isaac {
- pub use deprecated::{IsaacRng, Isaac64Rng};
-}
-#[allow(deprecated)]
-#[cfg(feature="std")]
-#[doc(hidden)]
-pub mod read {
- pub use deprecated::ReadRng;
-}
-
-#[allow(deprecated)]
-#[cfg(feature="std")] #[doc(hidden)] pub use deprecated::ThreadRng;
-
-////////////////////////////////////////////////////////////////////////////////
-
-
-use core::{mem, slice};
-use distributions::{Distribution, Standard};
-use distributions::uniform::{SampleUniform, UniformSampler, SampleBorrow};
-
-/// An automatically-implemented extension trait on [`RngCore`] providing high-level
-/// generic methods for sampling values and other convenience methods.
-///
-/// This is the primary trait to use when generating random values.
-///
-/// # Generic usage
-///
-/// The basic pattern is `fn foo<R: Rng + ?Sized>(rng: &mut R)`. Some
-/// things are worth noting here:
-///
-/// - Since `Rng: RngCore` and every `RngCore` implements `Rng`, it makes no
-/// difference whether we use `R: Rng` or `R: RngCore`.
-/// - The `+ ?Sized` un-bounding allows functions to be called directly on
-/// type-erased references; i.e. `foo(r)` where `r: &mut RngCore`. Without
-/// this it would be necessary to write `foo(&mut r)`.
-///
-/// An alternative pattern is possible: `fn foo<R: Rng>(rng: R)`. This has some
-/// trade-offs. It allows the argument to be consumed directly without a `&mut`
-/// (which is how `from_rng(thread_rng())` works); also it still works directly
-/// on references (including type-erased references). Unfortunately within the
-/// function `foo` it is not known whether `rng` is a reference type or not,
-/// hence many uses of `rng` require an extra reference, either explicitly
-/// (`distr.sample(&mut rng)`) or implicitly (`rng.gen()`); one may hope the
-/// optimiser can remove redundant references later.
-///
-/// Example:
-///
-/// ```
-/// # use rand::thread_rng;
-/// use rand::Rng;
-///
-/// fn foo<R: Rng + ?Sized>(rng: &mut R) -> f32 {
-/// rng.gen()
-/// }
-///
-/// # let v = foo(&mut thread_rng());
-/// ```
-///
-/// [`RngCore`]: trait.RngCore.html
-pub trait Rng: RngCore {
- /// Return a random value supporting the [`Standard`] distribution.
- ///
- /// [`Standard`]: distributions/struct.Standard.html
- ///
- /// # Example
- ///
- /// ```
- /// use rand::{thread_rng, Rng};
- ///
- /// let mut rng = thread_rng();
- /// let x: u32 = rng.gen();
- /// println!("{}", x);
- /// println!("{:?}", rng.gen::<(f64, bool)>());
- /// ```
- #[inline]
- fn gen<T>(&mut self) -> T where Standard: Distribution<T> {
- Standard.sample(self)
- }
-
- /// Generate a random value in the range [`low`, `high`), i.e. inclusive of
- /// `low` and exclusive of `high`.
- ///
- /// This function is optimised for the case that only a single sample is
- /// made from the given range. See also the [`Uniform`] distribution
- /// type which may be faster if sampling from the same range repeatedly.
- ///
- /// # Panics
- ///
- /// Panics if `low >= high`.
- ///
- /// # Example
- ///
- /// ```
- /// use rand::{thread_rng, Rng};
- ///
- /// let mut rng = thread_rng();
- /// let n: u32 = rng.gen_range(0, 10);
- /// println!("{}", n);
- /// let m: f64 = rng.gen_range(-40.0f64, 1.3e5f64);
- /// println!("{}", m);
- /// ```
- ///
- /// [`Uniform`]: distributions/uniform/struct.Uniform.html
- fn gen_range<T: SampleUniform, B1, B2>(&mut self, low: B1, high: B2) -> T
- where B1: SampleBorrow<T> + Sized,
- B2: SampleBorrow<T> + Sized {
- T::Sampler::sample_single(low, high, self)
- }
-
- /// Sample a new value, using the given distribution.
- ///
- /// ### Example
- ///
- /// ```
- /// use rand::{thread_rng, Rng};
- /// use rand::distributions::Uniform;
- ///
- /// let mut rng = thread_rng();
- /// let x = rng.sample(Uniform::new(10u32, 15));
- /// // Type annotation requires two types, the type and distribution; the
- /// // distribution can be inferred.
- /// let y = rng.sample::<u16, _>(Uniform::new(10, 15));
- /// ```
- fn sample<T, D: Distribution<T>>(&mut self, distr: D) -> T {
- distr.sample(self)
- }
-
- /// Create an iterator that generates values using the given distribution.
- ///
- /// # Example
- ///
- /// ```
- /// use rand::{thread_rng, Rng};
- /// use rand::distributions::{Alphanumeric, Uniform, Standard};
- ///
- /// let mut rng = thread_rng();
- ///
- /// // Vec of 16 x f32:
- /// let v: Vec<f32> = thread_rng().sample_iter(&Standard).take(16).collect();
- ///
- /// // String:
- /// let s: String = rng.sample_iter(&Alphanumeric).take(7).collect();
- ///
- /// // Combined values
- /// println!("{:?}", thread_rng().sample_iter(&Standard).take(5)
- /// .collect::<Vec<(f64, bool)>>());
- ///
- /// // Dice-rolling:
- /// let die_range = Uniform::new_inclusive(1, 6);
- /// let mut roll_die = rng.sample_iter(&die_range);
- /// while roll_die.next().unwrap() != 6 {
- /// println!("Not a 6; rolling again!");
- /// }
- /// ```
- fn sample_iter<'a, T, D: Distribution<T>>(&'a mut self, distr: &'a D)
- -> distributions::DistIter<'a, D, Self, T> where Self: Sized
- {
- distr.sample_iter(self)
- }
-
- /// Fill `dest` entirely with random bytes (uniform value distribution),
- /// where `dest` is any type supporting [`AsByteSliceMut`], namely slices
- /// and arrays over primitive integer types (`i8`, `i16`, `u32`, etc.).
- ///
- /// On big-endian platforms this performs byte-swapping to ensure
- /// portability of results from reproducible generators.
- ///
- /// This uses [`fill_bytes`] internally which may handle some RNG errors
- /// implicitly (e.g. waiting if the OS generator is not ready), but panics
- /// on other errors. See also [`try_fill`] which returns errors.
- ///
- /// # Example
- ///
- /// ```
- /// use rand::{thread_rng, Rng};
- ///
- /// let mut arr = [0i8; 20];
- /// thread_rng().fill(&mut arr[..]);
- /// ```
- ///
- /// [`fill_bytes`]: trait.RngCore.html#method.fill_bytes
- /// [`try_fill`]: trait.Rng.html#method.try_fill
- /// [`AsByteSliceMut`]: trait.AsByteSliceMut.html
- fn fill<T: AsByteSliceMut + ?Sized>(&mut self, dest: &mut T) {
- self.fill_bytes(dest.as_byte_slice_mut());
- dest.to_le();
- }
-
- /// Fill `dest` entirely with random bytes (uniform value distribution),
- /// where `dest` is any type supporting [`AsByteSliceMut`], namely slices
- /// and arrays over primitive integer types (`i8`, `i16`, `u32`, etc.).
- ///
- /// On big-endian platforms this performs byte-swapping to ensure
- /// portability of results from reproducible generators.
- ///
- /// This uses [`try_fill_bytes`] internally and forwards all RNG errors. In
- /// some cases errors may be resolvable; see [`ErrorKind`] and
- /// documentation for the RNG in use. If you do not plan to handle these
- /// errors you may prefer to use [`fill`].
- ///
- /// # Example
- ///
- /// ```
- /// # use rand::Error;
- /// use rand::{thread_rng, Rng};
- ///
- /// # fn try_inner() -> Result<(), Error> {
- /// let mut arr = [0u64; 4];
- /// thread_rng().try_fill(&mut arr[..])?;
- /// # Ok(())
- /// # }
- ///
- /// # try_inner().unwrap()
- /// ```
- ///
- /// [`ErrorKind`]: enum.ErrorKind.html
- /// [`try_fill_bytes`]: trait.RngCore.html#method.try_fill_bytes
- /// [`fill`]: trait.Rng.html#method.fill
- /// [`AsByteSliceMut`]: trait.AsByteSliceMut.html
- fn try_fill<T: AsByteSliceMut + ?Sized>(&mut self, dest: &mut T) -> Result<(), Error> {
- self.try_fill_bytes(dest.as_byte_slice_mut())?;
- dest.to_le();
- Ok(())
- }
-
- /// Return a bool with a probability `p` of being true.
- ///
- /// See also the [`Bernoulli`] distribution, which may be faster if
- /// sampling from the same probability repeatedly.
- ///
- /// # Example
- ///
- /// ```
- /// use rand::{thread_rng, Rng};
- ///
- /// let mut rng = thread_rng();
- /// println!("{}", rng.gen_bool(1.0 / 3.0));
- /// ```
- ///
- /// # Panics
- ///
- /// If `p < 0` or `p > 1`.
- ///
- /// [`Bernoulli`]: distributions/bernoulli/struct.Bernoulli.html
- #[inline]
- fn gen_bool(&mut self, p: f64) -> bool {
- let d = distributions::Bernoulli::new(p);
- self.sample(d)
- }
-
- /// Return a bool with a probability of `numerator/denominator` of being
- /// true. I.e. `gen_ratio(2, 3)` has chance of 2 in 3, or about 67%, of
- /// returning true. If `numerator == denominator`, then the returned value
- /// is guaranteed to be `true`. If `numerator == 0`, then the returned
- /// value is guaranteed to be `false`.
- ///
- /// See also the [`Bernoulli`] distribution, which may be faster if
- /// sampling from the same `numerator` and `denominator` repeatedly.
- ///
- /// # Panics
- ///
- /// If `denominator == 0` or `numerator > denominator`.
- ///
- /// # Example
- ///
- /// ```
- /// use rand::{thread_rng, Rng};
- ///
- /// let mut rng = thread_rng();
- /// println!("{}", rng.gen_ratio(2, 3));
- /// ```
- ///
- /// [`Bernoulli`]: distributions/bernoulli/struct.Bernoulli.html
- #[inline]
- fn gen_ratio(&mut self, numerator: u32, denominator: u32) -> bool {
- let d = distributions::Bernoulli::from_ratio(numerator, denominator);
- self.sample(d)
- }
-
- /// Return a random element from `values`.
- ///
- /// Deprecated: use [`SliceRandom::choose`] instead.
- ///
- /// [`SliceRandom::choose`]: seq/trait.SliceRandom.html#method.choose
- #[deprecated(since="0.6.0", note="use SliceRandom::choose instead")]
- fn choose<'a, T>(&mut self, values: &'a [T]) -> Option<&'a T> {
- use seq::SliceRandom;
- values.choose(self)
- }
-
- /// Return a mutable pointer to a random element from `values`.
- ///
- /// Deprecated: use [`SliceRandom::choose_mut`] instead.
- ///
- /// [`SliceRandom::choose_mut`]: seq/trait.SliceRandom.html#method.choose_mut
- #[deprecated(since="0.6.0", note="use SliceRandom::choose_mut instead")]
- fn choose_mut<'a, T>(&mut self, values: &'a mut [T]) -> Option<&'a mut T> {
- use seq::SliceRandom;
- values.choose_mut(self)
- }
-
- /// Shuffle a mutable slice in place.
- ///
- /// Deprecated: use [`SliceRandom::shuffle`] instead.
- ///
- /// [`SliceRandom::shuffle`]: seq/trait.SliceRandom.html#method.shuffle
- #[deprecated(since="0.6.0", note="use SliceRandom::shuffle instead")]
- fn shuffle<T>(&mut self, values: &mut [T]) {
- use seq::SliceRandom;
- values.shuffle(self)
- }
-}
-
-impl<R: RngCore + ?Sized> Rng for R {}
-
-/// Trait for casting types to byte slices
-///
-/// This is used by the [`fill`] and [`try_fill`] methods.
-///
-/// [`fill`]: trait.Rng.html#method.fill
-/// [`try_fill`]: trait.Rng.html#method.try_fill
-pub trait AsByteSliceMut {
- /// Return a mutable reference to self as a byte slice
- fn as_byte_slice_mut(&mut self) -> &mut [u8];
-
- /// Call `to_le` on each element (i.e. byte-swap on Big Endian platforms).
- fn to_le(&mut self);
-}
-
-impl AsByteSliceMut for [u8] {
- fn as_byte_slice_mut(&mut self) -> &mut [u8] {
- self
- }
-
- fn to_le(&mut self) {}
-}
-
-macro_rules! impl_as_byte_slice {
- ($t:ty) => {
- impl AsByteSliceMut for [$t] {
- fn as_byte_slice_mut(&mut self) -> &mut [u8] {
- if self.len() == 0 {
- unsafe {
- // must not use null pointer
- slice::from_raw_parts_mut(0x1 as *mut u8, 0)
- }
- } else {
- unsafe {
- slice::from_raw_parts_mut(&mut self[0]
- as *mut $t
- as *mut u8,
- self.len() * mem::size_of::<$t>()
- )
- }
- }
- }
-
- fn to_le(&mut self) {
- for x in self {
- *x = x.to_le();
- }
- }
- }
- }
-}
-
-impl_as_byte_slice!(u16);
-impl_as_byte_slice!(u32);
-impl_as_byte_slice!(u64);
-#[cfg(all(rustc_1_26, not(target_os = "emscripten")))] impl_as_byte_slice!(u128);
-impl_as_byte_slice!(usize);
-impl_as_byte_slice!(i8);
-impl_as_byte_slice!(i16);
-impl_as_byte_slice!(i32);
-impl_as_byte_slice!(i64);
-#[cfg(all(rustc_1_26, not(target_os = "emscripten")))] impl_as_byte_slice!(i128);
-impl_as_byte_slice!(isize);
-
-macro_rules! impl_as_byte_slice_arrays {
- ($n:expr,) => {};
- ($n:expr, $N:ident, $($NN:ident,)*) => {
- impl_as_byte_slice_arrays!($n - 1, $($NN,)*);
-
- impl<T> AsByteSliceMut for [T; $n] where [T]: AsByteSliceMut {
- fn as_byte_slice_mut(&mut self) -> &mut [u8] {
- self[..].as_byte_slice_mut()
- }
-
- fn to_le(&mut self) {
- self[..].to_le()
- }
- }
- };
- (!div $n:expr,) => {};
- (!div $n:expr, $N:ident, $($NN:ident,)*) => {
- impl_as_byte_slice_arrays!(!div $n / 2, $($NN,)*);
-
- impl<T> AsByteSliceMut for [T; $n] where [T]: AsByteSliceMut {
- fn as_byte_slice_mut(&mut self) -> &mut [u8] {
- self[..].as_byte_slice_mut()
- }
-
- fn to_le(&mut self) {
- self[..].to_le()
- }
- }
- };
-}
-impl_as_byte_slice_arrays!(32, N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,);
-impl_as_byte_slice_arrays!(!div 4096, N,N,N,N,N,N,N,);
-
-
-/// A convenience extension to [`SeedableRng`] allowing construction from fresh
-/// entropy. This trait is automatically implemented for any PRNG implementing
-/// [`SeedableRng`] and is not intended to be implemented by users.
-///
-/// This is equivalent to using `SeedableRng::from_rng(EntropyRng::new())` then
-/// unwrapping the result.
-///
-/// Since this is convenient and secure, it is the recommended way to create
-/// PRNGs, though two alternatives may be considered:
-///
-/// * Deterministic creation using [`SeedableRng::from_seed`] with a fixed seed
-/// * Seeding from `thread_rng`: `SeedableRng::from_rng(thread_rng())?`;
-/// this will usually be faster and should also be secure, but requires
-/// trusting one extra component.
-///
-/// ## Example
-///
-/// ```
-/// use rand::{Rng, FromEntropy};
-/// use rand::rngs::StdRng;
-///
-/// let mut rng = StdRng::from_entropy();
-/// println!("Random die roll: {}", rng.gen_range(1, 7));
-/// ```
-///
-/// [`EntropyRng`]: rngs/struct.EntropyRng.html
-/// [`SeedableRng`]: trait.SeedableRng.html
-/// [`SeedableRng::from_seed`]: trait.SeedableRng.html#tymethod.from_seed
-#[cfg(feature="std")]
-pub trait FromEntropy: SeedableRng {
- /// Creates a new instance, automatically seeded with fresh entropy.
- ///
- /// Normally this will use `OsRng`, but if that fails `JitterRng` will be
- /// used instead. Both should be suitable for cryptography. It is possible
- /// that both entropy sources will fail though unlikely; failures would
- /// almost certainly be platform limitations or build issues, i.e. most
- /// applications targetting PC/mobile platforms should not need to worry
- /// about this failing.
- ///
- /// # Panics
- ///
- /// If all entropy sources fail this will panic. If you need to handle
- /// errors, use the following code, equivalent aside from error handling:
- ///
- /// ```
- /// # use rand::Error;
- /// use rand::prelude::*;
- /// use rand::rngs::EntropyRng;
- ///
- /// # fn try_inner() -> Result<(), Error> {
- /// // This uses StdRng, but is valid for any R: SeedableRng
- /// let mut rng = StdRng::from_rng(EntropyRng::new())?;
- ///
- /// println!("random number: {}", rng.gen_range(1, 10));
- /// # Ok(())
- /// # }
- ///
- /// # try_inner().unwrap()
- /// ```
- fn from_entropy() -> Self;
-}
-
-#[cfg(feature="std")]
-impl<R: SeedableRng> FromEntropy for R {
- fn from_entropy() -> R {
- R::from_rng(rngs::EntropyRng::new()).unwrap_or_else(|err|
- panic!("FromEntropy::from_entropy() failed: {}", err))
- }
-}
-
-
-/// Generates a random value using the thread-local random number generator.
-///
-/// This is simply a shortcut for `thread_rng().gen()`. See [`thread_rng`] for
-/// documentation of the entropy source and [`Standard`] for documentation of
-/// distributions and type-specific generation.
-///
-/// # Examples
-///
-/// ```
-/// let x = rand::random::<u8>();
-/// println!("{}", x);
-///
-/// let y = rand::random::<f64>();
-/// println!("{}", y);
-///
-/// if rand::random() { // generates a boolean
-/// println!("Better lucky than good!");
-/// }
-/// ```
-///
-/// If you're calling `random()` in a loop, caching the generator as in the
-/// following example can increase performance.
-///
-/// ```
-/// use rand::Rng;
-///
-/// let mut v = vec![1, 2, 3];
-///
-/// for x in v.iter_mut() {
-/// *x = rand::random()
-/// }
-///
-/// // can be made faster by caching thread_rng
-///
-/// let mut rng = rand::thread_rng();
-///
-/// for x in v.iter_mut() {
-/// *x = rng.gen();
-/// }
-/// ```
-///
-/// [`thread_rng`]: fn.thread_rng.html
-/// [`Standard`]: distributions/struct.Standard.html
-#[cfg(feature="std")]
-#[inline]
-pub fn random<T>() -> T where Standard: Distribution<T> {
- thread_rng().gen()
-}
-
-#[cfg(test)]
-mod test {
- use rngs::mock::StepRng;
- use rngs::StdRng;
- use super::*;
- #[cfg(all(not(feature="std"), feature="alloc"))] use alloc::boxed::Box;
-
- pub struct TestRng<R> { inner: R }
-
- impl<R: RngCore> RngCore for TestRng<R> {
- fn next_u32(&mut self) -> u32 {
- self.inner.next_u32()
- }
- fn next_u64(&mut self) -> u64 {
- self.inner.next_u64()
- }
- fn fill_bytes(&mut self, dest: &mut [u8]) {
- self.inner.fill_bytes(dest)
- }
- fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), Error> {
- self.inner.try_fill_bytes(dest)
- }
- }
-
- pub fn rng(seed: u64) -> TestRng<StdRng> {
- TestRng { inner: StdRng::seed_from_u64(seed) }
- }
-
- #[test]
- fn test_fill_bytes_default() {
- let mut r = StepRng::new(0x11_22_33_44_55_66_77_88, 0);
-
- // check every remainder mod 8, both in small and big vectors.
- let lengths = [0, 1, 2, 3, 4, 5, 6, 7,
- 80, 81, 82, 83, 84, 85, 86, 87];
- for &n in lengths.iter() {
- let mut buffer = [0u8; 87];
- let v = &mut buffer[0..n];
- r.fill_bytes(v);
-
- // use this to get nicer error messages.
- for (i, &byte) in v.iter().enumerate() {
- if byte == 0 {
- panic!("byte {} of {} is zero", i, n)
- }
- }
- }
- }
-
- #[test]
- fn test_fill() {
- let x = 9041086907909331047; // a random u64
- let mut rng = StepRng::new(x, 0);
-
- // Convert to byte sequence and back to u64; byte-swap twice if BE.
- let mut array = [0u64; 2];
- rng.fill(&mut array[..]);
- assert_eq!(array, [x, x]);
- assert_eq!(rng.next_u64(), x);
-
- // Convert to bytes then u32 in LE order
- let mut array = [0u32; 2];
- rng.fill(&mut array[..]);
- assert_eq!(array, [x as u32, (x >> 32) as u32]);
- assert_eq!(rng.next_u32(), x as u32);
- }
-
- #[test]
- fn test_fill_empty() {
- let mut array = [0u32; 0];
- let mut rng = StepRng::new(0, 1);
- rng.fill(&mut array);
- rng.fill(&mut array[..]);
- }
-
- #[test]
- fn test_gen_range() {
- let mut r = rng(101);
- for _ in 0..1000 {
- let a = r.gen_range(-4711, 17);
- assert!(a >= -4711 && a < 17);
- let a = r.gen_range(-3i8, 42);
- assert!(a >= -3i8 && a < 42i8);
- let a = r.gen_range(&10u16, 99);
- assert!(a >= 10u16 && a < 99u16);
- let a = r.gen_range(-100i32, &2000);
- assert!(a >= -100i32 && a < 2000i32);
- let a = r.gen_range(&12u32, &24u32);
- assert!(a >= 12u32 && a < 24u32);
-
- assert_eq!(r.gen_range(0u32, 1), 0u32);
- assert_eq!(r.gen_range(-12i64, -11), -12i64);
- assert_eq!(r.gen_range(3_000_000, 3_000_001), 3_000_000);
- }
- }
-
- #[test]
- #[should_panic]
- fn test_gen_range_panic_int() {
- let mut r = rng(102);
- r.gen_range(5, -2);
- }
-
- #[test]
- #[should_panic]
- fn test_gen_range_panic_usize() {
- let mut r = rng(103);
- r.gen_range(5, 2);
- }
-
- #[test]
- fn test_gen_bool() {
- let mut r = rng(105);
- for _ in 0..5 {
- assert_eq!(r.gen_bool(0.0), false);
- assert_eq!(r.gen_bool(1.0), true);
- }
- }
-
- #[test]
- fn test_rng_trait_object() {
- use distributions::{Distribution, Standard};
- let mut rng = rng(109);
- let mut r = &mut rng as &mut RngCore;
- r.next_u32();
- r.gen::<i32>();
- assert_eq!(r.gen_range(0, 1), 0);
- let _c: u8 = Standard.sample(&mut r);
- }
-
- #[test]
- #[cfg(feature="alloc")]
- fn test_rng_boxed_trait() {
- use distributions::{Distribution, Standard};
- let rng = rng(110);
- let mut r = Box::new(rng) as Box<RngCore>;
- r.next_u32();
- r.gen::<i32>();
- assert_eq!(r.gen_range(0, 1), 0);
- let _c: u8 = Standard.sample(&mut r);
- }
-
- #[test]
- #[cfg(feature="std")]
- fn test_random() {
- // not sure how to test this aside from just getting some values
- let _n : usize = random();
- let _f : f32 = random();
- let _o : Option<Option<i8>> = random();
- let _many : ((),
- (usize,
- isize,
- Option<(u32, (bool,))>),
- (u8, i8, u16, i16, u32, i32, u64, i64),
- (f32, (f64, (f64,)))) = random();
- }
-
- #[test]
- fn test_gen_ratio_average() {
- const NUM: u32 = 3;
- const DENOM: u32 = 10;
- const N: u32 = 100_000;
-
- let mut sum: u32 = 0;
- let mut rng = rng(111);
- for _ in 0..N {
- if rng.gen_ratio(NUM, DENOM) {
- sum += 1;
- }
- }
- // Have Binomial(N, NUM/DENOM) distribution
- let expected = (NUM * N) / DENOM; // exact integer
- assert!(((sum - expected) as i32).abs() < 500);
- }
-}
diff --git a/rand/src/prelude.rs b/rand/src/prelude.rs
deleted file mode 100644
index 5d8a0e9..0000000
--- a/rand/src/prelude.rs
+++ /dev/null
@@ -1,27 +0,0 @@
-// Copyright 2018 Developers of the Rand project.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-//! Convenience re-export of common members
-//!
-//! Like the standard library's prelude, this module simplifies importing of
-//! common items. Unlike the standard prelude, the contents of this module must
-//! be imported manually:
-//!
-//! ```
-//! use rand::prelude::*;
-//! # let _ = StdRng::from_entropy();
-//! # let mut r = SmallRng::from_rng(thread_rng()).unwrap();
-//! # let _: f32 = r.gen();
-//! ```
-
-#[doc(no_inline)] pub use distributions::Distribution;
-#[doc(no_inline)] pub use rngs::{SmallRng, StdRng};
-#[doc(no_inline)] #[cfg(feature="std")] pub use rngs::ThreadRng;
-#[doc(no_inline)] pub use {Rng, RngCore, CryptoRng, SeedableRng};
-#[doc(no_inline)] #[cfg(feature="std")] pub use {FromEntropy, random, thread_rng};
-#[doc(no_inline)] pub use seq::{SliceRandom, IteratorRandom};
diff --git a/rand/src/prng/mod.rs b/rand/src/prng/mod.rs
deleted file mode 100644
index 3c0d27b..0000000
--- a/rand/src/prng/mod.rs
+++ /dev/null
@@ -1,37 +0,0 @@
-// Copyright 2018 Developers of the Rand project.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-//! Pseudo-random number generators.
-//!
-//! This module is deprecated:
-//!
-//! - documentation has moved to
-//! [The Book](https://rust-random.github.io/book/guide-rngs.html),
-//! - PRNGs have moved to other `rand_*` crates.
-
-// Deprecations (to be removed in 0.7)
-#[doc(hidden)] #[allow(deprecated)]
-pub use deprecated::XorShiftRng;
-#[doc(hidden)] pub mod isaac {
- // Note: we miss `IsaacCore` here but probably unimportant.
- #[allow(deprecated)] pub use deprecated::IsaacRng;
-}
-#[doc(hidden)] pub mod isaac64 {
- #[allow(deprecated)] pub use deprecated::Isaac64Rng;
-}
-#[doc(hidden)] #[allow(deprecated)] pub use deprecated::{IsaacRng, Isaac64Rng};
-#[doc(hidden)] pub mod chacha {
- // Note: we miss `ChaChaCore` here but probably unimportant.
- #[allow(deprecated)] pub use deprecated::ChaChaRng;
-}
-#[doc(hidden)] #[allow(deprecated)] pub use deprecated::ChaChaRng;
-#[doc(hidden)] pub mod hc128 {
- // Note: we miss `Hc128Core` here but probably unimportant.
- #[allow(deprecated)] pub use deprecated::Hc128Rng;
-}
-#[doc(hidden)] #[allow(deprecated)] pub use deprecated::Hc128Rng;
diff --git a/rand/src/rngs/adapter/mod.rs b/rand/src/rngs/adapter/mod.rs
deleted file mode 100644
index 60b832e..0000000
--- a/rand/src/rngs/adapter/mod.rs
+++ /dev/null
@@ -1,15 +0,0 @@
-// Copyright 2018 Developers of the Rand project.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-//! Wrappers / adapters forming RNGs
-
-#[cfg(feature="std")] #[doc(hidden)] pub mod read;
-mod reseeding;
-
-#[cfg(feature="std")] pub use self::read::ReadRng;
-pub use self::reseeding::ReseedingRng;
diff --git a/rand/src/rngs/adapter/read.rs b/rand/src/rngs/adapter/read.rs
deleted file mode 100644
index 30b6de6..0000000
--- a/rand/src/rngs/adapter/read.rs
+++ /dev/null
@@ -1,137 +0,0 @@
-// Copyright 2018 Developers of the Rand project.
-// Copyright 2013 The Rust Project Developers.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-//! A wrapper around any Read to treat it as an RNG.
-
-use std::io::Read;
-
-use rand_core::{RngCore, Error, ErrorKind, impls};
-
-
-/// An RNG that reads random bytes straight from any type supporting
-/// `std::io::Read`, for example files.
-///
-/// This will work best with an infinite reader, but that is not required.
-///
-/// This can be used with `/dev/urandom` on Unix but it is recommended to use
-/// [`OsRng`] instead.
-///
-/// # Panics
-///
-/// `ReadRng` uses `std::io::read_exact`, which retries on interrupts. All other
-/// errors from the underlying reader, including when it does not have enough
-/// data, will only be reported through [`try_fill_bytes`]. The other
-/// [`RngCore`] methods will panic in case of an error.
-///
-/// # Example
-///
-/// ```
-/// use rand::Rng;
-/// use rand::rngs::adapter::ReadRng;
-///
-/// let data = vec![1, 2, 3, 4, 5, 6, 7, 8];
-/// let mut rng = ReadRng::new(&data[..]);
-/// println!("{:x}", rng.gen::<u32>());
-/// ```
-///
-/// [`OsRng`]: ../struct.OsRng.html
-/// [`RngCore`]: ../../trait.RngCore.html
-/// [`try_fill_bytes`]: ../../trait.RngCore.html#method.tymethod.try_fill_bytes
-#[derive(Debug)]
-pub struct ReadRng<R> {
- reader: R
-}
-
-impl<R: Read> ReadRng<R> {
- /// Create a new `ReadRng` from a `Read`.
- pub fn new(r: R) -> ReadRng<R> {
- ReadRng {
- reader: r
- }
- }
-}
-
-impl<R: Read> RngCore for ReadRng<R> {
- fn next_u32(&mut self) -> u32 {
- impls::next_u32_via_fill(self)
- }
-
- fn next_u64(&mut self) -> u64 {
- impls::next_u64_via_fill(self)
- }
-
- fn fill_bytes(&mut self, dest: &mut [u8]) {
- self.try_fill_bytes(dest).unwrap_or_else(|err|
- panic!("reading random bytes from Read implementation failed; error: {}", err));
- }
-
- fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), Error> {
- if dest.len() == 0 { return Ok(()); }
- // Use `std::io::read_exact`, which retries on `ErrorKind::Interrupted`.
- self.reader.read_exact(dest).map_err(|err| {
- match err.kind() {
- ::std::io::ErrorKind::UnexpectedEof => Error::with_cause(
- ErrorKind::Unavailable,
- "not enough bytes available, reached end of source", err),
- _ => Error::with_cause(ErrorKind::Unavailable,
- "error reading from Read source", err)
- }
- })
- }
-}
-
-#[cfg(test)]
-mod test {
- use super::ReadRng;
- use {RngCore, ErrorKind};
-
- #[test]
- fn test_reader_rng_u64() {
- // transmute from the target to avoid endianness concerns.
- let v = vec![0u8, 0, 0, 0, 0, 0, 0, 1,
- 0 , 0, 0, 0, 0, 0, 0, 2,
- 0, 0, 0, 0, 0, 0, 0, 3];
- let mut rng = ReadRng::new(&v[..]);
-
- assert_eq!(rng.next_u64(), 1_u64.to_be());
- assert_eq!(rng.next_u64(), 2_u64.to_be());
- assert_eq!(rng.next_u64(), 3_u64.to_be());
- }
-
- #[test]
- fn test_reader_rng_u32() {
- let v = vec![0u8, 0, 0, 1, 0, 0, 0, 2, 0, 0, 0, 3];
- let mut rng = ReadRng::new(&v[..]);
-
- assert_eq!(rng.next_u32(), 1_u32.to_be());
- assert_eq!(rng.next_u32(), 2_u32.to_be());
- assert_eq!(rng.next_u32(), 3_u32.to_be());
- }
-
- #[test]
- fn test_reader_rng_fill_bytes() {
- let v = [1u8, 2, 3, 4, 5, 6, 7, 8];
- let mut w = [0u8; 8];
-
- let mut rng = ReadRng::new(&v[..]);
- rng.fill_bytes(&mut w);
-
- assert!(v == w);
- }
-
- #[test]
- fn test_reader_rng_insufficient_bytes() {
- let v = [1u8, 2, 3, 4, 5, 6, 7, 8];
- let mut w = [0u8; 9];
-
- let mut rng = ReadRng::new(&v[..]);
-
- assert!(rng.try_fill_bytes(&mut w).err().unwrap().kind == ErrorKind::Unavailable);
- }
-}
diff --git a/rand/src/rngs/adapter/reseeding.rs b/rand/src/rngs/adapter/reseeding.rs
deleted file mode 100644
index 016afab..0000000
--- a/rand/src/rngs/adapter/reseeding.rs
+++ /dev/null
@@ -1,370 +0,0 @@
-// Copyright 2018 Developers of the Rand project.
-// Copyright 2013 The Rust Project Developers.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-//! A wrapper around another PRNG that reseeds it after it
-//! generates a certain number of random bytes.
-
-use core::mem::size_of;
-
-use rand_core::{RngCore, CryptoRng, SeedableRng, Error, ErrorKind};
-use rand_core::block::{BlockRngCore, BlockRng};
-
-/// A wrapper around any PRNG that implements [`BlockRngCore`], that adds the
-/// ability to reseed it.
-///
-/// `ReseedingRng` reseeds the underlying PRNG in the following cases:
-///
-/// - On a manual call to [`reseed()`].
-/// - After `clone()`, the clone will be reseeded on first use.
-/// - After a process is forked, the RNG in the child process is reseeded within
-/// the next few generated values, depending on the block size of the
-/// underlying PRNG. For [`ChaChaCore`] and [`Hc128Core`] this is a maximum of
-/// 15 `u32` values before reseeding.
-/// - After the PRNG has generated a configurable number of random bytes.
-///
-/// # When should reseeding after a fixed number of generated bytes be used?
-///
-/// Reseeding after a fixed number of generated bytes is never strictly
-/// *necessary*. Cryptographic PRNGs don't have a limited number of bytes they
-/// can output, or at least not a limit reachable in any practical way. There is
-/// no such thing as 'running out of entropy'.
-///
-/// Occasionally reseeding can be seen as some form of 'security in depth'. Even
-/// if in the future a cryptographic weakness is found in the CSPRNG being used,
-/// or a flaw in the implementation, occasionally reseeding should make
-/// exploiting it much more difficult or even impossible.
-///
-/// Use [`ReseedingRng::new`] with a `threshold` of `0` to disable reseeding
-/// after a fixed number of generated bytes.
-///
-/// # Error handling
-///
-/// Although unlikely, reseeding the wrapped PRNG can fail. `ReseedingRng` will
-/// never panic but try to handle the error intelligently through some
-/// combination of retrying and delaying reseeding until later.
-/// If handling the source error fails `ReseedingRng` will continue generating
-/// data from the wrapped PRNG without reseeding.
-///
-/// Manually calling [`reseed()`] will not have this retry or delay logic, but
-/// reports the error.
-///
-/// # Example
-///
-/// ```
-/// # extern crate rand;
-/// # extern crate rand_chacha;
-/// # fn main() {
-/// use rand::prelude::*;
-/// use rand_chacha::ChaChaCore; // Internal part of ChaChaRng that
-/// // implements BlockRngCore
-/// use rand::rngs::OsRng;
-/// use rand::rngs::adapter::ReseedingRng;
-///
-/// let prng = ChaChaCore::from_entropy();
-// FIXME: it is better to use EntropyRng as reseeder, but that doesn't implement
-// clone yet.
-/// let reseeder = OsRng::new().unwrap();
-/// let mut reseeding_rng = ReseedingRng::new(prng, 0, reseeder);
-///
-/// println!("{}", reseeding_rng.gen::<u64>());
-///
-/// let mut cloned_rng = reseeding_rng.clone();
-/// assert!(reseeding_rng.gen::<u64>() != cloned_rng.gen::<u64>());
-/// # }
-/// ```
-///
-/// [`ChaChaCore`]: ../../../rand_chacha/struct.ChaChaCore.html
-/// [`Hc128Core`]: ../../../rand_hc/struct.Hc128Core.html
-/// [`BlockRngCore`]: ../../../rand_core/block/trait.BlockRngCore.html
-/// [`ReseedingRng::new`]: struct.ReseedingRng.html#method.new
-/// [`reseed()`]: struct.ReseedingRng.html#method.reseed
-#[derive(Debug)]
-pub struct ReseedingRng<R, Rsdr>(BlockRng<ReseedingCore<R, Rsdr>>)
-where R: BlockRngCore + SeedableRng,
- Rsdr: RngCore;
-
-impl<R, Rsdr> ReseedingRng<R, Rsdr>
-where R: BlockRngCore + SeedableRng,
- Rsdr: RngCore
-{
- /// Create a new `ReseedingRng` from an existing PRNG, combined with a RNG
- /// to use as reseeder.
- ///
- /// `threshold` sets the number of generated bytes after which to reseed the
- /// PRNG. Set it to zero to never reseed based on the number of generated
- /// values.
- pub fn new(rng: R, threshold: u64, reseeder: Rsdr) -> Self {
- ReseedingRng(BlockRng::new(ReseedingCore::new(rng, threshold, reseeder)))
- }
-
- /// Reseed the internal PRNG.
- pub fn reseed(&mut self) -> Result<(), Error> {
- self.0.core.reseed()
- }
-}
-
-// TODO: this should be implemented for any type where the inner type
-// implements RngCore, but we can't specify that because ReseedingCore is private
-impl<R, Rsdr: RngCore> RngCore for ReseedingRng<R, Rsdr>
-where R: BlockRngCore<Item = u32> + SeedableRng,
- <R as BlockRngCore>::Results: AsRef<[u32]> + AsMut<[u32]>
-{
- #[inline(always)]
- fn next_u32(&mut self) -> u32 {
- self.0.next_u32()
- }
-
- #[inline(always)]
- fn next_u64(&mut self) -> u64 {
- self.0.next_u64()
- }
-
- fn fill_bytes(&mut self, dest: &mut [u8]) {
- self.0.fill_bytes(dest)
- }
-
- fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), Error> {
- self.0.try_fill_bytes(dest)
- }
-}
-
-impl<R, Rsdr> Clone for ReseedingRng<R, Rsdr>
-where R: BlockRngCore + SeedableRng + Clone,
- Rsdr: RngCore + Clone
-{
- fn clone(&self) -> ReseedingRng<R, Rsdr> {
- // Recreating `BlockRng` seems easier than cloning it and resetting
- // the index.
- ReseedingRng(BlockRng::new(self.0.core.clone()))
- }
-}
-
-impl<R, Rsdr> CryptoRng for ReseedingRng<R, Rsdr>
-where R: BlockRngCore + SeedableRng + CryptoRng,
- Rsdr: RngCore + CryptoRng {}
-
-#[derive(Debug)]
-struct ReseedingCore<R, Rsdr> {
- inner: R,
- reseeder: Rsdr,
- threshold: i64,
- bytes_until_reseed: i64,
- fork_counter: usize,
-}
-
-impl<R, Rsdr> BlockRngCore for ReseedingCore<R, Rsdr>
-where R: BlockRngCore + SeedableRng,
- Rsdr: RngCore
-{
- type Item = <R as BlockRngCore>::Item;
- type Results = <R as BlockRngCore>::Results;
-
- fn generate(&mut self, results: &mut Self::Results) {
- let global_fork_counter = fork::get_fork_counter();
- if self.bytes_until_reseed <= 0 ||
- self.is_forked(global_fork_counter) {
- // We get better performance by not calling only `reseed` here
- // and continuing with the rest of the function, but by directly
- // returning from a non-inlined function.
- return self.reseed_and_generate(results, global_fork_counter);
- }
- let num_bytes = results.as_ref().len() * size_of::<Self::Item>();
- self.bytes_until_reseed -= num_bytes as i64;
- self.inner.generate(results);
- }
-}
-
-impl<R, Rsdr> ReseedingCore<R, Rsdr>
-where R: BlockRngCore + SeedableRng,
- Rsdr: RngCore
-{
- /// Create a new `ReseedingCore`.
- fn new(rng: R, threshold: u64, reseeder: Rsdr) -> Self {
- use ::core::i64::MAX;
- fork::register_fork_handler();
-
- // Because generating more values than `i64::MAX` takes centuries on
- // current hardware, we just clamp to that value.
- // Also we set a threshold of 0, which indicates no limit, to that
- // value.
- let threshold =
- if threshold == 0 { MAX }
- else if threshold <= MAX as u64 { threshold as i64 }
- else { MAX };
-
- ReseedingCore {
- inner: rng,
- reseeder,
- threshold: threshold as i64,
- bytes_until_reseed: threshold as i64,
- fork_counter: 0,
- }
- }
-
- /// Reseed the internal PRNG.
- fn reseed(&mut self) -> Result<(), Error> {
- R::from_rng(&mut self.reseeder).map(|result| {
- self.bytes_until_reseed = self.threshold;
- self.inner = result
- })
- }
-
- fn is_forked(&self, global_fork_counter: usize) -> bool {
- // In theory, on 32-bit platforms, it is possible for
- // `global_fork_counter` to wrap around after ~4e9 forks.
- //
- // This check will detect a fork in the normal case where
- // `fork_counter < global_fork_counter`, and also when the difference
- // between both is greater than `isize::MAX` (wrapped around).
- //
- // It will still fail to detect a fork if there have been more than
- // `isize::MAX` forks, without any reseed in between. Seems unlikely
- // enough.
- (self.fork_counter.wrapping_sub(global_fork_counter) as isize) < 0
- }
-
- #[inline(never)]
- fn reseed_and_generate(&mut self,
- results: &mut <Self as BlockRngCore>::Results,
- global_fork_counter: usize)
- {
- if self.is_forked(global_fork_counter) {
- info!("Fork detected, reseeding RNG");
- } else {
- trace!("Reseeding RNG (periodic reseed)");
- }
-
- let num_bytes =
- results.as_ref().len() * size_of::<<R as BlockRngCore>::Item>();
-
- let threshold = if let Err(e) = self.reseed() {
- let delay = match e.kind {
- ErrorKind::Transient => num_bytes as i64,
- kind @ _ if kind.should_retry() => self.threshold >> 8,
- _ => self.threshold,
- };
- warn!("Reseeding RNG delayed reseeding by {} bytes due to \
- error from source: {}", delay, e);
- delay
- } else {
- self.fork_counter = global_fork_counter;
- self.threshold
- };
-
- self.bytes_until_reseed = threshold - num_bytes as i64;
- self.inner.generate(results);
- }
-}
-
-impl<R, Rsdr> Clone for ReseedingCore<R, Rsdr>
-where R: BlockRngCore + SeedableRng + Clone,
- Rsdr: RngCore + Clone
-{
- fn clone(&self) -> ReseedingCore<R, Rsdr> {
- ReseedingCore {
- inner: self.inner.clone(),
- reseeder: self.reseeder.clone(),
- threshold: self.threshold,
- bytes_until_reseed: 0, // reseed clone on first use
- fork_counter: self.fork_counter,
- }
- }
-}
-
-impl<R, Rsdr> CryptoRng for ReseedingCore<R, Rsdr>
-where R: BlockRngCore + SeedableRng + CryptoRng,
- Rsdr: RngCore + CryptoRng {}
-
-
-#[cfg(all(feature="std", unix, not(target_os="emscripten")))]
-mod fork {
- extern crate libc;
-
- use std::sync::atomic::{AtomicUsize, ATOMIC_USIZE_INIT, Ordering};
- use std::sync::atomic::{AtomicBool, ATOMIC_BOOL_INIT};
-
- // Fork protection
- //
- // We implement fork protection on Unix using `pthread_atfork`.
- // When the process is forked, we increment `RESEEDING_RNG_FORK_COUNTER`.
- // Every `ReseedingRng` stores the last known value of the static in
- // `fork_counter`. If the cached `fork_counter` is less than
- // `RESEEDING_RNG_FORK_COUNTER`, it is time to reseed this RNG.
- //
- // If reseeding fails, we don't deal with this by setting a delay, but just
- // don't update `fork_counter`, so a reseed is attempted as soon as
- // possible.
-
- static RESEEDING_RNG_FORK_COUNTER: AtomicUsize = ATOMIC_USIZE_INIT;
-
- pub fn get_fork_counter() -> usize {
- RESEEDING_RNG_FORK_COUNTER.load(Ordering::Relaxed)
- }
-
- static FORK_HANDLER_REGISTERED: AtomicBool = ATOMIC_BOOL_INIT;
-
- extern fn fork_handler() {
- // Note: fetch_add is defined to wrap on overflow
- // (which is what we want).
- RESEEDING_RNG_FORK_COUNTER.fetch_add(1, Ordering::Relaxed);
- }
-
- pub fn register_fork_handler() {
- if FORK_HANDLER_REGISTERED.load(Ordering::Relaxed) == false {
- unsafe { libc::pthread_atfork(None, None, Some(fork_handler)) };
- FORK_HANDLER_REGISTERED.store(true, Ordering::Relaxed);
- }
- }
-}
-
-#[cfg(not(all(feature="std", unix, not(target_os="emscripten"))))]
-mod fork {
- pub fn get_fork_counter() -> usize { 0 }
- pub fn register_fork_handler() {}
-}
-
-
-#[cfg(test)]
-mod test {
- use {Rng, SeedableRng};
- use rand_chacha::ChaChaCore;
- use rngs::mock::StepRng;
- use super::ReseedingRng;
-
- #[test]
- fn test_reseeding() {
- let mut zero = StepRng::new(0, 0);
- let rng = ChaChaCore::from_rng(&mut zero).unwrap();
- let mut reseeding = ReseedingRng::new(rng, 32*4, zero);
-
- // Currently we only support for arrays up to length 32.
- // TODO: cannot generate seq via Rng::gen because it uses different alg
- let mut buf = [0u32; 32]; // Needs to be a multiple of the RNGs result
- // size to test exactly.
- reseeding.fill(&mut buf);
- let seq = buf;
- for _ in 0..10 {
- reseeding.fill(&mut buf);
- assert_eq!(buf, seq);
- }
- }
-
- #[test]
- fn test_clone_reseeding() {
- let mut zero = StepRng::new(0, 0);
- let rng = ChaChaCore::from_rng(&mut zero).unwrap();
- let mut rng1 = ReseedingRng::new(rng, 32*4, zero);
-
- let first: u32 = rng1.gen();
- for _ in 0..10 { let _ = rng1.gen::<u32>(); }
-
- let mut rng2 = rng1.clone();
- assert_eq!(first, rng2.gen::<u32>());
- }
-}
diff --git a/rand/src/rngs/entropy.rs b/rand/src/rngs/entropy.rs
deleted file mode 100644
index 372b4d7..0000000
--- a/rand/src/rngs/entropy.rs
+++ /dev/null
@@ -1,249 +0,0 @@
-// Copyright 2018 Developers of the Rand project.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-//! Entropy generator, or wrapper around external generators
-
-use rand_core::{RngCore, CryptoRng, Error, ErrorKind, impls};
-#[allow(unused)]
-use rngs;
-
-/// An interface returning random data from external source(s), provided
-/// specifically for securely seeding algorithmic generators (PRNGs).
-///
-/// Where possible, `EntropyRng` retrieves random data from the operating
-/// system's interface for random numbers ([`OsRng`]); if that fails it will
-/// fall back to the [`JitterRng`] entropy collector. In the latter case it will
-/// still try to use [`OsRng`] on the next usage.
-///
-/// If no secure source of entropy is available `EntropyRng` will panic on use;
-/// i.e. it should never output predictable data.
-///
-/// This is either a little slow ([`OsRng`] requires a system call) or extremely
-/// slow ([`JitterRng`] must use significant CPU time to generate sufficient
-/// jitter); for better performance it is common to seed a local PRNG from
-/// external entropy then primarily use the local PRNG ([`thread_rng`] is
-/// provided as a convenient, local, automatically-seeded CSPRNG).
-///
-/// # Panics
-///
-/// On most systems, like Windows, Linux, macOS and *BSD on common hardware, it
-/// is highly unlikely for both [`OsRng`] and [`JitterRng`] to fail. But on
-/// combinations like webassembly without Emscripten or stdweb both sources are
-/// unavailable. If both sources fail, only [`try_fill_bytes`] is able to
-/// report the error, and only the one from `OsRng`. The other [`RngCore`]
-/// methods will panic in case of an error.
-///
-/// [`OsRng`]: struct.OsRng.html
-/// [`JitterRng`]: jitter/struct.JitterRng.html
-/// [`thread_rng`]: ../fn.thread_rng.html
-/// [`RngCore`]: ../trait.RngCore.html
-/// [`try_fill_bytes`]: ../trait.RngCore.html#method.tymethod.try_fill_bytes
-#[derive(Debug)]
-pub struct EntropyRng {
- source: Source,
-}
-
-#[derive(Debug)]
-enum Source {
- Os(Os),
- Custom(Custom),
- Jitter(Jitter),
- None,
-}
-
-impl EntropyRng {
- /// Create a new `EntropyRng`.
- ///
- /// This method will do no system calls or other initialization routines,
- /// those are done on first use. This is done to make `new` infallible,
- /// and `try_fill_bytes` the only place to report errors.
- pub fn new() -> Self {
- EntropyRng { source: Source::None }
- }
-}
-
-impl Default for EntropyRng {
- fn default() -> Self {
- EntropyRng::new()
- }
-}
-
-impl RngCore for EntropyRng {
- fn next_u32(&mut self) -> u32 {
- impls::next_u32_via_fill(self)
- }
-
- fn next_u64(&mut self) -> u64 {
- impls::next_u64_via_fill(self)
- }
-
- fn fill_bytes(&mut self, dest: &mut [u8]) {
- self.try_fill_bytes(dest).unwrap_or_else(|err|
- panic!("all entropy sources failed; first error: {}", err))
- }
-
- fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), Error> {
- let mut reported_error = None;
-
- if let Source::Os(ref mut os_rng) = self.source {
- match os_rng.fill(dest) {
- Ok(()) => return Ok(()),
- Err(err) => {
- warn!("EntropyRng: OsRng failed \
- [trying other entropy sources]: {}", err);
- reported_error = Some(err);
- },
- }
- } else if Os::is_supported() {
- match Os::new_and_fill(dest) {
- Ok(os_rng) => {
- debug!("EntropyRng: using OsRng");
- self.source = Source::Os(os_rng);
- return Ok(());
- },
- Err(err) => { reported_error = reported_error.or(Some(err)) },
- }
- }
-
- if let Source::Custom(ref mut rng) = self.source {
- match rng.fill(dest) {
- Ok(()) => return Ok(()),
- Err(err) => {
- warn!("EntropyRng: custom entropy source failed \
- [trying other entropy sources]: {}", err);
- reported_error = Some(err);
- },
- }
- } else if Custom::is_supported() {
- match Custom::new_and_fill(dest) {
- Ok(custom) => {
- debug!("EntropyRng: using custom entropy source");
- self.source = Source::Custom(custom);
- return Ok(());
- },
- Err(err) => { reported_error = reported_error.or(Some(err)) },
- }
- }
-
- if let Source::Jitter(ref mut jitter_rng) = self.source {
- match jitter_rng.fill(dest) {
- Ok(()) => return Ok(()),
- Err(err) => {
- warn!("EntropyRng: JitterRng failed: {}", err);
- reported_error = Some(err);
- },
- }
- } else if Jitter::is_supported() {
- match Jitter::new_and_fill(dest) {
- Ok(jitter_rng) => {
- debug!("EntropyRng: using JitterRng");
- self.source = Source::Jitter(jitter_rng);
- return Ok(());
- },
- Err(err) => { reported_error = reported_error.or(Some(err)) },
- }
- }
-
- if let Some(err) = reported_error {
- Err(Error::with_cause(ErrorKind::Unavailable,
- "All entropy sources failed",
- err))
- } else {
- Err(Error::new(ErrorKind::Unavailable,
- "No entropy sources available"))
- }
- }
-}
-
-impl CryptoRng for EntropyRng {}
-
-
-
-trait EntropySource {
- fn new_and_fill(dest: &mut [u8]) -> Result<Self, Error>
- where Self: Sized;
-
- fn fill(&mut self, dest: &mut [u8]) -> Result<(), Error>;
-
- fn is_supported() -> bool { true }
-}
-
-#[allow(unused)]
-#[derive(Clone, Debug)]
-struct NoSource;
-
-#[allow(unused)]
-impl EntropySource for NoSource {
- fn new_and_fill(dest: &mut [u8]) -> Result<Self, Error> {
- Err(Error::new(ErrorKind::Unavailable, "Source not supported"))
- }
-
- fn fill(&mut self, dest: &mut [u8]) -> Result<(), Error> {
- unreachable!()
- }
-
- fn is_supported() -> bool { false }
-}
-
-
-#[cfg(feature="rand_os")]
-#[derive(Clone, Debug)]
-pub struct Os(rngs::OsRng);
-
-#[cfg(feature="rand_os")]
-impl EntropySource for Os {
- fn new_and_fill(dest: &mut [u8]) -> Result<Self, Error> {
- let mut rng = rngs::OsRng::new()?;
- rng.try_fill_bytes(dest)?;
- Ok(Os(rng))
- }
-
- fn fill(&mut self, dest: &mut [u8]) -> Result<(), Error> {
- self.0.try_fill_bytes(dest)
- }
-}
-
-#[cfg(not(feature="std"))]
-type Os = NoSource;
-
-
-type Custom = NoSource;
-
-
-#[cfg(not(target_arch = "wasm32"))]
-#[derive(Clone, Debug)]
-pub struct Jitter(rngs::JitterRng);
-
-#[cfg(not(target_arch = "wasm32"))]
-impl EntropySource for Jitter {
- fn new_and_fill(dest: &mut [u8]) -> Result<Self, Error> {
- let mut rng = rngs::JitterRng::new()?;
- rng.try_fill_bytes(dest)?;
- Ok(Jitter(rng))
- }
-
- fn fill(&mut self, dest: &mut [u8]) -> Result<(), Error> {
- self.0.try_fill_bytes(dest)
- }
-}
-
-#[cfg(target_arch = "wasm32")]
-type Jitter = NoSource;
-
-
-#[cfg(test)]
-mod test {
- use super::*;
-
- #[test]
- fn test_entropy() {
- let mut rng = EntropyRng::new();
- let n = (rng.next_u32() ^ rng.next_u32()).count_ones();
- assert!(n >= 2); // p(failure) approx 1e-7
- }
-}
diff --git a/rand/src/rngs/jitter.rs b/rand/src/rngs/jitter.rs
deleted file mode 100644
index 3e93477..0000000
--- a/rand/src/rngs/jitter.rs
+++ /dev/null
@@ -1,885 +0,0 @@
-// Copyright 2018 Developers of the Rand project.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-//
-// Based on jitterentropy-library, http://www.chronox.de/jent.html.
-// Copyright Stephan Mueller <smueller@chronox.de>, 2014 - 2017.
-//
-// With permission from Stephan Mueller to relicense the Rust translation under
-// the MIT license.
-
-//! Non-physical true random number generator based on timing jitter.
-
-// Note: the C implementation of `Jitterentropy` relies on being compiled
-// without optimizations. This implementation goes through lengths to make the
-// compiler not optimize out code which does influence timing jitter, but is
-// technically dead code.
-
-use rand_core::{RngCore, CryptoRng, Error, ErrorKind, impls};
-
-use core::{fmt, mem, ptr};
-#[cfg(all(feature="std", not(target_arch = "wasm32")))]
-use std::sync::atomic::{AtomicUsize, ATOMIC_USIZE_INIT, Ordering};
-
-const MEMORY_BLOCKS: usize = 64;
-const MEMORY_BLOCKSIZE: usize = 32;
-const MEMORY_SIZE: usize = MEMORY_BLOCKS * MEMORY_BLOCKSIZE;
-
-/// A true random number generator based on jitter in the CPU execution time,
-/// and jitter in memory access time.
-///
-/// This is a true random number generator, as opposed to pseudo-random
-/// generators. Random numbers generated by `JitterRng` can be seen as fresh
-/// entropy. A consequence is that is orders of magnitude slower than [`OsRng`]
-/// and PRNGs (about 10<sup>3</sup>..10<sup>6</sup> slower).
-///
-/// There are very few situations where using this RNG is appropriate. Only very
-/// few applications require true entropy. A normal PRNG can be statistically
-/// indistinguishable, and a cryptographic PRNG should also be as impossible to
-/// predict.
-///
-/// Use of `JitterRng` is recommended for initializing cryptographic PRNGs when
-/// [`OsRng`] is not available.
-///
-/// `JitterRng` can be used without the standard library, but not conveniently,
-/// you must provide a high-precision timer and carefully have to follow the
-/// instructions of [`new_with_timer`].
-///
-/// This implementation is based on
-/// [Jitterentropy](http://www.chronox.de/jent.html) version 2.1.0.
-///
-/// Note: There is no accurate timer available on Wasm platforms, to help
-/// prevent fingerprinting or timing side-channel attacks. Therefore
-/// [`JitterRng::new()`] is not available on Wasm.
-///
-/// # Quality testing
-///
-/// [`JitterRng::new()`] has build-in, but limited, quality testing, however
-/// before using `JitterRng` on untested hardware, or after changes that could
-/// effect how the code is optimized (such as a new LLVM version), it is
-/// recommend to run the much more stringent
-/// [NIST SP 800-90B Entropy Estimation Suite](
-/// https://github.com/usnistgov/SP800-90B_EntropyAssessment).
-///
-/// Use the following code using [`timer_stats`] to collect the data:
-///
-/// ```no_run
-/// use rand::rngs::JitterRng;
-/// #
-/// # use std::error::Error;
-/// # use std::fs::File;
-/// # use std::io::Write;
-/// #
-/// # fn try_main() -> Result<(), Box<Error>> {
-/// let mut rng = JitterRng::new()?;
-///
-/// // 1_000_000 results are required for the
-/// // NIST SP 800-90B Entropy Estimation Suite
-/// const ROUNDS: usize = 1_000_000;
-/// let mut deltas_variable: Vec<u8> = Vec::with_capacity(ROUNDS);
-/// let mut deltas_minimal: Vec<u8> = Vec::with_capacity(ROUNDS);
-///
-/// for _ in 0..ROUNDS {
-/// deltas_variable.push(rng.timer_stats(true) as u8);
-/// deltas_minimal.push(rng.timer_stats(false) as u8);
-/// }
-///
-/// // Write out after the statistics collection loop, to not disturb the
-/// // test results.
-/// File::create("jitter_rng_var.bin")?.write(&deltas_variable)?;
-/// File::create("jitter_rng_min.bin")?.write(&deltas_minimal)?;
-/// #
-/// # Ok(())
-/// # }
-/// #
-/// # fn main() {
-/// # try_main().unwrap();
-/// # }
-/// ```
-///
-/// This will produce two files: `jitter_rng_var.bin` and `jitter_rng_min.bin`.
-/// Run the Entropy Estimation Suite in three configurations, as outlined below.
-/// Every run has two steps. One step to produce an estimation, another to
-/// validate the estimation.
-///
-/// 1. Estimate the expected amount of entropy that is at least available with
-/// each round of the entropy collector. This number should be greater than
-/// the amount estimated with `64 / test_timer()`.
-/// ```sh
-/// python noniid_main.py -v jitter_rng_var.bin 8
-/// restart.py -v jitter_rng_var.bin 8 <min-entropy>
-/// ```
-/// 2. Estimate the expected amount of entropy that is available in the last 4
-/// bits of the timer delta after running noice sources. Note that a value of
-/// `3.70` is the minimum estimated entropy for true randomness.
-/// ```sh
-/// python noniid_main.py -v -u 4 jitter_rng_var.bin 4
-/// restart.py -v -u 4 jitter_rng_var.bin 4 <min-entropy>
-/// ```
-/// 3. Estimate the expected amount of entropy that is available to the entropy
-/// collector if both noice sources only run their minimal number of times.
-/// This measures the absolute worst-case, and gives a lower bound for the
-/// available entropy.
-/// ```sh
-/// python noniid_main.py -v -u 4 jitter_rng_min.bin 4
-/// restart.py -v -u 4 jitter_rng_min.bin 4 <min-entropy>
-/// ```
-///
-/// [`OsRng`]: struct.OsRng.html
-/// [`JitterRng::new()`]: struct.JitterRng.html#method.new
-/// [`new_with_timer`]: struct.JitterRng.html#method.new_with_timer
-/// [`timer_stats`]: struct.JitterRng.html#method.timer_stats
-pub struct JitterRng {
- data: u64, // Actual random number
- // Number of rounds to run the entropy collector per 64 bits
- rounds: u8,
- // Timer used by `measure_jitter`
- timer: fn() -> u64,
- // Memory for the Memory Access noise source
- mem_prev_index: u16,
- // Make `next_u32` not waste 32 bits
- data_half_used: bool,
-}
-
-// Note: `JitterRng` maintains a small 64-bit entropy pool. With every
-// `generate` 64 new bits should be integrated in the pool. If a round of
-// `generate` were to collect less than the expected 64 bit, then the returned
-// value, and the new state of the entropy pool, would be in some way related to
-// the initial state. It is therefore better if the initial state of the entropy
-// pool is different on each call to `generate`. This has a few implications:
-// - `generate` should be called once before using `JitterRng` to produce the
-// first usable value (this is done by default in `new`);
-// - We do not zero the entropy pool after generating a result. The reference
-// implementation also does not support zeroing, but recommends generating a
-// new value without using it if you want to protect a previously generated
-// 'secret' value from someone inspecting the memory;
-// - Implementing `Clone` seems acceptable, as it would not cause the systematic
-// bias a constant might cause. Only instead of one value that could be
-// potentially related to the same initial state, there are now two.
-
-// Entropy collector state.
-// These values are not necessary to preserve across runs.
-struct EcState {
- // Previous time stamp to determine the timer delta
- prev_time: u64,
- // Deltas used for the stuck test
- last_delta: i32,
- last_delta2: i32,
- // Memory for the Memory Access noise source
- mem: [u8; MEMORY_SIZE],
-}
-
-impl EcState {
- // Stuck test by checking the:
- // - 1st derivation of the jitter measurement (time delta)
- // - 2nd derivation of the jitter measurement (delta of time deltas)
- // - 3rd derivation of the jitter measurement (delta of delta of time
- // deltas)
- //
- // All values must always be non-zero.
- // This test is a heuristic to see whether the last measurement holds
- // entropy.
- fn stuck(&mut self, current_delta: i32) -> bool {
- let delta2 = self.last_delta - current_delta;
- let delta3 = delta2 - self.last_delta2;
-
- self.last_delta = current_delta;
- self.last_delta2 = delta2;
-
- current_delta == 0 || delta2 == 0 || delta3 == 0
- }
-}
-
-// Custom Debug implementation that does not expose the internal state
-impl fmt::Debug for JitterRng {
- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
- write!(f, "JitterRng {{}}")
- }
-}
-
-impl Clone for JitterRng {
- fn clone(&self) -> JitterRng {
- JitterRng {
- data: self.data,
- rounds: self.rounds,
- timer: self.timer,
- mem_prev_index: self.mem_prev_index,
- // The 32 bits that may still be unused from the previous round are
- // for the original to use, not for the clone.
- data_half_used: false,
- }
- }
-}
-
-/// An error that can occur when [`JitterRng::test_timer`] fails.
-///
-/// [`JitterRng::test_timer`]: struct.JitterRng.html#method.test_timer
-#[derive(Debug, Clone, PartialEq, Eq)]
-pub enum TimerError {
- /// No timer available.
- NoTimer,
- /// Timer too coarse to use as an entropy source.
- CoarseTimer,
- /// Timer is not monotonically increasing.
- NotMonotonic,
- /// Variations of deltas of time too small.
- TinyVariantions,
- /// Too many stuck results (indicating no added entropy).
- TooManyStuck,
- #[doc(hidden)]
- __Nonexhaustive,
-}
-
-impl TimerError {
- fn description(&self) -> &'static str {
- match *self {
- TimerError::NoTimer => "no timer available",
- TimerError::CoarseTimer => "coarse timer",
- TimerError::NotMonotonic => "timer not monotonic",
- TimerError::TinyVariantions => "time delta variations too small",
- TimerError::TooManyStuck => "too many stuck results",
- TimerError::__Nonexhaustive => unreachable!(),
- }
- }
-}
-
-impl fmt::Display for TimerError {
- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
- write!(f, "{}", self.description())
- }
-}
-
-#[cfg(feature="std")]
-impl ::std::error::Error for TimerError {
- fn description(&self) -> &str {
- self.description()
- }
-}
-
-impl From<TimerError> for Error {
- fn from(err: TimerError) -> Error {
- // Timer check is already quite permissive of failures so we don't
- // expect false-positive failures, i.e. any error is irrecoverable.
- Error::with_cause(ErrorKind::Unavailable,
- "timer jitter failed basic quality tests", err)
- }
-}
-
-// Initialise to zero; must be positive
-#[cfg(all(feature="std", not(target_arch = "wasm32")))]
-static JITTER_ROUNDS: AtomicUsize = ATOMIC_USIZE_INIT;
-
-impl JitterRng {
- /// Create a new `JitterRng`. Makes use of `std::time` for a timer, or a
- /// platform-specific function with higher accuracy if necessary and
- /// available.
- ///
- /// During initialization CPU execution timing jitter is measured a few
- /// hundred times. If this does not pass basic quality tests, an error is
- /// returned. The test result is cached to make subsequent calls faster.
- #[cfg(all(feature="std", not(target_arch = "wasm32")))]
- pub fn new() -> Result<JitterRng, TimerError> {
- let mut state = JitterRng::new_with_timer(platform::get_nstime);
- let mut rounds = JITTER_ROUNDS.load(Ordering::Relaxed) as u8;
- if rounds == 0 {
- // No result yet: run test.
- // This allows the timer test to run multiple times; we don't care.
- rounds = state.test_timer()?;
- JITTER_ROUNDS.store(rounds as usize, Ordering::Relaxed);
- info!("JitterRng: using {} rounds per u64 output", rounds);
- }
- state.set_rounds(rounds);
-
- // Fill `data` with a non-zero value.
- state.gen_entropy();
- Ok(state)
- }
-
- /// Create a new `JitterRng`.
- /// A custom timer can be supplied, making it possible to use `JitterRng` in
- /// `no_std` environments.
- ///
- /// The timer must have nanosecond precision.
- ///
- /// This method is more low-level than `new()`. It is the responsibility of
- /// the caller to run [`test_timer`] before using any numbers generated with
- /// `JitterRng`, and optionally call [`set_rounds`]. Also it is important to
- /// consume at least one `u64` before using the first result to initialize
- /// the entropy collection pool.
- ///
- /// # Example
- ///
- /// ```
- /// # use rand::{Rng, Error};
- /// use rand::rngs::JitterRng;
- ///
- /// # fn try_inner() -> Result<(), Error> {
- /// fn get_nstime() -> u64 {
- /// use std::time::{SystemTime, UNIX_EPOCH};
- ///
- /// let dur = SystemTime::now().duration_since(UNIX_EPOCH).unwrap();
- /// // The correct way to calculate the current time is
- /// // `dur.as_secs() * 1_000_000_000 + dur.subsec_nanos() as u64`
- /// // But this is faster, and the difference in terms of entropy is
- /// // negligible (log2(10^9) == 29.9).
- /// dur.as_secs() << 30 | dur.subsec_nanos() as u64
- /// }
- ///
- /// let mut rng = JitterRng::new_with_timer(get_nstime);
- /// let rounds = rng.test_timer()?;
- /// rng.set_rounds(rounds); // optional
- /// let _ = rng.gen::<u64>();
- ///
- /// // Ready for use
- /// let v: u64 = rng.gen();
- /// # Ok(())
- /// # }
- ///
- /// # let _ = try_inner();
- /// ```
- ///
- /// [`test_timer`]: struct.JitterRng.html#method.test_timer
- /// [`set_rounds`]: struct.JitterRng.html#method.set_rounds
- pub fn new_with_timer(timer: fn() -> u64) -> JitterRng {
- JitterRng {
- data: 0,
- rounds: 64,
- timer,
- mem_prev_index: 0,
- data_half_used: false,
- }
- }
-
- /// Configures how many rounds are used to generate each 64-bit value.
- /// This must be greater than zero, and has a big impact on performance
- /// and output quality.
- ///
- /// [`new_with_timer`] conservatively uses 64 rounds, but often less rounds
- /// can be used. The `test_timer()` function returns the minimum number of
- /// rounds required for full strength (platform dependent), so one may use
- /// `rng.set_rounds(rng.test_timer()?);` or cache the value.
- ///
- /// [`new_with_timer`]: struct.JitterRng.html#method.new_with_timer
- pub fn set_rounds(&mut self, rounds: u8) {
- assert!(rounds > 0);
- self.rounds = rounds;
- }
-
- // Calculate a random loop count used for the next round of an entropy
- // collection, based on bits from a fresh value from the timer.
- //
- // The timer is folded to produce a number that contains at most `n_bits`
- // bits.
- //
- // Note: A constant should be added to the resulting random loop count to
- // prevent loops that run 0 times.
- #[inline(never)]
- fn random_loop_cnt(&mut self, n_bits: u32) -> u32 {
- let mut rounds = 0;
-
- let mut time = (self.timer)();
- // Mix with the current state of the random number balance the random
- // loop counter a bit more.
- time ^= self.data;
-
- // We fold the time value as much as possible to ensure that as many
- // bits of the time stamp are included as possible.
- let folds = (64 + n_bits - 1) / n_bits;
- let mask = (1 << n_bits) - 1;
- for _ in 0..folds {
- rounds ^= time & mask;
- time >>= n_bits;
- }
-
- rounds as u32
- }
-
- // CPU jitter noise source
- // Noise source based on the CPU execution time jitter
- //
- // This function injects the individual bits of the time value into the
- // entropy pool using an LFSR.
- //
- // The code is deliberately inefficient with respect to the bit shifting.
- // This function not only acts as folding operation, but this function's
- // execution is used to measure the CPU execution time jitter. Any change to
- // the loop in this function implies that careful retesting must be done.
- #[inline(never)]
- fn lfsr_time(&mut self, time: u64, var_rounds: bool) {
- fn lfsr(mut data: u64, time: u64) -> u64{
- for i in 1..65 {
- let mut tmp = time << (64 - i);
- tmp >>= 64 - 1;
-
- // Fibonacci LSFR with polynomial of
- // x^64 + x^61 + x^56 + x^31 + x^28 + x^23 + 1 which is
- // primitive according to
- // http://poincare.matf.bg.ac.rs/~ezivkovm/publications/primpol1.pdf
- // (the shift values are the polynomial values minus one
- // due to counting bits from 0 to 63). As the current
- // position is always the LSB, the polynomial only needs
- // to shift data in from the left without wrap.
- data ^= tmp;
- data ^= (data >> 63) & 1;
- data ^= (data >> 60) & 1;
- data ^= (data >> 55) & 1;
- data ^= (data >> 30) & 1;
- data ^= (data >> 27) & 1;
- data ^= (data >> 22) & 1;
- data = data.rotate_left(1);
- }
- data
- }
-
- // Note: in the reference implementation only the last round effects
- // `self.data`, all the other results are ignored. To make sure the
- // other rounds are not optimised out, we first run all but the last
- // round on a throw-away value instead of the real `self.data`.
- let mut lfsr_loop_cnt = 0;
- if var_rounds { lfsr_loop_cnt = self.random_loop_cnt(4) };
-
- let mut throw_away: u64 = 0;
- for _ in 0..lfsr_loop_cnt {
- throw_away = lfsr(throw_away, time);
- }
- black_box(throw_away);
-
- self.data = lfsr(self.data, time);
- }
-
- // Memory Access noise source
- // This is a noise source based on variations in memory access times
- //
- // This function performs memory accesses which will add to the timing
- // variations due to an unknown amount of CPU wait states that need to be
- // added when accessing memory. The memory size should be larger than the L1
- // caches as outlined in the documentation and the associated testing.
- //
- // The L1 cache has a very high bandwidth, albeit its access rate is usually
- // slower than accessing CPU registers. Therefore, L1 accesses only add
- // minimal variations as the CPU has hardly to wait. Starting with L2,
- // significant variations are added because L2 typically does not belong to
- // the CPU any more and therefore a wider range of CPU wait states is
- // necessary for accesses. L3 and real memory accesses have even a wider
- // range of wait states. However, to reliably access either L3 or memory,
- // the `self.mem` memory must be quite large which is usually not desirable.
- #[inline(never)]
- fn memaccess(&mut self, mem: &mut [u8; MEMORY_SIZE], var_rounds: bool) {
- let mut acc_loop_cnt = 128;
- if var_rounds { acc_loop_cnt += self.random_loop_cnt(4) };
-
- let mut index = self.mem_prev_index as usize;
- for _ in 0..acc_loop_cnt {
- // Addition of memblocksize - 1 to index with wrap around logic to
- // ensure that every memory location is hit evenly.
- // The modulus also allows the compiler to remove the indexing
- // bounds check.
- index = (index + MEMORY_BLOCKSIZE - 1) % MEMORY_SIZE;
-
- // memory access: just add 1 to one byte
- // memory access implies read from and write to memory location
- mem[index] = mem[index].wrapping_add(1);
- }
- self.mem_prev_index = index as u16;
- }
-
- // This is the heart of the entropy generation: calculate time deltas and
- // use the CPU jitter in the time deltas. The jitter is injected into the
- // entropy pool.
- //
- // Ensure that `ec.prev_time` is primed before using the output of this
- // function. This can be done by calling this function and not using its
- // result.
- fn measure_jitter(&mut self, ec: &mut EcState) -> Option<()> {
- // Invoke one noise source before time measurement to add variations
- self.memaccess(&mut ec.mem, true);
-
- // Get time stamp and calculate time delta to previous
- // invocation to measure the timing variations
- let time = (self.timer)();
- // Note: wrapping_sub combined with a cast to `i64` generates a correct
- // delta, even in the unlikely case this is a timer that is not strictly
- // monotonic.
- let current_delta = time.wrapping_sub(ec.prev_time) as i64 as i32;
- ec.prev_time = time;
-
- // Call the next noise source which also injects the data
- self.lfsr_time(current_delta as u64, true);
-
- // Check whether we have a stuck measurement (i.e. does the last
- // measurement holds entropy?).
- if ec.stuck(current_delta) { return None };
-
- // Rotate the data buffer by a prime number (any odd number would
- // do) to ensure that every bit position of the input time stamp
- // has an even chance of being merged with a bit position in the
- // entropy pool. We do not use one here as the adjacent bits in
- // successive time deltas may have some form of dependency. The
- // chosen value of 7 implies that the low 7 bits of the next
- // time delta value is concatenated with the current time delta.
- self.data = self.data.rotate_left(7);
-
- Some(())
- }
-
- // Shuffle the pool a bit by mixing some value with a bijective function
- // (XOR) into the pool.
- //
- // The function generates a mixer value that depends on the bits set and
- // the location of the set bits in the random number generated by the
- // entropy source. Therefore, based on the generated random number, this
- // mixer value can have 2^64 different values. That mixer value is
- // initialized with the first two SHA-1 constants. After obtaining the
- // mixer value, it is XORed into the random number.
- //
- // The mixer value is not assumed to contain any entropy. But due to the
- // XOR operation, it can also not destroy any entropy present in the
- // entropy pool.
- #[inline(never)]
- fn stir_pool(&mut self) {
- // This constant is derived from the first two 32 bit initialization
- // vectors of SHA-1 as defined in FIPS 180-4 section 5.3.1
- // The order does not really matter as we do not rely on the specific
- // numbers. We just pick the SHA-1 constants as they have a good mix of
- // bit set and unset.
- const CONSTANT: u64 = 0x67452301efcdab89;
-
- // The start value of the mixer variable is derived from the third
- // and fourth 32 bit initialization vector of SHA-1 as defined in
- // FIPS 180-4 section 5.3.1
- let mut mixer = 0x98badcfe10325476;
-
- // This is a constant time function to prevent leaking timing
- // information about the random number.
- // The normal code is:
- // ```
- // for i in 0..64 {
- // if ((self.data >> i) & 1) == 1 { mixer ^= CONSTANT; }
- // }
- // ```
- // This is a bit fragile, as LLVM really wants to use branches here, and
- // we rely on it to not recognise the opportunity.
- for i in 0..64 {
- let apply = (self.data >> i) & 1;
- let mask = !apply.wrapping_sub(1);
- mixer ^= CONSTANT & mask;
- mixer = mixer.rotate_left(1);
- }
-
- self.data ^= mixer;
- }
-
- fn gen_entropy(&mut self) -> u64 {
- trace!("JitterRng: collecting entropy");
-
- // Prime `ec.prev_time`, and run the noice sources to make sure the
- // first loop round collects the expected entropy.
- let mut ec = EcState {
- prev_time: (self.timer)(),
- last_delta: 0,
- last_delta2: 0,
- mem: [0; MEMORY_SIZE],
- };
- let _ = self.measure_jitter(&mut ec);
-
- for _ in 0..self.rounds {
- // If a stuck measurement is received, repeat measurement
- // Note: we do not guard against an infinite loop, that would mean
- // the timer suddenly became broken.
- while self.measure_jitter(&mut ec).is_none() {}
- }
-
- // Do a single read from `self.mem` to make sure the Memory Access noise
- // source is not optimised out.
- black_box(ec.mem[0]);
-
- self.stir_pool();
- self.data
- }
-
- /// Basic quality tests on the timer, by measuring CPU timing jitter a few
- /// hundred times.
- ///
- /// If succesful, this will return the estimated number of rounds necessary
- /// to collect 64 bits of entropy. Otherwise a [`TimerError`] with the cause
- /// of the failure will be returned.
- ///
- /// [`TimerError`]: enum.TimerError.html
- pub fn test_timer(&mut self) -> Result<u8, TimerError> {
- debug!("JitterRng: testing timer ...");
- // We could add a check for system capabilities such as `clock_getres`
- // or check for `CONFIG_X86_TSC`, but it does not make much sense as the
- // following sanity checks verify that we have a high-resolution timer.
-
- let mut delta_sum = 0;
- let mut old_delta = 0;
-
- let mut time_backwards = 0;
- let mut count_mod = 0;
- let mut count_stuck = 0;
-
- let mut ec = EcState {
- prev_time: (self.timer)(),
- last_delta: 0,
- last_delta2: 0,
- mem: [0; MEMORY_SIZE],
- };
-
- // TESTLOOPCOUNT needs some loops to identify edge systems.
- // 100 is definitely too little.
- const TESTLOOPCOUNT: u64 = 300;
- const CLEARCACHE: u64 = 100;
-
- for i in 0..(CLEARCACHE + TESTLOOPCOUNT) {
- // Measure time delta of core entropy collection logic
- let time = (self.timer)();
- self.memaccess(&mut ec.mem, true);
- self.lfsr_time(time, true);
- let time2 = (self.timer)();
-
- // Test whether timer works
- if time == 0 || time2 == 0 {
- return Err(TimerError::NoTimer);
- }
- let delta = time2.wrapping_sub(time) as i64 as i32;
-
- // Test whether timer is fine grained enough to provide delta even
- // when called shortly after each other -- this implies that we also
- // have a high resolution timer
- if delta == 0 {
- return Err(TimerError::CoarseTimer);
- }
-
- // Up to here we did not modify any variable that will be
- // evaluated later, but we already performed some work. Thus we
- // already have had an impact on the caches, branch prediction,
- // etc. with the goal to clear it to get the worst case
- // measurements.
- if i < CLEARCACHE { continue; }
-
- if ec.stuck(delta) { count_stuck += 1; }
-
- // Test whether we have an increasing timer.
- if !(time2 > time) { time_backwards += 1; }
-
- // Count the number of times the counter increases in steps of 100ns
- // or greater.
- if (delta % 100) == 0 { count_mod += 1; }
-
- // Ensure that we have a varying delta timer which is necessary for
- // the calculation of entropy -- perform this check only after the
- // first loop is executed as we need to prime the old_delta value
- delta_sum += (delta - old_delta).abs() as u64;
- old_delta = delta;
- }
-
- // Do a single read from `self.mem` to make sure the Memory Access noise
- // source is not optimised out.
- black_box(ec.mem[0]);
-
- // We allow the time to run backwards for up to three times.
- // This can happen if the clock is being adjusted by NTP operations.
- // If such an operation just happens to interfere with our test, it
- // should not fail. The value of 3 should cover the NTP case being
- // performed during our test run.
- if time_backwards > 3 {
- return Err(TimerError::NotMonotonic);
- }
-
- // Test that the available amount of entropy per round does not get to
- // low. We expect 1 bit of entropy per round as a reasonable minimum
- // (although less is possible, it means the collector loop has to run
- // much more often).
- // `assert!(delta_average >= log2(1))`
- // `assert!(delta_sum / TESTLOOPCOUNT >= 1)`
- // `assert!(delta_sum >= TESTLOOPCOUNT)`
- if delta_sum < TESTLOOPCOUNT {
- return Err(TimerError::TinyVariantions);
- }
-
- // Ensure that we have variations in the time stamp below 100 for at
- // least 10% of all checks -- on some platforms, the counter increments
- // in multiples of 100, but not always
- if count_mod > (TESTLOOPCOUNT * 9 / 10) {
- return Err(TimerError::CoarseTimer);
- }
-
- // If we have more than 90% stuck results, then this Jitter RNG is
- // likely to not work well.
- if count_stuck > (TESTLOOPCOUNT * 9 / 10) {
- return Err(TimerError::TooManyStuck);
- }
-
- // Estimate the number of `measure_jitter` rounds necessary for 64 bits
- // of entropy.
- //
- // We don't try very hard to come up with a good estimate of the
- // available bits of entropy per round here for two reasons:
- // 1. Simple estimates of the available bits (like Shannon entropy) are
- // too optimistic.
- // 2. Unless we want to waste a lot of time during intialization, there
- // only a small number of samples are available.
- //
- // Therefore we use a very simple and conservative estimate:
- // `let bits_of_entropy = log2(delta_average) / 2`.
- //
- // The number of rounds `measure_jitter` should run to collect 64 bits
- // of entropy is `64 / bits_of_entropy`.
- let delta_average = delta_sum / TESTLOOPCOUNT;
-
- if delta_average >= 16 {
- let log2 = 64 - delta_average.leading_zeros();
- // Do something similar to roundup(64/(log2/2)):
- Ok( ((64u32 * 2 + log2 - 1) / log2) as u8)
- } else {
- // For values < 16 the rounding error becomes too large, use a
- // lookup table.
- // Values 0 and 1 are invalid, and filtered out by the
- // `delta_sum < TESTLOOPCOUNT` test above.
- let log2_lookup = [0, 0, 128, 81, 64, 56, 50, 46,
- 43, 41, 39, 38, 36, 35, 34, 33];
- Ok(log2_lookup[delta_average as usize])
- }
- }
-
- /// Statistical test: return the timer delta of one normal run of the
- /// `JitterRng` entropy collector.
- ///
- /// Setting `var_rounds` to `true` will execute the memory access and the
- /// CPU jitter noice sources a variable amount of times (just like a real
- /// `JitterRng` round).
- ///
- /// Setting `var_rounds` to `false` will execute the noice sources the
- /// minimal number of times. This can be used to measure the minimum amount
- /// of entropy one round of the entropy collector can collect in the worst
- /// case.
- ///
- /// See [Quality testing](struct.JitterRng.html#quality-testing) on how to
- /// use `timer_stats` to test the quality of `JitterRng`.
- pub fn timer_stats(&mut self, var_rounds: bool) -> i64 {
- let mut mem = [0; MEMORY_SIZE];
-
- let time = (self.timer)();
- self.memaccess(&mut mem, var_rounds);
- self.lfsr_time(time, var_rounds);
- let time2 = (self.timer)();
- time2.wrapping_sub(time) as i64
- }
-}
-
-#[cfg(feature="std")]
-mod platform {
- #[cfg(not(any(target_os = "macos", target_os = "ios",
- target_os = "windows",
- target_arch = "wasm32")))]
- pub fn get_nstime() -> u64 {
- use std::time::{SystemTime, UNIX_EPOCH};
-
- let dur = SystemTime::now().duration_since(UNIX_EPOCH).unwrap();
- // The correct way to calculate the current time is
- // `dur.as_secs() * 1_000_000_000 + dur.subsec_nanos() as u64`
- // But this is faster, and the difference in terms of entropy is
- // negligible (log2(10^9) == 29.9).
- dur.as_secs() << 30 | dur.subsec_nanos() as u64
- }
-
- #[cfg(any(target_os = "macos", target_os = "ios"))]
- pub fn get_nstime() -> u64 {
- extern crate libc;
- // On Mac OS and iOS std::time::SystemTime only has 1000ns resolution.
- // We use `mach_absolute_time` instead. This provides a CPU dependent
- // unit, to get real nanoseconds the result should by multiplied by
- // numer/denom from `mach_timebase_info`.
- // But we are not interested in the exact nanoseconds, just entropy. So
- // we use the raw result.
- unsafe { libc::mach_absolute_time() }
- }
-
- #[cfg(target_os = "windows")]
- pub fn get_nstime() -> u64 {
- extern crate winapi;
- unsafe {
- let mut t = super::mem::zeroed();
- winapi::um::profileapi::QueryPerformanceCounter(&mut t);
- *t.QuadPart() as u64
- }
- }
-}
-
-// A function that is opaque to the optimizer to assist in avoiding dead-code
-// elimination. Taken from `bencher`.
-fn black_box<T>(dummy: T) -> T {
- unsafe {
- let ret = ptr::read_volatile(&dummy);
- mem::forget(dummy);
- ret
- }
-}
-
-impl RngCore for JitterRng {
- fn next_u32(&mut self) -> u32 {
- // We want to use both parts of the generated entropy
- if self.data_half_used {
- self.data_half_used = false;
- (self.data >> 32) as u32
- } else {
- self.data = self.next_u64();
- self.data_half_used = true;
- self.data as u32
- }
- }
-
- fn next_u64(&mut self) -> u64 {
- self.data_half_used = false;
- self.gen_entropy()
- }
-
- fn fill_bytes(&mut self, dest: &mut [u8]) {
- // Fill using `next_u32`. This is faster for filling small slices (four
- // bytes or less), while the overhead is negligible.
- //
- // This is done especially for wrappers that implement `next_u32`
- // themselves via `fill_bytes`.
- impls::fill_bytes_via_next(self, dest)
- }
-
- fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), Error> {
- Ok(self.fill_bytes(dest))
- }
-}
-
-impl CryptoRng for JitterRng {}
-
-#[cfg(test)]
-mod test_jitter_init {
- use super::JitterRng;
-
- #[cfg(all(feature="std", not(target_arch = "wasm32")))]
- #[test]
- fn test_jitter_init() {
- use RngCore;
- // Because this is a debug build, measurements here are not representive
- // of the final release build.
- // Don't fail this test if initializing `JitterRng` fails because of a
- // bad timer (the timer from the standard library may not have enough
- // accuracy on all platforms).
- match JitterRng::new() {
- Ok(ref mut rng) => {
- // false positives are possible, but extremely unlikely
- assert!(rng.next_u32() | rng.next_u32() != 0);
- },
- Err(_) => {},
- }
- }
-
- #[test]
- fn test_jitter_bad_timer() {
- fn bad_timer() -> u64 { 0 }
- let mut rng = JitterRng::new_with_timer(bad_timer);
- assert!(rng.test_timer().is_err());
- }
-}
diff --git a/rand/src/rngs/mock.rs b/rand/src/rngs/mock.rs
deleted file mode 100644
index 3c9a994..0000000
--- a/rand/src/rngs/mock.rs
+++ /dev/null
@@ -1,59 +0,0 @@
-// Copyright 2018 Developers of the Rand project.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-//! Mock random number generator
-
-use rand_core::{RngCore, Error, impls};
-
-/// A simple implementation of `RngCore` for testing purposes.
-///
-/// This generates an arithmetic sequence (i.e. adds a constant each step)
-/// over a `u64` number, using wrapping arithmetic. If the increment is 0
-/// the generator yields a constant.
-///
-/// ```
-/// use rand::Rng;
-/// use rand::rngs::mock::StepRng;
-///
-/// let mut my_rng = StepRng::new(2, 1);
-/// let sample: [u64; 3] = my_rng.gen();
-/// assert_eq!(sample, [2, 3, 4]);
-/// ```
-#[derive(Debug, Clone)]
-pub struct StepRng {
- v: u64,
- a: u64,
-}
-
-impl StepRng {
- /// Create a `StepRng`, yielding an arithmetic sequence starting with
- /// `initial` and incremented by `increment` each time.
- pub fn new(initial: u64, increment: u64) -> Self {
- StepRng { v: initial, a: increment }
- }
-}
-
-impl RngCore for StepRng {
- fn next_u32(&mut self) -> u32 {
- self.next_u64() as u32
- }
-
- fn next_u64(&mut self) -> u64 {
- let result = self.v;
- self.v = self.v.wrapping_add(self.a);
- result
- }
-
- fn fill_bytes(&mut self, dest: &mut [u8]) {
- impls::fill_bytes_via_next(self, dest);
- }
-
- fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), Error> {
- Ok(self.fill_bytes(dest))
- }
-}
diff --git a/rand/src/rngs/mod.rs b/rand/src/rngs/mod.rs
deleted file mode 100644
index 847fc94..0000000
--- a/rand/src/rngs/mod.rs
+++ /dev/null
@@ -1,182 +0,0 @@
-// Copyright 2018 Developers of the Rand project.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-//! Random number generators and adapters for common usage:
-//!
-//! - [`ThreadRng`], a fast, secure, auto-seeded thread-local generator
-//! - [`StdRng`] and [`SmallRng`], algorithms to cover typical usage
-//! - [`EntropyRng`], [`OsRng`] and [`JitterRng`] as entropy sources
-//! - [`mock::StepRng`] as a simple counter for tests
-//! - [`adapter::ReadRng`] to read from a file/stream
-//! - [`adapter::ReseedingRng`] to reseed a PRNG on clone / process fork etc.
-//!
-//! # Background — Random number generators (RNGs)
-//!
-//! Computers are inherently deterministic, so to get *random* numbers one
-//! either has to use a hardware generator or collect bits of *entropy* from
-//! various sources (e.g. event timestamps, or jitter). This is a relatively
-//! slow and complicated operation.
-//!
-//! Generally the operating system will collect some entropy, remove bias, and
-//! use that to seed its own PRNG; [`OsRng`] provides an interface to this.
-//! [`JitterRng`] is an entropy collector included with Rand that measures
-//! jitter in the CPU execution time, and jitter in memory access time.
-//! [`EntropyRng`] is a wrapper that uses the best entropy source that is
-//! available.
-//!
-//! ## Pseudo-random number generators
-//!
-//! What is commonly used instead of "true" random number renerators, are
-//! *pseudo-random number generators* (PRNGs), deterministic algorithms that
-//! produce an infinite stream of pseudo-random numbers from a small random
-//! seed. PRNGs are faster, and have better provable properties. The numbers
-//! produced can be statistically of very high quality and can be impossible to
-//! predict. (They can also have obvious correlations and be trivial to predict;
-//! quality varies.)
-//!
-//! There are two different types of PRNGs: those developed for simulations
-//! and statistics, and those developed for use in cryptography; the latter are
-//! called Cryptographically Secure PRNGs (CSPRNG or CPRNG). Both types can
-//! have good statistical quality but the latter also have to be impossible to
-//! predict, even after seeing many previous output values. Rand provides a good
-//! default algorithm from each class:
-//!
-//! - [`SmallRng`] is a PRNG chosen for low memory usage, high performance and
-//! good statistical quality.
-//! - [`StdRng`] is a CSPRNG chosen for good performance and trust of security
-//! (based on reviews, maturity and usage). The current algorithm is HC-128,
-//! which is one of the recommendations by ECRYPT's eSTREAM project.
-//!
-//! The above PRNGs do not cover all use-cases; more algorithms can be found in
-//! the [`prng` module], as well as in several other crates. For example, you
-//! may wish a CSPRNG with significantly lower memory usage than [`StdRng`]
-//! while being less concerned about performance, in which case [`ChaChaRng`]
-//! is a good choice.
-//!
-//! One complexity is that the internal state of a PRNG must change with every
-//! generated number. For APIs this generally means a mutable reference to the
-//! state of the PRNG has to be passed around.
-//!
-//! A solution is [`ThreadRng`]. This is a thread-local implementation of
-//! [`StdRng`] with automatic seeding on first use. It is the best choice if you
-//! "just" want a convenient, secure, fast random number source. Use via the
-//! [`thread_rng`] function, which gets a reference to the current thread's
-//! local instance.
-//!
-//! ## Seeding
-//!
-//! As mentioned above, PRNGs require a random seed in order to produce random
-//! output. This is especially important for CSPRNGs, which are still
-//! deterministic algorithms, thus can only be secure if their seed value is
-//! also secure. To seed a PRNG, use one of:
-//!
-//! - [`FromEntropy::from_entropy`]; this is the most convenient way to seed
-//! with fresh, secure random data.
-//! - [`SeedableRng::from_rng`]; this allows seeding from another PRNG or
-//! from an entropy source such as [`EntropyRng`].
-//! - [`SeedableRng::from_seed`]; this is mostly useful if you wish to be able
-//! to reproduce the output sequence by using a fixed seed. (Don't use
-//! [`StdRng`] or [`SmallRng`] in this case since different algorithms may be
-//! used by future versions of Rand; use an algorithm from the
-//! [`prng` module].)
-//!
-//! ## Conclusion
-//!
-//! - [`thread_rng`] is what you often want to use.
-//! - If you want more control, flexibility, or better performance, use
-//! [`StdRng`], [`SmallRng`] or an algorithm from the [`prng` module].
-//! - Use [`FromEntropy::from_entropy`] to seed new PRNGs.
-//! - If you need reproducibility, use [`SeedableRng::from_seed`] combined with
-//! a named PRNG.
-//!
-//! More information and notes on cryptographic security can be found
-//! in the [`prng` module].
-//!
-//! ## Examples
-//!
-//! Examples of seeding PRNGs:
-//!
-//! ```
-//! use rand::prelude::*;
-//! # use rand::Error;
-//!
-//! // StdRng seeded securely by the OS or local entropy collector:
-//! let mut rng = StdRng::from_entropy();
-//! # let v: u32 = rng.gen();
-//!
-//! // SmallRng seeded from thread_rng:
-//! # fn try_inner() -> Result<(), Error> {
-//! let mut rng = SmallRng::from_rng(thread_rng())?;
-//! # let v: u32 = rng.gen();
-//! # Ok(())
-//! # }
-//! # try_inner().unwrap();
-//!
-//! // SmallRng seeded by a constant, for deterministic results:
-//! let seed = [1,2,3,4, 5,6,7,8, 9,10,11,12, 13,14,15,16]; // byte array
-//! let mut rng = SmallRng::from_seed(seed);
-//! # let v: u32 = rng.gen();
-//! ```
-//!
-//!
-//! # Implementing custom RNGs
-//!
-//! If you want to implement custom RNG, see the [`rand_core`] crate. The RNG
-//! will have to implement the [`RngCore`] trait, where the [`Rng`] trait is
-//! build on top of.
-//!
-//! If the RNG needs seeding, also implement the [`SeedableRng`] trait.
-//!
-//! [`CryptoRng`] is a marker trait cryptographically secure PRNGs can
-//! implement.
-//!
-//!
-// This module:
-//! [`ThreadRng`]: struct.ThreadRng.html
-//! [`StdRng`]: struct.StdRng.html
-//! [`SmallRng`]: struct.SmallRng.html
-//! [`EntropyRng`]: struct.EntropyRng.html
-//! [`OsRng`]: struct.OsRng.html
-//! [`JitterRng`]: struct.JitterRng.html
-// Other traits and functions:
-//! [`rand_core`]: https://crates.io/crates/rand_core
-//! [`prng` module]: ../prng/index.html
-//! [`CryptoRng`]: ../trait.CryptoRng.html
-//! [`FromEntropy`]: ../trait.FromEntropy.html
-//! [`FromEntropy::from_entropy`]: ../trait.FromEntropy.html#tymethod.from_entropy
-//! [`RngCore`]: ../trait.RngCore.html
-//! [`Rng`]: ../trait.Rng.html
-//! [`SeedableRng`]: ../trait.SeedableRng.html
-//! [`SeedableRng::from_rng`]: ../trait.SeedableRng.html#tymethod.from_rng
-//! [`SeedableRng::from_seed`]: ../trait.SeedableRng.html#tymethod.from_seed
-//! [`thread_rng`]: ../fn.thread_rng.html
-//! [`mock::StepRng`]: mock/struct.StepRng.html
-//! [`adapter::ReadRng`]: adapter/struct.ReadRng.html
-//! [`adapter::ReseedingRng`]: adapter/struct.ReseedingRng.html
-//! [`ChaChaRng`]: ../../rand_chacha/struct.ChaChaRng.html
-
-pub mod adapter;
-
-#[cfg(feature="std")] mod entropy;
-mod jitter;
-pub mod mock; // Public so we don't export `StepRng` directly, making it a bit
- // more clear it is intended for testing.
-mod small;
-mod std;
-#[cfg(feature="std")] pub(crate) mod thread;
-
-
-pub use self::jitter::{JitterRng, TimerError};
-#[cfg(feature="std")] pub use self::entropy::EntropyRng;
-
-pub use self::small::SmallRng;
-pub use self::std::StdRng;
-#[cfg(feature="std")] pub use self::thread::ThreadRng;
-
-#[cfg(feature="rand_os")]
-pub use rand_os::OsRng;
diff --git a/rand/src/rngs/small.rs b/rand/src/rngs/small.rs
deleted file mode 100644
index b652c8c..0000000
--- a/rand/src/rngs/small.rs
+++ /dev/null
@@ -1,105 +0,0 @@
-// Copyright 2018 Developers of the Rand project.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-//! A small fast RNG
-
-use {RngCore, SeedableRng, Error};
-
-#[cfg(all(all(rustc_1_26, not(target_os = "emscripten")), target_pointer_width = "64"))]
-type Rng = ::rand_pcg::Pcg64Mcg;
-#[cfg(not(all(all(rustc_1_26, not(target_os = "emscripten")), target_pointer_width = "64")))]
-type Rng = ::rand_pcg::Pcg32;
-
-/// An RNG recommended when small state, cheap initialization and good
-/// performance are required. The PRNG algorithm in `SmallRng` is chosen to be
-/// efficient on the current platform, **without consideration for cryptography
-/// or security**. The size of its state is much smaller than for [`StdRng`].
-///
-/// Reproducibility of output from this generator is however not required, thus
-/// future library versions may use a different internal generator with
-/// different output. Further, this generator may not be portable and can
-/// produce different output depending on the architecture. If you require
-/// reproducible output, use a named RNG. Refer to the documentation on the
-/// [`prng` module](../prng/index.html).
-///
-/// The current algorithm is [`Pcg64Mcg`] on 64-bit platforms with Rust version
-/// 1.26 and later, or [`Pcg32`] otherwise.
-///
-/// # Examples
-///
-/// Initializing `SmallRng` with a random seed can be done using [`FromEntropy`]:
-///
-/// ```
-/// # use rand::Rng;
-/// use rand::FromEntropy;
-/// use rand::rngs::SmallRng;
-///
-/// // Create small, cheap to initialize and fast RNG with a random seed.
-/// // The randomness is supplied by the operating system.
-/// let mut small_rng = SmallRng::from_entropy();
-/// # let v: u32 = small_rng.gen();
-/// ```
-///
-/// When initializing a lot of `SmallRng`'s, using [`thread_rng`] can be more
-/// efficient:
-///
-/// ```
-/// use std::iter;
-/// use rand::{SeedableRng, thread_rng};
-/// use rand::rngs::SmallRng;
-///
-/// // Create a big, expensive to initialize and slower, but unpredictable RNG.
-/// // This is cached and done only once per thread.
-/// let mut thread_rng = thread_rng();
-/// // Create small, cheap to initialize and fast RNGs with random seeds.
-/// // One can generally assume this won't fail.
-/// let rngs: Vec<SmallRng> = iter::repeat(())
-/// .map(|()| SmallRng::from_rng(&mut thread_rng).unwrap())
-/// .take(10)
-/// .collect();
-/// ```
-///
-/// [`FromEntropy`]: ../trait.FromEntropy.html
-/// [`StdRng`]: struct.StdRng.html
-/// [`thread_rng`]: ../fn.thread_rng.html
-/// [`Pcg64Mcg`]: ../../rand_pcg/type.Pcg64Mcg.html
-/// [`Pcg32`]: ../../rand_pcg/type.Pcg32.html
-#[derive(Clone, Debug)]
-pub struct SmallRng(Rng);
-
-impl RngCore for SmallRng {
- #[inline(always)]
- fn next_u32(&mut self) -> u32 {
- self.0.next_u32()
- }
-
- #[inline(always)]
- fn next_u64(&mut self) -> u64 {
- self.0.next_u64()
- }
-
- fn fill_bytes(&mut self, dest: &mut [u8]) {
- self.0.fill_bytes(dest);
- }
-
- fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), Error> {
- self.0.try_fill_bytes(dest)
- }
-}
-
-impl SeedableRng for SmallRng {
- type Seed = <Rng as SeedableRng>::Seed;
-
- fn from_seed(seed: Self::Seed) -> Self {
- SmallRng(Rng::from_seed(seed))
- }
-
- fn from_rng<R: RngCore>(rng: R) -> Result<Self, Error> {
- Rng::from_rng(rng).map(SmallRng)
- }
-}
diff --git a/rand/src/rngs/std.rs b/rand/src/rngs/std.rs
deleted file mode 100644
index ce1658b..0000000
--- a/rand/src/rngs/std.rs
+++ /dev/null
@@ -1,81 +0,0 @@
-// Copyright 2018 Developers of the Rand project.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-//! The standard RNG
-
-use {RngCore, CryptoRng, Error, SeedableRng};
-use rand_hc::Hc128Rng;
-
-/// The standard RNG. The PRNG algorithm in `StdRng` is chosen to be efficient
-/// on the current platform, to be statistically strong and unpredictable
-/// (meaning a cryptographically secure PRNG).
-///
-/// The current algorithm used on all platforms is [HC-128].
-///
-/// Reproducibility of output from this generator is however not required, thus
-/// future library versions may use a different internal generator with
-/// different output. Further, this generator may not be portable and can
-/// produce different output depending on the architecture. If you require
-/// reproducible output, use a named RNG, for example [`ChaChaRng`].
-///
-/// [HC-128]: ../../rand_hc/struct.Hc128Rng.html
-/// [`ChaChaRng`]: ../../rand_chacha/struct.ChaChaRng.html
-#[derive(Clone, Debug)]
-pub struct StdRng(Hc128Rng);
-
-impl RngCore for StdRng {
- #[inline(always)]
- fn next_u32(&mut self) -> u32 {
- self.0.next_u32()
- }
-
- #[inline(always)]
- fn next_u64(&mut self) -> u64 {
- self.0.next_u64()
- }
-
- fn fill_bytes(&mut self, dest: &mut [u8]) {
- self.0.fill_bytes(dest);
- }
-
- fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), Error> {
- self.0.try_fill_bytes(dest)
- }
-}
-
-impl SeedableRng for StdRng {
- type Seed = <Hc128Rng as SeedableRng>::Seed;
-
- fn from_seed(seed: Self::Seed) -> Self {
- StdRng(Hc128Rng::from_seed(seed))
- }
-
- fn from_rng<R: RngCore>(rng: R) -> Result<Self, Error> {
- Hc128Rng::from_rng(rng).map(StdRng)
- }
-}
-
-impl CryptoRng for StdRng {}
-
-
-#[cfg(test)]
-mod test {
- use {RngCore, SeedableRng};
- use rngs::StdRng;
-
- #[test]
- fn test_stdrng_construction() {
- let seed = [1,0,0,0, 23,0,0,0, 200,1,0,0, 210,30,0,0,
- 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0];
- let mut rng1 = StdRng::from_seed(seed);
- assert_eq!(rng1.next_u64(), 15759097995037006553);
-
- let mut rng2 = StdRng::from_rng(rng1).unwrap();
- assert_eq!(rng2.next_u64(), 6766915756997287454);
- }
-}
diff --git a/rand/src/rngs/thread.rs b/rand/src/rngs/thread.rs
deleted file mode 100644
index 7977d85..0000000
--- a/rand/src/rngs/thread.rs
+++ /dev/null
@@ -1,141 +0,0 @@
-// Copyright 2018 Developers of the Rand project.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-//! Thread-local random number generator
-
-use std::cell::UnsafeCell;
-
-use {RngCore, CryptoRng, SeedableRng, Error};
-use rngs::adapter::ReseedingRng;
-use rngs::EntropyRng;
-use rand_hc::Hc128Core;
-
-// Rationale for using `UnsafeCell` in `ThreadRng`:
-//
-// Previously we used a `RefCell`, with an overhead of ~15%. There will only
-// ever be one mutable reference to the interior of the `UnsafeCell`, because
-// we only have such a reference inside `next_u32`, `next_u64`, etc. Within a
-// single thread (which is the definition of `ThreadRng`), there will only ever
-// be one of these methods active at a time.
-//
-// A possible scenario where there could be multiple mutable references is if
-// `ThreadRng` is used inside `next_u32` and co. But the implementation is
-// completely under our control. We just have to ensure none of them use
-// `ThreadRng` internally, which is nonsensical anyway. We should also never run
-// `ThreadRng` in destructors of its implementation, which is also nonsensical.
-//
-// The additional `Rc` is not strictly neccesary, and could be removed. For now
-// it ensures `ThreadRng` stays `!Send` and `!Sync`, and implements `Clone`.
-
-
-// Number of generated bytes after which to reseed `TreadRng`.
-//
-// The time it takes to reseed HC-128 is roughly equivalent to generating 7 KiB.
-// We pick a treshold here that is large enough to not reduce the average
-// performance too much, but also small enough to not make reseeding something
-// that basically never happens.
-const THREAD_RNG_RESEED_THRESHOLD: u64 = 32*1024*1024; // 32 MiB
-
-/// The type returned by [`thread_rng`], essentially just a reference to the
-/// PRNG in thread-local memory.
-///
-/// `ThreadRng` uses [`ReseedingRng`] wrapping the same PRNG as [`StdRng`],
-/// which is reseeded after generating 32 MiB of random data. A single instance
-/// is cached per thread and the returned `ThreadRng` is a reference to this
-/// instance — hence `ThreadRng` is neither `Send` nor `Sync` but is safe to use
-/// within a single thread. This RNG is seeded and reseeded via [`EntropyRng`]
-/// as required.
-///
-/// Note that the reseeding is done as an extra precaution against entropy
-/// leaks and is in theory unnecessary — to predict `ThreadRng`'s output, an
-/// attacker would have to either determine most of the RNG's seed or internal
-/// state, or crack the algorithm used.
-///
-/// Like [`StdRng`], `ThreadRng` is a cryptographically secure PRNG. The current
-/// algorithm used is [HC-128], which is an array-based PRNG that trades memory
-/// usage for better performance. This makes it similar to ISAAC, the algorithm
-/// used in `ThreadRng` before rand 0.5.
-///
-/// Cloning this handle just produces a new reference to the same thread-local
-/// generator.
-///
-/// [`thread_rng`]: ../fn.thread_rng.html
-/// [`ReseedingRng`]: adapter/struct.ReseedingRng.html
-/// [`StdRng`]: struct.StdRng.html
-/// [`EntropyRng`]: struct.EntropyRng.html
-/// [HC-128]: ../../rand_hc/struct.Hc128Rng.html
-#[derive(Clone, Debug)]
-pub struct ThreadRng {
- // use of raw pointer implies type is neither Send nor Sync
- rng: *mut ReseedingRng<Hc128Core, EntropyRng>,
-}
-
-thread_local!(
- static THREAD_RNG_KEY: UnsafeCell<ReseedingRng<Hc128Core, EntropyRng>> = {
- let mut entropy_source = EntropyRng::new();
- let r = Hc128Core::from_rng(&mut entropy_source).unwrap_or_else(|err|
- panic!("could not initialize thread_rng: {}", err));
- let rng = ReseedingRng::new(r,
- THREAD_RNG_RESEED_THRESHOLD,
- entropy_source);
- UnsafeCell::new(rng)
- }
-);
-
-/// Retrieve the lazily-initialized thread-local random number generator,
-/// seeded by the system. Intended to be used in method chaining style,
-/// e.g. `thread_rng().gen::<i32>()`, or cached locally, e.g.
-/// `let mut rng = thread_rng();`. Invoked by the `Default` trait, making
-/// `ThreadRng::default()` equivelent.
-///
-/// For more information see [`ThreadRng`].
-///
-/// [`ThreadRng`]: rngs/struct.ThreadRng.html
-pub fn thread_rng() -> ThreadRng {
- ThreadRng { rng: THREAD_RNG_KEY.with(|t| t.get()) }
-}
-
-impl Default for ThreadRng {
- fn default() -> ThreadRng {
- ::prelude::thread_rng()
- }
-}
-
-impl RngCore for ThreadRng {
- #[inline(always)]
- fn next_u32(&mut self) -> u32 {
- unsafe { (*self.rng).next_u32() }
- }
-
- #[inline(always)]
- fn next_u64(&mut self) -> u64 {
- unsafe { (*self.rng).next_u64() }
- }
-
- fn fill_bytes(&mut self, dest: &mut [u8]) {
- unsafe { (*self.rng).fill_bytes(dest) }
- }
-
- fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), Error> {
- unsafe { (*self.rng).try_fill_bytes(dest) }
- }
-}
-
-impl CryptoRng for ThreadRng {}
-
-
-#[cfg(test)]
-mod test {
- #[test]
- fn test_thread_rng() {
- use Rng;
- let mut r = ::thread_rng();
- r.gen::<i32>();
- assert_eq!(r.gen_range(0, 1), 0);
- }
-}
diff --git a/rand/src/seq/index.rs b/rand/src/seq/index.rs
deleted file mode 100644
index 3d4df3a..0000000
--- a/rand/src/seq/index.rs
+++ /dev/null
@@ -1,378 +0,0 @@
-// Copyright 2018 Developers of the Rand project.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-//! Index sampling
-
-#[cfg(feature="alloc")] use core::slice;
-
-#[cfg(feature="std")] use std::vec;
-#[cfg(all(feature="alloc", not(feature="std")))] use alloc::vec::{self, Vec};
-// BTreeMap is not as fast in tests, but better than nothing.
-#[cfg(feature="std")] use std::collections::{HashSet};
-#[cfg(all(feature="alloc", not(feature="std")))] use alloc::collections::BTreeSet;
-
-#[cfg(feature="alloc")] use distributions::{Distribution, Uniform};
-use Rng;
-
-/// A vector of indices.
-///
-/// Multiple internal representations are possible.
-#[derive(Clone, Debug)]
-pub enum IndexVec {
- #[doc(hidden)] U32(Vec<u32>),
- #[doc(hidden)] USize(Vec<usize>),
-}
-
-impl IndexVec {
- /// Returns the number of indices
- pub fn len(&self) -> usize {
- match self {
- &IndexVec::U32(ref v) => v.len(),
- &IndexVec::USize(ref v) => v.len(),
- }
- }
-
- /// Return the value at the given `index`.
- ///
- /// (Note: we cannot implement `std::ops::Index` because of lifetime
- /// restrictions.)
- pub fn index(&self, index: usize) -> usize {
- match self {
- &IndexVec::U32(ref v) => v[index] as usize,
- &IndexVec::USize(ref v) => v[index],
- }
- }
-
- /// Return result as a `Vec<usize>`. Conversion may or may not be trivial.
- pub fn into_vec(self) -> Vec<usize> {
- match self {
- IndexVec::U32(v) => v.into_iter().map(|i| i as usize).collect(),
- IndexVec::USize(v) => v,
- }
- }
-
- /// Iterate over the indices as a sequence of `usize` values
- pub fn iter<'a>(&'a self) -> IndexVecIter<'a> {
- match self {
- &IndexVec::U32(ref v) => IndexVecIter::U32(v.iter()),
- &IndexVec::USize(ref v) => IndexVecIter::USize(v.iter()),
- }
- }
-
- /// Convert into an iterator over the indices as a sequence of `usize` values
- pub fn into_iter(self) -> IndexVecIntoIter {
- match self {
- IndexVec::U32(v) => IndexVecIntoIter::U32(v.into_iter()),
- IndexVec::USize(v) => IndexVecIntoIter::USize(v.into_iter()),
- }
- }
-}
-
-impl PartialEq for IndexVec {
- fn eq(&self, other: &IndexVec) -> bool {
- use self::IndexVec::*;
- match (self, other) {
- (&U32(ref v1), &U32(ref v2)) => v1 == v2,
- (&USize(ref v1), &USize(ref v2)) => v1 == v2,
- (&U32(ref v1), &USize(ref v2)) => (v1.len() == v2.len())
- && (v1.iter().zip(v2.iter()).all(|(x, y)| *x as usize == *y)),
- (&USize(ref v1), &U32(ref v2)) => (v1.len() == v2.len())
- && (v1.iter().zip(v2.iter()).all(|(x, y)| *x == *y as usize)),
- }
- }
-}
-
-impl From<Vec<u32>> for IndexVec {
- fn from(v: Vec<u32>) -> Self {
- IndexVec::U32(v)
- }
-}
-
-impl From<Vec<usize>> for IndexVec {
- fn from(v: Vec<usize>) -> Self {
- IndexVec::USize(v)
- }
-}
-
-/// Return type of `IndexVec::iter`.
-#[derive(Debug)]
-pub enum IndexVecIter<'a> {
- #[doc(hidden)] U32(slice::Iter<'a, u32>),
- #[doc(hidden)] USize(slice::Iter<'a, usize>),
-}
-
-impl<'a> Iterator for IndexVecIter<'a> {
- type Item = usize;
- fn next(&mut self) -> Option<usize> {
- use self::IndexVecIter::*;
- match self {
- &mut U32(ref mut iter) => iter.next().map(|i| *i as usize),
- &mut USize(ref mut iter) => iter.next().cloned(),
- }
- }
-
- fn size_hint(&self) -> (usize, Option<usize>) {
- match self {
- &IndexVecIter::U32(ref v) => v.size_hint(),
- &IndexVecIter::USize(ref v) => v.size_hint(),
- }
- }
-}
-
-impl<'a> ExactSizeIterator for IndexVecIter<'a> {}
-
-/// Return type of `IndexVec::into_iter`.
-#[derive(Clone, Debug)]
-pub enum IndexVecIntoIter {
- #[doc(hidden)] U32(vec::IntoIter<u32>),
- #[doc(hidden)] USize(vec::IntoIter<usize>),
-}
-
-impl Iterator for IndexVecIntoIter {
- type Item = usize;
-
- fn next(&mut self) -> Option<Self::Item> {
- use self::IndexVecIntoIter::*;
- match self {
- &mut U32(ref mut v) => v.next().map(|i| i as usize),
- &mut USize(ref mut v) => v.next(),
- }
- }
-
- fn size_hint(&self) -> (usize, Option<usize>) {
- use self::IndexVecIntoIter::*;
- match self {
- &U32(ref v) => v.size_hint(),
- &USize(ref v) => v.size_hint(),
- }
- }
-}
-
-impl ExactSizeIterator for IndexVecIntoIter {}
-
-
-/// Randomly sample exactly `amount` distinct indices from `0..length`, and
-/// return them in random order (fully shuffled).
-///
-/// This method is used internally by the slice sampling methods, but it can
-/// sometimes be useful to have the indices themselves so this is provided as
-/// an alternative.
-///
-/// The implementation used is not specified; we automatically select the
-/// fastest available algorithm for the `length` and `amount` parameters
-/// (based on detailed profiling on an Intel Haswell CPU). Roughly speaking,
-/// complexity is `O(amount)`, except that when `amount` is small, performance
-/// is closer to `O(amount^2)`, and when `length` is close to `amount` then
-/// `O(length)`.
-///
-/// Note that performance is significantly better over `u32` indices than over
-/// `u64` indices. Because of this we hide the underlying type behind an
-/// abstraction, `IndexVec`.
-///
-/// If an allocation-free `no_std` function is required, it is suggested
-/// to adapt the internal `sample_floyd` implementation.
-///
-/// Panics if `amount > length`.
-pub fn sample<R>(rng: &mut R, length: usize, amount: usize) -> IndexVec
- where R: Rng + ?Sized,
-{
- if amount > length {
- panic!("`amount` of samples must be less than or equal to `length`");
- }
- if length > (::core::u32::MAX as usize) {
- // We never want to use inplace here, but could use floyd's alg
- // Lazy version: always use the cache alg.
- return sample_rejection(rng, length, amount);
- }
- let amount = amount as u32;
- let length = length as u32;
-
- // Choice of algorithm here depends on both length and amount. See:
- // https://github.com/rust-random/rand/pull/479
- // We do some calculations with f32. Accuracy is not very important.
-
- if amount < 163 {
- const C: [[f32; 2]; 2] = [[1.6, 8.0/45.0], [10.0, 70.0/9.0]];
- let j = if length < 500_000 { 0 } else { 1 };
- let amount_fp = amount as f32;
- let m4 = C[0][j] * amount_fp;
- // Short-cut: when amount < 12, floyd's is always faster
- if amount > 11 && (length as f32) < (C[1][j] + m4) * amount_fp {
- sample_inplace(rng, length, amount)
- } else {
- sample_floyd(rng, length, amount)
- }
- } else {
- const C: [f32; 2] = [270.0, 330.0/9.0];
- let j = if length < 500_000 { 0 } else { 1 };
- if (length as f32) < C[j] * (amount as f32) {
- sample_inplace(rng, length, amount)
- } else {
- // note: could have a specific u32 impl, but I'm lazy and
- // generics don't have usable conversions
- sample_rejection(rng, length as usize, amount as usize)
- }
- }
-}
-
-/// Randomly sample exactly `amount` indices from `0..length`, using Floyd's
-/// combination algorithm.
-///
-/// The output values are fully shuffled. (Overhead is under 50%.)
-///
-/// This implementation uses `O(amount)` memory and `O(amount^2)` time.
-fn sample_floyd<R>(rng: &mut R, length: u32, amount: u32) -> IndexVec
- where R: Rng + ?Sized,
-{
- // For small amount we use Floyd's fully-shuffled variant. For larger
- // amounts this is slow due to Vec::insert performance, so we shuffle
- // afterwards. Benchmarks show little overhead from extra logic.
- let floyd_shuffle = amount < 50;
-
- debug_assert!(amount <= length);
- let mut indices = Vec::with_capacity(amount as usize);
- for j in length - amount .. length {
- let t = rng.gen_range(0, j + 1);
- if floyd_shuffle {
- if let Some(pos) = indices.iter().position(|&x| x == t) {
- indices.insert(pos, j);
- continue;
- }
- } else {
- if indices.contains(&t) {
- indices.push(j);
- continue;
- }
- }
- indices.push(t);
- }
- if !floyd_shuffle {
- // Reimplement SliceRandom::shuffle with smaller indices
- for i in (1..amount).rev() {
- // invariant: elements with index > i have been locked in place.
- indices.swap(i as usize, rng.gen_range(0, i + 1) as usize);
- }
- }
- IndexVec::from(indices)
-}
-
-/// Randomly sample exactly `amount` indices from `0..length`, using an inplace
-/// partial Fisher-Yates method.
-/// Sample an amount of indices using an inplace partial fisher yates method.
-///
-/// This allocates the entire `length` of indices and randomizes only the first `amount`.
-/// It then truncates to `amount` and returns.
-///
-/// This method is not appropriate for large `length` and potentially uses a lot
-/// of memory; because of this we only implement for `u32` index (which improves
-/// performance in all cases).
-///
-/// Set-up is `O(length)` time and memory and shuffling is `O(amount)` time.
-fn sample_inplace<R>(rng: &mut R, length: u32, amount: u32) -> IndexVec
- where R: Rng + ?Sized,
-{
- debug_assert!(amount <= length);
- let mut indices: Vec<u32> = Vec::with_capacity(length as usize);
- indices.extend(0..length);
- for i in 0..amount {
- let j: u32 = rng.gen_range(i, length);
- indices.swap(i as usize, j as usize);
- }
- indices.truncate(amount as usize);
- debug_assert_eq!(indices.len(), amount as usize);
- IndexVec::from(indices)
-}
-
-/// Randomly sample exactly `amount` indices from `0..length`, using rejection
-/// sampling.
-///
-/// Since `amount <<< length` there is a low chance of a random sample in
-/// `0..length` being a duplicate. We test for duplicates and resample where
-/// necessary. The algorithm is `O(amount)` time and memory.
-fn sample_rejection<R>(rng: &mut R, length: usize, amount: usize) -> IndexVec
- where R: Rng + ?Sized,
-{
- debug_assert!(amount < length);
- #[cfg(feature="std")] let mut cache = HashSet::with_capacity(amount);
- #[cfg(not(feature="std"))] let mut cache = BTreeSet::new();
- let distr = Uniform::new(0, length);
- let mut indices = Vec::with_capacity(amount);
- for _ in 0..amount {
- let mut pos = distr.sample(rng);
- while !cache.insert(pos) {
- pos = distr.sample(rng);
- }
- indices.push(pos);
- }
-
- debug_assert_eq!(indices.len(), amount);
- IndexVec::from(indices)
-}
-
-#[cfg(test)]
-mod test {
- use super::*;
-
- #[test]
- fn test_sample_boundaries() {
- let mut r = ::test::rng(404);
-
- assert_eq!(sample_inplace(&mut r, 0, 0).len(), 0);
- assert_eq!(sample_inplace(&mut r, 1, 0).len(), 0);
- assert_eq!(sample_inplace(&mut r, 1, 1).into_vec(), vec![0]);
-
- assert_eq!(sample_rejection(&mut r, 1, 0).len(), 0);
-
- assert_eq!(sample_floyd(&mut r, 0, 0).len(), 0);
- assert_eq!(sample_floyd(&mut r, 1, 0).len(), 0);
- assert_eq!(sample_floyd(&mut r, 1, 1).into_vec(), vec![0]);
-
- // These algorithms should be fast with big numbers. Test average.
- let sum: usize = sample_rejection(&mut r, 1 << 25, 10)
- .into_iter().sum();
- assert!(1 << 25 < sum && sum < (1 << 25) * 25);
-
- let sum: usize = sample_floyd(&mut r, 1 << 25, 10)
- .into_iter().sum();
- assert!(1 << 25 < sum && sum < (1 << 25) * 25);
- }
-
- #[test]
- fn test_sample_alg() {
- let seed_rng = ::test::rng;
-
- // We can't test which algorithm is used directly, but Floyd's alg
- // should produce different results from the others. (Also, `inplace`
- // and `cached` currently use different sizes thus produce different results.)
-
- // A small length and relatively large amount should use inplace
- let (length, amount): (usize, usize) = (100, 50);
- let v1 = sample(&mut seed_rng(420), length, amount);
- let v2 = sample_inplace(&mut seed_rng(420), length as u32, amount as u32);
- assert!(v1.iter().all(|e| e < length));
- assert_eq!(v1, v2);
-
- // Test Floyd's alg does produce different results
- let v3 = sample_floyd(&mut seed_rng(420), length as u32, amount as u32);
- assert!(v1 != v3);
-
- // A large length and small amount should use Floyd
- let (length, amount): (usize, usize) = (1<<20, 50);
- let v1 = sample(&mut seed_rng(421), length, amount);
- let v2 = sample_floyd(&mut seed_rng(421), length as u32, amount as u32);
- assert!(v1.iter().all(|e| e < length));
- assert_eq!(v1, v2);
-
- // A large length and larger amount should use cache
- let (length, amount): (usize, usize) = (1<<20, 600);
- let v1 = sample(&mut seed_rng(422), length, amount);
- let v2 = sample_rejection(&mut seed_rng(422), length, amount);
- assert!(v1.iter().all(|e| e < length));
- assert_eq!(v1, v2);
- }
-}
diff --git a/rand/src/seq/mod.rs b/rand/src/seq/mod.rs
deleted file mode 100644
index 9959602..0000000
--- a/rand/src/seq/mod.rs
+++ /dev/null
@@ -1,836 +0,0 @@
-// Copyright 2018 Developers of the Rand project.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-//! Functions for randomly accessing and sampling sequences.
-//!
-//! TODO: module doc
-
-
-#[cfg(feature="alloc")] pub mod index;
-
-#[cfg(feature="alloc")] use core::ops::Index;
-
-#[cfg(all(feature="alloc", not(feature="std")))] use alloc::vec::Vec;
-
-use Rng;
-#[cfg(feature="alloc")] use distributions::WeightedError;
-#[cfg(feature="alloc")] use distributions::uniform::{SampleUniform, SampleBorrow};
-
-/// Extension trait on slices, providing random mutation and sampling methods.
-///
-/// An implementation is provided for slices. This may also be implementable for
-/// other types.
-pub trait SliceRandom {
- /// The element type.
- type Item;
-
- /// Returns a reference to one random element of the slice, or `None` if the
- /// slice is empty.
- ///
- /// Depending on the implementation, complexity is expected to be `O(1)`.
- ///
- /// # Example
- ///
- /// ```
- /// use rand::thread_rng;
- /// use rand::seq::SliceRandom;
- ///
- /// let choices = [1, 2, 4, 8, 16, 32];
- /// let mut rng = thread_rng();
- /// println!("{:?}", choices.choose(&mut rng));
- /// assert_eq!(choices[..0].choose(&mut rng), None);
- /// ```
- fn choose<R>(&self, rng: &mut R) -> Option<&Self::Item>
- where R: Rng + ?Sized;
-
- /// Returns a mutable reference to one random element of the slice, or
- /// `None` if the slice is empty.
- ///
- /// Depending on the implementation, complexity is expected to be `O(1)`.
- fn choose_mut<R>(&mut self, rng: &mut R) -> Option<&mut Self::Item>
- where R: Rng + ?Sized;
-
- /// Produces an iterator that chooses `amount` elements from the slice at
- /// random without repeating any, and returns them in random order.
- ///
- /// In case this API is not sufficiently flexible, use `index::sample` then
- /// apply the indices to the slice.
- ///
- /// Complexity is expected to be the same as `index::sample`.
- ///
- /// # Example
- /// ```
- /// use rand::seq::SliceRandom;
- ///
- /// let mut rng = &mut rand::thread_rng();
- /// let sample = "Hello, audience!".as_bytes();
- ///
- /// // collect the results into a vector:
- /// let v: Vec<u8> = sample.choose_multiple(&mut rng, 3).cloned().collect();
- ///
- /// // store in a buffer:
- /// let mut buf = [0u8; 5];
- /// for (b, slot) in sample.choose_multiple(&mut rng, buf.len()).zip(buf.iter_mut()) {
- /// *slot = *b;
- /// }
- /// ```
- #[cfg(feature = "alloc")]
- fn choose_multiple<R>(&self, rng: &mut R, amount: usize) -> SliceChooseIter<Self, Self::Item>
- where R: Rng + ?Sized;
-
- /// Similar to [`choose`], where the likelihood of each outcome may be
- /// specified. The specified function `weight` maps items `x` to a relative
- /// likelihood `weight(x)`. The probability of each item being selected is
- /// therefore `weight(x) / s`, where `s` is the sum of all `weight(x)`.
- ///
- /// # Example
- ///
- /// ```
- /// use rand::prelude::*;
- ///
- /// let choices = [('a', 2), ('b', 1), ('c', 1)];
- /// let mut rng = thread_rng();
- /// // 50% chance to print 'a', 25% chance to print 'b', 25% chance to print 'c'
- /// println!("{:?}", choices.choose_weighted(&mut rng, |item| item.1).unwrap().0);
- /// ```
- /// [`choose`]: trait.SliceRandom.html#method.choose
- #[cfg(feature = "alloc")]
- fn choose_weighted<R, F, B, X>(&self, rng: &mut R, weight: F) -> Result<&Self::Item, WeightedError>
- where R: Rng + ?Sized,
- F: Fn(&Self::Item) -> B,
- B: SampleBorrow<X>,
- X: SampleUniform +
- for<'a> ::core::ops::AddAssign<&'a X> +
- ::core::cmp::PartialOrd<X> +
- Clone +
- Default;
-
- /// Similar to [`choose_mut`], where the likelihood of each outcome may be
- /// specified. The specified function `weight` maps items `x` to a relative
- /// likelihood `weight(x)`. The probability of each item being selected is
- /// therefore `weight(x) / s`, where `s` is the sum of all `weight(x)`.
- ///
- /// See also [`choose_weighted`].
- ///
- /// [`choose_mut`]: trait.SliceRandom.html#method.choose_mut
- /// [`choose_weighted`]: trait.SliceRandom.html#method.choose_weighted
- #[cfg(feature = "alloc")]
- fn choose_weighted_mut<R, F, B, X>(&mut self, rng: &mut R, weight: F) -> Result<&mut Self::Item, WeightedError>
- where R: Rng + ?Sized,
- F: Fn(&Self::Item) -> B,
- B: SampleBorrow<X>,
- X: SampleUniform +
- for<'a> ::core::ops::AddAssign<&'a X> +
- ::core::cmp::PartialOrd<X> +
- Clone +
- Default;
-
- /// Shuffle a mutable slice in place.
- ///
- /// Depending on the implementation, complexity is expected to be `O(1)`.
- ///
- /// # Example
- ///
- /// ```
- /// use rand::thread_rng;
- /// use rand::seq::SliceRandom;
- ///
- /// let mut rng = thread_rng();
- /// let mut y = [1, 2, 3, 4, 5];
- /// println!("Unshuffled: {:?}", y);
- /// y.shuffle(&mut rng);
- /// println!("Shuffled: {:?}", y);
- /// ```
- fn shuffle<R>(&mut self, rng: &mut R) where R: Rng + ?Sized;
-
- /// Shuffle a slice in place, but exit early.
- ///
- /// Returns two mutable slices from the source slice. The first contains
- /// `amount` elements randomly permuted. The second has the remaining
- /// elements that are not fully shuffled.
- ///
- /// This is an efficient method to select `amount` elements at random from
- /// the slice, provided the slice may be mutated.
- ///
- /// If you only need to choose elements randomly and `amount > self.len()/2`
- /// then you may improve performance by taking
- /// `amount = values.len() - amount` and using only the second slice.
- ///
- /// If `amount` is greater than the number of elements in the slice, this
- /// will perform a full shuffle.
- ///
- /// Complexity is expected to be `O(m)` where `m = amount`.
- fn partial_shuffle<R>(&mut self, rng: &mut R, amount: usize)
- -> (&mut [Self::Item], &mut [Self::Item]) where R: Rng + ?Sized;
-}
-
-/// Extension trait on iterators, providing random sampling methods.
-pub trait IteratorRandom: Iterator + Sized {
- /// Choose one element at random from the iterator. If you have a slice,
- /// it's significantly faster to call the [`choose`] or [`choose_mut`]
- /// functions using the slice instead.
- ///
- /// Returns `None` if and only if the iterator is empty.
- ///
- /// Complexity is `O(n)`, where `n` is the length of the iterator.
- /// This likely consumes multiple random numbers, but the exact number
- /// is unspecified.
- ///
- /// [`choose`]: trait.SliceRandom.html#method.choose
- /// [`choose_mut`]: trait.SliceRandom.html#method.choose_mut
- fn choose<R>(mut self, rng: &mut R) -> Option<Self::Item>
- where R: Rng + ?Sized
- {
- let (mut lower, mut upper) = self.size_hint();
- let mut consumed = 0;
- let mut result = None;
-
- if upper == Some(lower) {
- return if lower == 0 { None } else { self.nth(rng.gen_range(0, lower)) };
- }
-
- // Continue until the iterator is exhausted
- loop {
- if lower > 1 {
- let ix = rng.gen_range(0, lower + consumed);
- let skip;
- if ix < lower {
- result = self.nth(ix);
- skip = lower - (ix + 1);
- } else {
- skip = lower;
- }
- if upper == Some(lower) {
- return result;
- }
- consumed += lower;
- if skip > 0 {
- self.nth(skip - 1);
- }
- } else {
- let elem = self.next();
- if elem.is_none() {
- return result;
- }
- consumed += 1;
- let denom = consumed as f64; // accurate to 2^53 elements
- if rng.gen_bool(1.0 / denom) {
- result = elem;
- }
- }
-
- let hint = self.size_hint();
- lower = hint.0;
- upper = hint.1;
- }
- }
-
- /// Collects `amount` values at random from the iterator into a supplied
- /// buffer.
- ///
- /// Although the elements are selected randomly, the order of elements in
- /// the buffer is neither stable nor fully random. If random ordering is
- /// desired, shuffle the result.
- ///
- /// Returns the number of elements added to the buffer. This equals `amount`
- /// unless the iterator contains insufficient elements, in which case this
- /// equals the number of elements available.
- ///
- /// Complexity is `O(n)` where `n` is the length of the iterator.
- fn choose_multiple_fill<R>(mut self, rng: &mut R, buf: &mut [Self::Item])
- -> usize where R: Rng + ?Sized
- {
- let amount = buf.len();
- let mut len = 0;
- while len < amount {
- if let Some(elem) = self.next() {
- buf[len] = elem;
- len += 1;
- } else {
- // Iterator exhausted; stop early
- return len;
- }
- }
-
- // Continue, since the iterator was not exhausted
- for (i, elem) in self.enumerate() {
- let k = rng.gen_range(0, i + 1 + amount);
- if let Some(slot) = buf.get_mut(k) {
- *slot = elem;
- }
- }
- len
- }
-
- /// Collects `amount` values at random from the iterator into a vector.
- ///
- /// This is equivalent to `choose_multiple_fill` except for the result type.
- ///
- /// Although the elements are selected randomly, the order of elements in
- /// the buffer is neither stable nor fully random. If random ordering is
- /// desired, shuffle the result.
- ///
- /// The length of the returned vector equals `amount` unless the iterator
- /// contains insufficient elements, in which case it equals the number of
- /// elements available.
- ///
- /// Complexity is `O(n)` where `n` is the length of the iterator.
- #[cfg(feature = "alloc")]
- fn choose_multiple<R>(mut self, rng: &mut R, amount: usize) -> Vec<Self::Item>
- where R: Rng + ?Sized
- {
- let mut reservoir = Vec::with_capacity(amount);
- reservoir.extend(self.by_ref().take(amount));
-
- // Continue unless the iterator was exhausted
- //
- // note: this prevents iterators that "restart" from causing problems.
- // If the iterator stops once, then so do we.
- if reservoir.len() == amount {
- for (i, elem) in self.enumerate() {
- let k = rng.gen_range(0, i + 1 + amount);
- if let Some(slot) = reservoir.get_mut(k) {
- *slot = elem;
- }
- }
- } else {
- // Don't hang onto extra memory. There is a corner case where
- // `amount` was much less than `self.len()`.
- reservoir.shrink_to_fit();
- }
- reservoir
- }
-}
-
-
-impl<T> SliceRandom for [T] {
- type Item = T;
-
- fn choose<R>(&self, rng: &mut R) -> Option<&Self::Item>
- where R: Rng + ?Sized
- {
- if self.is_empty() {
- None
- } else {
- Some(&self[rng.gen_range(0, self.len())])
- }
- }
-
- fn choose_mut<R>(&mut self, rng: &mut R) -> Option<&mut Self::Item>
- where R: Rng + ?Sized
- {
- if self.is_empty() {
- None
- } else {
- let len = self.len();
- Some(&mut self[rng.gen_range(0, len)])
- }
- }
-
- #[cfg(feature = "alloc")]
- fn choose_multiple<R>(&self, rng: &mut R, amount: usize)
- -> SliceChooseIter<Self, Self::Item>
- where R: Rng + ?Sized
- {
- let amount = ::core::cmp::min(amount, self.len());
- SliceChooseIter {
- slice: self,
- _phantom: Default::default(),
- indices: index::sample(rng, self.len(), amount).into_iter(),
- }
- }
-
- #[cfg(feature = "alloc")]
- fn choose_weighted<R, F, B, X>(&self, rng: &mut R, weight: F) -> Result<&Self::Item, WeightedError>
- where R: Rng + ?Sized,
- F: Fn(&Self::Item) -> B,
- B: SampleBorrow<X>,
- X: SampleUniform +
- for<'a> ::core::ops::AddAssign<&'a X> +
- ::core::cmp::PartialOrd<X> +
- Clone +
- Default {
- use distributions::{Distribution, WeightedIndex};
- let distr = WeightedIndex::new(self.iter().map(weight))?;
- Ok(&self[distr.sample(rng)])
- }
-
- #[cfg(feature = "alloc")]
- fn choose_weighted_mut<R, F, B, X>(&mut self, rng: &mut R, weight: F) -> Result<&mut Self::Item, WeightedError>
- where R: Rng + ?Sized,
- F: Fn(&Self::Item) -> B,
- B: SampleBorrow<X>,
- X: SampleUniform +
- for<'a> ::core::ops::AddAssign<&'a X> +
- ::core::cmp::PartialOrd<X> +
- Clone +
- Default {
- use distributions::{Distribution, WeightedIndex};
- let distr = WeightedIndex::new(self.iter().map(weight))?;
- Ok(&mut self[distr.sample(rng)])
- }
-
- fn shuffle<R>(&mut self, rng: &mut R) where R: Rng + ?Sized
- {
- for i in (1..self.len()).rev() {
- // invariant: elements with index > i have been locked in place.
- self.swap(i, rng.gen_range(0, i + 1));
- }
- }
-
- fn partial_shuffle<R>(&mut self, rng: &mut R, amount: usize)
- -> (&mut [Self::Item], &mut [Self::Item]) where R: Rng + ?Sized
- {
- // This applies Durstenfeld's algorithm for the
- // [Fisher–Yates shuffle](https://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle#The_modern_algorithm)
- // for an unbiased permutation, but exits early after choosing `amount`
- // elements.
-
- let len = self.len();
- let end = if amount >= len { 0 } else { len - amount };
-
- for i in (end..len).rev() {
- // invariant: elements with index > i have been locked in place.
- self.swap(i, rng.gen_range(0, i + 1));
- }
- let r = self.split_at_mut(end);
- (r.1, r.0)
- }
-}
-
-impl<I> IteratorRandom for I where I: Iterator + Sized {}
-
-
-/// Iterator over multiple choices, as returned by [`SliceRandom::choose_multiple](
-/// trait.SliceRandom.html#method.choose_multiple).
-#[cfg(feature = "alloc")]
-#[derive(Debug)]
-pub struct SliceChooseIter<'a, S: ?Sized + 'a, T: 'a> {
- slice: &'a S,
- _phantom: ::core::marker::PhantomData<T>,
- indices: index::IndexVecIntoIter,
-}
-
-#[cfg(feature = "alloc")]
-impl<'a, S: Index<usize, Output = T> + ?Sized + 'a, T: 'a> Iterator for SliceChooseIter<'a, S, T> {
- type Item = &'a T;
-
- fn next(&mut self) -> Option<Self::Item> {
- // TODO: investigate using SliceIndex::get_unchecked when stable
- self.indices.next().map(|i| &self.slice[i as usize])
- }
-
- fn size_hint(&self) -> (usize, Option<usize>) {
- (self.indices.len(), Some(self.indices.len()))
- }
-}
-
-#[cfg(feature = "alloc")]
-impl<'a, S: Index<usize, Output = T> + ?Sized + 'a, T: 'a> ExactSizeIterator
- for SliceChooseIter<'a, S, T>
-{
- fn len(&self) -> usize {
- self.indices.len()
- }
-}
-
-
-/// Randomly sample `amount` elements from a finite iterator.
-///
-/// Deprecated: use [`IteratorRandom::choose_multiple`] instead.
-///
-/// [`IteratorRandom::choose_multiple`]: trait.IteratorRandom.html#method.choose_multiple
-#[cfg(feature = "alloc")]
-#[deprecated(since="0.6.0", note="use IteratorRandom::choose_multiple instead")]
-pub fn sample_iter<T, I, R>(rng: &mut R, iterable: I, amount: usize) -> Result<Vec<T>, Vec<T>>
- where I: IntoIterator<Item=T>,
- R: Rng + ?Sized,
-{
- use seq::IteratorRandom;
- let iter = iterable.into_iter();
- let result = iter.choose_multiple(rng, amount);
- if result.len() == amount {
- Ok(result)
- } else {
- Err(result)
- }
-}
-
-/// Randomly sample exactly `amount` values from `slice`.
-///
-/// The values are non-repeating and in random order.
-///
-/// This implementation uses `O(amount)` time and memory.
-///
-/// Panics if `amount > slice.len()`
-///
-/// Deprecated: use [`SliceRandom::choose_multiple`] instead.
-///
-/// [`SliceRandom::choose_multiple`]: trait.SliceRandom.html#method.choose_multiple
-#[cfg(feature = "alloc")]
-#[deprecated(since="0.6.0", note="use SliceRandom::choose_multiple instead")]
-pub fn sample_slice<R, T>(rng: &mut R, slice: &[T], amount: usize) -> Vec<T>
- where R: Rng + ?Sized,
- T: Clone
-{
- let indices = index::sample(rng, slice.len(), amount).into_iter();
-
- let mut out = Vec::with_capacity(amount);
- out.extend(indices.map(|i| slice[i].clone()));
- out
-}
-
-/// Randomly sample exactly `amount` references from `slice`.
-///
-/// The references are non-repeating and in random order.
-///
-/// This implementation uses `O(amount)` time and memory.
-///
-/// Panics if `amount > slice.len()`
-///
-/// Deprecated: use [`SliceRandom::choose_multiple`] instead.
-///
-/// [`SliceRandom::choose_multiple`]: trait.SliceRandom.html#method.choose_multiple
-#[cfg(feature = "alloc")]
-#[deprecated(since="0.6.0", note="use SliceRandom::choose_multiple instead")]
-pub fn sample_slice_ref<'a, R, T>(rng: &mut R, slice: &'a [T], amount: usize) -> Vec<&'a T>
- where R: Rng + ?Sized
-{
- let indices = index::sample(rng, slice.len(), amount).into_iter();
-
- let mut out = Vec::with_capacity(amount);
- out.extend(indices.map(|i| &slice[i]));
- out
-}
-
-#[cfg(test)]
-mod test {
- use super::*;
- #[cfg(feature = "alloc")] use {Rng, SeedableRng};
- #[cfg(feature = "alloc")] use rngs::SmallRng;
- #[cfg(all(feature="alloc", not(feature="std")))]
- use alloc::vec::Vec;
-
- #[test]
- fn test_slice_choose() {
- let mut r = ::test::rng(107);
- let chars = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n'];
- let mut chosen = [0i32; 14];
- for _ in 0..1000 {
- let picked = *chars.choose(&mut r).unwrap();
- chosen[(picked as usize) - ('a' as usize)] += 1;
- }
- for count in chosen.iter() {
- let err = *count - (1000 / (chars.len() as i32));
- assert!(-20 <= err && err <= 20);
- }
-
- chosen.iter_mut().for_each(|x| *x = 0);
- for _ in 0..1000 {
- *chosen.choose_mut(&mut r).unwrap() += 1;
- }
- for count in chosen.iter() {
- let err = *count - (1000 / (chosen.len() as i32));
- assert!(-20 <= err && err <= 20);
- }
-
- let mut v: [isize; 0] = [];
- assert_eq!(v.choose(&mut r), None);
- assert_eq!(v.choose_mut(&mut r), None);
- }
-
- #[derive(Clone)]
- struct UnhintedIterator<I: Iterator + Clone> {
- iter: I,
- }
- impl<I: Iterator + Clone> Iterator for UnhintedIterator<I> {
- type Item = I::Item;
- fn next(&mut self) -> Option<Self::Item> {
- self.iter.next()
- }
- }
-
- #[derive(Clone)]
- struct ChunkHintedIterator<I: ExactSizeIterator + Iterator + Clone> {
- iter: I,
- chunk_remaining: usize,
- chunk_size: usize,
- hint_total_size: bool,
- }
- impl<I: ExactSizeIterator + Iterator + Clone> Iterator for ChunkHintedIterator<I> {
- type Item = I::Item;
- fn next(&mut self) -> Option<Self::Item> {
- if self.chunk_remaining == 0 {
- self.chunk_remaining = ::core::cmp::min(self.chunk_size,
- self.iter.len());
- }
- self.chunk_remaining = self.chunk_remaining.saturating_sub(1);
-
- self.iter.next()
- }
- fn size_hint(&self) -> (usize, Option<usize>) {
- (self.chunk_remaining,
- if self.hint_total_size { Some(self.iter.len()) } else { None })
- }
- }
-
- #[derive(Clone)]
- struct WindowHintedIterator<I: ExactSizeIterator + Iterator + Clone> {
- iter: I,
- window_size: usize,
- hint_total_size: bool,
- }
- impl<I: ExactSizeIterator + Iterator + Clone> Iterator for WindowHintedIterator<I> {
- type Item = I::Item;
- fn next(&mut self) -> Option<Self::Item> {
- self.iter.next()
- }
- fn size_hint(&self) -> (usize, Option<usize>) {
- (::core::cmp::min(self.iter.len(), self.window_size),
- if self.hint_total_size { Some(self.iter.len()) } else { None })
- }
- }
-
- #[test]
- fn test_iterator_choose() {
- let r = &mut ::test::rng(109);
- fn test_iter<R: Rng + ?Sized, Iter: Iterator<Item=usize> + Clone>(r: &mut R, iter: Iter) {
- let mut chosen = [0i32; 9];
- for _ in 0..1000 {
- let picked = iter.clone().choose(r).unwrap();
- chosen[picked] += 1;
- }
- for count in chosen.iter() {
- // Samples should follow Binomial(1000, 1/9)
- // Octave: binopdf(x, 1000, 1/9) gives the prob of *count == x
- // Note: have seen 153, which is unlikely but not impossible.
- assert!(72 < *count && *count < 154, "count not close to 1000/9: {}", count);
- }
- }
-
- test_iter(r, 0..9);
- test_iter(r, [0, 1, 2, 3, 4, 5, 6, 7, 8].iter().cloned());
- #[cfg(feature = "alloc")]
- test_iter(r, (0..9).collect::<Vec<_>>().into_iter());
- test_iter(r, UnhintedIterator { iter: 0..9 });
- test_iter(r, ChunkHintedIterator { iter: 0..9, chunk_size: 4, chunk_remaining: 4, hint_total_size: false });
- test_iter(r, ChunkHintedIterator { iter: 0..9, chunk_size: 4, chunk_remaining: 4, hint_total_size: true });
- test_iter(r, WindowHintedIterator { iter: 0..9, window_size: 2, hint_total_size: false });
- test_iter(r, WindowHintedIterator { iter: 0..9, window_size: 2, hint_total_size: true });
-
- assert_eq!((0..0).choose(r), None);
- assert_eq!(UnhintedIterator{ iter: 0..0 }.choose(r), None);
- }
-
- #[test]
- fn test_shuffle() {
- let mut r = ::test::rng(108);
- let empty: &mut [isize] = &mut [];
- empty.shuffle(&mut r);
- let mut one = [1];
- one.shuffle(&mut r);
- let b: &[_] = &[1];
- assert_eq!(one, b);
-
- let mut two = [1, 2];
- two.shuffle(&mut r);
- assert!(two == [1, 2] || two == [2, 1]);
-
- fn move_last(slice: &mut [usize], pos: usize) {
- // use slice[pos..].rotate_left(1); once we can use that
- let last_val = slice[pos];
- for i in pos..slice.len() - 1 {
- slice[i] = slice[i + 1];
- }
- *slice.last_mut().unwrap() = last_val;
- }
- let mut counts = [0i32; 24];
- for _ in 0..10000 {
- let mut arr: [usize; 4] = [0, 1, 2, 3];
- arr.shuffle(&mut r);
- let mut permutation = 0usize;
- let mut pos_value = counts.len();
- for i in 0..4 {
- pos_value /= 4 - i;
- let pos = arr.iter().position(|&x| x == i).unwrap();
- assert!(pos < (4 - i));
- permutation += pos * pos_value;
- move_last(&mut arr, pos);
- assert_eq!(arr[3], i);
- }
- for i in 0..4 {
- assert_eq!(arr[i], i);
- }
- counts[permutation] += 1;
- }
- for count in counts.iter() {
- let err = *count - 10000i32 / 24;
- assert!(-50 <= err && err <= 50);
- }
- }
-
- #[test]
- fn test_partial_shuffle() {
- let mut r = ::test::rng(118);
-
- let mut empty: [u32; 0] = [];
- let res = empty.partial_shuffle(&mut r, 10);
- assert_eq!((res.0.len(), res.1.len()), (0, 0));
-
- let mut v = [1, 2, 3, 4, 5];
- let res = v.partial_shuffle(&mut r, 2);
- assert_eq!((res.0.len(), res.1.len()), (2, 3));
- assert!(res.0[0] != res.0[1]);
- // First elements are only modified if selected, so at least one isn't modified:
- assert!(res.1[0] == 1 || res.1[1] == 2 || res.1[2] == 3);
- }
-
- #[test]
- #[cfg(feature = "alloc")]
- fn test_sample_iter() {
- let min_val = 1;
- let max_val = 100;
-
- let mut r = ::test::rng(401);
- let vals = (min_val..max_val).collect::<Vec<i32>>();
- let small_sample = vals.iter().choose_multiple(&mut r, 5);
- let large_sample = vals.iter().choose_multiple(&mut r, vals.len() + 5);
-
- assert_eq!(small_sample.len(), 5);
- assert_eq!(large_sample.len(), vals.len());
- // no randomization happens when amount >= len
- assert_eq!(large_sample, vals.iter().collect::<Vec<_>>());
-
- assert!(small_sample.iter().all(|e| {
- **e >= min_val && **e <= max_val
- }));
- }
-
- #[test]
- #[cfg(feature = "alloc")]
- #[allow(deprecated)]
- fn test_sample_slice_boundaries() {
- let empty: &[u8] = &[];
-
- let mut r = ::test::rng(402);
-
- // sample 0 items
- assert_eq!(&sample_slice(&mut r, empty, 0)[..], [0u8; 0]);
- assert_eq!(&sample_slice(&mut r, &[42, 2, 42], 0)[..], [0u8; 0]);
-
- // sample 1 item
- assert_eq!(&sample_slice(&mut r, &[42], 1)[..], [42]);
- let v = sample_slice(&mut r, &[1, 42], 1)[0];
- assert!(v == 1 || v == 42);
-
- // sample "all" the items
- let v = sample_slice(&mut r, &[42, 133], 2);
- assert!(&v[..] == [42, 133] || v[..] == [133, 42]);
-
- // Make sure lucky 777's aren't lucky
- let slice = &[42, 777];
- let mut num_42 = 0;
- let total = 1000;
- for _ in 0..total {
- let v = sample_slice(&mut r, slice, 1);
- assert_eq!(v.len(), 1);
- let v = v[0];
- assert!(v == 42 || v == 777);
- if v == 42 {
- num_42 += 1;
- }
- }
- let ratio_42 = num_42 as f64 / 1000 as f64;
- assert!(0.4 <= ratio_42 || ratio_42 <= 0.6, "{}", ratio_42);
- }
-
- #[test]
- #[cfg(feature = "alloc")]
- #[allow(deprecated)]
- fn test_sample_slice() {
- let seeded_rng = SmallRng::from_seed;
-
- let mut r = ::test::rng(403);
-
- for n in 1..20 {
- let length = 5*n - 4; // 1, 6, ...
- let amount = r.gen_range(0, length);
- let mut seed = [0u8; 16];
- r.fill(&mut seed);
-
- // assert the basics work
- let regular = index::sample(&mut seeded_rng(seed), length, amount);
- assert_eq!(regular.len(), amount);
- assert!(regular.iter().all(|e| e < length));
-
- // also test that sampling the slice works
- let vec: Vec<u32> = (0..(length as u32)).collect();
- let result = sample_slice(&mut seeded_rng(seed), &vec, amount);
- assert_eq!(result, regular.iter().map(|i| i as u32).collect::<Vec<_>>());
-
- let result = sample_slice_ref(&mut seeded_rng(seed), &vec, amount);
- assert!(result.iter().zip(regular.iter()).all(|(i,j)| **i == j as u32));
- }
- }
-
- #[test]
- #[cfg(feature = "alloc")]
- fn test_weighted() {
- let mut r = ::test::rng(406);
- const N_REPS: u32 = 3000;
- let weights = [1u32, 2, 3, 0, 5, 6, 7, 1, 2, 3, 4, 5, 6, 7];
- let total_weight = weights.iter().sum::<u32>() as f32;
-
- let verify = |result: [i32; 14]| {
- for (i, count) in result.iter().enumerate() {
- let exp = (weights[i] * N_REPS) as f32 / total_weight;
- let mut err = (*count as f32 - exp).abs();
- if err != 0.0 {
- err /= exp;
- }
- assert!(err <= 0.25);
- }
- };
-
- // choose_weighted
- fn get_weight<T>(item: &(u32, T)) -> u32 {
- item.0
- }
- let mut chosen = [0i32; 14];
- let mut items = [(0u32, 0usize); 14]; // (weight, index)
- for (i, item) in items.iter_mut().enumerate() {
- *item = (weights[i], i);
- }
- for _ in 0..N_REPS {
- let item = items.choose_weighted(&mut r, get_weight).unwrap();
- chosen[item.1] += 1;
- }
- verify(chosen);
-
- // choose_weighted_mut
- let mut items = [(0u32, 0i32); 14]; // (weight, count)
- for (i, item) in items.iter_mut().enumerate() {
- *item = (weights[i], 0);
- }
- for _ in 0..N_REPS {
- items.choose_weighted_mut(&mut r, get_weight).unwrap().1 += 1;
- }
- for (ch, item) in chosen.iter_mut().zip(items.iter()) {
- *ch = item.1;
- }
- verify(chosen);
-
- // Check error cases
- let empty_slice = &mut [10][0..0];
- assert_eq!(empty_slice.choose_weighted(&mut r, |_| 1), Err(WeightedError::NoItem));
- assert_eq!(empty_slice.choose_weighted_mut(&mut r, |_| 1), Err(WeightedError::NoItem));
- assert_eq!(['x'].choose_weighted_mut(&mut r, |_| 0), Err(WeightedError::AllWeightsZero));
- assert_eq!([0, -1].choose_weighted_mut(&mut r, |x| *x), Err(WeightedError::NegativeWeight));
- assert_eq!([-1, 0].choose_weighted_mut(&mut r, |x| *x), Err(WeightedError::NegativeWeight));
- }
-}
diff --git a/rand/tests/uniformity.rs b/rand/tests/uniformity.rs
deleted file mode 100644
index b8f74a6..0000000
--- a/rand/tests/uniformity.rs
+++ /dev/null
@@ -1,67 +0,0 @@
-// Copyright 2018 Developers of the Rand project.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-#![cfg(feature = "std")]
-
-#[macro_use]
-extern crate average;
-extern crate rand;
-
-use std as core;
-use rand::FromEntropy;
-use rand::distributions::Distribution;
-use average::Histogram;
-
-const N_BINS: usize = 100;
-const N_SAMPLES: u32 = 1_000_000;
-const TOL: f64 = 1e-3;
-define_histogram!(hist, 100);
-use hist::Histogram as Histogram100;
-
-#[test]
-fn unit_sphere() {
- const N_DIM: usize = 3;
- let h = Histogram100::with_const_width(-1., 1.);
- let mut histograms = [h.clone(), h.clone(), h];
- let dist = rand::distributions::UnitSphereSurface::new();
- let mut rng = rand::rngs::SmallRng::from_entropy();
- for _ in 0..N_SAMPLES {
- let v = dist.sample(&mut rng);
- for i in 0..N_DIM {
- histograms[i].add(v[i]).map_err(
- |e| { println!("v: {}", v[i]); e }
- ).unwrap();
- }
- }
- for h in &histograms {
- let sum: u64 = h.bins().iter().sum();
- println!("{:?}", h);
- for &b in h.bins() {
- let p = (b as f64) / (sum as f64);
- assert!((p - 1.0 / (N_BINS as f64)).abs() < TOL, "{}", p);
- }
- }
-}
-
-#[test]
-fn unit_circle() {
- use ::std::f64::consts::PI;
- let mut h = Histogram100::with_const_width(-PI, PI);
- let dist = rand::distributions::UnitCircle::new();
- let mut rng = rand::rngs::SmallRng::from_entropy();
- for _ in 0..N_SAMPLES {
- let v = dist.sample(&mut rng);
- h.add(v[0].atan2(v[1])).unwrap();
- }
- let sum: u64 = h.bins().iter().sum();
- println!("{:?}", h);
- for &b in h.bins() {
- let p = (b as f64) / (sum as f64);
- assert!((p - 1.0 / (N_BINS as f64)).abs() < TOL, "{}", p);
- }
-}
diff --git a/rand/utils/ci/install.sh b/rand/utils/ci/install.sh
deleted file mode 100644
index 8e636e1..0000000
--- a/rand/utils/ci/install.sh
+++ /dev/null
@@ -1,49 +0,0 @@
-# From https://github.com/japaric/trust
-
-set -ex
-
-main() {
- local target=
- if [ $TRAVIS_OS_NAME = linux ]; then
- target=x86_64-unknown-linux-musl
- sort=sort
- else
- target=x86_64-apple-darwin
- sort=gsort # for `sort --sort-version`, from brew's coreutils.
- fi
-
- # Builds for iOS are done on OSX, but require the specific target to be
- # installed.
- case $TARGET in
- aarch64-apple-ios)
- rustup target install aarch64-apple-ios
- ;;
- armv7-apple-ios)
- rustup target install armv7-apple-ios
- ;;
- armv7s-apple-ios)
- rustup target install armv7s-apple-ios
- ;;
- i386-apple-ios)
- rustup target install i386-apple-ios
- ;;
- x86_64-apple-ios)
- rustup target install x86_64-apple-ios
- ;;
- esac
-
- # This fetches latest stable release
- local tag=$(git ls-remote --tags --refs --exit-code https://github.com/japaric/cross \
- | cut -d/ -f3 \
- | grep -E '^v[0.1.0-9.]+$' \
- | $sort --version-sort \
- | tail -n1)
- curl -LSfs https://japaric.github.io/trust/install.sh | \
- sh -s -- \
- --force \
- --git japaric/cross \
- --tag $tag \
- --target $target
-}
-
-main
diff --git a/rand/utils/ci/install_cargo_web.sh b/rand/utils/ci/install_cargo_web.sh
deleted file mode 100755
index b35f069..0000000
--- a/rand/utils/ci/install_cargo_web.sh
+++ /dev/null
@@ -1,15 +0,0 @@
-#!/bin/bash
-
-set -euo pipefail
-IFS=$'\n\t'
-
-CARGO_WEB_RELEASE=$(curl -L -s -H 'Accept: application/json' https://github.com/koute/cargo-web/releases/latest)
-CARGO_WEB_VERSION=$(echo $CARGO_WEB_RELEASE | sed -e 's/.*"tag_name":"\([^"]*\)".*/\1/')
-CARGO_WEB_URL="https://github.com/koute/cargo-web/releases/download/$CARGO_WEB_VERSION/cargo-web-x86_64-unknown-linux-gnu.gz"
-
-echo "Downloading cargo-web from: $CARGO_WEB_URL"
-curl -L $CARGO_WEB_URL | gzip -d > cargo-web
-chmod +x cargo-web
-
-mkdir -p ~/.cargo/bin
-mv cargo-web ~/.cargo/bin
diff --git a/rand/utils/ci/script.sh b/rand/utils/ci/script.sh
deleted file mode 100644
index e8c1189..0000000
--- a/rand/utils/ci/script.sh
+++ /dev/null
@@ -1,24 +0,0 @@
-# Derived from https://github.com/japaric/trust
-
-set -ex
-
-main() {
- cross test --target $TARGET --lib --no-default-features
- # TODO: add simd_support feature:
- cross test --target $TARGET --features=serde1,log
- cross test --target $TARGET --examples
- cross test --target $TARGET --manifest-path rand_core/Cargo.toml
- cross test --target $TARGET --manifest-path rand_core/Cargo.toml --no-default-features
- cross test --target $TARGET --manifest-path rand_isaac/Cargo.toml --features=serde1
- cross test --target $TARGET --manifest-path rand_pcg/Cargo.toml --features=serde1
- cross test --target $TARGET --manifest-path rand_xorshift/Cargo.toml --features=serde1
- cross test --target $TARGET --manifest-path rand_xoshiro/Cargo.toml
- cross test --target $TARGET --manifest-path rand_chacha/Cargo.toml
- cross test --target $TARGET --manifest-path rand_hc/Cargo.toml
- cross test --target $TARGET --manifest-path rand_os/Cargo.toml
-}
-
-# we don't run the "test phase" when doing deploys
-if [ -z $TRAVIS_TAG ]; then
- main
-fi
diff --git a/rand/utils/ziggurat_tables.py b/rand/utils/ziggurat_tables.py
deleted file mode 100755
index 88cfdab..0000000
--- a/rand/utils/ziggurat_tables.py
+++ /dev/null
@@ -1,125 +0,0 @@
-#!/usr/bin/env python
-#
-# Copyright 2018 Developers of the Rand project.
-# Copyright 2013 The Rust Project Developers.
-#
-# Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-# https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-# <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
-# option. This file may not be copied, modified, or distributed
-# except according to those terms.
-
-# This creates the tables used for distributions implemented using the
-# ziggurat algorithm in `rand::distributions;`. They are
-# (basically) the tables as used in the ZIGNOR variant (Doornik 2005).
-# They are changed rarely, so the generated file should be checked in
-# to git.
-#
-# It creates 3 tables: X as in the paper, F which is f(x_i), and
-# F_DIFF which is f(x_i) - f(x_{i-1}). The latter two are just cached
-# values which is not done in that paper (but is done in other
-# variants). Note that the adZigR table is unnecessary because of
-# algebra.
-#
-# It is designed to be compatible with Python 2 and 3.
-
-from math import exp, sqrt, log, floor
-import random
-
-# The order should match the return value of `tables`
-TABLE_NAMES = ['X', 'F']
-
-# The actual length of the table is 1 more, to stop
-# index-out-of-bounds errors. This should match the bitwise operation
-# to find `i` in `zigurrat` in `libstd/rand/mod.rs`. Also the *_R and
-# *_V constants below depend on this value.
-TABLE_LEN = 256
-
-# equivalent to `zigNorInit` in Doornik2005, but generalised to any
-# distribution. r = dR, v = dV, f = probability density function,
-# f_inv = inverse of f
-def tables(r, v, f, f_inv):
- # compute the x_i
- xvec = [0]*(TABLE_LEN+1)
-
- xvec[0] = v / f(r)
- xvec[1] = r
-
- for i in range(2, TABLE_LEN):
- last = xvec[i-1]
- xvec[i] = f_inv(v / last + f(last))
-
- # cache the f's
- fvec = [0]*(TABLE_LEN+1)
- for i in range(TABLE_LEN+1):
- fvec[i] = f(xvec[i])
-
- return xvec, fvec
-
-# Distributions
-# N(0, 1)
-def norm_f(x):
- return exp(-x*x/2.0)
-def norm_f_inv(y):
- return sqrt(-2.0*log(y))
-
-NORM_R = 3.6541528853610088
-NORM_V = 0.00492867323399
-
-NORM = tables(NORM_R, NORM_V,
- norm_f, norm_f_inv)
-
-# Exp(1)
-def exp_f(x):
- return exp(-x)
-def exp_f_inv(y):
- return -log(y)
-
-EXP_R = 7.69711747013104972
-EXP_V = 0.0039496598225815571993
-
-EXP = tables(EXP_R, EXP_V,
- exp_f, exp_f_inv)
-
-
-# Output the tables/constants/types
-
-def render_static(name, type, value):
- # no space or
- return 'pub static %s: %s =%s;\n' % (name, type, value)
-
-# static `name`: [`type`, .. `len(values)`] =
-# [values[0], ..., values[3],
-# values[4], ..., values[7],
-# ... ];
-def render_table(name, values):
- rows = []
- # 4 values on each row
- for i in range(0, len(values), 4):
- row = values[i:i+4]
- rows.append(', '.join('%.18f' % f for f in row))
-
- rendered = '\n [%s]' % ',\n '.join(rows)
- return render_static(name, '[f64, .. %d]' % len(values), rendered)
-
-
-with open('ziggurat_tables.rs', 'w') as f:
- f.write('''// Copyright 2018 Developers of the Rand project.
-// Copyright 2013 The Rust Project Developers.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-// Tables for distributions which are sampled using the ziggurat
-// algorithm. Autogenerated by `ziggurat_tables.py`.
-
-pub type ZigTable = &\'static [f64, .. %d];
-''' % (TABLE_LEN + 1))
- for name, tables, r in [('NORM', NORM, NORM_R),
- ('EXP', EXP, EXP_R)]:
- f.write(render_static('ZIG_%s_R' % name, 'f64', ' %.18f' % r))
- for (tabname, table) in zip(TABLE_NAMES, tables):
- f.write(render_table('ZIG_%s_%s' % (name, tabname), table))
diff --git a/nitrocli/rustfmt.toml b/rustfmt.toml
index b196eaa..b196eaa 100644
--- a/nitrocli/rustfmt.toml
+++ b/rustfmt.toml
diff --git a/nitrocli/src/arg_util.rs b/src/arg_util.rs
index e2e7b1d..439a594 100644
--- a/nitrocli/src/arg_util.rs
+++ b/src/arg_util.rs
@@ -1,7 +1,7 @@
// arg_util.rs
// *************************************************************************
-// * Copyright (C) 2019 Daniel Mueller (deso@posteo.net) *
+// * Copyright (C) 2019-2020 Daniel Mueller (deso@posteo.net) *
// * *
// * This program is free software: you can redistribute it and/or modify *
// * it under the terms of the GNU General Public License as published by *
@@ -24,31 +24,45 @@ macro_rules! count {
}
}
-/// A macro for generating an enum with a set of simple (i.e., no
-/// parameters) variants and their textual representations.
-// TODO: Right now we hard code the derives we create. We may want to
-// make this set configurable.
-macro_rules! Enum {
- ( $name:ident, [ $( $var:ident => ($str:expr, $exec:expr), ) *] ) => {
- Enum! {$name, [
- $( $var => $str, )*
- ]}
+/// Translate an optional source into an optional destination.
+macro_rules! tr {
+ ($dst:tt, $src:tt) => {
+ $dst
+ };
+ ($dst:tt) => {};
+}
+
+macro_rules! Command {
+ ( $name:ident, [ $( $(#[$doc:meta])* $var:ident$(($inner:ty))? => $exec:expr, ) *] ) => {
+ #[derive(Debug, PartialEq, structopt::StructOpt)]
+ pub enum $name {
+ $(
+ $(#[$doc])*
+ $var$(($inner))?,
+ )*
+ }
#[allow(unused_qualifications)]
impl $name {
- fn execute(
+ pub fn execute(
self,
- ctx: &mut crate::args::ExecCtx<'_>,
- args: ::std::vec::Vec<::std::string::String>,
+ ctx: &mut crate::ExecCtx<'_>,
) -> crate::Result<()> {
match self {
$(
- $name::$var => $exec(ctx, args),
+ $name::$var$((tr!(args, $inner)))? => $exec(ctx $(,tr!(args, $inner))?),
)*
}
}
}
};
+}
+
+/// A macro for generating an enum with a set of simple (i.e., no
+/// parameters) variants and their textual representations.
+// TODO: Right now we hard code the derives we create. We may want to
+// make this set configurable.
+macro_rules! Enum {
( $name:ident, [ $( $var:ident => $str:expr, ) *] ) => {
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum $name {
@@ -57,6 +71,14 @@ macro_rules! Enum {
)*
}
+ enum_int! {$name, [
+ $( $var => $str, )*
+ ]}
+ };
+}
+
+macro_rules! enum_int {
+ ( $name:ident, [ $( $var:ident => $str:expr, ) *] ) => {
impl $name {
#[allow(unused)]
pub fn all(&self) -> [$name; count!($($var),*) ] {
@@ -70,6 +92,15 @@ macro_rules! Enum {
)*
]
}
+
+ #[allow(unused)]
+ pub fn all_str() -> [&'static str; count!($($var),*)] {
+ [
+ $(
+ $str,
+ )*
+ ]
+ }
}
impl ::std::convert::AsRef<str> for $name {
@@ -89,50 +120,25 @@ macro_rules! Enum {
}
impl ::std::str::FromStr for $name {
- type Err = ();
+ type Err = ::std::string::String;
fn from_str(s: &str) -> ::std::result::Result<Self, Self::Err> {
match s {
$(
$str => Ok($name::$var),
)*
- _ => Err(()),
+ _ => Err(
+ format!(
+ "expected one of {}",
+ $name::all_str().join(", "),
+ )
+ )
}
}
}
};
}
-/// A macro for formatting the variants of an enum (as created by the
-/// Enum!{} macro) ready to be used in a help text. The supplied `fmt`
-/// needs to contain the named parameter `{variants}`, which will be
-/// replaced with a generated version of the enum's variants.
-macro_rules! fmt_enum {
- ( $enm:ident ) => {{
- fmt_enum!($enm.all())
- }};
- ( $all:expr ) => {{
- $all
- .iter()
- .map(::std::convert::AsRef::as_ref)
- .collect::<::std::vec::Vec<_>>()
- .join("|")
- }};
-}
-
-/// A macro for generating the help text for a command/subcommand. The
-/// argument is the variable representing the command (which in turn is
-/// an enum).
-/// Note that the name of this variable is embedded into the help text!
-macro_rules! cmd_help {
- ( $cmd:ident ) => {
- format!(
- concat!("The ", stringify!($cmd), " to execute ({})"),
- fmt_enum!($cmd)
- )
- };
-}
-
#[cfg(test)]
mod tests {
Enum! {Command, [
diff --git a/src/args.rs b/src/args.rs
new file mode 100644
index 0000000..20392a8
--- /dev/null
+++ b/src/args.rs
@@ -0,0 +1,433 @@
+// args.rs
+
+// *************************************************************************
+// * Copyright (C) 2020 Daniel Mueller (deso@posteo.net) *
+// * *
+// * This program is free software: you can redistribute it and/or modify *
+// * it under the terms of the GNU General Public License as published by *
+// * the Free Software Foundation, either version 3 of the License, or *
+// * (at your option) any later version. *
+// * *
+// * This program is distributed in the hope that it will be useful, *
+// * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+// * GNU General Public License for more details. *
+// * *
+// * You should have received a copy of the GNU General Public License *
+// * along with this program. If not, see <http://www.gnu.org/licenses/>. *
+// *************************************************************************
+
+/// Provides access to a Nitrokey device
+#[derive(structopt::StructOpt)]
+#[structopt(name = "nitrocli")]
+pub struct Args {
+ /// Increases the log level (can be supplied multiple times)
+ #[structopt(short, long, global = true, parse(from_occurrences))]
+ pub verbose: u8,
+ /// Selects the device model to connect to
+ #[structopt(short, long, global = true, possible_values = &DeviceModel::all_str())]
+ pub model: Option<DeviceModel>,
+ #[structopt(subcommand)]
+ pub cmd: Command,
+}
+
+/// The available Nitrokey models.
+#[allow(unused_doc_comments)]
+Enum! {DeviceModel, [
+ Pro => "pro",
+ Storage => "storage",
+]}
+
+impl DeviceModel {
+ pub fn as_user_facing_str(&self) -> &str {
+ match self {
+ DeviceModel::Pro => "Pro",
+ DeviceModel::Storage => "Storage",
+ }
+ }
+}
+
+impl From<DeviceModel> for nitrokey::Model {
+ fn from(model: DeviceModel) -> nitrokey::Model {
+ match model {
+ DeviceModel::Pro => nitrokey::Model::Pro,
+ DeviceModel::Storage => nitrokey::Model::Storage,
+ }
+ }
+}
+
+/// A top-level command for nitrocli.
+#[allow(unused_doc_comments)]
+Command! {Command, [
+ /// Reads or writes the device configuration
+ Config(ConfigArgs) => |ctx, args: ConfigArgs| args.subcmd.execute(ctx),
+ /// Interacts with the device's encrypted volume
+ Encrypted(EncryptedArgs) => |ctx, args: EncryptedArgs| args.subcmd.execute(ctx),
+ /// Interacts with the device's hidden volume
+ Hidden(HiddenArgs) => |ctx, args: HiddenArgs| args.subcmd.execute(ctx),
+ /// Lists the attached Nitrokey devices
+ List(ListArgs) => |ctx, args: ListArgs| crate::commands::list(ctx, args.no_connect),
+ /// Locks the connected Nitrokey device
+ Lock => crate::commands::lock,
+ /// Accesses one-time passwords
+ Otp(OtpArgs) => |ctx, args: OtpArgs| args.subcmd.execute(ctx),
+ /// Manages the Nitrokey PINs
+ Pin(PinArgs) => |ctx, args: PinArgs| args.subcmd.execute(ctx),
+ /// Accesses the password safe
+ Pws(PwsArgs) => |ctx, args: PwsArgs| args.subcmd.execute(ctx),
+ /// Performs a factory reset
+ Reset => crate::commands::reset,
+ /// Prints the status of the connected Nitrokey device
+ Status => crate::commands::status,
+ /// Interacts with the device's unencrypted volume
+ Unencrypted(UnencryptedArgs) => |ctx, args: UnencryptedArgs| args.subcmd.execute(ctx),
+]}
+
+#[derive(Debug, PartialEq, structopt::StructOpt)]
+pub struct ConfigArgs {
+ #[structopt(subcommand)]
+ subcmd: ConfigCommand,
+}
+
+Command! {ConfigCommand, [
+ /// Prints the Nitrokey configuration
+ Get => crate::commands::config_get,
+ /// Changes the Nitrokey configuration
+ Set(ConfigSetArgs) => crate::commands::config_set,
+]}
+
+#[derive(Debug, PartialEq, structopt::StructOpt)]
+pub struct ConfigSetArgs {
+ /// Sets the numlock option to the given HOTP slot
+ #[structopt(short = "n", long)]
+ pub numlock: Option<u8>,
+ /// Unsets the numlock option
+ #[structopt(short = "N", long, conflicts_with("numlock"))]
+ pub no_numlock: bool,
+ /// Sets the capslock option to the given HOTP slot
+ #[structopt(short = "c", long)]
+ pub capslock: Option<u8>,
+ /// Unsets the capslock option
+ #[structopt(short = "C", long, conflicts_with("capslock"))]
+ pub no_capslock: bool,
+ /// Sets the scrollock option to the given HOTP slot
+ #[structopt(short = "s", long)]
+ pub scrollock: Option<u8>,
+ /// Unsets the scrollock option
+ #[structopt(short = "S", long, conflicts_with("scrollock"))]
+ pub no_scrollock: bool,
+ /// Requires the user PIN to generate one-time passwords
+ #[structopt(short = "o", long)]
+ pub otp_pin: bool,
+ /// Allows one-time password generation without PIN
+ #[structopt(short = "O", long, conflicts_with("otp-pin"))]
+ pub no_otp_pin: bool,
+}
+
+#[derive(Clone, Copy, Debug)]
+pub enum ConfigOption<T> {
+ Enable(T),
+ Disable,
+ Ignore,
+}
+
+impl<T> ConfigOption<T> {
+ pub fn try_from(disable: bool, value: Option<T>, name: &'static str) -> Result<Self, String> {
+ if disable {
+ if value.is_some() {
+ Err(format!(
+ "--{name} and --no-{name} are mutually exclusive",
+ name = name
+ ))
+ } else {
+ Ok(ConfigOption::Disable)
+ }
+ } else {
+ match value {
+ Some(value) => Ok(ConfigOption::Enable(value)),
+ None => Ok(ConfigOption::Ignore),
+ }
+ }
+ }
+
+ pub fn or(self, default: Option<T>) -> Option<T> {
+ match self {
+ ConfigOption::Enable(value) => Some(value),
+ ConfigOption::Disable => None,
+ ConfigOption::Ignore => default,
+ }
+ }
+}
+
+#[derive(Debug, PartialEq, structopt::StructOpt)]
+pub struct EncryptedArgs {
+ #[structopt(subcommand)]
+ subcmd: EncryptedCommand,
+}
+
+Command! {EncryptedCommand, [
+ /// Closes the encrypted volume on a Nitrokey Storage
+ Close => crate::commands::encrypted_close,
+ /// Opens the encrypted volume on a Nitrokey Storage
+ Open => crate::commands::encrypted_open,
+]}
+
+#[derive(Debug, PartialEq, structopt::StructOpt)]
+pub struct HiddenArgs {
+ #[structopt(subcommand)]
+ subcmd: HiddenCommand,
+}
+
+Command! {HiddenCommand, [
+ /// Closes the hidden volume on a Nitrokey Storage
+ Close => crate::commands::hidden_close,
+ /// Creates a hidden volume on a Nitrokey Storage
+ Create(HiddenCreateArgs) => |ctx, args: HiddenCreateArgs| {
+ crate::commands::hidden_create(ctx, args.slot, args.start, args.end)
+ },
+ /// Opens the hidden volume on a Nitrokey Storage
+ Open => crate::commands::hidden_open,
+]}
+
+#[derive(Debug, PartialEq, structopt::StructOpt)]
+pub struct HiddenCreateArgs {
+ /// The hidden volume slot to use
+ pub slot: u8,
+ /// The start location of the hidden volume as a percentage of the encrypted volume's size (0-99)
+ pub start: u8,
+ /// The end location of the hidden volume as a percentage of the encrypted volume's size (1-100)
+ pub end: u8,
+}
+
+#[derive(Debug, PartialEq, structopt::StructOpt)]
+pub struct ListArgs {
+ /// Only print the information that is available without connecting to a device
+ #[structopt(short, long)]
+ pub no_connect: bool,
+}
+
+#[derive(Debug, PartialEq, structopt::StructOpt)]
+pub struct OtpArgs {
+ #[structopt(subcommand)]
+ subcmd: OtpCommand,
+}
+
+Command! {OtpCommand, [
+ /// Clears a one-time password slot
+ Clear(OtpClearArgs) => |ctx, args: OtpClearArgs| {
+ crate::commands::otp_clear(ctx, args.slot, args.algorithm)
+ },
+ /// Generates a one-time password
+ Get(OtpGetArgs) => |ctx, args: OtpGetArgs| {
+ crate::commands::otp_get(ctx, args.slot, args.algorithm, args.time)
+ },
+ /// Configures a one-time password slot
+ Set(OtpSetArgs) => crate::commands::otp_set,
+ /// Prints the status of the one-time password slots
+ Status(OtpStatusArgs) => |ctx, args: OtpStatusArgs| crate::commands::otp_status(ctx, args.all),
+]}
+
+#[derive(Debug, PartialEq, structopt::StructOpt)]
+pub struct OtpClearArgs {
+ /// The OTP algorithm to use
+ #[structopt(short, long, default_value = OtpAlgorithm::Totp.as_ref(),
+ possible_values = &OtpAlgorithm::all_str())]
+ pub algorithm: OtpAlgorithm,
+ /// The OTP slot to clear
+ pub slot: u8,
+}
+
+#[derive(Debug, PartialEq, structopt::StructOpt)]
+pub struct OtpGetArgs {
+ /// The OTP algorithm to use
+ #[structopt(short, long, default_value = OtpAlgorithm::Totp.as_ref(),
+ possible_values = &OtpAlgorithm::all_str())]
+ pub algorithm: OtpAlgorithm,
+ /// The time to use for TOTP generation (Unix timestamp) [default: system time]
+ #[structopt(short, long)]
+ pub time: Option<u64>,
+ /// The OTP slot to use
+ pub slot: u8,
+}
+
+#[derive(Debug, PartialEq, structopt::StructOpt)]
+pub struct OtpSetArgs {
+ /// The OTP algorithm to use
+ #[structopt(short, long, default_value = OtpAlgorithm::Totp.as_ref(),
+ possible_values = &OtpAlgorithm::all_str())]
+ pub algorithm: OtpAlgorithm,
+ /// The number of digits to use for the one-time password
+ #[structopt(short, long, default_value = OtpMode::SixDigits.as_ref(),
+ possible_values = &OtpMode::all_str())]
+ pub digits: OtpMode,
+ /// The counter value for HOTP
+ #[structopt(short, long, default_value = "0")]
+ pub counter: u64,
+ /// The time window for TOTP
+ #[structopt(short, long, default_value = "30")]
+ pub time_window: u16,
+ /// The format of the secret
+ #[structopt(short, long, default_value = OtpSecretFormat::Hex.as_ref(),
+ possible_values = &OtpSecretFormat::all_str())]
+ pub format: OtpSecretFormat,
+ /// The OTP slot to use
+ pub slot: u8,
+ /// The name of the slot
+ pub name: String,
+ /// The secret to store on the slot as a hexadecimal string (or in the format set with the
+ /// --format option)
+ pub secret: String,
+}
+
+#[derive(Debug, PartialEq, structopt::StructOpt)]
+pub struct OtpStatusArgs {
+ /// Shows slots that are not programmed
+ #[structopt(short, long)]
+ pub all: bool,
+}
+
+Enum! {OtpAlgorithm, [
+ Hotp => "hotp",
+ Totp => "totp",
+]}
+
+Enum! {OtpMode, [
+ SixDigits => "6",
+ EightDigits => "8",
+]}
+
+impl From<OtpMode> for nitrokey::OtpMode {
+ fn from(mode: OtpMode) -> Self {
+ match mode {
+ OtpMode::SixDigits => nitrokey::OtpMode::SixDigits,
+ OtpMode::EightDigits => nitrokey::OtpMode::EightDigits,
+ }
+ }
+}
+
+Enum! {OtpSecretFormat, [
+ Ascii => "ascii",
+ Base32 => "base32",
+ Hex => "hex",
+]}
+
+#[derive(Debug, PartialEq, structopt::StructOpt)]
+pub struct PinArgs {
+ #[structopt(subcommand)]
+ subcmd: PinCommand,
+}
+
+Command! {PinCommand, [
+ /// Clears the cached PINs
+ Clear => crate::commands::pin_clear,
+ /// Changes a PIN
+ Set(PinSetArgs) => |ctx, args: PinSetArgs| crate::commands::pin_set(ctx, args.pintype),
+ /// Unblocks and resets the user PIN
+ Unblock => crate::commands::pin_unblock,
+]}
+
+/// PIN type requested from pinentry.
+///
+/// The available PIN types correspond to the PIN types used by the Nitrokey devices: user and
+/// admin.
+#[allow(unused_doc_comments)]
+Enum! {PinType, [
+ Admin => "admin",
+ User => "user",
+]}
+
+#[derive(Debug, PartialEq, structopt::StructOpt)]
+pub struct PinSetArgs {
+ /// The PIN type to change
+ #[structopt(name = "type", possible_values = &PinType::all_str())]
+ pub pintype: PinType,
+}
+
+#[derive(Debug, PartialEq, structopt::StructOpt)]
+pub struct PwsArgs {
+ #[structopt(subcommand)]
+ subcmd: PwsCommand,
+}
+
+Command! {PwsCommand, [
+ /// Clears a password safe slot
+ Clear(PwsClearArgs) => |ctx, args: PwsClearArgs| crate::commands::pws_clear(ctx, args.slot),
+ /// Reads a password safe slot
+ Get(PwsGetArgs) => |ctx, args: PwsGetArgs| {
+ crate::commands::pws_get(ctx, args.slot, args.name, args.login, args.password, args.quiet)
+ },
+ /// Writes a password safe slot
+ Set(PwsSetArgs) => |ctx, args: PwsSetArgs| {
+ crate::commands::pws_set(ctx, args.slot, &args.name, &args.login, &args.password)
+ },
+ /// Prints the status of the password safe slots
+ Status(PwsStatusArgs) => |ctx, args: PwsStatusArgs| crate::commands::pws_status(ctx, args.all),
+]}
+
+#[derive(Debug, PartialEq, structopt::StructOpt)]
+pub struct PwsClearArgs {
+ /// The PWS slot to clear
+ pub slot: u8,
+}
+
+#[derive(Debug, PartialEq, structopt::StructOpt)]
+pub struct PwsGetArgs {
+ /// Shows the name stored on the slot
+ #[structopt(short, long)]
+ pub name: bool,
+ /// Shows the login stored on the slot
+ #[structopt(short, long)]
+ pub login: bool,
+ /// Shows the password stored on the slot
+ #[structopt(short, long)]
+ pub password: bool,
+ /// Prints the stored data without description
+ #[structopt(short, long)]
+ pub quiet: bool,
+ /// The PWS slot to read
+ pub slot: u8,
+}
+
+#[derive(Debug, PartialEq, structopt::StructOpt)]
+pub struct PwsSetArgs {
+ /// The PWS slot to write
+ pub slot: u8,
+ /// The name to store on the slot
+ pub name: String,
+ /// The login to store on the slot
+ pub login: String,
+ /// The password to store on the slot
+ pub password: String,
+}
+
+#[derive(Debug, PartialEq, structopt::StructOpt)]
+pub struct PwsStatusArgs {
+ /// Shows slots that are not programmed
+ #[structopt(short, long)]
+ pub all: bool,
+}
+
+#[derive(Debug, PartialEq, structopt::StructOpt)]
+pub struct UnencryptedArgs {
+ #[structopt(subcommand)]
+ subcmd: UnencryptedCommand,
+}
+
+Command! {UnencryptedCommand, [
+ /// Changes the configuration of the unencrypted volume on a Nitrokey Storage
+ Set(UnencryptedSetArgs) => |ctx, args: UnencryptedSetArgs| {
+ crate::commands::unencrypted_set(ctx, args.mode)
+ },
+]}
+
+#[derive(Debug, PartialEq, structopt::StructOpt)]
+pub struct UnencryptedSetArgs {
+ /// The mode to change to
+ #[structopt(name = "type", possible_values = &UnencryptedVolumeMode::all_str())]
+ pub mode: UnencryptedVolumeMode,
+}
+
+Enum! {UnencryptedVolumeMode, [
+ ReadWrite => "read-write",
+ ReadOnly => "read-only",
+]}
diff --git a/src/commands.rs b/src/commands.rs
new file mode 100644
index 0000000..a2b6004
--- /dev/null
+++ b/src/commands.rs
@@ -0,0 +1,1008 @@
+// commands.rs
+
+// *************************************************************************
+// * Copyright (C) 2018-2020 Daniel Mueller (deso@posteo.net) *
+// * *
+// * This program is free software: you can redistribute it and/or modify *
+// * it under the terms of the GNU General Public License as published by *
+// * the Free Software Foundation, either version 3 of the License, or *
+// * (at your option) any later version. *
+// * *
+// * This program is distributed in the hope that it will be useful, *
+// * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+// * GNU General Public License for more details. *
+// * *
+// * You should have received a copy of the GNU General Public License *
+// * along with this program. If not, see <http://www.gnu.org/licenses/>. *
+// *************************************************************************
+
+use std::fmt;
+use std::mem;
+use std::result;
+use std::thread;
+use std::time;
+use std::u8;
+
+use libc::sync;
+
+use nitrokey::ConfigureOtp;
+use nitrokey::Device;
+use nitrokey::GenerateOtp;
+use nitrokey::GetPasswordSafe;
+
+use crate::args;
+use crate::error;
+use crate::error::Error;
+use crate::pinentry;
+use crate::ExecCtx;
+use crate::Result;
+
+/// Create an `error::Error` with an error message of the format `msg: err`.
+fn get_error(msg: &'static str, err: nitrokey::Error) -> Error {
+ Error::NitrokeyError(Some(msg), err)
+}
+
+/// Set `libnitrokey`'s log level based on the execution context's verbosity.
+fn set_log_level(ctx: &mut ExecCtx<'_>) {
+ let log_lvl = match ctx.verbosity {
+ // The error log level is what libnitrokey uses by default. As such,
+ // there is no harm in us setting that as well when the user did not
+ // ask for higher verbosity.
+ 0 => nitrokey::LogLevel::Error,
+ 1 => nitrokey::LogLevel::Warning,
+ 2 => nitrokey::LogLevel::Info,
+ 3 => nitrokey::LogLevel::DebugL1,
+ 4 => nitrokey::LogLevel::Debug,
+ _ => nitrokey::LogLevel::DebugL2,
+ };
+ nitrokey::set_log_level(log_lvl);
+}
+
+/// Connect to any Nitrokey device and do something with it.
+fn with_device<F>(ctx: &mut ExecCtx<'_>, op: F) -> Result<()>
+where
+ F: FnOnce(&mut ExecCtx<'_>, nitrokey::DeviceWrapper<'_>) -> Result<()>,
+{
+ let mut manager = nitrokey::take()?;
+ set_log_level(ctx);
+
+ let device = match ctx.model {
+ Some(model) => manager.connect_model(model.into()).map_err(|_| {
+ let error = format!("Nitrokey {} device not found", model.as_user_facing_str());
+ Error::Error(error)
+ })?,
+ None => manager
+ .connect()
+ .map_err(|_| Error::from("Nitrokey device not found"))?,
+ };
+
+ op(ctx, device)
+}
+
+/// Connect to a Nitrokey Storage device and do something with it.
+fn with_storage_device<F>(ctx: &mut ExecCtx<'_>, op: F) -> Result<()>
+where
+ F: FnOnce(&mut ExecCtx<'_>, nitrokey::Storage<'_>) -> Result<()>,
+{
+ let mut manager = nitrokey::take()?;
+ set_log_level(ctx);
+
+ if let Some(model) = ctx.model {
+ if model != args::DeviceModel::Storage {
+ return Err(Error::from(
+ "This command is only available on the Nitrokey Storage",
+ ));
+ }
+ }
+
+ let device = manager
+ .connect_storage()
+ .map_err(|_| Error::from("Nitrokey Storage device not found"))?;
+ op(ctx, device)
+}
+
+/// Connect to any Nitrokey device, retrieve a password safe handle, and
+/// do something with it.
+fn with_password_safe<F>(ctx: &mut ExecCtx<'_>, mut op: F) -> Result<()>
+where
+ F: FnMut(&mut ExecCtx<'_>, nitrokey::PasswordSafe<'_, '_>) -> Result<()>,
+{
+ with_device(ctx, |ctx, mut device| {
+ let pin_entry = pinentry::PinEntry::from(args::PinType::User, &device)?;
+ try_with_pin_and_data(
+ ctx,
+ &pin_entry,
+ "Could not access the password safe",
+ (),
+ move |ctx, _, pin| {
+ let pws = device
+ .get_password_safe(pin)
+ .map_err(|err| ((), Error::from(err)))?;
+
+ op(ctx, pws).map_err(|err| ((), err))
+ },
+ )
+ })?;
+ Ok(())
+}
+
+/// Authenticate the given device using the given PIN type and operation.
+///
+/// If an error occurs, the error message `msg` is used.
+fn authenticate<'mgr, D, A, F>(
+ ctx: &mut ExecCtx<'_>,
+ device: D,
+ pin_type: args::PinType,
+ msg: &'static str,
+ op: F,
+) -> Result<A>
+where
+ D: Device<'mgr>,
+ F: FnMut(&mut ExecCtx<'_>, D, &str) -> result::Result<A, (D, nitrokey::Error)>,
+{
+ let pin_entry = pinentry::PinEntry::from(pin_type, &device)?;
+
+ try_with_pin_and_data(ctx, &pin_entry, msg, device, op)
+}
+
+/// Authenticate the given device with the user PIN.
+fn authenticate_user<'mgr, T>(ctx: &mut ExecCtx<'_>, device: T) -> Result<nitrokey::User<'mgr, T>>
+where
+ T: Device<'mgr>,
+{
+ authenticate(
+ ctx,
+ device,
+ args::PinType::User,
+ "Could not authenticate as user",
+ |_ctx, device, pin| device.authenticate_user(pin),
+ )
+}
+
+/// Authenticate the given device with the admin PIN.
+fn authenticate_admin<'mgr, T>(ctx: &mut ExecCtx<'_>, device: T) -> Result<nitrokey::Admin<'mgr, T>>
+where
+ T: Device<'mgr>,
+{
+ authenticate(
+ ctx,
+ device,
+ args::PinType::Admin,
+ "Could not authenticate as admin",
+ |_ctx, device, pin| device.authenticate_admin(pin),
+ )
+}
+
+/// Return a string representation of the given volume status.
+fn get_volume_status(status: &nitrokey::VolumeStatus) -> &'static str {
+ if status.active {
+ if status.read_only {
+ "read-only"
+ } else {
+ "active"
+ }
+ } else {
+ "inactive"
+ }
+}
+
+/// Try to execute the given function with a pin queried using pinentry.
+///
+/// This function will query the pin of the given type from the user
+/// using pinentry. It will then execute the given function. If this
+/// function returns a result, the result will be passed on. If it
+/// returns a `CommandError::WrongPassword`, the user will be asked
+/// again to enter the pin. Otherwise, this function returns an error
+/// containing the given error message. The user will have at most
+/// three tries to get the pin right.
+///
+/// The data argument can be used to pass on data between the tries. At
+/// the first try, this function will call `op` with `data`. At the
+/// second or third try, it will call `op` with the data returned by the
+/// previous call to `op`.
+fn try_with_pin_and_data_with_pinentry<D, F, R, E>(
+ ctx: &mut ExecCtx<'_>,
+ pin_entry: &pinentry::PinEntry,
+ msg: &'static str,
+ data: D,
+ mut op: F,
+) -> Result<R>
+where
+ F: FnMut(&mut ExecCtx<'_>, D, &str) -> result::Result<R, (D, E)>,
+ E: error::TryInto<nitrokey::Error>,
+{
+ let mut data = data;
+ let mut retry = 3;
+ let mut error_msg = None;
+ loop {
+ let pin = pinentry::inquire(ctx, pin_entry, pinentry::Mode::Query, error_msg)?;
+ match op(ctx, data, &pin) {
+ Ok(result) => return Ok(result),
+ Err((new_data, err)) => match err.try_into() {
+ Ok(err) => match err {
+ nitrokey::Error::CommandError(nitrokey::CommandError::WrongPassword) => {
+ pinentry::clear(pin_entry)?;
+ retry -= 1;
+
+ if retry > 0 {
+ error_msg = Some("Wrong password, please reenter");
+ data = new_data;
+ continue;
+ }
+ return Err(get_error(msg, err));
+ }
+ err => return Err(get_error(msg, err)),
+ },
+ Err(err) => return Err(err),
+ },
+ };
+ }
+}
+
+/// Try to execute the given function with a PIN.
+fn try_with_pin_and_data<D, F, R, E>(
+ ctx: &mut ExecCtx<'_>,
+ pin_entry: &pinentry::PinEntry,
+ msg: &'static str,
+ data: D,
+ mut op: F,
+) -> Result<R>
+where
+ F: FnMut(&mut ExecCtx<'_>, D, &str) -> result::Result<R, (D, E)>,
+ E: Into<Error> + error::TryInto<nitrokey::Error>,
+{
+ let pin = match pin_entry.pin_type() {
+ // Ideally we would not clone here, but that would require us to
+ // restrict op to work with an immutable ExecCtx, which is not
+ // possible given that some clients print data.
+ args::PinType::Admin => ctx.admin_pin.clone(),
+ args::PinType::User => ctx.user_pin.clone(),
+ };
+
+ if let Some(pin) = pin {
+ let pin = pin.to_str().ok_or_else(|| {
+ Error::Error(format!(
+ "{}: Failed to read PIN due to invalid Unicode data",
+ msg
+ ))
+ })?;
+ op(ctx, data, &pin).map_err(|(_, err)| err.into())
+ } else {
+ try_with_pin_and_data_with_pinentry(ctx, pin_entry, msg, data, op)
+ }
+}
+
+/// Try to execute the given function with a pin queried using pinentry.
+///
+/// This function behaves exactly as `try_with_pin_and_data`, but
+/// it refrains from passing any data to it.
+fn try_with_pin<F, E>(
+ ctx: &mut ExecCtx<'_>,
+ pin_entry: &pinentry::PinEntry,
+ msg: &'static str,
+ mut op: F,
+) -> Result<()>
+where
+ F: FnMut(&str) -> result::Result<(), E>,
+ E: Into<Error> + error::TryInto<nitrokey::Error>,
+{
+ try_with_pin_and_data(ctx, pin_entry, msg, (), |_ctx, data, pin| {
+ op(pin).map_err(|err| (data, err))
+ })
+}
+
+/// Pretty print the status of a Nitrokey Storage.
+fn print_storage_status(ctx: &mut ExecCtx<'_>, status: &nitrokey::StorageStatus) -> Result<()> {
+ println!(
+ ctx,
+ r#" Storage:
+ SD card ID: {id:#x}
+ firmware: {fw}
+ storage keys: {sk}
+ volumes:
+ unencrypted: {vu}
+ encrypted: {ve}
+ hidden: {vh}"#,
+ id = status.serial_number_sd_card,
+ fw = if status.firmware_locked {
+ "locked"
+ } else {
+ "unlocked"
+ },
+ sk = if status.stick_initialized {
+ "created"
+ } else {
+ "not created"
+ },
+ vu = get_volume_status(&status.unencrypted_volume),
+ ve = get_volume_status(&status.encrypted_volume),
+ vh = get_volume_status(&status.hidden_volume),
+ )?;
+ Ok(())
+}
+
+/// Query and pretty print the status that is common to all Nitrokey devices.
+fn print_status(
+ ctx: &mut ExecCtx<'_>,
+ model: &'static str,
+ device: &nitrokey::DeviceWrapper<'_>,
+) -> Result<()> {
+ let serial_number = device
+ .get_serial_number()
+ .map_err(|err| get_error("Could not query the serial number", err))?;
+
+ println!(
+ ctx,
+ r#"Status:
+ model: {model}
+ serial number: {id}
+ firmware version: {fwv}
+ user retry count: {urc}
+ admin retry count: {arc}"#,
+ model = model,
+ id = serial_number,
+ fwv = device.get_firmware_version()?,
+ urc = device.get_user_retry_count()?,
+ arc = device.get_admin_retry_count()?,
+ )?;
+
+ if let nitrokey::DeviceWrapper::Storage(device) = device {
+ let status = device
+ .get_storage_status()
+ .map_err(|err| get_error("Getting Storage status failed", err))?;
+
+ print_storage_status(ctx, &status)
+ } else {
+ Ok(())
+ }
+}
+
+/// Inquire the status of the nitrokey.
+pub fn status(ctx: &mut ExecCtx<'_>) -> Result<()> {
+ with_device(ctx, |ctx, device| {
+ let model = match device {
+ nitrokey::DeviceWrapper::Pro(_) => "Pro",
+ nitrokey::DeviceWrapper::Storage(_) => "Storage",
+ };
+ print_status(ctx, model, &device)
+ })
+}
+
+/// List the attached Nitrokey devices.
+pub fn list(ctx: &mut ExecCtx<'_>, no_connect: bool) -> Result<()> {
+ set_log_level(ctx);
+
+ let device_infos = nitrokey::list_devices()?;
+ if device_infos.is_empty() {
+ println!(ctx, "No Nitrokey device connected")?;
+ } else {
+ println!(ctx, "device path\tmodel\tserial number")?;
+ let mut manager = nitrokey::take()?;
+
+ for device_info in device_infos {
+ let model = device_info
+ .model
+ .map(|m| m.to_string())
+ .unwrap_or_else(|| "unknown".into());
+ let serial_number = match device_info.serial_number {
+ Some(serial_number) => serial_number.to_string(),
+ None => {
+ // Storage devices do not have the serial number present in
+ // the device information. We have to connect to them to
+ // retrieve the information.
+ if no_connect {
+ "N/A".to_string()
+ } else {
+ let device = manager.connect_path(device_info.path.clone())?;
+ device.get_serial_number()?.to_string()
+ }
+ }
+ };
+
+ println!(ctx, "{}\t{}\t{}", device_info.path, model, serial_number)?;
+ }
+ }
+
+ Ok(())
+}
+
+/// Perform a factory reset.
+pub fn reset(ctx: &mut ExecCtx<'_>) -> Result<()> {
+ with_device(ctx, |ctx, mut device| {
+ let pin_entry = pinentry::PinEntry::from(args::PinType::Admin, &device)?;
+
+ // To force the user to enter the admin PIN before performing a
+ // factory reset, we clear the pinentry cache for the admin PIN.
+ pinentry::clear(&pin_entry)?;
+
+ try_with_pin(ctx, &pin_entry, "Factory reset failed", |pin| {
+ device.factory_reset(&pin)?;
+ // Work around for a timing issue between factory_reset and
+ // build_aes_key, see
+ // https://github.com/Nitrokey/nitrokey-storage-firmware/issues/80
+ thread::sleep(time::Duration::from_secs(3));
+ // Another work around for spurious WrongPassword returns of
+ // build_aes_key after a factory reset on Pro devices.
+ // https://github.com/Nitrokey/nitrokey-pro-firmware/issues/57
+ let _ = device.get_user_retry_count();
+ device.build_aes_key(nitrokey::DEFAULT_ADMIN_PIN)
+ })
+ })
+}
+
+/// Change the configuration of the unencrypted volume.
+pub fn unencrypted_set(ctx: &mut ExecCtx<'_>, mode: args::UnencryptedVolumeMode) -> Result<()> {
+ with_storage_device(ctx, |ctx, mut device| {
+ let pin_entry = pinentry::PinEntry::from(args::PinType::Admin, &device)?;
+ let mode = match mode {
+ args::UnencryptedVolumeMode::ReadWrite => nitrokey::VolumeMode::ReadWrite,
+ args::UnencryptedVolumeMode::ReadOnly => nitrokey::VolumeMode::ReadOnly,
+ };
+
+ // The unencrypted volume may reconnect, so be sure to flush caches to
+ // disk.
+ unsafe { sync() };
+
+ try_with_pin(
+ ctx,
+ &pin_entry,
+ "Changing unencrypted volume mode failed",
+ |pin| device.set_unencrypted_volume_mode(&pin, mode),
+ )
+ })
+}
+
+/// Open the encrypted volume on the Nitrokey.
+pub fn encrypted_open(ctx: &mut ExecCtx<'_>) -> Result<()> {
+ with_storage_device(ctx, |ctx, mut device| {
+ let pin_entry = pinentry::PinEntry::from(args::PinType::User, &device)?;
+
+ // We may forcefully close a hidden volume, if active, so be sure to
+ // flush caches to disk.
+ unsafe { sync() };
+
+ try_with_pin(ctx, &pin_entry, "Opening encrypted volume failed", |pin| {
+ device.enable_encrypted_volume(&pin)
+ })
+ })
+}
+
+/// Close the previously opened encrypted volume.
+pub fn encrypted_close(ctx: &mut ExecCtx<'_>) -> Result<()> {
+ with_storage_device(ctx, |_ctx, mut device| {
+ // Flush all filesystem caches to disk. We are mostly interested in
+ // making sure that the encrypted volume on the Nitrokey we are
+ // about to close is not closed while not all data was written to
+ // it.
+ unsafe { sync() };
+
+ device
+ .disable_encrypted_volume()
+ .map_err(|err| get_error("Closing encrypted volume failed", err))
+ })
+}
+
+/// Create a hidden volume.
+pub fn hidden_create(ctx: &mut ExecCtx<'_>, slot: u8, start: u8, end: u8) -> Result<()> {
+ with_storage_device(ctx, |ctx, mut device| {
+ let pwd_entry = pinentry::PwdEntry::from(&device)?;
+ let pwd = if let Some(pwd) = &ctx.password {
+ pwd
+ .to_str()
+ .ok_or_else(|| Error::from("Failed to read password: invalid Unicode data found"))
+ .map(ToOwned::to_owned)
+ } else {
+ pinentry::choose(ctx, &pwd_entry)
+ }?;
+
+ device
+ .create_hidden_volume(slot, start, end, &pwd)
+ .map_err(|err| get_error("Creating hidden volume failed", err))
+ })
+}
+
+/// Open a hidden volume.
+pub fn hidden_open(ctx: &mut ExecCtx<'_>) -> Result<()> {
+ with_storage_device(ctx, |ctx, mut device| {
+ let pwd_entry = pinentry::PwdEntry::from(&device)?;
+ let pwd = if let Some(pwd) = &ctx.password {
+ pwd
+ .to_str()
+ .ok_or_else(|| Error::from("Failed to read password: invalid Unicode data found"))
+ .map(ToOwned::to_owned)
+ } else {
+ pinentry::inquire(ctx, &pwd_entry, pinentry::Mode::Query, None)
+ }?;
+
+ // We may forcefully close an encrypted volume, if active, so be sure
+ // to flush caches to disk.
+ unsafe { sync() };
+
+ device
+ .enable_hidden_volume(&pwd)
+ .map_err(|err| get_error("Opening hidden volume failed", err))
+ })
+}
+
+/// Close a previously opened hidden volume.
+pub fn hidden_close(ctx: &mut ExecCtx<'_>) -> Result<()> {
+ with_storage_device(ctx, |_ctx, mut device| {
+ unsafe { sync() };
+
+ device
+ .disable_hidden_volume()
+ .map_err(|err| get_error("Closing hidden volume failed", err))
+ })
+}
+
+/// Return a String representation of the given Option.
+fn format_option<T: fmt::Display>(option: Option<T>) -> String {
+ match option {
+ Some(value) => format!("{}", value),
+ None => "not set".to_string(),
+ }
+}
+
+/// Read the Nitrokey configuration.
+pub fn config_get(ctx: &mut ExecCtx<'_>) -> Result<()> {
+ with_device(ctx, |ctx, device| {
+ let config = device
+ .get_config()
+ .map_err(|err| get_error("Could not get configuration", err))?;
+ println!(
+ ctx,
+ r#"Config:
+ numlock binding: {nl}
+ capslock binding: {cl}
+ scrollock binding: {sl}
+ require user PIN for OTP: {otp}"#,
+ nl = format_option(config.numlock),
+ cl = format_option(config.capslock),
+ sl = format_option(config.scrollock),
+ otp = config.user_password,
+ )?;
+ Ok(())
+ })
+}
+
+/// Write the Nitrokey configuration.
+pub fn config_set(ctx: &mut ExecCtx<'_>, args: args::ConfigSetArgs) -> Result<()> {
+ let numlock = args::ConfigOption::try_from(args.no_numlock, args.numlock, "numlock")?;
+ let capslock = args::ConfigOption::try_from(args.no_capslock, args.capslock, "capslock")?;
+ let scrollock = args::ConfigOption::try_from(args.no_scrollock, args.scrollock, "scrollock")?;
+ let otp_pin = if args.otp_pin {
+ Some(true)
+ } else if args.no_otp_pin {
+ Some(false)
+ } else {
+ None
+ };
+
+ with_device(ctx, |ctx, device| {
+ let mut device = authenticate_admin(ctx, device)?;
+ let config = device
+ .get_config()
+ .map_err(|err| get_error("Could not get configuration", err))?;
+ let config = nitrokey::Config {
+ numlock: numlock.or(config.numlock),
+ capslock: capslock.or(config.capslock),
+ scrollock: scrollock.or(config.scrollock),
+ user_password: otp_pin.unwrap_or(config.user_password),
+ };
+ device
+ .write_config(config)
+ .map_err(|err| get_error("Could not set configuration", err))
+ })
+}
+
+/// Lock the Nitrokey device.
+pub fn lock(ctx: &mut ExecCtx<'_>) -> Result<()> {
+ with_device(ctx, |_ctx, mut device| {
+ device
+ .lock()
+ .map_err(|err| get_error("Could not lock the device", err))
+ })
+}
+
+fn get_otp<T>(slot: u8, algorithm: args::OtpAlgorithm, device: &mut T) -> Result<String>
+where
+ T: GenerateOtp,
+{
+ match algorithm {
+ args::OtpAlgorithm::Hotp => device.get_hotp_code(slot),
+ args::OtpAlgorithm::Totp => device.get_totp_code(slot),
+ }
+ .map_err(|err| get_error("Could not generate OTP", err))
+}
+
+fn get_unix_timestamp() -> Result<u64> {
+ time::SystemTime::now()
+ .duration_since(time::UNIX_EPOCH)
+ .map_err(|_| Error::from("Current system time is before the Unix epoch"))
+ .map(|duration| duration.as_secs())
+}
+
+/// Generate a one-time password on the Nitrokey device.
+pub fn otp_get(
+ ctx: &mut ExecCtx<'_>,
+ slot: u8,
+ algorithm: args::OtpAlgorithm,
+ time: Option<u64>,
+) -> Result<()> {
+ with_device(ctx, |ctx, mut device| {
+ if algorithm == args::OtpAlgorithm::Totp {
+ device
+ .set_time(
+ match time {
+ Some(time) => time,
+ None => get_unix_timestamp()?,
+ },
+ true,
+ )
+ .map_err(|err| get_error("Could not set time", err))?;
+ }
+ let config = device
+ .get_config()
+ .map_err(|err| get_error("Could not get device configuration", err))?;
+ let otp = if config.user_password {
+ let mut user = authenticate_user(ctx, device)?;
+ get_otp(slot, algorithm, &mut user)
+ } else {
+ get_otp(slot, algorithm, &mut device)
+ }?;
+ println!(ctx, "{}", otp)?;
+ Ok(())
+ })
+}
+
+/// Format a byte vector as a hex string.
+fn format_bytes(bytes: &[u8]) -> String {
+ bytes
+ .iter()
+ .map(|c| format!("{:02x}", c))
+ .collect::<Vec<_>>()
+ .join("")
+}
+
+/// Prepare an ASCII secret string for libnitrokey.
+///
+/// libnitrokey expects secrets as hexadecimal strings. This function transforms an ASCII string
+/// into a hexadecimal string or returns an error if the given string contains non-ASCII
+/// characters.
+fn prepare_ascii_secret(secret: &str) -> Result<String> {
+ if secret.is_ascii() {
+ Ok(format_bytes(&secret.as_bytes()))
+ } else {
+ Err(Error::from(
+ "The given secret is not an ASCII string despite --format ascii being set",
+ ))
+ }
+}
+
+/// Prepare a base32 secret string for libnitrokey.
+fn prepare_base32_secret(secret: &str) -> Result<String> {
+ base32::decode(base32::Alphabet::RFC4648 { padding: false }, secret)
+ .map(|vec| format_bytes(&vec))
+ .ok_or_else(|| Error::from("Could not parse base32 secret"))
+}
+
+/// Configure a one-time password slot on the Nitrokey device.
+pub fn otp_set(ctx: &mut ExecCtx<'_>, mut args: args::OtpSetArgs) -> Result<()> {
+ let mut data = nitrokey::OtpSlotData {
+ number: args.slot,
+ name: mem::take(&mut args.name),
+ secret: mem::take(&mut args.secret),
+ mode: args.digits.into(),
+ use_enter: false,
+ token_id: None,
+ };
+
+ with_device(ctx, |ctx, device| {
+ let secret = match args.format {
+ args::OtpSecretFormat::Ascii => prepare_ascii_secret(&data.secret)?,
+ args::OtpSecretFormat::Base32 => prepare_base32_secret(&data.secret)?,
+ args::OtpSecretFormat::Hex => {
+ // We need to ensure to provide a string with an even number of
+ // characters in it, just because that's what libnitrokey
+ // expects. So prepend a '0' if that is not the case.
+ // TODO: This code can be removed once upstream issue #164
+ // (https://github.com/Nitrokey/libnitrokey/issues/164) is
+ // addressed.
+ if data.secret.len() % 2 != 0 {
+ data.secret.insert(0, '0')
+ }
+ data.secret
+ }
+ };
+ let data = nitrokey::OtpSlotData { secret, ..data };
+ let mut device = authenticate_admin(ctx, device)?;
+ match args.algorithm {
+ args::OtpAlgorithm::Hotp => device.write_hotp_slot(data, args.counter),
+ args::OtpAlgorithm::Totp => device.write_totp_slot(data, args.time_window),
+ }
+ .map_err(|err| get_error("Could not write OTP slot", err))?;
+ Ok(())
+ })
+}
+
+/// Clear an OTP slot.
+pub fn otp_clear(ctx: &mut ExecCtx<'_>, slot: u8, algorithm: args::OtpAlgorithm) -> Result<()> {
+ with_device(ctx, |ctx, device| {
+ let mut device = authenticate_admin(ctx, device)?;
+ match algorithm {
+ args::OtpAlgorithm::Hotp => device.erase_hotp_slot(slot),
+ args::OtpAlgorithm::Totp => device.erase_totp_slot(slot),
+ }
+ .map_err(|err| get_error("Could not clear OTP slot", err))?;
+ Ok(())
+ })
+}
+
+fn print_otp_status(
+ ctx: &mut ExecCtx<'_>,
+ algorithm: args::OtpAlgorithm,
+ device: &nitrokey::DeviceWrapper<'_>,
+ all: bool,
+) -> Result<()> {
+ let mut slot: u8 = 0;
+ loop {
+ let result = match algorithm {
+ args::OtpAlgorithm::Hotp => device.get_hotp_slot_name(slot),
+ args::OtpAlgorithm::Totp => device.get_totp_slot_name(slot),
+ };
+ slot = match slot.checked_add(1) {
+ Some(slot) => slot,
+ None => {
+ return Err(Error::from("Integer overflow when iterating OTP slots"));
+ }
+ };
+ let name = match result {
+ Ok(name) => name,
+ Err(nitrokey::Error::LibraryError(nitrokey::LibraryError::InvalidSlot)) => return Ok(()),
+ Err(nitrokey::Error::CommandError(nitrokey::CommandError::SlotNotProgrammed)) => {
+ if all {
+ "[not programmed]".to_string()
+ } else {
+ continue;
+ }
+ }
+ Err(err) => return Err(get_error("Could not check OTP slot", err)),
+ };
+ println!(ctx, "{}\t{}\t{}", algorithm, slot - 1, name)?;
+ }
+}
+
+/// Print the status of the OTP slots.
+pub fn otp_status(ctx: &mut ExecCtx<'_>, all: bool) -> Result<()> {
+ with_device(ctx, |ctx, device| {
+ println!(ctx, "alg\tslot\tname")?;
+ print_otp_status(ctx, args::OtpAlgorithm::Hotp, &device, all)?;
+ print_otp_status(ctx, args::OtpAlgorithm::Totp, &device, all)?;
+ Ok(())
+ })
+}
+
+/// Clear the PIN stored by various operations.
+pub fn pin_clear(ctx: &mut ExecCtx<'_>) -> Result<()> {
+ with_device(ctx, |_ctx, device| {
+ pinentry::clear(&pinentry::PinEntry::from(args::PinType::Admin, &device)?)?;
+ pinentry::clear(&pinentry::PinEntry::from(args::PinType::User, &device)?)?;
+ Ok(())
+ })
+}
+
+/// Choose a PIN of the given type.
+///
+/// If the user has set the respective environment variable for the
+/// given PIN type, it will be used.
+fn choose_pin(ctx: &mut ExecCtx<'_>, pin_entry: &pinentry::PinEntry, new: bool) -> Result<String> {
+ let new_pin = match pin_entry.pin_type() {
+ args::PinType::Admin => {
+ if new {
+ &ctx.new_admin_pin
+ } else {
+ &ctx.admin_pin
+ }
+ }
+ args::PinType::User => {
+ if new {
+ &ctx.new_user_pin
+ } else {
+ &ctx.user_pin
+ }
+ }
+ };
+
+ if let Some(new_pin) = new_pin {
+ new_pin
+ .to_str()
+ .ok_or_else(|| Error::from("Failed to read PIN: invalid Unicode data found"))
+ .map(ToOwned::to_owned)
+ } else {
+ pinentry::choose(ctx, pin_entry)
+ }
+}
+
+/// Change a PIN.
+pub fn pin_set(ctx: &mut ExecCtx<'_>, pin_type: args::PinType) -> Result<()> {
+ with_device(ctx, |ctx, mut device| {
+ let pin_entry = pinentry::PinEntry::from(pin_type, &device)?;
+ let new_pin = choose_pin(ctx, &pin_entry, true)?;
+
+ try_with_pin(
+ ctx,
+ &pin_entry,
+ "Could not change the PIN",
+ |current_pin| match pin_type {
+ args::PinType::Admin => device.change_admin_pin(&current_pin, &new_pin),
+ args::PinType::User => device.change_user_pin(&current_pin, &new_pin),
+ },
+ )?;
+
+ // We just changed the PIN but confirmed the action with the old PIN,
+ // which may have caused it to be cached. Since it no longer applies,
+ // make sure to evict the corresponding entry from the cache.
+ pinentry::clear(&pin_entry)
+ })
+}
+
+/// Unblock and reset the user PIN.
+pub fn pin_unblock(ctx: &mut ExecCtx<'_>) -> Result<()> {
+ with_device(ctx, |ctx, mut device| {
+ let pin_entry = pinentry::PinEntry::from(args::PinType::User, &device)?;
+ let user_pin = choose_pin(ctx, &pin_entry, false)?;
+ let pin_entry = pinentry::PinEntry::from(args::PinType::Admin, &device)?;
+
+ try_with_pin(
+ ctx,
+ &pin_entry,
+ "Could not unblock the user PIN",
+ |admin_pin| device.unlock_user_pin(&admin_pin, &user_pin),
+ )
+ })
+}
+
+fn print_pws_data(
+ ctx: &mut ExecCtx<'_>,
+ description: &'static str,
+ result: result::Result<String, nitrokey::Error>,
+ quiet: bool,
+) -> Result<()> {
+ let value = result.map_err(|err| get_error("Could not access PWS slot", err))?;
+ if quiet {
+ println!(ctx, "{}", value)?;
+ } else {
+ println!(ctx, "{} {}", description, value)?;
+ }
+ Ok(())
+}
+
+fn check_slot(pws: &nitrokey::PasswordSafe<'_, '_>, slot: u8) -> Result<()> {
+ if slot >= nitrokey::SLOT_COUNT {
+ return Err(nitrokey::Error::from(nitrokey::LibraryError::InvalidSlot).into());
+ }
+ let status = pws
+ .get_slot_status()
+ .map_err(|err| get_error("Could not read PWS slot status", err))?;
+ if status[slot as usize] {
+ Ok(())
+ } else {
+ Err(get_error(
+ "Could not access PWS slot",
+ nitrokey::CommandError::SlotNotProgrammed.into(),
+ ))
+ }
+}
+
+/// Read a PWS slot.
+pub fn pws_get(
+ ctx: &mut ExecCtx<'_>,
+ slot: u8,
+ show_name: bool,
+ show_login: bool,
+ show_password: bool,
+ quiet: bool,
+) -> Result<()> {
+ with_password_safe(ctx, |ctx, pws| {
+ check_slot(&pws, slot)?;
+
+ let show_all = !show_name && !show_login && !show_password;
+ if show_all || show_name {
+ print_pws_data(ctx, "name: ", pws.get_slot_name(slot), quiet)?;
+ }
+ if show_all || show_login {
+ print_pws_data(ctx, "login: ", pws.get_slot_login(slot), quiet)?;
+ }
+ if show_all || show_password {
+ print_pws_data(ctx, "password:", pws.get_slot_password(slot), quiet)?;
+ }
+ Ok(())
+ })
+}
+
+/// Write a PWS slot.
+pub fn pws_set(
+ ctx: &mut ExecCtx<'_>,
+ slot: u8,
+ name: &str,
+ login: &str,
+ password: &str,
+) -> Result<()> {
+ with_password_safe(ctx, |_ctx, mut pws| {
+ pws
+ .write_slot(slot, name, login, password)
+ .map_err(|err| get_error("Could not write PWS slot", err))
+ })
+}
+
+/// Clear a PWS slot.
+pub fn pws_clear(ctx: &mut ExecCtx<'_>, slot: u8) -> Result<()> {
+ with_password_safe(ctx, |_ctx, mut pws| {
+ pws
+ .erase_slot(slot)
+ .map_err(|err| get_error("Could not clear PWS slot", err))
+ })
+}
+
+fn print_pws_slot(
+ ctx: &mut ExecCtx<'_>,
+ pws: &nitrokey::PasswordSafe<'_, '_>,
+ slot: usize,
+ programmed: bool,
+) -> Result<()> {
+ if slot > u8::MAX as usize {
+ return Err(Error::from("Invalid PWS slot number"));
+ }
+ let slot = slot as u8;
+ let name = if programmed {
+ pws
+ .get_slot_name(slot)
+ .map_err(|err| get_error("Could not read PWS slot", err))?
+ } else {
+ "[not programmed]".to_string()
+ };
+ println!(ctx, "{}\t{}", slot, name)?;
+ Ok(())
+}
+
+/// Print the status of all PWS slots.
+pub fn pws_status(ctx: &mut ExecCtx<'_>, all: bool) -> Result<()> {
+ with_password_safe(ctx, |ctx, pws| {
+ let slots = pws
+ .get_slot_status()
+ .map_err(|err| get_error("Could not read PWS slot status", err))?;
+ println!(ctx, "slot\tname")?;
+ for (i, &value) in slots.iter().enumerate().filter(|(_, &value)| all || value) {
+ print_pws_slot(ctx, &pws, i, value)?;
+ }
+ Ok(())
+ })
+}
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+
+ #[test]
+ fn prepare_secret_ascii() {
+ let result = prepare_ascii_secret("12345678901234567890");
+ assert_eq!(
+ "3132333435363738393031323334353637383930".to_string(),
+ result.unwrap()
+ );
+ }
+
+ #[test]
+ fn prepare_secret_non_ascii() {
+ let result = prepare_ascii_secret("Österreich");
+ assert!(result.is_err());
+ }
+
+ #[test]
+ fn hex_string() {
+ assert_eq!(format_bytes(&[b' ']), "20");
+ assert_eq!(format_bytes(&[b' ', b' ']), "2020");
+ assert_eq!(format_bytes(&[b'\n', b'\n']), "0a0a");
+ }
+}
diff --git a/nitrocli/src/error.rs b/src/error.rs
index 1346526..e891da2 100644
--- a/nitrocli/src/error.rs
+++ b/src/error.rs
@@ -1,7 +1,7 @@
// error.rs
// *************************************************************************
-// * Copyright (C) 2017-2019 Daniel Mueller (deso@posteo.net) *
+// * Copyright (C) 2017-2020 Daniel Mueller (deso@posteo.net) *
// * *
// * This program is free software: you can redistribute it and/or modify *
// * it under the terms of the GNU General Public License as published by *
@@ -22,24 +22,63 @@ use std::io;
use std::str;
use std::string;
+use structopt::clap;
+
+/// A trait used to simplify error handling in conjunction with the
+/// try_with_* functions we use for repeatedly asking the user for a
+/// secret.
+pub trait TryInto<T> {
+ fn try_into(self) -> Result<T, Error>;
+}
+
+impl<T, U> TryInto<U> for T
+where
+ T: Into<U>,
+{
+ fn try_into(self) -> Result<U, Error> {
+ Ok(self.into())
+ }
+}
+
#[derive(Debug)]
pub enum Error {
- ArgparseError(i32),
- CommandError(Option<&'static str>, nitrokey::CommandError),
+ ClapError(clap::Error),
IoError(io::Error),
+ NitrokeyError(Option<&'static str>, nitrokey::Error),
Utf8Error(str::Utf8Error),
Error(String),
}
+impl TryInto<nitrokey::Error> for Error {
+ fn try_into(self) -> Result<nitrokey::Error, Error> {
+ match self {
+ Error::NitrokeyError(_, err) => Ok(err),
+ err => Err(err),
+ }
+ }
+}
+
impl From<&str> for Error {
fn from(s: &str) -> Error {
Error::Error(s.to_string())
}
}
-impl From<nitrokey::CommandError> for Error {
- fn from(e: nitrokey::CommandError) -> Error {
- Error::CommandError(None, e)
+impl From<String> for Error {
+ fn from(s: String) -> Error {
+ Error::Error(s)
+ }
+}
+
+impl From<clap::Error> for Error {
+ fn from(e: clap::Error) -> Error {
+ Error::ClapError(e)
+ }
+}
+
+impl From<nitrokey::Error> for Error {
+ fn from(e: nitrokey::Error) -> Error {
+ Error::NitrokeyError(None, e)
}
}
@@ -64,8 +103,8 @@ impl From<string::FromUtf8Error> for Error {
impl fmt::Display for Error {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match *self {
- Error::ArgparseError(_) => write!(f, "Could not parse arguments"),
- Error::CommandError(ref ctx, ref e) => {
+ Error::ClapError(ref e) => write!(f, "{}", e),
+ Error::NitrokeyError(ref ctx, ref e) => {
if let Some(ctx) = ctx {
write!(f, "{}: ", ctx)?;
}
diff --git a/nitrocli/src/main.rs b/src/main.rs
index 5cb3faf..27097c9 100644
--- a/nitrocli/src/main.rs
+++ b/src/main.rs
@@ -1,7 +1,7 @@
// main.rs
// *************************************************************************
-// * Copyright (C) 2017-2019 Daniel Mueller (deso@posteo.net) *
+// * Copyright (C) 2017-2020 Daniel Mueller (deso@posteo.net) *
// * *
// * This program is free software: you can redistribute it and/or modify *
// * it under the terms of the GNU General Public License as published by *
@@ -17,8 +17,10 @@
// * along with this program. If not, see <http://www.gnu.org/licenses/>. *
// *************************************************************************
-#![deny(
+#![warn(
+ bad_style,
dead_code,
+ future_incompatible,
illegal_floating_point_literal_pattern,
improper_ctypes,
intra_doc_link_resolution_failure,
@@ -28,12 +30,15 @@
missing_docs,
no_mangle_generic_items,
non_shorthand_field_patterns,
+ nonstandard_style,
overflowing_literals,
path_statements,
patterns_in_fns_without_body,
- plugin_as_library,
private_in_public,
proc_macro_derive_resolution_fallback,
+ renamed_and_removed_lints,
+ rust_2018_compatibility,
+ rust_2018_idioms,
safe_packed_borrows,
stable_features,
trivial_bounds,
@@ -41,7 +46,6 @@
type_alias_bounds,
tyvar_behind_raw_pointer,
unconditional_recursion,
- unions_with_drop_fields,
unreachable_code,
unreachable_patterns,
unstable_features,
@@ -55,14 +59,6 @@
where_clauses_object_safety,
while_true
)]
-#![warn(
- bad_style,
- future_incompatible,
- nonstandard_style,
- renamed_and_removed_lints,
- rust_2018_compatibility,
- rust_2018_idioms
-)]
//! Nitrocli is a program providing a command line interface to certain
//! commands of Nitrokey Pro and Storage devices.
@@ -79,7 +75,6 @@ mod pinentry;
#[cfg(test)]
mod tests;
-use std::alloc;
use std::env;
use std::ffi;
use std::io;
@@ -88,13 +83,6 @@ use std::result;
use crate::error::Error;
-// Switch from the default allocator (typically jemalloc) to the system
-// allocator (malloc based on Unix systems). Our application is by no
-// means allocation intensive and the default allocator is typically
-// much larger in size, causing binary bloat.
-#[global_allocator]
-static A: alloc::System = alloc::System;
-
type Result<T> = result::Result<T, Error>;
const NITROCLI_ADMIN_PIN: &str = "NITROCLI_ADMIN_PIN";
@@ -104,6 +92,88 @@ const NITROCLI_NEW_USER_PIN: &str = "NITROCLI_NEW_USER_PIN";
const NITROCLI_PASSWORD: &str = "NITROCLI_PASSWORD";
const NITROCLI_NO_CACHE: &str = "NITROCLI_NO_CACHE";
+trait Stdio {
+ fn stdio(&mut self) -> (&mut dyn io::Write, &mut dyn io::Write);
+}
+
+impl<'io> Stdio for RunCtx<'io> {
+ fn stdio(&mut self) -> (&mut dyn io::Write, &mut dyn io::Write) {
+ (self.stdout, self.stderr)
+ }
+}
+
+impl<W> Stdio for (&mut W, &mut W)
+where
+ W: io::Write,
+{
+ fn stdio(&mut self) -> (&mut dyn io::Write, &mut dyn io::Write) {
+ (self.0, self.1)
+ }
+}
+
+/// A command execution context that captures additional data pertaining
+/// the command execution.
+#[allow(missing_debug_implementations)]
+pub struct ExecCtx<'io> {
+ /// The Nitrokey model to use.
+ pub model: Option<args::DeviceModel>,
+ /// See `RunCtx::stdout`.
+ pub stdout: &'io mut dyn io::Write,
+ /// See `RunCtx::stderr`.
+ pub stderr: &'io mut dyn io::Write,
+ /// See `RunCtx::admin_pin`.
+ pub admin_pin: Option<ffi::OsString>,
+ /// See `RunCtx::user_pin`.
+ pub user_pin: Option<ffi::OsString>,
+ /// See `RunCtx::new_admin_pin`.
+ pub new_admin_pin: Option<ffi::OsString>,
+ /// See `RunCtx::new_user_pin`.
+ pub new_user_pin: Option<ffi::OsString>,
+ /// See `RunCtx::password`.
+ pub password: Option<ffi::OsString>,
+ /// See `RunCtx::no_cache`.
+ pub no_cache: bool,
+ /// The verbosity level to use for logging.
+ pub verbosity: u64,
+}
+
+impl<'io> Stdio for ExecCtx<'io> {
+ fn stdio(&mut self) -> (&mut dyn io::Write, &mut dyn io::Write) {
+ (self.stdout, self.stderr)
+ }
+}
+
+/// Parse the command-line arguments and execute the selected command.
+fn handle_arguments(ctx: &mut RunCtx<'_>, args: Vec<String>) -> Result<()> {
+ use structopt::StructOpt;
+
+ match args::Args::from_iter_safe(args.iter()) {
+ Ok(args) => {
+ let mut ctx = ExecCtx {
+ model: args.model,
+ stdout: ctx.stdout,
+ stderr: ctx.stderr,
+ admin_pin: ctx.admin_pin.take(),
+ user_pin: ctx.user_pin.take(),
+ new_admin_pin: ctx.new_admin_pin.take(),
+ new_user_pin: ctx.new_user_pin.take(),
+ password: ctx.password.take(),
+ no_cache: ctx.no_cache,
+ verbosity: args.verbose.into(),
+ };
+ args.cmd.execute(&mut ctx)
+ }
+ Err(err) => {
+ if err.use_stderr() {
+ Err(err.into())
+ } else {
+ println!(ctx, "{}", err.message)?;
+ Ok(())
+ }
+ }
+ }
+}
+
/// The context used when running the program.
pub(crate) struct RunCtx<'io> {
/// The `Write` object used as standard output throughout the program.
@@ -129,20 +199,12 @@ pub(crate) struct RunCtx<'io> {
}
fn run<'ctx, 'io: 'ctx>(ctx: &'ctx mut RunCtx<'io>, args: Vec<String>) -> i32 {
- match args::handle_arguments(ctx, args) {
+ match handle_arguments(ctx, args) {
Ok(()) => 0,
- Err(err) => match err {
- Error::ArgparseError(err) => match err {
- // argparse printed the help message
- 0 => 0,
- // argparse printed an error message
- _ => 1,
- },
- _ => {
- let _ = eprintln!(ctx, "{}", err);
- 1
- }
- },
+ Err(err) => {
+ let _ = eprintln!(ctx, "{}", err);
+ 1
+ }
}
}
diff --git a/nitrocli/src/pinentry.rs b/src/pinentry.rs
index d8a77d4..d1387f4 100644
--- a/nitrocli/src/pinentry.rs
+++ b/src/pinentry.rs
@@ -1,7 +1,7 @@
// pinentry.rs
// *************************************************************************
-// * Copyright (C) 2017-2019 Daniel Mueller (deso@posteo.net) *
+// * Copyright (C) 2017-2020 Daniel Mueller (deso@posteo.net) *
// * *
// * This program is free software: you can redistribute it and/or modify *
// * it under the terms of the GNU General Public License as published by *
@@ -19,24 +19,16 @@
use std::borrow;
use std::fmt;
+use std::io;
use std::process;
use std::str;
use crate::args;
use crate::error::Error;
+use crate::ExecCtx;
type CowStr = borrow::Cow<'static, str>;
-/// PIN type requested from pinentry.
-///
-/// The available PIN types correspond to the PIN types used by the Nitrokey devices: user and
-/// admin.
-#[allow(unused_doc_comments)]
-Enum! {PinType, [
- Admin => "admin",
- User => "user",
-]}
-
/// A trait representing a secret to be entered by the user.
pub trait SecretEntry: fmt::Debug {
/// The cache ID to use for this secret.
@@ -51,15 +43,15 @@ pub trait SecretEntry: fmt::Debug {
#[derive(Debug)]
pub struct PinEntry {
- pin_type: PinType,
+ pin_type: args::PinType,
model: nitrokey::Model,
- serial: String,
+ serial: nitrokey::SerialNumber,
}
impl PinEntry {
- pub fn from<D>(pin_type: PinType, device: &D) -> crate::Result<Self>
+ pub fn from<'mgr, D>(pin_type: args::PinType, device: &D) -> crate::Result<Self>
where
- D: nitrokey::Device,
+ D: nitrokey::Device<'mgr>,
{
let model = device.get_model();
let serial = device.get_serial_number()?;
@@ -70,7 +62,7 @@ impl PinEntry {
})
}
- pub fn pin_type(&self) -> PinType {
+ pub fn pin_type(&self) -> args::PinType {
self.pin_type
}
}
@@ -80,16 +72,16 @@ impl SecretEntry for PinEntry {
let model = self.model.to_string().to_lowercase();
let suffix = format!("{}:{}", model, self.serial);
let cache_id = match self.pin_type {
- PinType::Admin => format!("nitrocli:admin:{}", suffix),
- PinType::User => format!("nitrocli:user:{}", suffix),
+ args::PinType::Admin => format!("nitrocli:admin:{}", suffix),
+ args::PinType::User => format!("nitrocli:user:{}", suffix),
};
Some(cache_id.into())
}
fn prompt(&self) -> CowStr {
match self.pin_type {
- PinType::Admin => "Admin PIN",
- PinType::User => "User PIN",
+ args::PinType::Admin => "Admin PIN",
+ args::PinType::User => "User PIN",
}
.into()
}
@@ -98,12 +90,12 @@ impl SecretEntry for PinEntry {
format!(
"{} for\rNitrokey {} {}",
match self.pin_type {
- PinType::Admin => match mode {
+ args::PinType::Admin => match mode {
Mode::Choose => "Please enter a new admin PIN",
Mode::Confirm => "Please confirm the new admin PIN",
Mode::Query => "Please enter the admin PIN",
},
- PinType::User => match mode {
+ args::PinType::User => match mode {
Mode::Choose => "Please enter a new user PIN",
Mode::Confirm => "Please confirm the new user PIN",
Mode::Query => "Please enter the user PIN",
@@ -117,8 +109,8 @@ impl SecretEntry for PinEntry {
fn min_len(&self) -> u8 {
match self.pin_type {
- PinType::Admin => 8,
- PinType::User => 6,
+ args::PinType::Admin => 8,
+ args::PinType::User => 6,
}
}
}
@@ -126,13 +118,13 @@ impl SecretEntry for PinEntry {
#[derive(Debug)]
pub struct PwdEntry {
model: nitrokey::Model,
- serial: String,
+ serial: nitrokey::SerialNumber,
}
impl PwdEntry {
- pub fn from<D>(device: &D) -> crate::Result<Self>
+ pub fn from<'mgr, D>(device: &D) -> crate::Result<Self>
where
- D: nitrokey::Device,
+ D: nitrokey::Device<'mgr>,
{
let model = device.get_model();
let serial = device.get_serial_number()?;
@@ -230,7 +222,7 @@ where
/// dialog. It is used to choose an appropriate description and to
/// decide whether a quality bar is shown in the dialog.
pub fn inquire<E>(
- ctx: &mut args::ExecCtx<'_>,
+ ctx: &mut ExecCtx<'_>,
entry: &E,
mode: Mode,
error_msg: Option<&str>,
@@ -263,7 +255,13 @@ where
let output = process::Command::new("gpg-connect-agent")
.arg(command)
.arg("/bye")
- .output()?;
+ .output()
+ .map_err(|err| match err.kind() {
+ io::ErrorKind::NotFound => {
+ io::Error::new(io::ErrorKind::NotFound, "gpg-connect-agent not found")
+ }
+ _ => err,
+ })?;
parse_pinentry_pin(str::from_utf8(&output.stdout)?)
}
@@ -281,7 +279,7 @@ where
}
}
-pub fn choose<E>(ctx: &mut args::ExecCtx<'_>, entry: &E) -> crate::Result<String>
+pub fn choose<E>(ctx: &mut ExecCtx<'_>, entry: &E) -> crate::Result<String>
where
E: SecretEntry,
{
@@ -350,7 +348,7 @@ mod tests {
let response = "ERR ".to_string() + error + "\n";
let expected = error;
- let error = parse_pinentry_pin(response.to_string());
+ let error = parse_pinentry_pin(response);
if let Error::Error(ref e) = error.err().unwrap() {
assert_eq!(e, &expected);
diff --git a/nitrocli/src/redefine.rs b/src/redefine.rs
index a79cb4b..a79cb4b 100644
--- a/nitrocli/src/redefine.rs
+++ b/src/redefine.rs
diff --git a/nitrocli/src/tests/config.rs b/src/tests/config.rs
index 8983cb8..fa311d5 100644
--- a/nitrocli/src/tests/config.rs
+++ b/src/tests/config.rs
@@ -1,7 +1,7 @@
// config.rs
// *************************************************************************
-// * Copyright (C) 2019 Daniel Mueller (deso@posteo.net) *
+// * Copyright (C) 2019-2020 Daniel Mueller (deso@posteo.net) *
// * *
// * This program is free software: you can redistribute it and/or modify *
// * it under the terms of the GNU General Public License as published by *
@@ -19,8 +19,25 @@
use super::*;
+#[test]
+fn mutually_exclusive_set_options() {
+ fn test(option1: &str, option2: &str) {
+ let (rc, out, err) = Nitrocli::new().run(&["config", "set", option1, option2]);
+
+ assert_ne!(rc, 0);
+ assert_eq!(out, b"");
+
+ let err = String::from_utf8(err).unwrap();
+ assert!(err.contains("cannot be used with"), err);
+ }
+
+ test("-c", "-C");
+ test("-o", "-O");
+ test("-s", "-S");
+}
+
#[test_device]
-fn get(device: nitrokey::DeviceWrapper) -> crate::Result<()> {
+fn get(model: nitrokey::Model) -> crate::Result<()> {
let re = regex::Regex::new(
r#"^Config:
numlock binding: (not set|\d+)
@@ -31,23 +48,24 @@ $"#,
)
.unwrap();
- let out = Nitrocli::with_dev(device).handle(&["config", "get"])?;
+ let out = Nitrocli::with_model(model).handle(&["config", "get"])?;
assert!(re.is_match(&out), out);
Ok(())
}
#[test_device]
-fn set_wrong_usage(device: nitrokey::DeviceWrapper) {
- let res = Nitrocli::with_dev(device).handle(&["config", "set", "--numlock", "2", "-N"]);
- assert_eq!(
- res.unwrap_str_err(),
- "--numlock and --no-numlock are mutually exclusive"
+fn set_wrong_usage(model: nitrokey::Model) {
+ let res = Nitrocli::with_model(model).handle(&["config", "set", "--numlock", "2", "-N"]);
+ let err = res.unwrap_str_err();
+ assert!(
+ err.contains("The argument '--numlock <numlock>' cannot be used with '--no-numlock'"),
+ err,
);
}
#[test_device]
-fn set_get(device: nitrokey::DeviceWrapper) -> crate::Result<()> {
- let mut ncli = Nitrocli::with_dev(device);
+fn set_get(model: nitrokey::Model) -> crate::Result<()> {
+ let mut ncli = Nitrocli::with_model(model);
let _ = ncli.handle(&["config", "set", "-s", "1", "-c", "0", "-N"])?;
let re = regex::Regex::new(
diff --git a/src/tests/encrypted.rs b/src/tests/encrypted.rs
new file mode 100644
index 0000000..aed2662
--- /dev/null
+++ b/src/tests/encrypted.rs
@@ -0,0 +1,95 @@
+// encrypted.rs
+
+// *************************************************************************
+// * Copyright (C) 2019 Daniel Mueller (deso@posteo.net) *
+// * *
+// * This program is free software: you can redistribute it and/or modify *
+// * it under the terms of the GNU General Public License as published by *
+// * the Free Software Foundation, either version 3 of the License, or *
+// * (at your option) any later version. *
+// * *
+// * This program is distributed in the hope that it will be useful, *
+// * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+// * GNU General Public License for more details. *
+// * *
+// * You should have received a copy of the GNU General Public License *
+// * along with this program. If not, see <http://www.gnu.org/licenses/>. *
+// *************************************************************************
+
+use super::*;
+
+#[test_device(storage)]
+fn status_open_close(model: nitrokey::Model) -> crate::Result<()> {
+ fn make_re(open: Option<bool>) -> regex::Regex {
+ let encrypted = match open {
+ Some(open) => {
+ if open {
+ "active"
+ } else {
+ "(read-only|inactive)"
+ }
+ }
+ None => "(read-only|active|inactive)",
+ };
+ let re = format!(
+ r#"
+ volumes:
+ unencrypted: (read-only|active|inactive)
+ encrypted: {}
+ hidden: (read-only|active|inactive)
+$"#,
+ encrypted
+ );
+ regex::Regex::new(&re).unwrap()
+ }
+
+ let mut ncli = Nitrocli::with_model(model);
+ let out = ncli.handle(&["status"])?;
+ assert!(make_re(None).is_match(&out), out);
+
+ let _ = ncli.handle(&["encrypted", "open"])?;
+ let out = ncli.handle(&["status"])?;
+ assert!(make_re(Some(true)).is_match(&out), out);
+
+ let _ = ncli.handle(&["encrypted", "close"])?;
+ let out = ncli.handle(&["status"])?;
+ assert!(make_re(Some(false)).is_match(&out), out);
+
+ Ok(())
+}
+
+#[test_device(pro)]
+fn encrypted_open_on_pro(model: nitrokey::Model) {
+ let res = Nitrocli::with_model(model).handle(&["encrypted", "open"]);
+ assert_eq!(
+ res.unwrap_str_err(),
+ "This command is only available on the Nitrokey Storage",
+ );
+}
+
+#[test_device(storage)]
+fn encrypted_open_close(model: nitrokey::Model) -> crate::Result<()> {
+ let mut ncli = Nitrocli::with_model(model);
+ let out = ncli.handle(&["encrypted", "open"])?;
+ assert!(out.is_empty());
+
+ {
+ let mut manager = nitrokey::force_take()?;
+ let device = manager.connect_storage()?;
+ assert!(device.get_storage_status()?.encrypted_volume.active);
+ assert!(!device.get_storage_status()?.hidden_volume.active);
+ }
+
+ let out = ncli.handle(&["encrypted", "close"])?;
+ assert!(out.is_empty());
+
+ {
+ let mut manager = nitrokey::force_take()?;
+ let device = manager.connect_storage()?;
+ assert!(!device.get_storage_status()?.encrypted_volume.active);
+ assert!(!device.get_storage_status()?.hidden_volume.active);
+ }
+
+ Ok(())
+}
diff --git a/nitrocli/src/tests/run.rs b/src/tests/hidden.rs
index dda7473..eabcfd4 100644
--- a/nitrocli/src/tests/run.rs
+++ b/src/tests/hidden.rs
@@ -1,4 +1,4 @@
-// run.rs
+// hidden.rs
// *************************************************************************
// * Copyright (C) 2019 Daniel Mueller (deso@posteo.net) *
@@ -19,48 +19,31 @@
use super::*;
-#[test]
-fn no_command_or_option() {
- let (rc, out, err) = Nitrocli::new().run(&[]);
+#[test_device(storage)]
+fn hidden_create_open_close(model: nitrokey::Model) -> crate::Result<()> {
+ let mut ncli = Nitrocli::with_model(model);
+ let out = ncli.handle(&["hidden", "create", "0", "50", "100"])?;
+ assert!(out.is_empty());
- assert_ne!(rc, 0);
- assert_eq!(out, b"");
+ let out = ncli.handle(&["hidden", "open"])?;
+ assert!(out.is_empty());
- let s = String::from_utf8_lossy(&err).into_owned();
- assert!(s.starts_with("Usage:\n"), s);
-}
-
-#[test]
-fn help_option() {
- fn test(opt: &'static str) {
- let (rc, out, err) = Nitrocli::new().run(&[opt]);
-
- assert_eq!(rc, 0);
- assert_eq!(err, b"");
-
- let s = String::from_utf8_lossy(&out).into_owned();
- assert!(s.starts_with("Usage:\n"), s);
+ {
+ let mut manager = nitrokey::force_take()?;
+ let device = manager.connect_storage()?;
+ assert!(!device.get_storage_status()?.encrypted_volume.active);
+ assert!(device.get_storage_status()?.hidden_volume.active);
}
- test("--help");
- test("-h")
-}
-
-#[test]
-fn version_option() {
- fn test(re: &regex::Regex, opt: &'static str) {
- let (rc, out, err) = Nitrocli::new().run(&[opt]);
+ let out = ncli.handle(&["hidden", "close"])?;
+ assert!(out.is_empty());
- assert_eq!(rc, 0);
- assert_eq!(err, b"");
-
- let s = String::from_utf8_lossy(&out).into_owned();
- let _ = re;
- assert!(re.is_match(&s), out);
+ {
+ let mut manager = nitrokey::force_take()?;
+ let device = manager.connect_storage()?;
+ assert!(!device.get_storage_status()?.encrypted_volume.active);
+ assert!(!device.get_storage_status()?.hidden_volume.active);
}
- let re = regex::Regex::new(r"^nitrocli \d+.\d+.\d+(-[^-]+)*\n$").unwrap();
-
- test(&re, "--version");
- test(&re, "-V");
+ Ok(())
}
diff --git a/src/tests/list.rs b/src/tests/list.rs
new file mode 100644
index 0000000..4f80afe
--- /dev/null
+++ b/src/tests/list.rs
@@ -0,0 +1,42 @@
+// list.rs
+
+// *************************************************************************
+// * Copyright (C) 2020 Daniel Mueller (deso@posteo.net) *
+// * *
+// * This program is free software: you can redistribute it and/or modify *
+// * it under the terms of the GNU General Public License as published by *
+// * the Free Software Foundation, either version 3 of the License, or *
+// * (at your option) any later version. *
+// * *
+// * This program is distributed in the hope that it will be useful, *
+// * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+// * GNU General Public License for more details. *
+// * *
+// * You should have received a copy of the GNU General Public License *
+// * along with this program. If not, see <http://www.gnu.org/licenses/>. *
+// *************************************************************************
+
+use super::*;
+
+#[test_device]
+fn not_connected() -> crate::Result<()> {
+ let res = Nitrocli::new().handle(&["list"])?;
+ assert_eq!(res, "No Nitrokey device connected\n");
+
+ Ok(())
+}
+
+#[test_device]
+fn connected(model: nitrokey::Model) -> crate::Result<()> {
+ let re = regex::Regex::new(
+ r#"^device path\tmodel\tserial number
+([[:^space:]]+\t(Pro|Storage|unknown)\t0x[[:xdigit:]]+
+)+$"#,
+ )
+ .unwrap();
+
+ let out = Nitrocli::with_model(model).handle(&["list"])?;
+ assert!(re.is_match(&out), out);
+ Ok(())
+}
diff --git a/nitrocli/src/tests/lock.rs b/src/tests/lock.rs
index 1993350..b29f394 100644
--- a/nitrocli/src/tests/lock.rs
+++ b/src/tests/lock.rs
@@ -19,25 +19,26 @@
use super::*;
-#[test_device]
-fn lock_pro(device: nitrokey::Pro) -> crate::Result<()> {
+#[test_device(pro)]
+fn lock_pro(model: nitrokey::Model) -> crate::Result<()> {
// We can't really test much more here than just success of the command.
- let out = Nitrocli::with_dev(device).handle(&["lock"])?;
+ let out = Nitrocli::with_model(model).handle(&["lock"])?;
assert!(out.is_empty());
Ok(())
}
-#[test_device]
-fn lock_storage(device: nitrokey::Storage) -> crate::Result<()> {
- let mut ncli = Nitrocli::with_dev(device);
- let _ = ncli.handle(&["storage", "open"])?;
+#[test_device(storage)]
+fn lock_storage(model: nitrokey::Model) -> crate::Result<()> {
+ let mut ncli = Nitrocli::with_model(model);
+ let _ = ncli.handle(&["encrypted", "open"])?;
let out = ncli.handle(&["lock"])?;
assert!(out.is_empty());
- let device = nitrokey::Storage::connect()?;
- assert!(!device.get_status()?.encrypted_volume.active);
+ let mut manager = nitrokey::force_take()?;
+ let device = manager.connect_storage()?;
+ assert!(!device.get_storage_status()?.encrypted_volume.active);
Ok(())
}
diff --git a/nitrocli/src/tests/mod.rs b/src/tests/mod.rs
index b1e1618..abf63e3 100644
--- a/nitrocli/src/tests/mod.rs
+++ b/src/tests/mod.rs
@@ -1,7 +1,7 @@
// mod.rs
// *************************************************************************
-// * Copyright (C) 2019 Daniel Mueller (deso@posteo.net) *
+// * Copyright (C) 2019-2020 Daniel Mueller (deso@posteo.net) *
// * *
// * This program is free software: you can redistribute it and/or modify *
// * it under the terms of the GNU General Public License as published by *
@@ -22,21 +22,10 @@ use std::fmt;
use nitrokey_test::test as test_device;
-// TODO: Those defines should potentially be taken from the `nitrokey`
-// crate, once exported.
-const NITROKEY_DEFAULT_ADMIN_PIN: &str = "12345678";
-const NITROKEY_DEFAULT_USER_PIN: &str = "123456";
-
-// TODO: This is a hack to make the nitrokey-test crate work across
-// module boundaries. Upon first use of the nitrokey_test::test
-// macro a new function, __nitrokey_mutex, will be emitted, but it
-// is not visible in a different module. To work around that we
-// trigger the macro here first and then `use super::*` from all
-// of the submodules.
-#[test_device]
-fn dummy() {}
-
mod config;
+mod encrypted;
+mod hidden;
+mod list;
mod lock;
mod otp;
mod pin;
@@ -44,7 +33,7 @@ mod pws;
mod reset;
mod run;
mod status;
-mod storage;
+mod unencrypted;
/// A trait simplifying checking for expected errors.
pub trait UnwrapError {
@@ -52,6 +41,8 @@ pub trait UnwrapError {
fn unwrap_str_err(self) -> String;
/// Unwrap a Error::CommandError variant.
fn unwrap_cmd_err(self) -> (Option<&'static str>, nitrokey::CommandError);
+ /// Unwrap a Error::LibraryError variant.
+ fn unwrap_lib_err(self) -> (Option<&'static str>, nitrokey::LibraryError);
}
impl<T> UnwrapError for crate::Result<T>
@@ -60,6 +51,13 @@ where
{
fn unwrap_str_err(self) -> String {
match self.unwrap_err() {
+ crate::Error::ClapError(err) => {
+ if err.use_stderr() {
+ err.message
+ } else {
+ String::new()
+ }
+ }
crate::Error::Error(err) => err,
err => panic!("Unexpected error variant found: {:?}", err),
}
@@ -67,7 +65,20 @@ where
fn unwrap_cmd_err(self) -> (Option<&'static str>, nitrokey::CommandError) {
match self.unwrap_err() {
- crate::Error::CommandError(ctx, err) => (ctx, err),
+ crate::Error::NitrokeyError(ctx, err) => match err {
+ nitrokey::Error::CommandError(err) => (ctx, err),
+ err => panic!("Unexpected error variant found: {:?}", err),
+ },
+ err => panic!("Unexpected error variant found: {:?}", err),
+ }
+ }
+
+ fn unwrap_lib_err(self) -> (Option<&'static str>, nitrokey::LibraryError) {
+ match self.unwrap_err() {
+ crate::Error::NitrokeyError(ctx, err) => match err {
+ nitrokey::Error::LibraryError(err) => (ctx, err),
+ err => panic!("Unexpected error variant found: {:?}", err),
+ },
err => panic!("Unexpected error variant found: {:?}", err),
}
}
@@ -86,29 +97,26 @@ impl Nitrocli {
pub fn new() -> Self {
Self {
model: None,
- admin_pin: Some(NITROKEY_DEFAULT_ADMIN_PIN.into()),
- user_pin: Some(NITROKEY_DEFAULT_USER_PIN.into()),
+ admin_pin: Some(nitrokey::DEFAULT_ADMIN_PIN.into()),
+ user_pin: Some(nitrokey::DEFAULT_USER_PIN.into()),
new_admin_pin: None,
new_user_pin: None,
password: None,
}
}
- pub fn with_dev<D>(device: D) -> Self
+ pub fn with_model<M>(model: M) -> Self
where
- D: nitrokey::Device,
+ M: Into<nitrokey::Model>,
{
- let result = Self {
- model: Some(device.get_model()),
- admin_pin: Some(NITROKEY_DEFAULT_ADMIN_PIN.into()),
- user_pin: Some(NITROKEY_DEFAULT_USER_PIN.into()),
+ Self {
+ model: Some(model.into()),
+ admin_pin: Some(nitrokey::DEFAULT_ADMIN_PIN.into()),
+ user_pin: Some(nitrokey::DEFAULT_USER_PIN.into()),
new_admin_pin: None,
new_user_pin: None,
password: Some("1234567".into()),
- };
-
- drop(device);
- result
+ }
}
pub fn admin_pin(&mut self, pin: impl Into<ffi::OsString>) {
@@ -134,15 +142,15 @@ impl Nitrocli {
}
}
- fn do_run<F, R>(&mut self, args: &[&'static str], f: F) -> (R, Vec<u8>, Vec<u8>)
+ fn do_run<F, R>(&mut self, args: &[&str], f: F) -> (R, Vec<u8>, Vec<u8>)
where
F: FnOnce(&mut crate::RunCtx<'_>, Vec<String>) -> R,
{
let args = ["nitrocli"]
- .into_iter()
+ .iter()
.cloned()
.chain(self.model.map(Self::model_to_arg))
- .chain(args.into_iter().cloned())
+ .chain(args.iter().cloned())
.map(ToOwned::to_owned)
.collect();
@@ -164,13 +172,13 @@ impl Nitrocli {
}
/// Run `nitrocli`'s `run` function.
- pub fn run(&mut self, args: &[&'static str]) -> (i32, Vec<u8>, Vec<u8>) {
+ pub fn run(&mut self, args: &[&str]) -> (i32, Vec<u8>, Vec<u8>) {
self.do_run(args, |c, a| crate::run(c, a))
}
/// Run `nitrocli`'s `handle_arguments` function.
- pub fn handle(&mut self, args: &[&'static str]) -> crate::Result<String> {
- let (res, out, _) = self.do_run(args, |c, a| crate::args::handle_arguments(c, a));
+ pub fn handle(&mut self, args: &[&str]) -> crate::Result<String> {
+ let (res, out, _) = self.do_run(args, |c, a| crate::handle_arguments(c, a));
res.map(|_| String::from_utf8_lossy(&out).into_owned())
}
diff --git a/nitrocli/src/tests/otp.rs b/src/tests/otp.rs
index 39ddf29..f923170 100644
--- a/nitrocli/src/tests/otp.rs
+++ b/src/tests/otp.rs
@@ -1,7 +1,7 @@
// otp.rs
// *************************************************************************
-// * Copyright (C) 2019 Daniel Mueller (deso@posteo.net) *
+// * Copyright (C) 2019-2020 Daniel Mueller (deso@posteo.net) *
// * *
// * This program is free software: you can redistribute it and/or modify *
// * it under the terms of the GNU General Public License as published by *
@@ -19,9 +19,11 @@
use super::*;
+use crate::args;
+
#[test_device]
-fn set_invalid_slot_raw(device: nitrokey::DeviceWrapper) {
- let (rc, out, err) = Nitrocli::with_dev(device).run(&["otp", "set", "100", "name", "1234"]);
+fn set_invalid_slot_raw(model: nitrokey::Model) {
+ let (rc, out, err) = Nitrocli::with_model(model).run(&["otp", "set", "100", "name", "1234"]);
assert_ne!(rc, 0);
assert_eq!(out, b"");
@@ -29,27 +31,27 @@ fn set_invalid_slot_raw(device: nitrokey::DeviceWrapper) {
}
#[test_device]
-fn set_invalid_slot(device: nitrokey::DeviceWrapper) {
- let res = Nitrocli::with_dev(device).handle(&["otp", "set", "100", "name", "1234"]);
+fn set_invalid_slot(model: nitrokey::Model) {
+ let res = Nitrocli::with_model(model).handle(&["otp", "set", "100", "name", "1234"]);
assert_eq!(
- res.unwrap_cmd_err(),
+ res.unwrap_lib_err(),
(
Some("Could not write OTP slot"),
- nitrokey::CommandError::InvalidSlot
+ nitrokey::LibraryError::InvalidSlot
)
);
}
#[test_device]
-fn status(device: nitrokey::DeviceWrapper) -> crate::Result<()> {
+fn status(model: nitrokey::Model) -> crate::Result<()> {
let re = regex::Regex::new(
r#"^alg\tslot\tname
((totp|hotp)\t\d+\t.+\n)+$"#,
)
.unwrap();
- let mut ncli = Nitrocli::with_dev(device);
+ let mut ncli = Nitrocli::with_model(model);
// Make sure that we have at least something to display by ensuring
// that there is one slot programmed.
let _ = ncli.handle(&["otp", "set", "0", "the-name", "123456"])?;
@@ -60,14 +62,14 @@ fn status(device: nitrokey::DeviceWrapper) -> crate::Result<()> {
}
#[test_device]
-fn set_get_hotp(device: nitrokey::DeviceWrapper) -> crate::Result<()> {
+fn set_get_hotp(model: nitrokey::Model) -> crate::Result<()> {
// Secret and expected HOTP values as per RFC 4226: Appendix D -- HOTP
// Algorithm: Test Values.
const SECRET: &str = "12345678901234567890";
const OTP1: &str = concat!(755224, "\n");
const OTP2: &str = concat!(287082, "\n");
- let mut ncli = Nitrocli::with_dev(device);
+ let mut ncli = Nitrocli::with_model(model);
let _ = ncli.handle(&[
"otp", "set", "-a", "hotp", "-f", "ascii", "1", "name", &SECRET,
])?;
@@ -81,14 +83,14 @@ fn set_get_hotp(device: nitrokey::DeviceWrapper) -> crate::Result<()> {
}
#[test_device]
-fn set_get_totp(device: nitrokey::DeviceWrapper) -> crate::Result<()> {
+fn set_get_totp(model: nitrokey::Model) -> crate::Result<()> {
// Secret and expected TOTP values as per RFC 6238: Appendix B --
// Test Vectors.
const SECRET: &str = "12345678901234567890";
const TIME: &str = stringify!(1111111111);
const OTP: &str = concat!(14050471, "\n");
- let mut ncli = Nitrocli::with_dev(device);
+ let mut ncli = Nitrocli::with_model(model);
let _ = ncli.handle(&["otp", "set", "-d", "8", "-f", "ascii", "2", "name", &SECRET])?;
let out = ncli.handle(&["otp", "get", "-t", TIME, "2"])?;
@@ -97,8 +99,22 @@ fn set_get_totp(device: nitrokey::DeviceWrapper) -> crate::Result<()> {
}
#[test_device]
-fn clear(device: nitrokey::DeviceWrapper) -> crate::Result<()> {
- let mut ncli = Nitrocli::with_dev(device);
+fn set_totp_uneven_chars(model: nitrokey::Model) -> crate::Result<()> {
+ let secrets = [
+ (args::OtpSecretFormat::Hex, "123"),
+ (args::OtpSecretFormat::Base32, "FBILDWWGA2"),
+ ];
+
+ for (format, secret) in &secrets {
+ let mut ncli = Nitrocli::with_model(model);
+ let _ = ncli.handle(&["otp", "set", "-f", format.as_ref(), "3", "foobar", &secret])?;
+ }
+ Ok(())
+}
+
+#[test_device]
+fn clear(model: nitrokey::Model) -> crate::Result<()> {
+ let mut ncli = Nitrocli::with_model(model);
let _ = ncli.handle(&["otp", "set", "3", "hotp-test", "abcdef"])?;
let _ = ncli.handle(&["otp", "clear", "3"])?;
let res = ncli.handle(&["otp", "get", "3"]);
diff --git a/nitrocli/src/tests/pin.rs b/src/tests/pin.rs
index fe61b2d..958a36d 100644
--- a/nitrocli/src/tests/pin.rs
+++ b/src/tests/pin.rs
@@ -23,42 +23,62 @@ use nitrokey::Device;
use super::*;
#[test_device]
-fn unblock(device: nitrokey::DeviceWrapper) -> crate::Result<()> {
- let (device, err) = device.authenticate_user("wrong-pin").unwrap_err();
- assert_eq!(err, nitrokey::CommandError::WrongPassword);
- assert!(device.get_user_retry_count() < 3);
+fn unblock(model: nitrokey::Model) -> crate::Result<()> {
+ {
+ let mut manager = nitrokey::force_take()?;
+ let device = manager.connect_model(model)?;
+ let (device, err) = device.authenticate_user("wrong-pin").unwrap_err();
+ match err {
+ nitrokey::Error::CommandError(err) if err == nitrokey::CommandError::WrongPassword => (),
+ _ => panic!("Unexpected error variant found: {:?}", err),
+ }
+ assert!(device.get_user_retry_count()? < 3);
+ }
- let model = device.get_model();
- let _ = Nitrocli::with_dev(device).handle(&["pin", "unblock"])?;
- let device = nitrokey::connect_model(model)?;
- assert_eq!(device.get_user_retry_count(), 3);
+ let _ = Nitrocli::with_model(model).handle(&["pin", "unblock"])?;
+
+ {
+ let mut manager = nitrokey::force_take()?;
+ let device = manager.connect_model(model)?;
+ assert_eq!(device.get_user_retry_count()?, 3);
+ }
Ok(())
}
#[test_device]
-fn set_user(device: nitrokey::DeviceWrapper) -> crate::Result<()> {
- let mut ncli = Nitrocli::with_dev(device);
-
+fn set_user(model: nitrokey::Model) -> crate::Result<()> {
+ let mut ncli = Nitrocli::with_model(model);
// Set a new user PIN.
ncli.new_user_pin("new-pin");
let out = ncli.handle(&["pin", "set", "user"])?;
assert!(out.is_empty());
- let device = nitrokey::connect_model(ncli.model().unwrap())?;
- let (device, err) = device
- .authenticate_user(NITROKEY_DEFAULT_USER_PIN)
- .unwrap_err();
- assert_eq!(err, nitrokey::CommandError::WrongPassword);
- drop(device);
+ {
+ let mut manager = nitrokey::force_take()?;
+ let device = manager.connect_model(model)?;
+ let (_, err) = device
+ .authenticate_user(nitrokey::DEFAULT_USER_PIN)
+ .unwrap_err();
+
+ match err {
+ nitrokey::Error::CommandError(err) if err == nitrokey::CommandError::WrongPassword => (),
+ _ => panic!("Unexpected error variant found: {:?}", err),
+ }
+ }
// Revert to the default user PIN.
ncli.user_pin("new-pin");
- ncli.new_user_pin(NITROKEY_DEFAULT_USER_PIN);
+ ncli.new_user_pin(nitrokey::DEFAULT_USER_PIN);
let out = ncli.handle(&["pin", "set", "user"])?;
assert!(out.is_empty());
- let device = nitrokey::connect_model(ncli.model().unwrap())?;
- let _ = device.authenticate_user(NITROKEY_DEFAULT_USER_PIN).unwrap();
+ {
+ let mut manager = nitrokey::force_take()?;
+ let device = manager.connect_model(ncli.model().unwrap())?;
+ let _ = device
+ .authenticate_user(nitrokey::DEFAULT_USER_PIN)
+ .unwrap();
+ }
Ok(())
}
diff --git a/nitrocli/src/tests/pws.rs b/src/tests/pws.rs
index 5d0f245..651b2d5 100644
--- a/nitrocli/src/tests/pws.rs
+++ b/src/tests/pws.rs
@@ -20,27 +20,27 @@
use super::*;
#[test_device]
-fn set_invalid_slot(device: nitrokey::DeviceWrapper) {
- let res = Nitrocli::with_dev(device).handle(&["pws", "set", "100", "name", "login", "1234"]);
+fn set_invalid_slot(model: nitrokey::Model) {
+ let res = Nitrocli::with_model(model).handle(&["pws", "set", "100", "name", "login", "1234"]);
assert_eq!(
- res.unwrap_cmd_err(),
+ res.unwrap_lib_err(),
(
Some("Could not write PWS slot"),
- nitrokey::CommandError::InvalidSlot
+ nitrokey::LibraryError::InvalidSlot
)
);
}
#[test_device]
-fn status(device: nitrokey::DeviceWrapper) -> crate::Result<()> {
+fn status(model: nitrokey::Model) -> crate::Result<()> {
let re = regex::Regex::new(
r#"^slot\tname
(\d+\t.+\n)+$"#,
)
.unwrap();
- let mut ncli = Nitrocli::with_dev(device);
+ let mut ncli = Nitrocli::with_model(model);
// Make sure that we have at least something to display by ensuring
// that there are there is one slot programmed.
let _ = ncli.handle(&["pws", "set", "0", "the-name", "the-login", "123456"])?;
@@ -51,12 +51,12 @@ fn status(device: nitrokey::DeviceWrapper) -> crate::Result<()> {
}
#[test_device]
-fn set_get(device: nitrokey::DeviceWrapper) -> crate::Result<()> {
+fn set_get(model: nitrokey::Model) -> crate::Result<()> {
const NAME: &str = "dropbox";
const LOGIN: &str = "d-e-s-o";
const PASSWORD: &str = "my-secret-password";
- let mut ncli = Nitrocli::with_dev(device);
+ let mut ncli = Nitrocli::with_model(model);
let _ = ncli.handle(&["pws", "set", "1", &NAME, &LOGIN, &PASSWORD])?;
let out = ncli.handle(&["pws", "get", "1", "--quiet", "--name"])?;
@@ -83,12 +83,12 @@ fn set_get(device: nitrokey::DeviceWrapper) -> crate::Result<()> {
}
#[test_device]
-fn set_reset_get(device: nitrokey::DeviceWrapper) -> crate::Result<()> {
+fn set_reset_get(model: nitrokey::Model) -> crate::Result<()> {
const NAME: &str = "some/svc";
const LOGIN: &str = "a\\user";
const PASSWORD: &str = "!@&-)*(&+%^@";
- let mut ncli = Nitrocli::with_dev(device);
+ let mut ncli = Nitrocli::with_model(model);
let _ = ncli.handle(&["pws", "set", "2", &NAME, &LOGIN, &PASSWORD])?;
let out = ncli.handle(&["reset"])?;
@@ -106,8 +106,8 @@ fn set_reset_get(device: nitrokey::DeviceWrapper) -> crate::Result<()> {
}
#[test_device]
-fn clear(device: nitrokey::DeviceWrapper) -> crate::Result<()> {
- let mut ncli = Nitrocli::with_dev(device);
+fn clear(model: nitrokey::Model) -> crate::Result<()> {
+ let mut ncli = Nitrocli::with_model(model);
let _ = ncli.handle(&["pws", "set", "10", "clear-test", "some-login", "abcdef"])?;
let _ = ncli.handle(&["pws", "clear", "10"])?;
let res = ncli.handle(&["pws", "get", "10"]);
diff --git a/nitrocli/src/tests/reset.rs b/src/tests/reset.rs
index 2e567fa..e197970 100644
--- a/nitrocli/src/tests/reset.rs
+++ b/src/tests/reset.rs
@@ -23,32 +23,38 @@ use nitrokey::GetPasswordSafe;
use super::*;
#[test_device]
-fn reset(device: nitrokey::DeviceWrapper) -> crate::Result<()> {
+fn reset(model: nitrokey::Model) -> crate::Result<()> {
let new_admin_pin = "87654321";
- let mut ncli = Nitrocli::with_dev(device);
+ let mut ncli = Nitrocli::with_model(model);
// Change the admin PIN.
ncli.new_admin_pin(new_admin_pin);
let _ = ncli.handle(&["pin", "set", "admin"])?;
- // Check that the admin PIN has been changed.
- let device = nitrokey::connect_model(ncli.model().unwrap())?;
- let _ = device.authenticate_admin(new_admin_pin).unwrap();
+ {
+ let mut manager = nitrokey::force_take()?;
+ // Check that the admin PIN has been changed.
+ let device = manager.connect_model(ncli.model().unwrap())?;
+ let _ = device.authenticate_admin(new_admin_pin).unwrap();
+ }
// Perform factory reset
ncli.admin_pin(new_admin_pin);
let out = ncli.handle(&["reset"])?;
assert!(out.is_empty());
- // Check that the admin PIN has been reset.
- let device = nitrokey::connect_model(ncli.model().unwrap())?;
- let device = device
- .authenticate_admin(NITROKEY_DEFAULT_ADMIN_PIN)
- .unwrap();
-
- // Check that the password store works, i.e., the AES key has been
- // built.
- let _ = device.get_password_safe(NITROKEY_DEFAULT_USER_PIN)?;
+ {
+ let mut manager = nitrokey::force_take()?;
+ // Check that the admin PIN has been reset.
+ let device = manager.connect_model(ncli.model().unwrap())?;
+ let mut device = device
+ .authenticate_admin(nitrokey::DEFAULT_ADMIN_PIN)
+ .unwrap();
+
+ // Check that the password store works, i.e., the AES key has been
+ // built.
+ let _ = device.get_password_safe(nitrokey::DEFAULT_USER_PIN)?;
+ }
Ok(())
}
diff --git a/src/tests/run.rs b/src/tests/run.rs
new file mode 100644
index 0000000..22e7004
--- /dev/null
+++ b/src/tests/run.rs
@@ -0,0 +1,110 @@
+// run.rs
+
+// *************************************************************************
+// * Copyright (C) 2019-2020 Daniel Mueller (deso@posteo.net) *
+// * *
+// * This program is free software: you can redistribute it and/or modify *
+// * it under the terms of the GNU General Public License as published by *
+// * the Free Software Foundation, either version 3 of the License, or *
+// * (at your option) any later version. *
+// * *
+// * This program is distributed in the hope that it will be useful, *
+// * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+// * GNU General Public License for more details. *
+// * *
+// * You should have received a copy of the GNU General Public License *
+// * along with this program. If not, see <http://www.gnu.org/licenses/>. *
+// *************************************************************************
+
+use super::*;
+
+#[test]
+fn no_command_or_option() {
+ let (rc, out, err) = Nitrocli::new().run(&[]);
+
+ assert_ne!(rc, 0);
+ assert_eq!(out, b"");
+
+ let s = String::from_utf8_lossy(&err).into_owned();
+ assert!(s.starts_with("nitrocli"), s);
+ assert!(s.contains("USAGE:\n"), s);
+}
+
+#[test]
+fn help_options() {
+ fn test_run(args: &[&str], help: &str) {
+ let mut all = args.to_vec();
+ all.push(help);
+
+ let (rc, out, err) = Nitrocli::new().run(&all);
+
+ assert_eq!(rc, 0);
+ assert_eq!(err, b"");
+
+ let s = String::from_utf8_lossy(&out).into_owned();
+ let mut args = args.to_vec();
+ args.insert(0, "nitrocli");
+ assert!(s.starts_with(&args.join("-")), s);
+ assert!(s.contains("USAGE:\n"), s);
+ }
+
+ fn test(args: &[&str]) {
+ test_run(args, "--help");
+ test_run(args, "-h");
+ }
+
+ test(&[]);
+ test(&["config"]);
+ test(&["config", "get"]);
+ test(&["config", "set"]);
+ test(&["encrypted"]);
+ test(&["encrypted", "open"]);
+ test(&["encrypted", "close"]);
+ test(&["hidden"]);
+ test(&["hidden", "close"]);
+ test(&["hidden", "create"]);
+ test(&["hidden", "open"]);
+ test(&["lock"]);
+ test(&["otp"]);
+ test(&["otp", "clear"]);
+ test(&["otp", "get"]);
+ test(&["otp", "set"]);
+ test(&["otp", "status"]);
+ test(&["pin"]);
+ test(&["pin", "clear"]);
+ test(&["pin", "set"]);
+ test(&["pin", "unblock"]);
+ test(&["pws"]);
+ test(&["pws", "clear"]);
+ test(&["pws", "get"]);
+ test(&["pws", "set"]);
+ test(&["pws", "status"]);
+ test(&["reset"]);
+ test(&["status"]);
+ test(&["unencrypted"]);
+ test(&["unencrypted", "set"]);
+}
+
+#[test]
+#[ignore]
+fn version_option() {
+ // clap sends the version output directly to stdout: https://github.com/clap-rs/clap/issues/1390
+ // Therefore we ignore this test for the time being.
+
+ fn test(re: &regex::Regex, opt: &'static str) {
+ let (rc, out, err) = Nitrocli::new().run(&[opt]);
+
+ assert_eq!(rc, 0);
+ assert_eq!(err, b"");
+
+ let s = String::from_utf8_lossy(&out).into_owned();
+ let _ = re;
+ assert!(re.is_match(&s), out);
+ }
+
+ let re = regex::Regex::new(r"^nitrocli \d+.\d+.\d+(-[^-]+)*\n$").unwrap();
+
+ test(&re, "--version");
+ test(&re, "-V");
+}
diff --git a/nitrocli/src/tests/status.rs b/src/tests/status.rs
index 83ce61f..c9f4976 100644
--- a/nitrocli/src/tests/status.rs
+++ b/src/tests/status.rs
@@ -36,20 +36,46 @@ fn not_found() {
assert_eq!(res.unwrap_str_err(), "Nitrokey device not found");
}
-#[test_device]
-fn output(device: nitrokey::DeviceWrapper) -> crate::Result<()> {
+#[test_device(pro)]
+fn output_pro(model: nitrokey::Model) -> crate::Result<()> {
+ let re = regex::Regex::new(
+ r#"^Status:
+ model: Pro
+ serial number: 0x[[:xdigit:]]{8}
+ firmware version: v\d+\.\d+
+ user retry count: [0-3]
+ admin retry count: [0-3]
+$"#,
+ )
+ .unwrap();
+
+ let out = Nitrocli::with_model(model).handle(&["status"])?;
+ assert!(re.is_match(&out), out);
+ Ok(())
+}
+
+#[test_device(storage)]
+fn output_storage(model: nitrokey::Model) -> crate::Result<()> {
let re = regex::Regex::new(
r#"^Status:
- model: (Pro|Storage)
+ model: Storage
serial number: 0x[[:xdigit:]]{8}
- firmware version: \d+\.\d+
+ firmware version: v\d+\.\d+
user retry count: [0-3]
admin retry count: [0-3]
+ Storage:
+ SD card ID: 0x[[:xdigit:]]{8}
+ firmware: (un)?locked
+ storage keys: (not )?created
+ volumes:
+ unencrypted: (read-only|active|inactive)
+ encrypted: (read-only|active|inactive)
+ hidden: (read-only|active|inactive)
$"#,
)
.unwrap();
- let out = Nitrocli::with_dev(device).handle(&["status"])?;
+ let out = Nitrocli::with_model(model).handle(&["status"])?;
assert!(re.is_match(&out), out);
Ok(())
}
diff --git a/src/tests/unencrypted.rs b/src/tests/unencrypted.rs
new file mode 100644
index 0000000..ceeb17c
--- /dev/null
+++ b/src/tests/unencrypted.rs
@@ -0,0 +1,46 @@
+// unencrypted.rs
+
+// *************************************************************************
+// * Copyright (C) 2019 Daniel Mueller (deso@posteo.net) *
+// * *
+// * This program is free software: you can redistribute it and/or modify *
+// * it under the terms of the GNU General Public License as published by *
+// * the Free Software Foundation, either version 3 of the License, or *
+// * (at your option) any later version. *
+// * *
+// * This program is distributed in the hope that it will be useful, *
+// * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+// * GNU General Public License for more details. *
+// * *
+// * You should have received a copy of the GNU General Public License *
+// * along with this program. If not, see <http://www.gnu.org/licenses/>. *
+// *************************************************************************
+
+use super::*;
+
+#[test_device(storage)]
+fn unencrypted_set_read_write(model: nitrokey::Model) -> crate::Result<()> {
+ let mut ncli = Nitrocli::with_model(model);
+ let out = ncli.handle(&["unencrypted", "set", "read-write"])?;
+ assert!(out.is_empty());
+
+ {
+ let mut manager = nitrokey::force_take()?;
+ let device = manager.connect_storage()?;
+ assert!(device.get_storage_status()?.unencrypted_volume.active);
+ assert!(!device.get_storage_status()?.unencrypted_volume.read_only);
+ }
+
+ let out = ncli.handle(&["unencrypted", "set", "read-only"])?;
+ assert!(out.is_empty());
+
+ {
+ let mut manager = nitrokey::force_take()?;
+ let device = manager.connect_storage()?;
+ assert!(device.get_storage_status()?.unencrypted_volume.active);
+ assert!(device.get_storage_status()?.unencrypted_volume.read_only);
+ }
+
+ Ok(())
+}
diff --git a/nitrocli/var/binary-size.py b/var/binary-size.py
index 3653814..3653814 100755
--- a/nitrocli/var/binary-size.py
+++ b/var/binary-size.py
diff --git a/var/shell-complete.rs b/var/shell-complete.rs
new file mode 100644
index 0000000..4793ed3
--- /dev/null
+++ b/var/shell-complete.rs
@@ -0,0 +1,164 @@
+// shell-complete.rs
+
+// *************************************************************************
+// * Copyright (C) 2020 Daniel Mueller (deso@posteo.net) *
+// * *
+// * This program is free software: you can redistribute it and/or modify *
+// * it under the terms of the GNU General Public License as published by *
+// * the Free Software Foundation, either version 3 of the License, or *
+// * (at your option) any later version. *
+// * *
+// * This program is distributed in the hope that it will be useful, *
+// * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+// * GNU General Public License for more details. *
+// * *
+// * You should have received a copy of the GNU General Public License *
+// * along with this program. If not, see <http://www.gnu.org/licenses/>. *
+// *************************************************************************
+
+use std::io;
+
+use structopt::clap;
+use structopt::StructOpt as _;
+
+#[allow(unused)]
+mod nitrocli {
+ include!("../src/arg_util.rs");
+
+ // We only need a stripped down version of the `Command` macro.
+ macro_rules! Command {
+ ( $name:ident, [ $( $(#[$doc:meta])* $var:ident$(($inner:ty))? => $exec:expr, ) *] ) => {
+ #[derive(Debug, PartialEq, structopt::StructOpt)]
+ pub enum $name {
+ $(
+ $(#[$doc])*
+ $var$(($inner))?,
+ )*
+ }
+ };
+ }
+
+ include!("../src/args.rs");
+}
+
+/// Generate a bash completion script for nitrocli.
+///
+/// The script will be emitted to standard output.
+#[derive(Debug, structopt::StructOpt)]
+pub struct Args {
+ /// The command for which to generate the bash completion script.
+ #[structopt(default_value = "nitrocli")]
+ pub command: String,
+}
+
+fn generate_bash<W>(command: &str, output: &mut W)
+where
+ W: io::Write,
+{
+ let mut app = nitrocli::Args::clap();
+ app.gen_completions_to(command, clap::Shell::Bash, output);
+}
+
+fn main() {
+ let args = Args::from_args();
+ generate_bash(&args.command, &mut io::stdout())
+}
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+
+ use std::io;
+ use std::ops::Add as _;
+ use std::process;
+
+ /// Separate the given words by newlines.
+ fn lines<'w, W>(mut words: W) -> String
+ where
+ W: Iterator<Item = &'w str>,
+ {
+ let first = words.next().unwrap_or("");
+ words
+ .fold(first.to_string(), |words, word| {
+ format!("{}\n{}", words, word)
+ })
+ .add("\n")
+ }
+
+ /// Check if `bash` is present on the system.
+ fn has_bash() -> bool {
+ match process::Command::new("bash").arg("-c").arg("exit").spawn() {
+ // We deliberately only indicate that bash does not exist if we
+ // get a file-not-found error. We don't expect any other error but
+ // should there be one things will blow up later.
+ Err(ref err) if err.kind() == io::ErrorKind::NotFound => false,
+ _ => true,
+ }
+ }
+
+ /// Perform a bash completion of the given arguments to nitrocli.
+ fn complete_bash<'w, W>(words: W) -> Vec<u8>
+ where
+ W: ExactSizeIterator<Item = &'w str>,
+ {
+ let mut buffer = Vec::new();
+ generate_bash("nitrocli", &mut buffer);
+
+ let script = String::from_utf8(buffer).unwrap();
+ let command = format!(
+ "
+set -e;
+eval '{script}';
+export COMP_WORDS=({words});
+export COMP_CWORD={index};
+_nitrocli;
+echo -n ${{COMPREPLY}}
+ ",
+ index = words.len(),
+ words = lines(Some("nitrocli").into_iter().chain(words)),
+ script = script
+ );
+
+ let output = process::Command::new("bash")
+ .arg("-c")
+ .arg(command)
+ .output()
+ .unwrap();
+
+ output.stdout
+ }
+
+ #[test]
+ fn array_lines() {
+ assert_eq!(&lines(vec![].into_iter()), "\n");
+ assert_eq!(&lines(vec!["first"].into_iter()), "first\n");
+ assert_eq!(
+ &lines(vec!["first", "second"].into_iter()),
+ "first\nsecond\n"
+ );
+ assert_eq!(
+ &lines(vec!["first", "second", "third"].into_iter()),
+ "first\nsecond\nthird\n"
+ );
+ }
+
+ #[test]
+ fn complete_all_the_things() {
+ if !has_bash() {
+ return;
+ }
+
+ assert_eq!(complete_bash(vec!["stat"].into_iter()), b"status");
+ assert_eq!(
+ complete_bash(vec!["status", "--ver"].into_iter()),
+ b"--version"
+ );
+ assert_eq!(complete_bash(vec!["--version"].into_iter()), b"--version");
+ assert_eq!(complete_bash(vec!["--model", "s"].into_iter()), b"storage");
+ assert_eq!(
+ complete_bash(vec!["otp", "get", "--model", "p"].into_iter()),
+ b"pro"
+ );
+ }
+}